Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using linux perf and PEBS to sample memory accesses in a program

I've been trying to use the linux perf tool to sample the memory accesses in my program. Specifically, I'm using the perf mem command to instrument the loads in the program:

perf mem -t load rec myprogram
perf mem -t load rep

However, I would like to increase the sampling frequency and collect more samples. But I did not find any option for the perf mem command that controls the sampling frequency.

Questions

  1. Is there an option that would let me control the sampling frequency when running perf mem?
  2. What's the default sampling frequency?
  3. Is there a better option that perf mem to instrument the memory accesses in the program? I'm specifically looking for the following bits of data for each of the sampled load operations - (i) Target data address (ii) And whether the load resulted in an L1/L2/LLC cache hit or not.
like image 688
jithinpt Avatar asked Dec 06 '25 03:12

jithinpt


1 Answers

1- have you tried the -F option used to specify the average sampling rate in samples per sec (https://perf.wiki.kernel.org/index.php/Tutorial#Sampling_with_perf_record) ?

2- According to the wiki (link above) "The perf tool defaults to the average rate. It is set to 1000Hz, or 1000 samples/sec."

3- I think perf mem provides all the information you need.

like image 101
Manuel Selva Avatar answered Dec 08 '25 22:12

Manuel Selva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!