Accessing hardware counters

Accessing hardware counters

CPU hardware counter registers provides information about CPU events such as cache miss, hit and etc. This can be done through injecting a simulated code. Assume that, this code is processed by process (A) to collect required information. Is it possible that another process (B) monitor process (A) instead itself? Even if this can be done through kernel will be fine.


Thread Topic: 

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I found this article that may be related to the information that you are looking for: Capturing Performance Counter Data for a Process by Process Id. - Thai


Thank you Thai, That is really interesting for Microsoft framework. But, I am working in Linux platform in C language. There are libraries like PAPI which can access PHC counters, but not sure if it is able to do that.

Many thanks Thai

Your welcome.  I found some other information that may give you some hints on this research: 
- Intel® Performance Counter Monitor - A better way to measure CPU utilization article;
- Intel Performance Processor Counter Monitor on github.
For questions and comments about Intel PCM and its use-cases, we recommend the Software Tuning, Performance Optimization & Platform Monitoring forum.



Thank you for giving me the hints.  I've tried pmc and msr (RDMSR and WRMSR instructions).

Leave a Comment

Please sign in to add a comment. Not a member? Join today