Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gregg Leventhal" <gleventhal@janestreet.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/core: Use the elapsed period for frequency-mode period adjustment
Date: Tue, 17 Nov 2026 20:37:08 +0000	[thread overview]
Message-ID: <sashiko-outbox-219630@kernel.org> (raw)
In-Reply-To: <20261117152351.1294050-1-gleventhal@janestreet.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] perf: data race in __perf_event_overflow() [1]
--

commit 3821f44b0f2d83639af791a4e85517a4c30f74ba
Author: Jay Hilton <jahilton@janestreet.com>

perf/core: Use the elapsed period for frequency-mode period adjustment

This commit passes the sample's elapsed period (data->period) instead of
hwc->last_period from __perf_event_overflow() to
__perf_event_account_interrupt() so frequency-mode period adjustment uses
the period of the interval that just completed rather than the newly
re-armed period.

> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 614f9f0e65005..5ce85180db7c6 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c

[ ... ]

> @@ -10912,7 +10919,7 @@ static int __perf_event_overflow(struct perf_event *event,
>  	if (unlikely(!is_sampling_event(event)))
>  		return 0;
>  
> -	ret = __perf_event_account_interrupt(event, throttle);
> +	ret = __perf_event_account_interrupt(event, throttle, data->period);
>  
>  	if (event->attr.aux_pause)
>  		perf_event_aux_pause(event->aux_event, true);

[Severity: Critical]
This problem wasn't introduced by this patch, but can
__perf_event_overflow() hit a data race [1] when reading
event->aux_event for aux_pause or aux_resume?

When a PMI fires in NMI context, __perf_event_overflow() loads
event->aux_event with a plain read instead of smp_load_acquire(), racing
with concurrent updates to event->aux_event.  Passing a stale or
uninitialized pointer to perf_event_aux_pause() -> ring_buffer_get() in
NMI context can dereference invalid memory and panic the kernel.

[1] https://sashiko.dev/#/bug/linux-3357f385-bcd3-40bc-a0de-f4f4d883aff5

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117152351.1294050-1-gleventhal@janestreet.com?part=1

      reply	other threads:[~2026-11-17 20:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 19:17 Subject: [BUG] perf/core: frequency-mode period overshoots during ramp-up Gregg Leventhal
2026-11-17 20:23 ` [PATCH] perf/core: Use the elapsed period for frequency-mode period adjustment Gregg Leventhal
2026-11-17 20:37   ` sashiko-bot [this message]

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-219630@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gleventhal@janestreet.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox