Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to learn how performance counter works for my research project. I have understood how hardware supports the monitoring of events.Intel manual gives description on how the performance monitoring units on the chip helps to get the counters. I also have learned how the MSR module gets the information of the msr registers for various events.

I need to learn the following things.

1) How performance monitoring tools are used for multiple processes simultaneously. I think all the registers will be saved during context switch and are loaded when the process start again.Browsing Internet I got something like "pfm_context_load" and "pfm_context_unload" but it didn't had much info......-> " I need more detailed information on how it works,so please provide some links,documentation which can help me achieve my understanding"

2) Also how performance counters work in virtual environment? And what are the problems measuring the counters in such environment? I have browsed through few papers and have some info, But need more detail information.

So if anyone can guide me with some documentation on these topics or at least guide me on where should I search for all these info with be a great help! ...

If this is not the right forum then please direct me towards right place..



share|improve this question

Install the perf tools using:

sudo apt-get install linux-tools

You can then run perf on an executable using using the appropriate event using the -e flag, for example to measure CPU cycles on the ps command use:

perf stat -e cycles ps

To see which events are available use:

perf list

..some are software events and some are hardware events like the ones you were referring to.

There is some excellent documentation at:

Hope that helps!

share|improve this answer
@King: I guess perf is not the answer to the question what Anup has asked as I am also looking for the answer of the same. The question is more on the basics of how it is implemented. Also you cannot use perf in scenarios where every single branch will effect you as the results of perf are not precise. – Jatin Kumar Mar 30 '13 at 14:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.