* [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open
@ 2026-06-09 15:37 l1za0.sec
0 siblings, 0 replies; only message in thread
From: l1za0.sec @ 2026-06-09 15:37 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung
Cc: mark.rutland, alexander.shishkin, jolsa, irogers, adrian.hunter,
james.clark, linux-perf-users, linux-kernel, sashiko-bot
From: Haocheng Yu <3230100410@zju.edu.cn>
A lockdep warning: possible deadlock in __perf_event_task_sched_out is
reported by a modified Syzkaller-based kernel fuzzing tool we use.
The warning is triggered on the self-monitoring perf_event_open() path.
When perf_install_in_context() targets the current task, it goes through
task_function_call() and the synchronous smp_call_function_single()
self-call path. The reported lockdep chain contains:
rq->__lock -> ctx->lock
and an existing reverse dependency from:
ctx->lock -> ... -> p->pi_lock -> rq->__lock
The current fix adds a fast path for task == current in
perf_install_in_context() and calls __perf_install_in_context()
directly.
This fix removes the self-call path for the reported self-monitoring
case. It does not change the scheduler-side locking order in
__perf_event_task_sched_out(), so it should be treated as a targeted
mitigation for this trigger path.
Signed-off-by: Haocheng Yu <3230100410@zju.edu.cn>
Signed-off-by: Haocheng Yu <l1za0.sec@gmail.com>
---
kernel/events/core.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7935d5663944..97837242db32 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3199,6 +3199,15 @@ perf_install_in_context(struct perf_event_context *ctx,
*/
smp_mb();
again:
+ if (task == current) {
+ unsigned long flags;
+ preempt_disable();
+ local_irq_save(flags);
+ __perf_install_in_context(event);
+ local_irq_restore(flags);
+ preempt_enable();
+ return;
+ }
if (!task_function_call(task, __perf_install_in_context, event))
return;
base-commit: 33d8d8ec31b591952ded59d596c2f3db45004937
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-09 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-09 15:37 [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open l1za0.sec
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®