Author Topic: Availability of performance monitoring in user mode  (Read 3143 times)

Offline Ux

  • Jr. Member
  • *
  • Posts: 12
Availability of performance monitoring in user mode
« 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.
« Last Edit: June 13, 2012, 05:15:13 PM by Ux »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2361
  • Country: us
Re: Availability of performance monitoring in user mode
« Reply #1 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


Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: Availability of performance monitoring in user mode
« Reply #2 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?

Offline Ux

  • Jr. Member
  • *
  • Posts: 12
Re: Availability of performance monitoring in user mode
« Reply #3 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.

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: Availability of performance monitoring in user mode
« Reply #4 on: June 14, 2012, 05:13:52 PM »
RDPMC lets you get access to that kind of fine-grained data.

Check out Valgrind/Cachegrind.