From: sashiko-bot@kernel.org
To: "Dominik Maier" <dmnk@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/hw_breakpoint: fix ctx->mutex vs perf_event_mutex inversion on attr modify
Date: Thu, 19 Nov 2026 19:31:12 +0000 [thread overview]
Message-ID: <sashiko-outbox-223927@kernel.org> (raw)
In-Reply-To: <20261119192228.2661266-1-dmnk@google.com>
> The perf events lock hierarchy documented in kernel/events/core.c orders
> task_struct::perf_event_mutex outside perf_event_context::mutex, which
> perf_event_open() and prctl(PR_TASK_PERF_EVENTS_ENABLE) follow.
>
> However, perf_ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) acquires
> ctx->mutex first via perf_event_ctx_lock() and then calls
> perf_event_modify_attr() -> modify_user_hw_breakpoint_check() ->
> modify_bp_slot() -> bp_constraints_lock(), which locks
> bp->hw.target->perf_event_mutex when bp_type changes. If one thread in a
> process calls prctl(PR_TASK_PERF_EVENTS_ENABLE) while another calls
> ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) with an alternating bp_type on a
> self-targeted breakpoint, the two threads deadlock against each other in
> TASK_UNINTERRUPTIBLE state.
>
> Decouple bp_constraints_lock() from task_struct::perf_event_mutex by
> [ ... ]
>
> Fixes: 0912037fec11 ("perf/hw_breakpoint: Reduce contention with large number of tasks")
> Fixes: 32ff77e8cc9e ("perf/core: Implement fast breakpoint modification via _IOC_MODIFY_ATTRIBUTES")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dominik Maier <dmnk@google.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119192228.2661266-1-dmnk@google.com?part=1
next prev parent reply other threads:[~2026-11-19 19:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:22 [PATCH] perf/hw_breakpoint: fix ctx->mutex vs perf_event_mutex inversion on attr modify Dominik Maier
2026-11-19 19:31 ` sashiko-bot [this message]
2026-11-20 11:56 ` Peter Zijlstra
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=sashiko-outbox-223927@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmnk@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.