I'm trying to use RDPMC
Instruction for counting retired instructions and as Intel Software Developer's Manual Volume 3, Appendix A (In PERFORMANCE MONITORING section) mentioned:
• Instructions Retired — Event select C0H, Umask 00H This event counts the number of instructions at retirement. For instructions that consist of multiple micro-ops, this event counts the retirement of the last micro-op of the instruction. An instruction with a REP prefix counts as one instruction (not per iteration). Faults before the retirement of the last micro-op of a multi-ops instruction are not counted.
I used the answer from here to enable the performance counter from Linux Kernel-Mode module.
As you can see from here (Description of RDPMC
):
Loads the contents of the 40-bit performance-monitoring counter specified in the ECX register into registers EDX:EAX. The EDX register is loaded with the high-order 8 bits of the counter and the EAX register is loaded with the low-order 32 bits. The Pentium® Pro processor has two performance-monitoring counters (0 and 1), which are specified by placing 0000H or 0001H, respectively, in the ECX register.
After that, I put the 0 to RAX
and execute RDPMC
(in user-mode) but after RDPMC
executed multiple times EDX:EAX
are still zero.
So my questions are :
- How to count the Retired Instructions on a specific process in user-mode?
- What are the differences between
Event select C0H
andUmask 00H
and I want to know how to useC0H
and00H
?