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 v3 4/5] dyndbg: Batch static branch updates across queries
Date: Fri, 04 Dec 2026 11:27:55 -0700 [thread overview]
Message-ID: <20261204-jump-batch-261128-v3-4-2adda55a5d71@gmail.com> (raw)
In-Reply-To: <20261204-jump-batch-261128-v3-0-2adda55a5d71@gmail.com>
From: Jim Cromie <jim.cromie@gmail.com>
Enabling or disabling pr_debug() callsites in ddebug_change() currently
patches each callsite's static branch synchronously, triggering one
cross-CPU text-poke IPI sequence per matched site. Because
ddebug_change() also acquires and releases ddebug_lock on every query,
semicolon-separated multi-queries cannot coalesce updates across
sub-queries either.
Hoist ddebug_lock and wrap the sub-query loop in static_key_batch
inside ddebug_exec_queries(). Disjoint sub-queries (e.g.
"class A +p; class B +p") coalesce into one shared text-poke batch,
while overlapping toggles (e.g. "module foo +p; func bar -p" or
"+p;-p") automatically flush the pending batch when revisiting a key so
the first state settles before queuing the reverse transition.
1. Replace mutex_lock(&ddebug_lock) and mutex_unlock(&ddebug_lock) in
ddebug_change() with lockdep_assert_held(&ddebug_lock).
2. Acquire ddebug_lock once in ddebug_exec_queries() and wrap the
sub-query loop in scoped_guard(static_key_batch), flushing all
queued static branch updates before releasing ddebug_lock.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 18a71a9108d3..1659c0604b18 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -170,7 +170,7 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
* Search the tables for _ddebug's which match the given `query' and
* apply the `flags' and `mask' to them. Returns number of matching
* callsites, normally the same as number of changes. If verbose,
- * logs the changes. Takes ddebug_lock.
+ * logs the changes. Caller must hold ddebug_lock.
*/
static int ddebug_change(const struct ddebug_query *query,
struct flag_settings *modifiers)
@@ -183,8 +183,9 @@ static int ddebug_change(const struct ddebug_query *query,
struct ddebug_class_map *map = NULL;
int __outvar valid_class;
+ lockdep_assert_held(&ddebug_lock);
+
/* search for matching ddebugs */
- mutex_lock(&ddebug_lock);
list_for_each_entry(dt, &ddebug_tables, link) {
/* match against the module name */
@@ -263,7 +264,6 @@ static int ddebug_change(const struct ddebug_query *query,
dp->flags = newflags;
}
}
- mutex_unlock(&ddebug_lock);
if (!nfound && verbose)
pr_info("no matches for query\n");
@@ -573,26 +573,30 @@ static int ddebug_exec_queries(char *query, const char *modname)
char *split;
int i, errs = 0, exitcode = 0, rc, nfound = 0;
- for (i = 0; query; query = split) {
- split = strpbrk(query, ";\n");
- if (split)
- *split++ = '\0';
-
- query = skip_spaces(query);
- if (!query || !*query || *query == '#')
- continue;
+ mutex_lock(&ddebug_lock);
+ scoped_guard(static_key_batch) {
+ for (i = 0; query; query = split) {
+ split = strpbrk(query, ";\n");
+ if (split)
+ *split++ = '\0';
+
+ query = skip_spaces(query);
+ if (!query || !*query || *query == '#')
+ continue;
- vpr_info("query %d: \"%s\" mod:%s\n", i, query, modname ?: "*");
+ vpr_info("query %d: \"%s\" mod:%s\n", i, query, modname ?: "*");
- rc = ddebug_exec_query(query, modname);
- if (rc < 0) {
- errs++;
- exitcode = rc;
- } else {
- nfound += rc;
+ rc = ddebug_exec_query(query, modname);
+ if (rc < 0) {
+ errs++;
+ exitcode = rc;
+ } else {
+ nfound += rc;
+ }
+ i++;
}
- i++;
}
+ mutex_unlock(&ddebug_lock);
if (i)
v2pr_info("processed %d queries, with %d matches, %d errs\n",
i, nfound, errs);
--
2.56.1
next prev parent reply other threads:[~2026-12-04 18:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:27 [PATCH v3 0/5] jump_label, x86, dyndbg: Batch multi-key static branch updates Jim Cromie via B4 Relay
2026-12-04 18:27 ` [PATCH v3 1/5] x86/alternatives: Keep text-poke batch sorted on insert Jim Cromie via B4 Relay
2026-12-04 18:27 ` [PATCH v3 2/5] x86/jump_label: Sync arch_jump_label_transform_queue() with batch limit Jim Cromie via B4 Relay
2026-12-04 18:27 ` [PATCH v3 3/5] jump_label: Add static_key_batch API Jim Cromie via B4 Relay
2026-12-04 18:27 ` Jim Cromie via B4 Relay [this message]
2026-12-04 18:27 ` [PATCH v3 5/5] dyndbg: Batch classmap param bit-changes into multi-query Jim Cromie via B4 Relay
2026-12-04 20:29 ` [PATCH v3 0/5] jump_label, x86, dyndbg: Batch multi-key static branch updates Andrew Morton
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=20261204-jump-batch-261128-v3-4-2adda55a5d71@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®