linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Jianhui Zhou <jianhuizz@qq.com>, peterz@infradead.org, mingo@redhat.com
Cc: acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	james.clark@linaro.org, jonaszhou@zhaoxin.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+a945e9d15c8a49a7a7f0@syzkaller.appspotmail.com
Subject: Re: [PATCH] perf: Fix lockdep warning in perf_event_throttle_group
Date: Thu, 13 Nov 2025 16:15:15 +0800	[thread overview]
Message-ID: <8dd3659d-8395-49da-94c0-3f18880ead1f@linux.intel.com> (raw)
In-Reply-To: <tencent_5A81C3E27E416B65341A899C62ADD6FF0D0A@qq.com>


On 11/12/2025 8:34 PM, Jianhui Zhou wrote:
> When perf samples a tracepoint like trace_lock_acquire with high
> frequency, it can trigger a WARN_ON in perf_event_throttle_group()
> due to lockdep assertion failure in for_each_sibling_event().
>
> The issue is that for_each_sibling_event() requires either:
> 1. Holding ctx->mutex, OR
> 2. Having IRQs disabled (since ctx->lock is IRQ-safe)
>
> The call trace shows the problematic path:
> futex_wake
>   lock_acquire
>     trace_lock_acquire
>       perf_trace_lock_acquire
>         perf_tp_event
>           perf_swevent_event
>             __perf_event_overflow
>               __perf_event_account_interrupt
>                 perf_event_throttle_group
>                   for_each_sibling_event [WARN]
>
> In this tracepoint path, IRQs may be enabled and neither ctx->lock
> nor ctx->mutex is held.
>
> The fix adds guard(irqsave)() protection around the sibling list
> iteration in perf_event_throttle_group().
>
> Reported-by: syzbot+a945e9d15c8a49a7a7f0@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/all/69122cb3.a70a0220.22f260.00ff.GAE@google.com/T/
> Signed-off-by: Jianhui Zhou <jianhuizz@qq.com>
> ---
>  kernel/events/core.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 1fd347da9026..253c514e9452 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2700,6 +2700,11 @@ static void perf_event_throttle_group(struct perf_event *event)
>  	struct perf_event *sibling, *leader = event->group_leader;
>  
>  	perf_event_throttle(leader);
> +    /*
> +     * Disable IRQs to protect sibling iteration; for_each_sibling_event()
> +     * needs ctx->mutex or IRQs off.
> +     */
> +	guard(irqsave)();

This seems the simplest way to fix the issue although it may bring a slight
overhead if hard irq is already disabled. Thanks.

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>


>  	for_each_sibling_event(sibling, leader)
>  		perf_event_throttle(sibling);
>  }

      reply	other threads:[~2025-11-13  8:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 12:34 [PATCH] perf: Fix lockdep warning in perf_event_throttle_group Jianhui Zhou
2025-11-13  8:15 ` Mi, Dapeng [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=8dd3659d-8395-49da-94c0-3f18880ead1f@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=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jianhuizz@qq.com \
    --cc=jolsa@kernel.org \
    --cc=jonaszhou@zhaoxin.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=syzbot+a945e9d15c8a49a7a7f0@syzkaller.appspotmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).