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 3/7] jump_label: Plumb bool apply through jump_label_update_key()
Date: Sun, 29 Nov 2026 00:44:16 -0700 [thread overview]
Message-ID: <20261129-jump-batch-261128-v2-3-b1829d2429f0@gmail.com> (raw)
In-Reply-To: <20261129-jump-batch-261128-v2-0-b1829d2429f0@gmail.com>
From: Jim Cromie <jim.cromie@gmail.com>
__jump_label_update() under HAVE_JUMP_LABEL_BATCH unconditionally calls
arch_jump_label_transform_apply() after queueing all jump entries for a
single static_key, which prevents callers from coalescing multiple keys
into one architecture batch flush.
Prepare for multi-key batching without changing current behavior:
0. Unify the #ifndef / #else HAVE_JUMP_LABEL_BATCH definitions of
__jump_label_update() and gate the trailing
arch_jump_label_transform_apply() on a new @apply parameter.
1. Thread @apply through __jump_label_mod_update() and
jump_label_update_key(), keeping jump_label_update() as a wrapper
passing apply = true.
No functional change.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
kernel/jump_label.c | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index ab6b774bcfd7..d20b5b3ffbd3 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -488,28 +488,16 @@ static bool jump_label_can_update(struct jump_entry *entry, bool init)
return true;
}
-#ifndef HAVE_JUMP_LABEL_BATCH
static void __jump_label_update(struct static_key *key,
struct jump_entry *entry,
struct jump_entry *stop,
- bool init)
+ bool init, bool apply)
{
for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
- if (jump_label_can_update(entry, init))
- arch_jump_label_transform(entry, jump_label_type(entry));
- }
-}
-#else
-static void __jump_label_update(struct static_key *key,
- struct jump_entry *entry,
- struct jump_entry *stop,
- bool init)
-{
- for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
-
if (!jump_label_can_update(entry, init))
continue;
+#ifdef HAVE_JUMP_LABEL_BATCH
if (!arch_jump_label_transform_queue(entry, jump_label_type(entry))) {
/*
* Queue is full: Apply the current queue and try again.
@@ -517,10 +505,15 @@ static void __jump_label_update(struct static_key *key,
arch_jump_label_transform_apply();
BUG_ON(!arch_jump_label_transform_queue(entry, jump_label_type(entry)));
}
+#else
+ arch_jump_label_transform(entry, jump_label_type(entry));
+#endif
}
- arch_jump_label_transform_apply();
-}
+#ifdef HAVE_JUMP_LABEL_BATCH
+ if (apply)
+ arch_jump_label_transform_apply();
#endif
+}
void __init jump_label_init(void)
{
@@ -662,7 +655,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
return ret;
}
-static void __jump_label_mod_update(struct static_key *key)
+static void __jump_label_mod_update(struct static_key *key, bool apply)
{
struct static_key_mod *mod;
@@ -683,7 +676,7 @@ static void __jump_label_mod_update(struct static_key *key)
else
stop = m->jump_entries + m->num_jump_entries;
__jump_label_update(key, mod->entries, stop,
- m && m->state == MODULE_STATE_COMING);
+ m && m->state == MODULE_STATE_COMING, apply);
}
}
@@ -752,7 +745,7 @@ static int jump_label_add_module(struct module *mod)
/* Only update if we've changed from our initial state */
do_poke:
if (jump_label_type(iter) != jump_label_init_type(iter))
- __jump_label_update(key, iter, iter_stop, true);
+ __jump_label_update(key, iter, iter_stop, true, true);
}
return 0;
@@ -882,7 +875,7 @@ int jump_label_text_reserved(void *start, void *end)
return ret;
}
-static void jump_label_update(struct static_key *key)
+static void jump_label_update_key(struct static_key *key, bool apply)
{
struct jump_entry *stop = __stop___jump_table;
bool init = system_state < SYSTEM_RUNNING;
@@ -891,7 +884,7 @@ static void jump_label_update(struct static_key *key)
struct module *mod;
if (static_key_linked(key)) {
- __jump_label_mod_update(key);
+ __jump_label_mod_update(key, apply);
return;
}
@@ -906,7 +899,12 @@ static void jump_label_update(struct static_key *key)
entry = static_key_entries(key);
/* if there are no users, entry can be NULL */
if (entry)
- __jump_label_update(key, entry, stop, init);
+ __jump_label_update(key, entry, stop, init, apply);
+}
+
+static void jump_label_update(struct static_key *key)
+{
+ jump_label_update_key(key, true);
}
#ifdef CONFIG_STATIC_KEYS_SELFTEST
--
2.56.1
next prev parent 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 [PATCH v2 0/7] jump_label, x86, dyndbg: Batch multi-key static branch updates Jim Cromie via B4 Relay
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 ` Jim Cromie via B4 Relay [this message]
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-3-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®