Skip to content

Commit 781bbc8

Browse files
Qing Wanggregkh
authored andcommitted
perf/core: Fix broken throttling when max_samples_per_tick=1
[ Upstream commit f51972e ] 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] Signed-off-by: Sasha Levin <[email protected]>
1 parent 5cd9865 commit 781bbc8

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
@@ -9715,14 +9715,14 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle)
97159715
hwc->interrupts = 1;
97169716
} else {
97179717
hwc->interrupts++;
9718-
if (unlikely(throttle &&
9719-
hwc->interrupts > max_samples_per_tick)) {
9720-
__this_cpu_inc(perf_throttled_count);
9721-
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
9722-
hwc->interrupts = MAX_INTERRUPTS;
9723-
perf_log_throttle(event, 0);
9724-
ret = 1;
9725-
}
9718+
}
9719+
9720+
if (unlikely(throttle && hwc->interrupts >= max_samples_per_tick)) {
9721+
__this_cpu_inc(perf_throttled_count);
9722+
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
9723+
hwc->interrupts = MAX_INTERRUPTS;
9724+
perf_log_throttle(event, 0);
9725+
ret = 1;
97269726
}
97279727

97289728
if (event->attr.freq) {

0 commit comments

Comments
 (0)