With this library you will be able to use some Intel Core 2 Performance Monitor Counters and to read and write on Model Specific Registers (MSR).

I use this library to profile programs. Using it, you will be able to count the number of instructions, or the number of unhalted cycles on your applications, for example. However, you will need to add some system calls to your kernel, a patch for kernel 2.6.31 is included. Note: it is not safe to use it on production environment.

The files can be found here. If you like it, feel free to use it. It is under LGPL license. I will appreciate your feedback.