From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073FE324718 for ; Mon, 4 May 2026 20:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777927539; cv=none; b=AUftSd6swRY0y1i8Wf1y+/SCOosHbfjbyl6GnQAwd6Ev4da3XW0APOhzh5M2acRHUKlb9uwUD3PwqAwBBlBFraxn20GMSW6t7TRLk7pBoViQIFB3JPhvZ/ul59K2kdwQ9EC9YSx+LyF6BQ/4yOYtYK6rjd+nrpETE0jDE0w7GYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777927539; c=relaxed/simple; bh=cvpyPjgBUZvJMXWxvbAPJHHdCeJYjPF8j74Dxznr/8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ovfwxPEZLewKV3SbndjaDVrvjlIlW0NnvL9+UGVP3jfhXKROjGeTb8SGxdF87yuYKiC6EYrfxJUK+f79owuLxqIBJ2qHuBwC07QE5SKOJVAt5zRlio5USYk6jpbU5xrx27rLGG9dVAOPE4+x+bl+APOInMyAM7T0cVEOwtQ5J24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ASaDpn5w; arc=none smtp.client-ip=209.85.161.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ASaDpn5w" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-6967080e6beso1332914eaf.2 for ; Mon, 04 May 2026 13:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777927533; x=1778532333; darn=vger.kernel.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=+iZawPPQ+X0bNikqrWnKmDXKxMGCDUmFmcpPVDJmjyY=; b=ASaDpn5wA4gWGDrf0Kl8uWNHLeXv+bTtBCKiBOBe3Iwc/7PkYl850tuQo2qe+/meA0 z92SqfFhWlYaW6WE1vZ+CcAc4zUh0x6D9jVf8cd+0tVdBHjwPukCJueYODe8WLxIDC0T e7AVEpG7eHMxc9N3il/MU+VsSH/zB8R2V0uVspLiPJABlQa1e/Nz4nHmATTidqaa7Rfp dsEAmY+NaKW9Wa0oOJgC7wufudAxP4itvtFppUgiFOR28G1GbAr6zjRoxG7JcAYyPSSj g03qRQyYcOvJwEZx7pyFyq7J8nPB16k21Dg/uq9KGiiHT9m8TpH7Altg6dN4o8wm8fbW 7+hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777927533; x=1778532333; 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=+iZawPPQ+X0bNikqrWnKmDXKxMGCDUmFmcpPVDJmjyY=; b=RPDSyXWqXRdnSAIteGxOjrJr3xwjphp5Lebl+MpKw+STDsyGW8E2FQUPWPvElXjYtd ccjBzic61Hx+xu+hkG+CMP1dqdvsT3ow2qhDCluOrjcaMnp0jP2jcZ5IVPz0PvD1OPeV WVmySI+d7TGFwv4GKmZ/aTSOf9V2GEwui0hnYV4O7QnohLdxev8jUYCCB6+OS/qprMHq 8fZ2klJ73H9LOCJC9/9iCiWizeY2rksVQ+5NywN8ZzTtDXsBvic2QXcSLUfNyfTaY0s9 CyIykG5PX63XZuUajdBTDtLU1UkC30QoRABy7ayesDwZkvFn5JDMLJh0/YC9Tw+fBahA /rPQ== X-Gm-Message-State: AOJu0YxSVNPUZyoxCn1On3ZDQU2Kgcw6pmwRKuMz6nh1yXoY86nz0hde 2G4ZFR5Q7Eu3BvpxvdY/DNZnH+SXqvZKds3W7hqzNO/ThXt3KF7NRxuy X-Gm-Gg: AeBDiesGo3d4EGJLPhwsmy+XYEYl/DX/gN2qiMCoS3R69tCNSgnJlazRw+V+SeAaUw+ dDHaJ/8x6kIvTloFJw2Expu2dtsJGwMu5a+3/ooSdBfHJyqGmkPr5nzf1sB23qNd8IUZ53KCRyZ 0UztInXhGi8mhjDz0tqvORtu7wnWdQzu/5RD1BOsQxM3KI84T74U+Qn+bIpLJnj/sI5GVLUlSUJ XXkmoVRCufXzMPZulCN4eiW6ed5+s8hcDKFMLZNEMX0MqlHfe4CBHfFq31ivAL//MzMph1qgsa+ ik8t4DnsiZisp4n1e9a/x1UAT5nZAglxUfFzDbTUP6V0vsFRJNGsrkxAHabRZhKL/iN6hHg9H7W HW3xg0b0k+z6ExNfLyXfn2e3OUrgvzYTD4ZlLGACUtmxlImT+4pXZxsZI21IHSeCJ3hypOGQ8n9 lf6HEWkmUhI02j/bb35johBiDfqomRj5q+wDAmHK/CBV3sy40YlM6+rTh/d4TiZfXmQTgqKTQD X-Received: by 2002:a05:6820:2214:b0:696:1450:ff14 with SMTP id 006d021491bc7-69697c64d5fmr5570398eaf.37.1777927533407; Mon, 04 May 2026 13:45:33 -0700 (PDT) Received: from [100.82.231.29] (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 006d021491bc7-69689266bacsm7144713eaf.0.2026.05.04.13.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 13:45:33 -0700 (PDT) From: Jim Cromie Date: Mon, 04 May 2026 14:45:19 -0600 Subject: [PATCH 13/17] 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: <20260504-dd-cleanups-2-v1-13-6fdd24040642@gmail.com> References: <20260504-dd-cleanups-2-v1-0-6fdd24040642@gmail.com> In-Reply-To: <20260504-dd-cleanups-2-v1-0-6fdd24040642@gmail.com> To: Andrew Morton , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Shuah Khan , Louis Chauvet Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777927513; l=7701; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=cvpyPjgBUZvJMXWxvbAPJHHdCeJYjPF8j74Dxznr/8s=; b=gGm7NM5Z53+s6mQeyZ3eOhd7I+c2zrov3fuZtR3kvuJGMbp1FsRdwJg/yxIU1eSPQ6b+pHLZB oDV+KfE3Wx0DS6iG+/RBAYW3DROE5RQXNmD9Hy3uiWqrfGfYPETGaLc X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- 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 7a4bf40c1eb8..7d60da0b9506 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -108,6 +108,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 83c5b27314da..4065c57637f2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -46,7 +46,6 @@ extern struct _ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { struct list_head link; - const char *mod_name; struct _ddebug_info info; }; @@ -253,10 +252,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) { @@ -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; @@ -1156,12 +1156,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]; @@ -1189,13 +1189,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 @@ -1256,7 +1256,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); @@ -1267,7 +1267,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); } } @@ -1275,27 +1275,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); @@ -1307,7 +1306,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; } @@ -1370,7 +1369,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; @@ -1390,7 +1389,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; @@ -1488,7 +1488,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; @@ -1499,7 +1500,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