Re: [PATCH] perf/x86/amd/core: Handle overflows of counters stopped by a throttle
From: Ravi Bangoria
Date: Tue Dec 01 2026 - 05:56:38 EST
Hi Oancea,
> amd_pmu_v2_handle_irq() reads PerfCntrGlobalStatus once, handles the
> overflows of the counters which are set in cpuc->active_mask and warns
> about every status bit which is left over:
>
> New overflows for inactive PMCs: 2
> WARNING: arch/x86/events/amd/core.c:1031 at amd_pmu_v2_handle_irq+0x86e/0x9a0
> Call Trace:
> perf_event_nmi_handler
> nmi_handle
> default_do_nmi
> exc_nmi
>
> Throttling stops the whole event group, so perf_event_overflow() can
> stop counters which the loop has not reached yet. When both events of a
> group overflow in the same NMI and the first one is throttled:
>
> amd_pmu_v2_handle_irq()
> status = 0x3
> counter 0: x86_perf_event_set_period()
> perf_event_overflow()
> perf_event_throttle_group()
> x86_pmu_stop(leader) clears active_mask bit 0
> x86_pmu_stop(sibling) clears active_mask bit 1
> counter 1: not in active_mask, skipped
> status = 0x2 warning
>
> The overflow of the sibling is not handled. Its period is not set up
> again and its status bit stays set, because only the handled bits are
> acknowledged.
I assume Intel's PMI handler as well as generic x86_pmu_handle_irq()
are also affected?
> @@ -1014,6 +1022,10 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
> if (!x86_perf_event_set_period(event))
> continue;
>
> + /* Stopped by a group throttle in an earlier iteration */
Nit: Can this comment be more explicit:
/*
* Group was throttled in an earlier iteration; re-arm the
* counter without delivering the sample.
*/
Thanks,
Ravi