prathmesh.kallurkar
prathmesh.kallurkar

Reputation: 5686

Hardware performance counters to count the accesses of operating system

I want to collect the performance counter numbers while running some workload. This can be done easily using existing LAPI performance counter infrastructure. But, I want some more statistics like

  1. Number of instructions in ring level 0,1,2,3
  2. Number of load requests for l1 cache by different ring levels
  3. Length of a ring-level switch

So, effectively I want distinction between memory accesses of operating system and application.

Can someone please guide me as to how to do this ? PS : I have not used performance counters before. So, things that may seem a bit trivial to you may actually help me. Thanks

PS : Is there any way to obtain execution trace and the memory access trace of a system without changing application behavior.

Upvotes: 2

Views: 842

Answers (1)

peeyush
peeyush

Reputation: 2921

You can use hardware performance counter like perf.

Modern hardware provides hardware performance counter, so there are pretty good chances that your machine has this feature. Also you might need to put kernel drivers for it. (on ubuntu sudo apt-get is magic for this).

A little description of perf (imported from above link)

Perf is a profiler tool for Linux 2.6+ based systems that abstracts away CPU hardware differences in Linux performance measurements and presents a simple commandline interface. Perf is based on the perf_events interface exported by recent versions of the Linux kernel.

The perf tool supports a list of measurable events

where those events are listed in above link.

Say out of many events, you want to get stats of cycles event for below

perf stat -e cycles:u -e cycles:k -e cycles dd if=/dev/zero of=/dev/null count=100000 where u and k stands user and kernel respectively. you can also put all the events by separating them using comma.

Upvotes: 3

Related Questions