Added code to read any location in memory a repetative number of and

average the results.

It works on alpha but I haven't got it working on x86 I think for
lack of knowing a good address to read.

--HG--
extra : convert_revision : e2442de641741674d692245712aa92e258cf6d48
This commit is contained in:
Ali Saidi 2004-07-05 15:49:42 -04:00
parent 5bbd57917f
commit 3512904c74
3 changed files with 190 additions and 0 deletions

29
util/ccdrv/Makefile Normal file
View file

@ -0,0 +1,29 @@
# Copyright (c) 2004 The Regents of The University of Michigan
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Ali Saidi
obj-m := devtime.o

143
util/ccdrv/devtime.c Normal file
View file

@ -0,0 +1,143 @@
/*
* Copyright (c) 2004 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <linux/module.h>
#include <linux/config.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/netdevice.h>
#ifdef __i386__
#include <asm/processor.h>
#include <asm/msr.h>
#endif
#define DRIVER_AUTHOR "Ali Saidi"
#define DRIVER_DESC "Interface to time uncacachable read and writes to device registers"
#define DRIVER_VER "0.1"
static unsigned long devCnt, devSum, devSsq;
static char *dataAddr = NULL;
static int count = 0;
static inline uint32_t cycleCounter(uint32_t dep);
static int __init devtime_start(void)
{
uint64_t addr;
uint32_t t1, t2;
uint32_t trash;
int x;
struct net_device *dev;
printk("Devtime Driver Version %s Loaded...\n", DRIVER_VER);
if ((dataAddr != 0) && (count != 0))
{
addr = simple_strtoull(dataAddr, NULL, 0);
devSum = 0;
devCnt = count;
printk("Preparing to read %#llx %d times.\n", addr, count);
t1 = cycleCounter(trash);
for (x=0; x < count; x++)
{
trash = readl(addr);
t2 = cycleCounter(trash);
devSum += t2 - t1;
t1 = t2;
}
printk("Read Address %#llx %ld times. Average latency %ld.\n", addr, devCnt, devSum/devCnt);
} else {
dev = dev_get_by_name("eth0");
if (dev)
{
printk("Eth0: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n", dev->mem_start,
dev->mem_end, dev->base_addr);
dev_put(dev);
}
dev = dev_get_by_name("eth1");
if (dev)
{
printk("Eth1: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n", dev->mem_start,
dev->mem_end, dev->base_addr);
dev_put(dev);
}
printk("Required information not supplied.\n");
}
return 0;
}
#ifdef __i386__
static inline uint32_t cycleCounter(uint32_t dep)
{
uint32_t time;
cpuid_eax(0);
rdtscl(time);
cpuid_eax(0);
return time;
}
#elif __alpha__
inline uint32_t cycleCounter(uint32_t dep)
{
uint32_t res;
asm volatile ("rpcc %0, %1" : "=r"(res) : "r" (dep) : "memory");
return res;
}
#else
#error Architecture NOT SUPPORTE
#endif
static void __exit devtime_end(void) {
printk("Devtime Driver Version %s Unloaded...\n", DRIVER_VER);
}
module_init(devtime_start);
module_exit(devtime_end);
MODULE_LICENSE("BSD");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
module_param(dataAddr, charp, 0);
module_param(count, int, 0);

18
util/ccdrv/readme.txt Normal file
View file

@ -0,0 +1,18 @@
This driver will read the address you point it to [count] times and
print the results to the systemlog.
To build the driver (Linux 2.6.X only) execute:
make -C /path/to/linux-2.6.X/ SUBDIRS=$PWD modules
Insmodding the kernel module without options will print
the device addresses of eth0 and eth1 if they exist.
Insmodding the kernel module with the options:
dataAddr=0xXXXXXXXXX and count=XXXXX
will read a long at addr dataAddr count times and return.
Between runs you need to rmmod the module from the kernel.