Skip to content

Commit f51972e

Browse files
Qing WangPeter Zijlstra
authored andcommitted
perf/core: Fix broken throttling when max_samples_per_tick=1
According to the throttling mechanism, the pmu interrupts number can not exceed the max_samples_per_tick in one tick. But this mechanism is ineffective when max_samples_per_tick=1, because the throttling check is skipped during the first interrupt and only performed when the second interrupt arrives. Perhaps this bug may cause little influence in one tick, but if in a larger time scale, the problem can not be underestimated. When max_samples_per_tick = 1: Allowed-interrupts-per-second max-samples-per-second default-HZ ARCH 200 100 100 X86 500 250 250 ARM64 ... Obviously, the pmu interrupt number far exceed the user's expect. Fixes: e050e3f ("perf: Fix broken interrupt rate throttling") Signed-off-by: Qing Wang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 1caafd9 commit f51972e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kernel/events/core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10065,14 +10065,14 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle)
1006510065
hwc->interrupts = 1;
1006610066
} else {
1006710067
hwc->interrupts++;
10068-
if (unlikely(throttle &&
10069-
hwc->interrupts > max_samples_per_tick)) {
10070-
__this_cpu_inc(perf_throttled_count);
10071-
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
10072-
hwc->interrupts = MAX_INTERRUPTS;
10073-
perf_log_throttle(event, 0);
10074-
ret = 1;
10075-
}
10068+
}
10069+
10070+
if (unlikely(throttle && hwc->interrupts >= max_samples_per_tick)) {
10071+
__this_cpu_inc(perf_throttled_count);
10072+
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
10073+
hwc->interrupts = MAX_INTERRUPTS;
10074+
perf_log_throttle(event, 0);
10075+
ret = 1;
1007610076
}
1007710077

1007810078
if (event->attr.freq) {

0 commit comments

Comments
 (0)