* [PATCH] perf: Fix lockdep warning in perf_event_throttle_group
@ 2025-11-12 12:34 Jianhui Zhou
2025-11-13 8:15 ` Mi, Dapeng
0 siblings, 1 reply; 3+ messages in thread
From: Jianhui Zhou @ 2025-11-12 12:34 UTC (permalink / raw)
To: peterz, mingo
Cc: acme, namhyung, mark.rutland, alexander.shishkin, jolsa, irogers,
adrian.hunter, james.clark, jonaszhou, linux-perf-users,
linux-kernel, Jianhui Zhou, syzbot+a945e9d15c8a49a7a7f0
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)();
for_each_sibling_event(sibling, leader)
perf_event_throttle(sibling);
}
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf: Fix lockdep warning in perf_event_throttle_group
2025-11-12 12:34 [PATCH] perf: Fix lockdep warning in perf_event_throttle_group Jianhui Zhou
@ 2025-11-13 8:15 ` Mi, Dapeng
2026-09-15 21:57 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Mi, Dapeng @ 2025-11-13 8:15 UTC (permalink / raw)
To: Jianhui Zhou, peterz, mingo
Cc: acme, namhyung, mark.rutland, alexander.shishkin, jolsa, irogers,
adrian.hunter, james.clark, jonaszhou, linux-perf-users,
linux-kernel, syzbot+a945e9d15c8a49a7a7f0
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);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf: Fix lockdep warning in perf_event_throttle_group
2025-11-13 8:15 ` Mi, Dapeng
@ 2026-09-15 21:57 ` Ian Rogers
0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2026-09-15 21:57 UTC (permalink / raw)
To: Mi, Dapeng, mingo, peterz
Cc: Jianhui Zhou, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, adrian.hunter, james.clark, jonaszhou, linux-perf-users,
linux-kernel, syzbot+a945e9d15c8a49a7a7f0
On Thu, Nov 13, 2025 at 12:15 AM Mi, Dapeng <dapeng1.mi@linux.intel.com> wrote:
>
>
> 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>
It seems this was never submitted, should it be?
Thanks,
Ian
> > for_each_sibling_event(sibling, leader)
> > perf_event_throttle(sibling);
> > }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-15 21:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-12 12:34 [PATCH] perf: Fix lockdep warning in perf_event_throttle_group Jianhui Zhou
2025-11-13 8:15 ` Mi, Dapeng
2026-09-15 21:57 ` Ian Rogers
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®