Skip to content

Commit 126ba99

Browse files
Qing Wangsmb49
authored andcommitted
perf/core: Fix broken throttling when max_samples_per_tick=1
BugLink: https://bugs.launchpad.net/bugs/2119603 [ Upstream commit f51972e6f8b9a737b2b3eb588069acb538fa72de ] 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]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent f979f59 commit 126ba99

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
@@ -9763,14 +9763,14 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle)
97639763
hwc->interrupts = 1;
97649764
} else {
97659765
hwc->interrupts++;
9766-
if (unlikely(throttle &&
9767-
hwc->interrupts > max_samples_per_tick)) {
9768-
__this_cpu_inc(perf_throttled_count);
9769-
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
9770-
hwc->interrupts = MAX_INTERRUPTS;
9771-
perf_log_throttle(event, 0);
9772-
ret = 1;
9773-
}
9766+
}
9767+
9768+
if (unlikely(throttle && hwc->interrupts >= max_samples_per_tick)) {
9769+
__this_cpu_inc(perf_throttled_count);
9770+
tick_dep_set_cpu(smp_processor_id(), TICK_DEP_BIT_PERF_EVENTS);
9771+
hwc->interrupts = MAX_INTERRUPTS;
9772+
perf_log_throttle(event, 0);
9773+
ret = 1;
97749774
}
97759775

97769776
if (event->attr.freq) {

0 commit comments

Comments
 (0)