We have used a Linux 2.4.7 kernel on a Pentium4 willamette core to develop the runtime power estimation and measurement framework.

Here you can download the the performance monitoring and power estimation tools in a single tarball: kernel_tools.tgz

I explain the details of the tools below.
You can get more info about our project in my webpage: --> Research highlights
Publications --> Here you can find the Micro'03 paper and the tech report on this work (look for "Runtime Power Monitoring").The tech reports sits at:
Talks --> Here you can get the Micro-36 talk slides


I'll try to go over each file briefly to help you get started. The ones with "[EXTRA]" are not needed for the tools to work. I include them in the package to give some info on our platform and as some helper tools for your platform. I had commented the programs extensively. So looking into the code will give you a lot of insight about how it works I hope. For many of them, i specify the compilation param-s at the beginning of code.

1) karelian_cpuinfo.txt: [EXTRA] This is the detailed CPU info for our experimental machine (gathered from LKM_CPUinfo) tells you about CPU signature and architectural parameters.

2) LKM_CPUinfo.c: [EXTRA] This is a helper kernel module that tells you the details for your intel system. Reads the cpuid and some control (CR) registers to get cpu specific information. Basically it defines a system call "sys_getCPUinfo()" that you can call from user level to get CPU information.

3) LKM_PerformanceReader.c: This is the kernel module that does the counter access syscalls that are defined in the paper. These syscalls let you read/write/configure counters from user space.

* If you are not familiar with P4 event monitoring, I recommend intel's software developer's manual (Appendix A and a the chapter about performance monitoring and debugging). Briefly, there are 3 sets of MSRs: 45 ESCRs to select events and masks, 18 CCCRs to configure counters and 18 corresponding counters. The syscalls read/write to these and couple other MISC registers to do performance monitoring.

4) PowerServer.c: This is the server side of the user code. You run this on the experimental machine as described in the paper. PowerServer collects counter info, rotates counters, and sends raw data to power client over ethernet.
It uses:
-PowerServer_DefineEvents --> to define event sets
-UserLevel_PerformanceReader.h --> to learn about syscalls

5) PowerServer_DefineEvents.c: This is where all the event definitions are made for the 18 counters. "define_events()" is called by the server at the beginning and all counters are set as defined in the structures in this file.

6) UserLevel_PerformanceReader.h: This is the header file that binds the server to the performance monitoring related syscalls.

7) Makefile_PowerServer: Makefile for power server

8) PowerClientvd.c: This is the client side, that collects counter info from server and actual current info from DMM and does the power modeling and monitors for total power and power breakdowns. This runs on a separate monitoring machine and talks to server over ethernet and reads power measurements over serial port. It performs power conversions and does a runtime plot of measured and modeled powers using the libplot library.

This is the kindof complicated one, has some threading, sockets, ether stuff, libplot functions etc. but the major power stuff is where the array references go:

--> this is where we compute the access rate for each functional unit

--> this is where we estimate unit-wise power based on activity rates.

These parameters are where you will probably spend most of your time to configure your system.

The overall operation of client is as follows:
- a separate thread continuously polls serial port to read current readings from current probe -> DMM
- another thread reads the socket for raw counter data from server and performs counter based power estimation. It gets the corresponding measured power from the other thread. Then, plots both measured and modeled powers on screen at runtime together with component breakdowns. Also logs the data to a file.

9) PowerClientvd_Makefile: Makefile for client

When you get all pieces compiled, the simplest way to run is:
server> PowerServer < port # >
client> PowerClient < ServerName > < port >

- The client requires libplot library to get the runtime power monitors working.
i.e. all the pl_XXXX stuff in the code.
- I use serial interface to read measured power, but will work w/o measurements as well as long as the serial device (/stty0 i think) is readable from user.
- It works with 2.4 kernel (my specific kernel was 2.4.7-10). In 2.6 syscall definitions and modules are done differently; also you need to export syscall_table and recompilefor 2.6.


Department of Electrical Engineering
Last Update: Tue, Dec 10, 2006 7:07