简体   繁体   中英

Perf Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/)

I am using perf to monitor the system for certain events. However, I get the following error and I have no idea where it comes from,as the event is listed in perf list

sudo perf record -e msr/tsc/ -a

Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?

How can I check No CONFIG_PERF_EVENTS=y kernel support configured?

**Some test results:

sudo dmesg | grep "perf\|pmu"**
[    0.029179] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[    0.029179] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 9475.406967] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[ 9475.990901] perf: interrupt took too long (3146 > 3136), lowering kernel.perf_event_max_sample_rate to 63500
[ 9476.886941] perf: interrupt took too long (3942 > 3932), lowering kernel.perf_event_max_sample_rate to 50500
[76057.268195] perf: interrupt took too long (4934 > 4927), lowering kernel.perf_event_max_sample_rate to 40500
[167368.007839] perf: interrupt took too long (6171 > 6167), lowering kernel.perf_event_max_sample_rate to 32250
[168338.165608] perf: interrupt took too long (7804 > 7713), lowering kernel.perf_event_max_sample_rate to 25500

perf list |grep msr

  msr/aperf/                                         [Kernel PMU event]
  msr/mperf/                                         [Kernel PMU event]
  msr/pperf/                                         [Kernel PMU event]
  msr/smi/                                           [Kernel PMU event]
  msr/tsc/   

sudo uname -a Linux bla 4.9.0-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux

sudo /proc/config.gz returns command not found Any help/ideas are appreciated.

There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC , IA32_APERF , IA32_MPERF and IA32_PPERF .

These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.

Snippet:

if event->attr.sample_period) /* no sampling */ return -EINVAL;

perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record , you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period , internally sampling is happening at a default sampling frequency.

To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --

perf stat -e msr/tsc/ -a

^C

Performance counter stats for 'system wide':

 34,83,07,96,035      msr/tsc/                                                    

 2.419151644 seconds time elapsed

Read this to understand more about counting and sampling events/modes.

It is possible to collect this information with perf record by using group sampling. For example, the following command

perf record -a -e '{cycles,msr/aperf/,msr/tsc/}:S'

collects values of all three events based on the cycle (first counter) overflow. The undocumented :S modifier is necessary, it makes sure that only the leader of the group triggers samples. For seeing this information, you use perf report --group , the parameter may not be necessary. I'm afraid the actual values for each sample are only visible in the very verbose perf script -D .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM