From: Aniket Gattani <aniketgattani@google.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"Paul E . McKenney" <paulmck@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Ben Segall <bsegall@google.com>,
Josh Don <joshdon@google.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Aniket Gattani <aniketgattani@google.com>
Subject: [PATCH v3 0/3] sched/membarrier: Use per-CPU mutexes for targeted commands
Date: Sun, 3 May 2026 21:22:02 +0000 [thread overview]
Message-ID: <20260503212205.3714217-1-aniketgattani@google.com> (raw)
This series mitigates a severe contention issue in the membarrier system
call by replacing the global membarrier_ipi_mutex with per-CPU mutexes
for targeted expedited commands.
Problem:
Currently, MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ relies on a single
global mutex to serialize IPIs. On large systems with heavy concurrent
usage, this creates significant contention. The issue cascades into
hard lockups when combined with CFS bandwidth throttling, during which
target CPUs may have interrupts disabled for extended periods.
If membarrier is waiting on such a CPU, it holds the global mutex,
stalling all other membarrier callers system-wide.
Solution:
Patch 1 introduces membarrier_cpu_mutexes to serialize expedited commands
specifically when a target CPU is provided, isolating the lock contention
to the targeted CPU. Broadcast commands continue to use the global mutex.
Patch 2 modernizes `membarrier_global_expedited` by using scoped cleanup
guards (`guard` and `__free`) to simplify error paths and resource
management.
Patch 3 introduces a dedicated kselftest reproducer
(membarrier_rseq_stress) to permanently test this interaction. It
aggressively hammers targeted membarrier commands within a deep,
aggressively throttled cgroup hierarchy to prove the lockup scenario
and validate the fix.
Results:
As measured by the stress test introduced in Patch 3, testing on an
AMD Turin machine with 384 CPUs (2 NUMA nodes, SMT=2) shows:
Throughput: ~200x increase in successful membarrier calls.
---
Changes in v3:
v2: https://lore.kernel.org/lkml/20260415232106.2803644-1-aniketgattani@google.com/
- Fixed the code path when `cpu_id < 0` in membarrier_private_expedited
as reported by Peter.
- Added Patch 2 to use cleanup guards in `membarrier_global_expedited`.
Aniket Gattani (3):
sched/membarrier: Use per-CPU mutexes for targeted commands
sched/membarrier: Modernize membarrier_global_expedited with cleanup
guards
selftests/membarrier: Add rseq stress test for CFS throttle
interactions
kernel/sched/membarrier.c | 98 +-
tools/testing/selftests/membarrier/Makefile | 5 +-
.../membarrier/membarrier_rseq_stress.c | 951 ++++++++++++++++++
3 files changed, 1002 insertions(+), 52 deletions(-)
create mode 100644 tools/testing/selftests/membarrier/membarrier_rseq_stress.c
--
2.54.0.545.g6539524ca2-goog
next reply other threads:[~2026-05-03 21:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 21:22 Aniket Gattani [this message]
2026-05-03 21:22 ` [PATCH v3 1/3] " Aniket Gattani
2026-05-05 10:55 ` [tip: locking/core] " tip-bot2 for Aniket Gattani
2026-05-03 21:22 ` [PATCH v3 2/3] sched/membarrier: Modernize membarrier_global_expedited with cleanup guards Aniket Gattani
2026-05-05 10:55 ` [tip: locking/core] " tip-bot2 for Aniket Gattani
2026-05-03 21:22 ` [PATCH v3 3/3] selftests/membarrier: Add rseq stress test for CFS throttle interactions Aniket Gattani
2026-05-05 10:55 ` [tip: locking/core] " tip-bot2 for Aniket Gattani
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=20260503212205.3714217-1-aniketgattani@google.com \
--to=aniketgattani@google.com \
--cc=bsegall@google.com \
--cc=joshdon@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®