From: Jim Cromie Date: Sun, 29 Nov 2026 00:44:18 -0700 Subject: [PATCH v2 5/7] dyndbg: Use queued static-key batching in ddebug_change() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261129-jump-batch-261128-v2-5-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=2411; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=bQyx4w+VLRpHmJHghGKxF+f3XTlNkT63eqKJt1tJPZE=; b=jq9RDMkTXvTZAp6HFU1zN3Iugz30lZ5SGLch2bn1DAHxFrjMnHgQ09lKNeC1MnoWMg49WRxUl 3vBlmTztwCUB0DO5sXD0hsCmX8OuQUSz+ZuTZus8H75FPddpnLYWSqm 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 List-Id: B4 Relay Submissions Toggling "+p" or "-p" across a broad query in ddebug_change() currently patches each callsite's static branch synchronously, triggering one cross-CPU text-poke IPI per matched descriptor. Switch ddebug_change() to the batched static-key queueing API: 0. Bracket the ddebug_tables scan in static_branch_batch_begin() and static_branch_batch_end() under ddebug_lock. 1. Replace static_branch_enable() and static_branch_disable() with static_branch_enable_queued() and static_branch_disable_queued(). 2. Log total matched sites after flushing the batch via v2pr_info(). Instead of one text-poke IPI sequence per matched pr_debug() site, synchronization is amortized per batch flush (~39.7k -> ~280 CAL IPIs toggling 1,997 sites across 8 CPUs on x86). What's Unchanged: 0. Lock ordering remains ddebug_lock -> cpus_read_lock -> jump_label_mutex -> text_mutex. 1. Query matching and descriptor flag updates in ddebug_change() are unchanged. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 18a71a9108d3..48f520a57b22 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -185,6 +185,7 @@ static int ddebug_change(const struct ddebug_query *query, /* search for matching ddebugs */ mutex_lock(&ddebug_lock); + static_branch_batch_begin(); list_for_each_entry(dt, &ddebug_tables, link) { /* match against the module name */ @@ -250,9 +251,9 @@ static int ddebug_change(const struct ddebug_query *query, #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { if (!(newflags & _DPRINTK_FLAGS_PRINT)) - static_branch_disable(&dp->key.dd_key_true); + static_branch_disable_queued(&dp->key.dd_key_true); } else if (newflags & _DPRINTK_FLAGS_PRINT) { - static_branch_enable(&dp->key.dd_key_true); + static_branch_enable_queued(&dp->key.dd_key_true); } #endif v4pr_info("changed %s:%d [%s]%s %s => %s\n", @@ -263,7 +264,9 @@ static int ddebug_change(const struct ddebug_query *query, dp->flags = newflags; } } + static_branch_batch_end(); mutex_unlock(&ddebug_lock); + v2pr_info("applied %d queued updates to sites in total\n", nfound); if (!nfound && verbose) pr_info("no matches for query\n"); -- 2.56.1