From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 593B3CD5BD1 for ; Tue, 2 Jun 2026 22:49:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA77A10F65E; Tue, 2 Jun 2026 22:49:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KGpiWGGS"; dkim-atps=neutral Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F0BD10F65E for ; Tue, 2 Jun 2026 22:49:09 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-45ef616daf6so4553456f8f.3 for ; Tue, 02 Jun 2026 15:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440548; x=1781045348; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sloEL2et+rScEj5ryw/ymmbW0pcpXUQyItBuc5/IW+w=; b=KGpiWGGSMr5bSvE39XSACGv90FibS19/sXV6eR5WcpQ3+5nf6W6SRGhoXuMuNTUrTZ huQYy/LhKWWdqyLdIIgU06ktOQsXT9wt3iuMqjHPvWKsN2taPDDsaD0kPhvGzyXf25Oe oHp5KRylNqvVOv98hUBhlg5wkJkZTqcu5PQ9e0nIIcWmbUQtIZS29c2+AfgACFFDB3Hq QYnN3WjDYVknYis4AFfD82iLlUh/aiKfWRGpBf9/XOCSSY39iqa4/t8f15zqOH/+BA6m UdWHS42XuK6a08agVyDaIl3DF/xLrQK8+22Uhrj1gMSdU3czPBFvP43B3K39jhVWpJO8 Nb+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440548; x=1781045348; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sloEL2et+rScEj5ryw/ymmbW0pcpXUQyItBuc5/IW+w=; b=IxaSxyxBAyZg5IsAoVb0CtM3LGPALq0/A+DOsAFA8JyB+eBAG5k042WYGNCU2QcYCC VZMuwPQ6be5u/lrqwUtEoyVLPkT2wNnC0vVDOA1WtkrHVbofPwDReFOVWeUuKFlWcv0w 7iwYBVNy/imFWoopf+WtUqGTIY8c8Bw9fUx2BSJ56AinLnWrB1sOpCZ3QCFEelxr/ac6 H9eeuCWaoc2mRxBrA0vyLFKlXEE+OnwJZWWw0+ja6Pa3RnIKRXYcOzooh/mL3WzFCI6Z aiCVzfzUn2z8I0oxDpPm9Jzp0kte6GmceaqpBRIUiuDma3J5KeqFNWBvfFryp98qN22e ENpw== X-Forwarded-Encrypted: i=1; AFNElJ9WuY8EjlhMoxSYJ8Xh9zxEu/ai6cveMgvpsWRDqaMAbo649W2LSggZVrLoPcnRVLZpz4A1lQ1jWzI=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwskYX9xp4T6kYkUojcZUZtZ/NLWnw9l92A8t4P00q79aGymDBN Ruvio+Dxzmv8gv3/8PlJ0JT2pIf1kaTgav5M0IzaVH8lMKAf7rgjkrmRL9FJ6A== X-Gm-Gg: Acq92OFBiGGywu5d/3XLgSTsPYn7NqKkojxZmwJBZgt4yizXqOliH433iSsT2MyxZ7r xhZntGUxCxFImyN58QN38ITx1LxZlfZeSMCFOpmxnvO7rVrV/LKLZC2XzSOo9huK0TuuzYFd/Hg N7jwx4cysKxOERgha84XxleWjB960KVohC6frDEQl+klwu0QV6W8UTAvZGRKgeAEdTejSBEsC7X VSQ7de5ib0fe80HTZhCEpGV9hayAqKoBXlXI/IoLyCiJ/iwjMN5oYsHel7ocXDvGqt55YBEdui5 sL2Au+vbyLxjgrxW0x5AO5LXEGFeOwvW5/Weh9pTQ2wz7j0YEEvoVYGuawOSTpcAjKmFIAAdeEm 0kIRANlZ2xmjqgQkeaUabnlzqLMS2ICZ0Hm8bYsI4f0uWS9q+M3xoqWmYBjYvX73UrdiQ4MyIbw re1DJYWCIj7l+ag8QVTTL8XACGu9sdKYx0f87Rx6dFjn0Bu9J5heX/ X-Received: by 2002:adf:f787:0:b0:45e:ebe5:2010 with SMTP id ffacd0b85a97d-4602185df32mr395619f8f.33.1780440547817; Tue, 02 Jun 2026 15:49:07 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:07 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:17 +0000 Subject: [PATCH v4 20/25] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260602-dd-maint-2-v4-20-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=7732; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=Z1Y6Y/lN5cW3h0OfB1fz/4unyD5Ttaclg3mMzAi4dCY=; b=fGSsz6AgkWDvMtSBE2DnPcZZQJGON4xwO0QWnQR8uo1UeMFZRN0SRe8NWWbvmBKlDVxKqvgZl lxad52gICAoCPKJ4zoNkZAit7PFTHNinfk6lnU5Uj28gRtZrbYA568v X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 its users keep 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 | 50 ++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8fc315d0e5a5..e4a62cb73267 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -97,6 +97,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 29086aad436b..c15b692ffc60 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; }; @@ -245,10 +244,11 @@ 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(query->module, dt->mod_name)) + !match_wildcard(query->module, di->mod_name)) continue; if (query->class_string) { @@ -260,8 +260,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; @@ -281,7 +281,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; @@ -1080,12 +1080,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]; @@ -1113,13 +1113,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 @@ -1180,7 +1180,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); @@ -1194,7 +1194,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug } if (nc) { dt->info.maps.len = 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); } } @@ -1202,27 +1202,26 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug * 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); @@ -1234,7 +1233,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; } @@ -1297,7 +1296,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; @@ -1317,7 +1316,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; @@ -1415,7 +1415,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; @@ -1426,7 +1427,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.54.0