NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Ux on June 12, 2012, 10:30:22 PM

Title: Availability of performance monitoring in user mode
Post by: Ux on June 12, 2012, 10:30:22 PM
Hi folks,

I want to do some performance monitoring using the processor's built-in counters, but when I tried using the RDPMC instruction, I got a segmentation fault on Mac OS/X, both when using sudo and when not.

Update:
Apparently the kernel needs to need the CR4 bit enabling that feature in user mode. In Mac OS/X this is unlikely but Linux remains a possibility.

Thanks.
Title: Re: Availability of performance monitoring in user mode
Post by: Frank Kotler on June 13, 2012, 06:46:16 PM
Never tried RDPMC... so I did. Sure enough, it segfaults in Linux too. I think you're right that you'd have to be a kernel module to modify cr4. I don't know why the OS would want to keep us away from that instruction, but apparently it does. I don't know much about it, period! Good luck!

Best,
Frank

Title: Re: Availability of performance monitoring in user mode
Post by: Keith Kanios on June 14, 2012, 12:05:11 AM
I don't know why the OS would want to keep us away from that instruction, but apparently it does.

Security, stability, etc.

Will something like Shark suffice, or are you trying to specifically learn about RDPMC and the like?
Title: Re: Availability of performance monitoring in user mode
Post by: Ux on June 14, 2012, 01:35:43 PM
Will something like Shark suffice, or are you trying to specifically learn about RDPMC and the like?

My goal is to determine how efficiently the caches are being used, like total L1 cache misses. RDPMC lets you get access to that kind of fine-grained data.
Title: Re: Availability of performance monitoring in user mode
Post by: Keith Kanios on June 14, 2012, 05:13:52 PM
RDPMC lets you get access to that kind of fine-grained data.

Check out Valgrind (http://valgrind.org/)/Cachegrind (http://valgrind.org/docs/manual/cg-manual.html).