Look at the principle of perf again

vim ./arch/x86/kernel/hw_breakpoint.c

How perf controls the frequency of sampling

The perf samples different events, and the results are not the same

cycles:

Add different functions to the PMU, add different

Using perf's default event, I can't catch my user-mode process,

cpu-cycles will catch this event

For the same event, the content sampled by different sampling frequencies is not the same.

sudo perf top -c 99 -C 1 was able to catch my loop process

sudo perf top -C 1 can't catch my loop process

Finally let me find the pmu handler function: intel_pmu_handle_irq

I set it to -c 99 here, and found that an intel_pmu_handle_irq interrupt is triggered every 4ms

When set to -c 200, it is found that the intel_pmu interrupt will be triggered every 4ms, but it is very strange that within this 4ms, yo will be set twice

Set to -c 300, or will start every 4ms intel-pum-handle-irq

Set to -c 400/500, it will start an interrupt of intel_pmu_handle_irq every 4ms, I feel that this is

If it is not set, the precision will be interrupted every 2us, but if it is set to -c 10, it will be interrupted every 4ms, but

I ran a loop process on CPU1, it should be said that it can occupy the CPU, but this CPU, if you press perf to capture, it should also capture the CPU of this loop process in full, but now I have captured a lot of native_sched_lock/ nmi_handler/ do_nmi /nmi / sched_lockzhe, I remember that a lot of functions in my loop process were caught before. . . .

native_write_msr_safe

You can catch the event by setting it to cycles. The default event is cycles:pp

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325001323&siteId=291194637