Community
cancel
Showing results for 
Search instead for 
Did you mean: 
anthony_b_
Beginner
552 Views

how to use rdmsr from my C program?

From intel software developer manual 3b, I came to know MSR (10H) equal to RDTSC. So I wanted to verify it using piece of code as follows in my program:

asm volatile("rdmsr":"=a"(lo),"=d"(hi):"c"(0x10));

But when I run my program it showed segmentation fault. Then a realized the caution that it work only in privilege level 0. So I run the program again with sudo access. This time the program ran without seg fault but the statement after asm volatile(..) are not getting executed. Even it dint work out.

What shall I do to make rdmsr work in my program?
(I am using linux on i7 core which supports these counters. I verified it.)

Thank you

0 Kudos
3 Replies
Adrian_C_
Beginner
552 Views

How would you do this in the Windows OS?

Thomas_G_4
New Contributor II
552 Views

I don't know whether there is a WindowsOS native way to access the MSRs, probably through some debugging interface or such.

You can use the Windows driver from Intel PCM https://github.com/opcm/pcm to get an interface to the user space. For further information see the Windows HOWTO https://github.com/opcm/pcm/blob/master/WINDOWS_HOWTO.rtf

Here is also a link with some explanations how to install the driver: https://software.intel.com/en-us/forums/software-tuning-performance-optimization-platform-monitoring...

SB17
Beginner
552 Views

If it will be helpfull - good examples of how to use rd/wrmsr is the source code of Intel Performance Counter Monitor and Likwid.

 

 

Reply