From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Oancea Catalin <john3@mailbox.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH v3 3/4] perf/x86: Handle overflows of counters stopped by a throttle
Date: Thu, 3 Dec 2026 17:03:00 +0800 [thread overview]
Message-ID: <cf802134-1b2e-4989-8d89-1ab926177681@linux.intel.com> (raw)
In-Reply-To: <20261203062703.15346-4-john3@mailbox.org>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Thanks.
On 12/3/2026 2:27 PM, Oancea Catalin wrote:
> x86_pmu_handle_irq() tests cpuc->active_mask while it walks the
> counters. When perf_event_overflow() throttles a group, the other
> events of the group are stopped and the loop skips them, also when
> they have overflowed in the same NMI.
>
> The period of such a counter is not set up again. The counter is
> restarted as it is when the group is unthrottled, so the overflow is
> noticed by a later NMI of another counter, or not at all when the
> event is scheduled out first.
>
> Take a copy of active_mask before the loop and walk the counters which
> were active on entry, as in amd_pmu_v2_handle_irq().
>
> 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@mailbox.org>
> Cc: stable@vger.kernel.org
> ---
> Tested with the reproducer of patch 2 on the same AMD machine and in
> the guest, booted with clearcpuid=perfmon_v2 so that
> amd_pmu_handle_irq() is used. I have no other hardware which uses
> this handler.
>
> arch/x86/events/core.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 4e344fb1ae3e..b4f956c5ca1c 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -2157,6 +2157,7 @@ void x86_pmu_update_perf_regs(struct perf_event *event,
>
> int x86_pmu_handle_irq(struct pt_regs *regs)
> {
> + DECLARE_BITMAP(active, X86_PMC_IDX_MAX);
> struct perf_sample_data data;
> struct cpu_hw_events *cpuc;
> struct perf_event *event;
> @@ -2176,8 +2177,15 @@ int x86_pmu_handle_irq(struct pt_regs *regs)
> */
> apic_write(APIC_LVTPC, APIC_DM_NMI);
>
> + /*
> + * perf_event_overflow() can throttle and thereby stop the whole group.
> + * Walk the counters which are active now, so that a pending overflow
> + * of a sibling stopped that way is still handled.
> + */
> + bitmap_copy(active, cpuc->active_mask, X86_PMC_IDX_MAX);
> +
> for_each_set_bit(idx, x86_pmu.cntr_mask, X86_PMC_IDX_MAX) {
> - if (!test_bit(idx, cpuc->active_mask))
> + if (!test_bit(idx, active))
> continue;
>
> event = cpuc->events[idx];
next prev parent reply other threads:[~2026-12-03 9:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:26 [PATCH v3 0/4] " Oancea Catalin
2026-12-03 6:27 ` [PATCH v3 1/4] perf/core: Do not account overflows of a throttled event Oancea Catalin
2026-12-03 8:59 ` Mi, Dapeng
2026-12-03 6:27 ` [PATCH v3 2/4] perf/x86/amd/core: Handle overflows of counters stopped by a throttle Oancea Catalin
2026-12-03 6:27 ` [PATCH v3 3/4] perf/x86: " Oancea Catalin
2026-12-03 9:03 ` Mi, Dapeng [this message]
2026-12-03 6:27 ` [PATCH v3 4/4] perf/x86/intel: " Oancea Catalin
2026-12-03 9:08 ` Mi, Dapeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf802134-1b2e-4989-8d89-1ab926177681@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john3@mailbox.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®