From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795938261; b=nGwYE9bn2++OuHV2cD+xULxtagHas83ZO/izjeEB4q76Qm3ASQL3ezlgN5Bty8ExVlQH 6NVFkE+vaq8HQZ1k6Lr1UJxT+msbTtsWUHRdV/CUs4vi88rUAFDcsxTYzhYrxFzdptq6t ApjZrIUbjLAUI5ohSNl+W5KLmQpispLOssbxqnv9yuj831DLzxC0mSPGHV38BLRprgZ6P 7DQQl2IRog9SbTkBevWGbwDZcb6ljAa2VwJS5dJUD0UtRcL9/9GX8v9HUNx4hjCPpX4Df 5vUEk5UG+AIb/VZ/zXZ1bCSPhDSUfbU0/eeybgvupex2Lxb1OKDh11ZFb2AgOL/QcOQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795938261; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=iqapBEMaUj0M+KcG1tvc5kzWk9NaC3AnX+SmgIokyPg=; b=5q+3TxDVlQgcN3dh0qm+t9ixthBwksvw2IHkI8UZvqv/xZQxLU+eQU2qwTjyDB5phtYp A+nUQrJaolvhvU1IoOKeDdLMCdnsKnpzilNS0NdDLdv/XpEjWwSXhwGCdCP303HxyDOAt /ApoKeQhymw+06Eh2jHanu/u7sEXBWJgFLl6n5djKURFPyzDP1WwsPFZO6zfwnl7y3uCU ZwHspNIE27M1qx3tUUsNCIylD0HrsULrPuzGwOgXINCIbspMo+ZN0eNQZbNzCdyCpjj5f 2TLSVi3rFPQfAxLyUa/SMG77X85i1D5RcOMol3cvMJCoZ9rbUOz/lhgVVlyMt+RevmQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PlVXo+6X; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77504606A335 for ; Sun, 29 Nov 2026 07:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PlVXo+6X Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795938261; b=PqtDu+RYlooU58wM8wSenhLFDZ4YbtIMYs7LVyMea2jXQx35/9+1jE5hzVxmrbN4B76K vkhK7RtY1Rxuru51R6w+K+RwLMOZXdCVSbjq+TQf1dzKOV/PVLTIXAirUbNh2O3W60dZC 0MKMOgwwk0kNiBsHAXK+lgQUgzGbat/BqsCT700kkKy0+e+OYI/q3Su1uVPWR+WxivzTa 5MMK8I0i0MUCEX9qtRnc0N4BRg7D5Zm7N1h4YP4NTzhW+bfId/k9gs/c6ZAS3ozDnAeuJ H89AuEyduqP+v39vU7uHQblVaiYqnhWi9c3dm1gUovS+HFLaA90jaqjX+U24S/3PjHw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795938261; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=iqapBEMaUj0M+KcG1tvc5kzWk9NaC3AnX+SmgIokyPg=; b=zFOfpxmBn3QDPfNv5IEid76sEkgrAqoNXENEHjnzGKu4v6r/FPFxx1lojOBp2/m+GZ4S w8zsUb9vyvFDzmiqoOpwgseeMaRQnbdlhBhCQ6/i3Pg/A4qIM3eB6K37qirhfDr1KjBmD cyuMdv5vLsx0vR1w8+MkBqJ3UV9H7n4jW/7BNYSicSJCWt39KbVzt2QP2qT/PulEZuBuB P9d5Wo9gTUFk+ZZn14jBmxP8Y9lXxpmsEUbJx27wxk8+ojvQBBd3KbA7/ZQmpevN/lirV 7DeCOcSzsLMDIMAh19N9JTXynfFjyis23wToJMjv/rRnQx8v3sVvtiwC564EmcQhyLA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 785BA1F00898; Sun, 29 Nov 2026 07:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795938261; bh=iqapBEMaUj0M+KcG1tvc5kzWk9NaC3AnX+SmgIokyPg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=PlVXo+6XnOEP1w/VjUcPCL14YrWGUxkjBqvspSMt+O2ECrXSeDV5JBLsJOOKvLuGK tXHYcEDtKE5+//XcLHVESZ3xRalATWBwLC1Ci8B7GtsJN6NcNcFMe8ScTT4pQOdOOR rtESYvETXNDXyloW4uipg7775it1ld/CTNotuO8+fT1ZIoGUyNygYmxUAXB4eEozKV mr8qoPhT9p0IMuXSRUqX7LinzpbdV8b0VKhegykoMKYz/Qegim7ZdE096FSFEUHqW3 7lXY/YXpkPGsOS4Puif5bJvPgoBrm3xzTsfxyqD6U37tznknCkrAf8aRJpdai+F7xG OZnJKBWRijiNg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 01B394E3ED; Sun, 29 Nov 2026 07:44:19 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Sun, 29 Nov 2026 00:44:16 -0700 Subject: [PATCH v2 3/7] jump_label: Plumb bool apply through jump_label_update_key() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261129-jump-batch-261128-v2-3-b1829d2429f0@gmail.com> References: <20261129-jump-batch-261128-v2-0-b1829d2429f0@gmail.com> In-Reply-To: <20261129-jump-batch-261128-v2-0-b1829d2429f0@gmail.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Alice Ryhl , Steven Rostedt , Ard Biesheuvel , Andrew Morton Cc: linux-kernel@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795938258; l=4384; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=72H7eBbX1RM7xrQ8rg9lXOv1tVDYs7URrmmg9D1yu8k=; b=hQEuXB8NO5irqVKPN8TXrOsY+C/V5cV7xBs8qXwitj1qPwLw32rBoODwGXRQtWxiXjyZi0jmM v7u9w90H2+SAMCjSNdu/kKIBhOlje/7/9B5ibSI/hjy+J27yKPphpBp X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com Content-Transfer-Encoding: 7bit From: Jim Cromie __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 --- 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