[PATCH v3 1/4] perf/core: Do not account overflows of a throttled event

From: Oancea Catalin

Date: Thu Dec 03 2026 - 01:27:25 EST


A throttle marks every event of the group with hw.interrupts ==
MAX_INTERRUPTS and stops it. The tick unthrottles the group when it
finds that mark on the group leader.

__perf_event_account_interrupt() counts the overflow of an event which
is already throttled like any other. This overwrites the mark, and if
the event is the leader, the group stays stopped until it is scheduled
in again.

A PMU interrupt handler can report such an overflow: one interrupt can
carry the overflows of several events of a group, and the first of
them may throttle the group. The following patches make the x86
handlers report the others too. Without this change a group with its
leader on a fixed counter of an Intel CPU then got 32 THROTTLE records
and no UNTHROTTLE record in 4 seconds.

Return early for an event which is already throttled. Its sample is
still delivered.

An AI coding assistant (Claude Code) was used in the analysis and in
writing the patch.

Fixes: 9734e25fbf5a ("perf: Fix the throttle logic for a group")
Signed-off-by: Oancea Catalin <john3@xxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
The numbers are from a test kernel with patches 2 to 4 but without
this one, on a Core i7-14700T: two instructions events with period
20000 in one group, pinned task. It delivered 1600 to 4046 samples per
second instead of 100000.

I looked for the same on mainline as it is, through the PEBS drain,
which also delivers for an event stopped earlier in the same PMI. Two
PEBS events in a group with one PMI per record did not show it.

perf_event_account_interrupt() has other callers (Intel PEBS, AMD IBS,
powerpc). For them the early return means that an event which is
already throttled is not throttled a second time.

kernel/events/core.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4ab3919ac78e..cfe9ec01fdff 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10773,6 +10773,15 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle,
int ret = 0;
u64 seq;

+ /*
+ * A PMU handler can report an overflow which was pending when a
+ * throttle stopped the event together with its group. Accounting it
+ * would overwrite MAX_INTERRUPTS, and the tick would no longer
+ * unthrottle the group if the event is its leader.
+ */
+ if (unlikely(hwc->interrupts == MAX_INTERRUPTS))
+ return 0;
+
seq = __this_cpu_read(perf_throttled_seq);
if (seq != hwc->interrupts_seq) {
hwc->interrupts_seq = seq;
--
2.56.1