From: sashiko-bot@kernel.org
To: "Oancea Catalin" <john3@mailbox.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 6/8] perf/core: Keep the throttle mark out of hwc->interrupts
Date: Sat, 05 Dec 2026 13:57:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-251610@kernel.org> (raw)
In-Reply-To: <20261205133221.3294-7-john3@mailbox.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf/core: missing READ_ONCE()/WRITE_ONCE() on NMI-shared
hw.throttled
--
commit 670a6e0b5b041b454dc0340976a55a8311e04937
Author: Oancea Catalin <john3@mailbox.org>
perf/core: Keep the throttle mark out of hwc->interrupts
This commit moves the perf event throttle mark out of hwc->interrupts into a
dedicated hw.throttled field in struct hw_perf_event, updating
perf_event_throttle(), perf_event_unthrottle(), and all throttle checks in
kernel/events/core.c to use it.
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index bfeabcd906f2e..59ea05f9594e8 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
[ ... ]
> @@ -2796,6 +2794,7 @@ static void perf_event_unthrottle(struct perf_event *event, bool start)
> return;
>
> event->hw.interrupts = 0;
> + event->hw.throttled = 0;
> if (start)
> event->pmu->start(event, 0);
> if (event == event->group_leader)
> @@ -2807,7 +2806,7 @@ static void perf_event_throttle(struct perf_event *event)
> if (event->state != PERF_EVENT_STATE_ACTIVE)
> return;
>
> - event->hw.interrupts = MAX_INTERRUPTS;
> + event->hw.throttled = 1;
> event->pmu->stop(event, 0);
> if (event == event->group_leader)
> perf_log_throttle(event, 0);
[Severity: Low]
Should the accesses to event->hw.throttled use READ_ONCE() and WRITE_ONCE()?
hw.throttled is shared locklessly between NMI context in perf_event_throttle()
and non-NMI contexts in perf_event_unthrottle() and the read sites. When a
hardware sibling PMI throttles a mixed group during a software overflow, the
plain load racing with the NMI store triggers a KCSAN data-race report.
Unmarked accesses also allow the compiler to CSE the load across
perf_swevent_overflow() and __perf_event_account_interrupt(), or reorder
hw.interrupts = 0 and hw.throttled = 0 in perf_event_unthrottle().
Commit "perf/core: Throttle an event only once" converts perf_event_throttle()
to xchg(), but perf_event_unthrottle() and the read sites remain unmarked.
Using READ_ONCE() and WRITE_ONCE() matches other NMI-shared flags in
kernel/events/core.c such as rb->aux_in_sampling.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205133221.3294-1-john3@mailbox.org?part=6
next prev parent reply other threads:[~2026-12-05 13:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 13:32 [PATCH v5 0/8] perf/x86: Handle overflows of counters stopped by a throttle Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 1/8] perf/core: Disable the PMU of the context in __perf_event_period() Oancea Catalin
2026-12-05 13:58 ` sashiko-bot
2026-12-05 13:32 ` [PATCH v5 2/8] perf/core: Do not account overflows of a throttled event Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 3/8] perf/x86/amd/core: Handle overflows of counters stopped by a throttle Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 4/8] perf/x86: " Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 5/8] perf/x86/intel: " Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 6/8] perf/core: Keep the throttle mark out of hwc->interrupts Oancea Catalin
2026-12-05 13:57 ` sashiko-bot [this message]
2026-12-05 13:32 ` [PATCH v5 7/8] perf/core: Throttle an event only once Oancea Catalin
2026-12-05 13:32 ` [PATCH v5 8/8] perf/core: Stop an event which overflows while it is throttled Oancea Catalin
2026-12-05 14:24 ` sashiko-bot
2026-12-05 14:24 ` [PATCH v5 0/8] perf/x86: Handle overflows of counters stopped by a throttle sashiko-bot
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=sashiko-outbox-251610@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=john3@mailbox.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.