From: Peter Zijlstra <peterz@infradead.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: linux-tip-commits@vger.kernel.org, Q8 <cipher.gnep@gmail.com>,
x86@kernel.org
Subject: Re: [tip: perf/urgent] perf: Fix perf_remove_from_context() event scheduling
Date: Tue, 27 Oct 2026 16:13:11 +0100 [thread overview]
Message-ID: <20261027151311.GB1739534@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <179284164324.4109677.8240630031562225279.tip-bot2@tip-bot2>
On Sat, Oct 24, 2026 at 11:34:03AM -0000, tip-bot2 for Peter Zijlstra wrote:
> The following commit has been merged into the perf/urgent branch of tip:
>
> Commit-ID: d095321349222961813333277881b3c74f10b17b
> Gitweb: https://git.kernel.org/tip/d095321349222961813333277881b3c74f10b17b
> Author: Peter Zijlstra <peterz@infradead.org>
> AuthorDate: Wed, 14 Oct 2026 14:45:51 +02:00
> Committer: Peter Zijlstra <peterz@infradead.org>
> CommitterDate: Fri, 23 Oct 2026 19:09:52 +02:00
>
> perf: Fix perf_remove_from_context() event scheduling
>
> Q8 noted that it is possible to get into an inconsistent state when
> using perf_remove_from_context() on a group leader event.
>
> Specifically, when the leader gets scheduled out, we should (when not
> destroying the grouping) schedule out the complete group, similar to
> __perf_event_disable().
>
I noticed that I forgot the Fixes line :-/ This is an ancient oversight
afaict and needs backporting to all still maintained kernels.
Fixes: b04243ef7006 ("perf: Complete software pmu grouping")
> Reported-by: Q8 <cipher.gnep@gmail.com>
> Tested-by: Q8 <cipher.gnep@gmail.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/events/core.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index e248f34..f36a3bb 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2590,6 +2590,7 @@ __perf_remove_from_context(struct perf_event *event,
> enum perf_event_state state = PERF_EVENT_STATE_OFF;
> unsigned long flags = (unsigned long)info;
>
> + perf_pmu_disable(pmu_ctx->pmu);
> ctx_time_update(cpuctx, ctx);
>
> /*
> @@ -2603,6 +2604,13 @@ __perf_remove_from_context(struct perf_event *event,
> if (flags & DETACH_DEAD)
> state = PERF_EVENT_STATE_DEAD;
>
> + /*
> + * When disabling a group leader, the whole group becomes ineligible
> + * to run, so schedule out the full group.
> + */
> + if (!(flags & DETACH_GROUP) && event == event->group_leader)
> + group_sched_out(event, ctx);
> +
> __event_disable(event, ctx, state);
>
> if (flags & DETACH_GROUP)
> @@ -2632,6 +2640,7 @@ __perf_remove_from_context(struct perf_event *event,
> cpuctx->task_ctx = NULL;
> }
> }
> + perf_pmu_enable(pmu_ctx->pmu);
> }
>
> /*
prev parent reply other threads:[~2026-10-27 15:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 11:34 tip-bot2 for Peter Zijlstra
2026-10-27 15:13 ` Peter Zijlstra [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=20261027151311.GB1739534@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=cipher.gnep@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=stable@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®