mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Luo Gengkun <luogengkun@huaweicloud.com>
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
	x86@kernel.org
Subject: Re: [tip: perf/urgent] perf/core: Fix WARN in perf_cgroup_switch()
Date: Thu, 26 Jun 2025 15:13:26 +0200	[thread overview]
Message-ID: <20250626131326.GH1613200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <3dfe387c-d1db-4cbe-b41d-8f9f27fe3a1f@huaweicloud.com>

On Thu, Jun 26, 2025 at 09:08:38PM +0800, Luo Gengkun wrote:

> Sorry for the late reply, I found that the link is v2 instead of v3.
> This v3 link is:
> 
> https://lore.kernel.org/all/20250609035316.250557-1-luogengkun@huaweicloud.com/
> 
> v2 attempts to fix a concurrency problem between perf_cgroup_switch
> and perf_cgroup_event_disable. But it does not to move WARN_ON_ONCE
> into lock-protected region, so the warning is still triggered.
> 
> The following patches have been tested and fix this issue.
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 1f746469fda5..a35784d42c66 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -951,8 +951,6 @@ static void perf_cgroup_switch(struct task_struct *task)
>         if (READ_ONCE(cpuctx->cgrp) == NULL)
>                 return;
> 
> -       WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0);
> -
>         cgrp = perf_cgroup_from_task(task, NULL);
>         if (READ_ONCE(cpuctx->cgrp) == cgrp)
>                 return;
> @@ -964,6 +962,8 @@ static void perf_cgroup_switch(struct task_struct *task)
>         if (READ_ONCE(cpuctx->cgrp) == NULL)
>                 return;
> 
> +       WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0);
> +
>         perf_ctx_disable(&cpuctx->ctx, true);
> 
>         ctx_sched_out(&cpuctx->ctx, NULL, EVENT_ALL|EVENT_CGROUP);

Can you send as a full new patch, the thing is already in Linus' tree.

      reply	other threads:[~2025-06-26 13:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-04  3:39 [PATCH v2 0/2] Fix perf cgroup problem Luo Gengkun
2025-06-04  3:39 ` [PATCH v2 1/2] perf/core: Fix nr_cgroups/cpuctx->cgrp is not updated correctly Luo Gengkun
2025-06-04  9:19   ` Peter Zijlstra
2025-06-04  9:42     ` Luo Gengkun
2025-06-04  3:39 ` [PATCH v2 2/2] perf/core: Fix WARN_ON_ONCE(cpuctx->ctx.nr_cgroups == 0) in perf_cgroup_switch Luo Gengkun
2025-06-04 10:00   ` Peter Zijlstra
2025-06-05  3:55     ` Luo Gengkun
2025-06-05  7:36       ` Peter Zijlstra
2025-06-11  9:29   ` [tip: perf/urgent] perf/core: Fix WARN in perf_cgroup_switch() tip-bot2 for Luo Gengkun
2025-06-26 13:08     ` Luo Gengkun
2025-06-26 13: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=20250626131326.GH1613200@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luogengkun@huaweicloud.com \
    --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®