Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum sampling frequency supported by perf

Tags:

linux

perf

How is the value of the maximum sampling frequency is determined by linux kernel? Why does this value change provided that perf is executed on the same machine?

When working with perf, I have noticed that the value of perf_event_max_sample_rate changes? Why? should not this value remain constant?

like image 629
user3527764 Avatar asked Oct 19 '25 06:10

user3527764


1 Answers

Linux kernel tracks of how long perf's non-maskable interrupt(NMI) handler is performing. If the sample duration exceeds a configurable threshold(perf_cpu_time_max_percent), it drops the sample rate. This allows to prevent system from hanging because it spends all of its time handling sampling process. In this case you will see the following message in kernel logs:

perf samples too long (2506 > 2500), lowering kernel.perf_event_max_sample_rate to 50000

You can disable this throttling mechanism by setting perf_cpu_time_max_percent to 0:

sysctl -w kernel.perf_cpu_time_max_percent=0

Useful links:

  • Documentation for the sysctl files perf_cpu_time_max_percent
  • Linux kernel sources
  • See also this patch which introduces this throttling mechanism
like image 157
Ivan Mamontov Avatar answered Oct 21 '25 21:10

Ivan Mamontov