From: sashiko-bot@kernel.org
To: l1za0.sec@gmail.com
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open
Date: Tue, 09 Jun 2026 15:51:55 +0000 [thread overview]
Message-ID: <20260609155156.0F5131F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260609153724.7878-1-l1za0.sec@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix for a core lock inversion (potential deadlock) between the scheduler runqueue lock and perf context lock.
--
commit 008930a2883145d064fbb634b2b2120e78395849
Author: Haocheng Yu <3230100410@zju.edu.cn>
perf: avoid lockdep warning in self-monitoring perf_event_open
This commit adds a fast path for self-monitoring events in
perf_install_in_context() to bypass task_function_call(). It is intended as a
targeted mitigation to avoid a lockdep warning about a potential deadlock
between the scheduler runqueue lock and the perf context lock.
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 7935d5663944e..97837242db328 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;
> + }
[Severity: High]
This isn't a bug introduced by this patch, but does this actually resolve the
underlying lock inversion?
The commit message documents an ABBA deadlock cycle involving rq->__lock and
ctx->lock. While this fast path avoids the specific lockdep warning triggered
during self-monitoring, cross-task monitoring (task != current) will skip this
block and fall through to task_function_call().
Does this mean the exact same lock inversion and potential deadlock remain
fully reachable by userspace when monitoring a different task?
> if (!task_function_call(task, __perf_install_in_context, event))
> return;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609153724.7878-1-l1za0.sec@gmail.com?part=1
prev parent reply other threads:[~2026-06-09 15:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:37 [PATCH v2] perf: avoid lockdep warning in self-monitoring perf_event_open l1za0.sec
2026-06-09 15:51 ` sashiko-bot [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=20260609155156.0F5131F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=l1za0.sec@gmail.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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