From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 720394FC8DD; Sat, 5 Sep 2026 18:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788632021; cv=none; b=T+kyiruDDd4wFSkBrTan7VYkJlyAHvyDSX53TP2JD2E6Xz8laTdV34zLM3/qW66TRbOBVNrM06GIvpv1qINOujnd09KbLqi6PBLlHpmSWtNjvRyggbdV8mc+vyEhhmcx4lRTzQWce/OxXDZm8U8jgi/fXW3GFKkZ6uxk0gi/tVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788632021; c=relaxed/simple; bh=bNvHlUXJclVIm7RC+Av1ijmZ+pokOWy+LtiMKYGC4WA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M2guWqtMd37SfqGIvvpMsrZmzhtapf5FSQTKxP/sRUrr0K87J0SXJW6K6NFJiCo6h/CW2+wRgLbkvxvB2P8XKfMRuiW/kl7UL3zn2aFRw8TYkcqXF0ZixMBvml2uXmNmOnYCWPytdbW7XmZ53Ggw6yJD4u+PZqtUbHIv9Ib9ji4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=twNUGY10; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="twNUGY10" Received: by smtp.kernel.org (Postfix) with ESMTPS id 47F1AC4AF10; Sat, 5 Sep 2026 18:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788632021; bh=bNvHlUXJclVIm7RC+Av1ijmZ+pokOWy+LtiMKYGC4WA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=twNUGY10GJMlCvF6xkXahey2Tcm5ualk6JPKTCxJZyLT2zCL6pCtz7PTsLdNttgIL VM2wW/zWrC2HwtZgS0O12SjAIdaQHUB8RwGuJu0ag8sGz8UYZwN92ykfgzJFC7JrXH 5f1uFezf0uX0avrbxUrChPLMD9R/oH+JsVLwXi0e8Bs/t52z2JWweYS7cuLaeUmq5q pUj7AgPJAaUmB7dRt7/uXctYwUz1PsQdT9r/A70H1bGw3cImc5NMBjhKpmz3MvgObz naOtBMm/wVuBw9XdYA9QegI6m10COQ4ZTd+TacNV4Hkjy4nOziarnHrprvJLlKe6KA HapVBVVAUSz9g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B623C624DB; Sat, 5 Sep 2026 18:13:41 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Sat, 05 Sep 2026 12:13:39 -0600 Subject: [PATCH v8 25/43] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260905-dd-cmap-part2-clean-v8-25-a4cc0674f6fd@gmail.com> References: <20260905-dd-cmap-part2-clean-v8-0-a4cc0674f6fd@gmail.com> In-Reply-To: <20260905-dd-cmap-part2-clean-v8-0-a4cc0674f6fd@gmail.com> To: Jason Baron , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Jonathan Corbet , Shuah Khan , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788632017; l=7818; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=uapa1HKVOlBNRkzmoxsKmuznCkdlZ9rTFr9Ax1JaMRI=; b=d5MZBpF0i17vZ0ddysVhWso/XtJ5XZJv1c1afr4NVKDlk5oTXEQgiLyybMndauKJIC4wTgUW8 VFHb6E1PGhiAJfcUSXOc/ykpMH5LXKVXHbGmoU1nlVsJdAU7Y6/gz1q 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 From: Jim Cromie struct _ddebug_info already has most of dyndbg's info for a module; push debug_table.mod_name down into it, finishing the encapsulation. This allows refactoring several callchains, passing &_ddebug_info instead of &ddebug_table, and hoisting the "&dt->info" deref up instead of repeating it thru the callchans ddebug_table contains a _ddebug_info member, so code with a ptr to a ddebug_table still have access to mod_name, just now with "->info." added in. In static ddebug_add_module(&di), reinforce the cursor-model by dropping the modname arg, and setting di->mod_name at each caller. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB old-v12 . moved up 1 position in series, ahead of hoist... --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 52 ++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 537658d583ff..661599a1302d 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -113,6 +113,7 @@ struct _ddebug_class_maps { }; struct _ddebug_info { + const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; }; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 11850aff438f..3b7d9eb8b40f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -46,7 +46,6 @@ extern struct ddebug_class_map __stop___dyndbg_class_maps[]; struct ddebug_table { struct list_head link; - const char *mod_name; struct _ddebug_info info; }; @@ -252,11 +251,12 @@ static int ddebug_change(const struct ddebug_query *query, /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { + struct _ddebug_info *di = &dt->info; /* match against the module name */ if (query->module && - !match_wildcard_hyphen(query->module, dt->mod_name) && - !match_wildcard_hyphen(query->module, kbasename(dt->mod_name))) + !match_wildcard_hyphen(query->module, di->mod_name) && + !match_wildcard_hyphen(query->module, kbasename(di->mod_name))) continue; if (query->class_string) { @@ -268,8 +268,8 @@ static int ddebug_change(const struct ddebug_query *query, valid_class = _DPRINTK_CLASS_DFLT; } - for (i = 0; i < dt->info.descs.len; i++) { - struct _ddebug *dp = &dt->info.descs.start[i]; + for (i = 0; i < di->descs.len; i++) { + struct _ddebug *dp = &di->descs.start[i]; if (!ddebug_match_desc(query, dp, valid_class)) continue; @@ -289,7 +289,7 @@ static int ddebug_change(const struct ddebug_query *query, #endif v4pr_info("changed %s:%d [%s]%s %s => %s\n", trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + di->mod_name, dp->function, ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags = newflags; @@ -1084,12 +1084,12 @@ static bool ddebug_class_in_range(const int class_id, const struct ddebug_class_ class_id < map->base + map->length); } -static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddebug *dp) +static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddebug *dp) { struct ddebug_class_map *map; int i; - for_subvec(i, map, &dt->info, maps) + for_subvec(i, map, di, maps) if (ddebug_class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; @@ -1117,13 +1117,13 @@ static int ddebug_proc_show(struct seq_file *m, void *p) seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + iter->table->info.mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_putc(m, '"'); if (dp->class_id != _DPRINTK_CLASS_DFLT) { - class = ddebug_class_name(iter->table, dp); + class = ddebug_class_name(&iter->table->info, dp); if (class) seq_printf(m, " class:%s", class); else @@ -1184,7 +1184,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug * and length of the subrange at its edges. */ for_subvec(i, cm, di, maps) { - if (!strcmp(cm->mod_name, dt->mod_name)) { + if (!strcmp(cm->mod_name, dt->info.mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n", i, cm->mod_name, cm->base, cm->length, cm->map_type); @@ -1198,34 +1198,33 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug } dt->info.maps.len = nc; if (nc) - vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + vpr_info("module:%s attached %d classes\n", dt->info.mod_name, nc); } /* * Allocate a new ddebug_table for the given module * and add it to the global list. */ -static int ddebug_add_module(struct _ddebug_info *di, const char *modname) +static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; if (!di->descs.len) return 0; - v3pr_info("add-module: %s %d sites\n", modname, di->descs.len); + v3pr_info("add-module: %s %d sites\n", di->mod_name, di->descs.len); dt = kzalloc_obj(*dt); if (dt == NULL) { - pr_err("error adding module: %s\n", modname); + pr_err("error adding module: %s\n", di->mod_name); return -ENOMEM; } /* - * For built-in modules, name lives in .rodata and is - * immortal. For loaded modules, name points at the name[] - * member of struct module, which lives at least as long as - * this struct ddebug_table. + * For built-in modules, name (as supplied in di by its + * callers) lives in .rodata and is immortal. For loaded + * modules, name points at the name[] member of struct module, + * which lives at least as long as this struct ddebug_table. */ - dt->mod_name = modname; dt->info = *di; INIT_LIST_HEAD(&dt->link); @@ -1237,7 +1236,7 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname) list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); - vpr_info("%3u debug prints in module %s\n", di->descs.len, modname); + vpr_info("%3u debug prints in module %s\n", di->descs.len, di->mod_name); return 0; } @@ -1300,7 +1299,7 @@ static int ddebug_remove_module(const char *mod_name) mutex_lock(&ddebug_lock); list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { - if (dt->mod_name == mod_name) { + if (dt->info.mod_name == mod_name) { ddebug_table_free(dt); ret = 0; break; @@ -1320,7 +1319,8 @@ static int ddebug_module_notify(struct notifier_block *self, unsigned long val, switch (val) { case MODULE_STATE_COMING: - ret = ddebug_add_module(&mod->dyndbg_info, mod->name); + mod->dyndbg_info.mod_name = mod->name; + ret = ddebug_add_module(&mod->dyndbg_info); if (ret) WARN(1, "Failed to allocate memory: dyndbg may not work properly.\n"); break; @@ -1418,7 +1418,8 @@ static int __init dynamic_debug_init(void) mod_ct++; di.descs.len = mod_sites; di.descs.start = iter_mod_start; - ret = ddebug_add_module(&di, modname); + di.mod_name = modname; + ret = ddebug_add_module(&di); if (ret) goto out_err; @@ -1429,7 +1430,8 @@ static int __init dynamic_debug_init(void) } di.descs.len = mod_sites; di.descs.start = iter_mod_start; - ret = ddebug_add_module(&di, modname); + di.mod_name = modname; + ret = ddebug_add_module(&di); if (ret) goto out_err; -- 2.55.0