From: l1za0.sec@gmail.com
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, sashiko-bot@kernel.org
Subject: [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open
Date: Tue, 9 Jun 2026 23:37:24 +0800 [thread overview]
Message-ID: <20260609153724.7878-1-l1za0.sec@gmail.com> (raw)
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
next reply other threads:[~2026-06-09 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:37 l1za0.sec [this message]
2026-06-09 15:51 ` [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open sashiko-bot
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=20260609153724.7878-1-l1za0.sec@gmail.com \
--to=l1za0.sec@gmail.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=jolsa@kernel.org \
--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=sashiko-bot@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