From: Jim Cromie via B4 Relay <devnull+jim.cromie.gmail.com@kernel.org>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Jason Baron <jbaron@akamai.com>,
Alice Ryhl <aliceryhl@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ard Biesheuvel <ardb@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH v2 0/7] jump_label, x86, dyndbg: Batch multi-key static branch updates
Date: Sun, 29 Nov 2026 00:44:13 -0700 [thread overview]
Message-ID: <20261129-jump-batch-261128-v2-0-b1829d2429f0@gmail.com> (raw)
Toggling many boolean static keys at once -- such as enabling or
disabling pr_debug() sites across vmlinux and loaded modules --
currently patches one static_key at a time, sending cross-CPU text-poke
IPIs per site (~39.7k CAL IPIs to flip 1,885 active builtin keys across
8 CPUs on x86). Even if kernel/jump_label.c defers
arch_jump_label_transform_apply() across keys, x86's
smp_text_poke_batch_add() finish()es whenever a patch address arrives
below the tail entry (~2 entries per batch in dyndbg descriptor order)
and hides its 256-entry queue limit from jump_label.c.
This series fixes all three layers so multi-key static_key_batch
updates fill x86's 256-entry text_poke_array cleanly:
0. x86/alternatives (1/7): keep text_poke_array.vec[] sorted on insert
via lower-bound binary search and memmove() inside its 4 KB page,
preserving the 1-comparison fastpath for pre-sorted callers (ftrace
and single-key jump_label) while letting unordered multi-key callers
fill the batch and rejecting duplicate @addr entries before queueing.
1. x86/jump_label (2/7): add smp_text_poke_batch_try_add() and return
its bool status from arch_jump_label_transform_queue() so
__jump_label_update() flushes at TEXT_POKE_ARRAY_MAX (256) in
lockstep with text_poke_array when multi-site (e.g. inlined) keys
fill the 256-site array ahead of MAX_QUEUED_KEYS (256).
2. jump_label (3/7..4/7): plumb @apply through jump_label_update_key()
(no functional change in 3/7), then add core-only (unexported)
static_key_batch_begin/end(), DEFINE_LOCK_GUARD_0(static_key_batch),
and static_key_{enable,disable}_queued() using negative transitional
markers (-1/-2) finalized via release stores after IPI completion.
3. dyndbg (5/7..7/7): switch ddebug_change() to queued static-key
batching, assemble changed classmap parameter bits into one
multi-query buffer, and hoist ddebug_lock and
scoped_guard(static_key_batch) to ddebug_exec_queries().
Measured on an 8-vCPU x86_64 guest (v7.4-rc4, 1,997 builtin pr_debug
descriptors / 1,885 non-init keys / 1,964 jump sites,
CONFIG_PROVE_LOCKING=y):
Workload master v2 (7 patches) Speedup
-------------------------------------------------------------------
echo "+p" > control 39,712 282 CAL 141x
echo "-p" > control 39,674 255 CAL 156x
"+p ; -p" (1x) 79,256 424 CAL 187x
"+p ; -p" (4x) 316,773 1,435 CAL 221x
classmap bitmap 0x3ff (10 cls) 330 143 CAL 2.3x
Bare-metal desktops (vmlinux + loaded modules incl. amdgpu):
Host / CPUs / Sites "module amdgpu +p" "+p ; -p" (4x)
----------------------------------------------------------------
Ryzen 9 6900HX, 16c, 8,484 615 CAL 12,524 CAL
Ryzen 9 3900X, 24c, 8,197 909 CAL 18,243 CAL
Both match the theoretical floor ceil(N / 256) * 3 * (CPUs - 1) per
toggle within ~2% (~240-250x fewer CAL IPIs than unbatched master).
Verification & Tooling Disclosure:
0. Tested on 16-CPU (CONFIG_PROVE_LOCKING=y,
CONFIG_FTRACE_STARTUP_TEST=y, CONFIG_EVENT_TRACE_STARTUP_TEST=y) and
24-CPU AMD Ryzen hosts, plus 8-vCPU virtme-ng with
CONFIG_STATIC_KEYS_SELFTEST=y (extended with batch + reversal cases),
CONFIG_TEST_STATIC_KEYS=m, CONFIG_TEST_DYNAMIC_DEBUG=m, boot dyndbg=
queries, and ftrace function tracer; 0 lockdep or dmesg warnings.
1. AI coding assistants (Gemini CLI / Antigravity) assisted with
refactoring the commit split, designing the binary-search insertion
sort in 1/7 and queue-limit sync in 2/7, and running virtme-ng and
host IPI benchmarks; all code and commit messages were reviewed and
tested by the author.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
Changes in v2:
0. CC x86, jump_label, ftrace, and dyndbg maintainers across the full
series.
1. Split the combined v1 patch into single-purpose commits ordered
x86 -> jump_label -> dyndbg, with mechanical @apply plumbing
isolated in 3/7.
2. Drop all EXPORT_SYMBOL_GPL() exports on the queued static-key API
(core-only).
3. Drop pr_debug() instrumentation from arch/x86/kernel/alternative.c.
4. Replace deferred sort() with binary-search insertion sort in
smp_text_poke_batch_add() so vec[] stays sorted and duplicate-free
at all times without touching smp_text_poke_batch_finish().
5. Propagate queue-full return from x86's
arch_jump_label_transform_queue() so multi-site keys do not
desynchronize the 256-site text_poke_array from the 256-key
jump_label queue.
- Link to v1: https://lore.kernel.org/lkml/20260306015022.1940986-1-jim.cromie@gmail.com/
---
Jim Cromie (7):
x86/alternatives: Keep text-poke batch sorted on insert
x86/jump_label: Sync arch_jump_label_transform_queue() with batch limit
jump_label: Plumb bool apply through jump_label_update_key()
jump_label: Add batching API for queued static key updates
dyndbg: Use queued static-key batching in ddebug_change()
dyndbg: Batch classmap param bit-changes into multi-query
dyndbg: Hoist lock and static_key_batch across queries
arch/x86/include/asm/text-patching.h | 1 +
arch/x86/kernel/alternative.c | 85 ++++++++---
arch/x86/kernel/jump_label.c | 6 +-
include/linux/jump_label.h | 22 +++
kernel/jump_label.c | 282 ++++++++++++++++++++++++++++++-----
lib/dynamic_debug.c | 81 ++++++----
6 files changed, 387 insertions(+), 90 deletions(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261128-jump-batch-261128-1d89de6673f4
Best regards,
--
Jim Cromie <jim.cromie@gmail.com>
next reply other threads:[~2026-11-29 7:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 7:44 Jim Cromie via B4 Relay [this message]
2026-11-29 7:44 ` [PATCH v2 1/7] x86/alternatives: Keep text-poke batch sorted on insert Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 2/7] x86/jump_label: Sync arch_jump_label_transform_queue() with batch limit Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 3/7] jump_label: Plumb bool apply through jump_label_update_key() Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 4/7] jump_label: Add batching API for queued static key updates Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 5/7] dyndbg: Use queued static-key batching in ddebug_change() Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 6/7] dyndbg: Batch classmap param bit-changes into multi-query Jim Cromie via B4 Relay
2026-11-29 7:44 ` [PATCH v2 7/7] dyndbg: Hoist lock and static_key_batch across queries Jim Cromie via B4 Relay
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=20261129-jump-batch-261128-v2-0-b1829d2429f0@gmail.com \
--to=devnull+jim.cromie.gmail.com@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jbaron@akamai.com \
--cc=jim.cromie@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®