I made two new MSR patches for kernels 2.0.30 and 2.1.32.
They include a fix by Harald Koenig.
Original MSR Announcement
Well, I implemented support for the Machine Specific Registers supported
by most recent processors that are compatible with the x86 line.
These registers provide access to options and statistics deeply buried
inside the CPU.
Some Examples:
- application interface to the cycle counter
(user level program to determine clock speed)
- counting of internal events:
- cache hits/misses
- [MMX] instructions executed in U/V pipe
- bad alignments
Intel claims that with each generation of processors, the meaning of the
registers might change. I only have information on the Pentium and I will
go find and post some URLs to listings of these features.
Access to the registers is made available through the character device
/dev/msr major 10 / minor 8. (Could the responsible person please make
this assignment official?). To read/write, you open the device and seek to
the index of the needed register. E.g. for register Nr.10, this becomes
"lseek(f,10,0);". Regardless of the specified size, always 8 bytes (two
long ints, 64 bits) are copied (actual size of a register). The high dword
(edx) is followed by the low dword (eax).
The code is very simple and should be easy to understand. However, it took
me quite some time to dig around in other sources to learn how to
implement a character device. And I don't understand, why an "open"
function is needed for a character device with major 10 (misc device).
It's just the body in my code.
The patch is against 2.0.29, but should probably work with 2.1.x, too. To
enable this, you need to check "Prompt for development and/or incomplete
code/drivers" and then enable "Enable /dev/msr to access Machine Specific
Registers" in section "General setup". Recompile and enjoy!
IMHO, this could be the way to many answers to performance related
questions. Especially debugger programmers might be interested in this.
Have fun and send me feedback!
Many thanks go to Ingo Molnar for encouraging me!