From nobody Tue Dec 2 02:41:31 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 B43FC2E0402 for ; Tue, 18 Nov 2025 20:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497167; cv=none; b=Qk9fm+En4lG4PXD3RvAWcZv//estrjow5jcu4m+Lynlo2EYgN/jYFML4QhHej7BtVVIL7VhO2E3Liqr91Pcf67c8XHikeH8ZWgORTt4jo9uVvIMd+EvlIJ8l7yB8bgTvDhebAyDdOVFW76EZdO7+mzaM8Hin5U6TZvicpsBEx4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497167; c=relaxed/simple; bh=2hQ9JNXCdcoJrsjqRtLX+egssbwP0g8MkV2bxONACaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ux8xO4+R+QCXNYm5tobIvd2HO+B+ZQbqd1ugrtxhlNkVKGMU0TvYqT6nZ09tyH37yZKGSBpg8d7Pp9U8rmaw+Dqms2YWkJJUM59F95OXtxBulFDWaDo83FfnJ2pnRayYVz3+/s7YeIe4Ghpy8VWS5YbMAe3RtF26s+zoLtRtFYs= 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=RKI6UeJS; arc=none smtp.client-ip=209.85.166.42 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="RKI6UeJS" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-9491ba846b2so45938739f.2 for ; Tue, 18 Nov 2025 12:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497160; x=1764101960; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7a7yVeAfR1EVEVSwMX5+J7VwmlWrIPE44SjKvRUAilI=; b=RKI6UeJSBJmOJczLnKjJBGU1Hy0JFyljQMyb4NUt5nvEBc3yhbETy2t3QPhDeTLKXN jG+ng1XqS84qJ3w8mz+oaeRTi39fHDxsa0osOTnLaTjCGtxjNytdOovSQU8DSOBJO1/A VIrB+meVY4t3SIunpZfxU8WrsAsLsj6who4Bq3bDhHXK1uuocaoTDj6TPig+HzwzKJXw CtAsXzL8gIejyrvi1qeh3QVXhXkZ/ewHDRwFapvfIm+IOO4mz5Uhtc5UyLJx7q66KUAM 2ksvt7wTBtRVoRPV+mWtUGNTg3QYP851PnM/Gry/vE3sKeWB6Zt9IrSOuUxMYpt31aIz 1yCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497160; x=1764101960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7a7yVeAfR1EVEVSwMX5+J7VwmlWrIPE44SjKvRUAilI=; b=E3yLs6rzWI7VlSTm7ucMLYo7Ge2z+47san2rIIAuYN2VH7XYrYHv6p0h1mIxXM1WGa dbOsGN698ZnPDQ18+vGkwjYMl63JQAVSLiwyaOU4FwMTFx524A3VR8W0IlIBu5F9wWfd fWFBAxRakBDKxCospoMLr9DOTbOEZ8S6mfvjpRHqJP8D5bUJUkptGu3A1akRU849/Kzt vS8kYwa3gnFBvBJx87MiGY92jodC5xvVzuDMJeOq2Ksig47AKKxYXEczs+MuEbljdiba 4Pt8C/aooAuWZBB2iVbUypgxoqqL0Jd26nxXRZMPAr90WTdoDSAVatqtJe/agWW/Ou42 PsSw== X-Gm-Message-State: AOJu0YzfTZtFu7kir75g+jbEbpZmpKlkTiProl2zTLfOfsM5Qm04j3PL 23bPB8QGdGRYzplOUDJIyiILn0P/W4z7kMMvF5gJ1jP/X0UqihrISnPFv5P2ZZG5 X-Gm-Gg: ASbGncsqhC4rKmMLKDBcdkhMi1vt9xipbeg7hkgxQhz9HvZMtKcqtB8XMHUR1p2ZYv8 wh6IsSlliLygl7Uc4LqgDM8SdjWcYTNwz9TwCZCbnygL67GnNcsL83pNZsBxxplfUXBLBJ6QNRc wkJMIyiMmhyTCE8wq+9a8MD+E7C0MSamfEtQDPwDtymH9/g74/ZKVdZhH1wUIb1jDu7pa7I3ixe ZErxVvj98Xhad8BPYZDzhOGi9x6LUq6OLcSDWAWB8ykyP594cMoKR+UyPx9BZplepxAYMoencga KZRwfnAOHZLu8izBjylLrW1v0Gs82o7rWCeEhkfDH2DGxyM/oPSnhIiM/haxIt5XfmrFyC2hGmF YZ5Kume2sFZAiWoUzqRvf3Z3P995xRd4UkOivc1//rm2yhX/CMKRS96m9qvn1uWjdqesxQ8Kivo o5d66kHv4wNEUanJFr2aQZ5iLmWXYeDPMaOJVhJXaVQtMaqfVY4DnD5Me+DJdlszDscGLJWs79g xfBMw42fyNtWBhF X-Google-Smtp-Source: AGHT+IHztsgt3/fkQp4gqi9bXTY2nV3n2hrYyO+viHqk00qj9yOnDdTzcnF4AOkxe1x/gL8MNUWq8w== X-Received: by 2002:a92:c269:0:b0:433:7900:f1b6 with SMTP id e9e14a558f8ab-4348c87af7emr212112075ab.7.1763497159637; Tue, 18 Nov 2025 12:19:19 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:18 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 17/31] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Date: Tue, 18 Nov 2025 13:18:27 -0700 Message-ID: <20251118201842.1447666-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- -v3 more s/dt/di/ internal interface changes -v5 convert class_in_range macro to function --- 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 4775f66e96dd..10f1a2a1bee4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -107,6 +107,7 @@ struct _ddebug_class_maps { }; =20 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 49de591f036a..e7a6ce260c34 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -46,7 +46,6 @@ extern struct _ddebug_class_map __stop___dyndbg_class_map= s[]; =20 struct ddebug_table { struct list_head link; - const char *mod_name; struct _ddebug_info info; }; =20 @@ -253,10 +252,11 @@ static int ddebug_change(const struct ddebug_query *q= uery, /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { + struct _ddebug_info *di =3D &dt->info; =20 /* match against the module name */ if (query->module && - !match_wildcard(query->module, dt->mod_name)) + !match_wildcard(query->module, di->mod_name)) continue; =20 if (query->class_string) { @@ -268,8 +268,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, valid_class =3D _DPRINTK_CLASS_DFLT; } =20 - for (i =3D 0; i < dt->info.descs.len; i++) { - struct _ddebug *dp =3D &dt->info.descs.start[i]; + for (i =3D 0; i < di->descs.len; i++) { + struct _ddebug *dp =3D &di->descs.start[i]; =20 if (!ddebug_match_desc(query, dp, valid_class)) continue; @@ -289,7 +289,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, #endif v4pr_info("changed %s:%d [%s]%s %s =3D> %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 =3D newflags; @@ -1156,12 +1156,12 @@ static bool ddebug_class_in_range(const int class_i= d, const struct _ddebug_class class_id < map->base + map->length); } =20 -static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddeb= ug *dp) +static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; int i; =20 - 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]; =20 @@ -1189,13 +1189,13 @@ static int ddebug_proc_show(struct seq_file *m, voi= d *p) =20 seq_printf(m, "%s:%u [%s]%s =3D%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, '"'); =20 if (dp->class_id !=3D _DPRINTK_CLASS_DFLT) { - class =3D ddebug_class_name(iter->table, dp); + class =3D ddebug_class_name(&iter->table->info, dp); if (class) seq_printf(m, " class:%s", class); else @@ -1247,7 +1247,7 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.l= en); + vpr_info("module:%s attached %d classes\n", dt->info.mod_name, dt->info.m= aps.len); } =20 /* @@ -1265,7 +1265,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug typeof(_dst) __dst =3D (_dst); \ int __nc =3D 0; \ for_subvec(_i, _sp, _box, _vec) { \ - if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!strcmp((_sp)->mod_name, (__dst)->info.mod_name)) { \ if (!__nc++) \ (__dst)->info._vec.start =3D (_sp); \ } else { \ @@ -1280,7 +1280,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_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; struct _ddebug_class_map *cm; @@ -1289,20 +1289,19 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) if (!di->descs.len) return 0; =20 - 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); =20 dt =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D 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 =3D modname; dt->info =3D *di; =20 INIT_LIST_HEAD(&dt->link); @@ -1316,7 +1315,7 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - 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; } =20 @@ -1379,7 +1378,7 @@ static int ddebug_remove_module(const char *mod_name) =20 mutex_lock(&ddebug_lock); list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { - if (dt->mod_name =3D=3D mod_name) { + if (dt->info.mod_name =3D=3D mod_name) { ddebug_table_free(dt); ret =3D 0; break; @@ -1399,7 +1398,8 @@ static int ddebug_module_notify(struct notifier_block= *self, unsigned long val, =20 switch (val) { case MODULE_STATE_COMING: - ret =3D ddebug_add_module(&mod->dyndbg_info, mod->name); + mod->dyndbg_info.mod_name =3D mod->name; + ret =3D ddebug_add_module(&mod->dyndbg_info); if (ret) WARN(1, "Failed to allocate memory: dyndbg may not work properly.\n"); break; @@ -1497,7 +1497,8 @@ static int __init dynamic_debug_init(void) mod_ct++; di.descs.len =3D mod_sites; di.descs.start =3D iter_mod_start; - ret =3D ddebug_add_module(&di, modname); + di.mod_name =3D modname; + ret =3D ddebug_add_module(&di); if (ret) goto out_err; =20 @@ -1508,7 +1509,8 @@ static int __init dynamic_debug_init(void) } di.descs.len =3D mod_sites; di.descs.start =3D iter_mod_start; - ret =3D ddebug_add_module(&di, modname); + di.mod_name =3D modname; + ret =3D ddebug_add_module(&di); if (ret) goto out_err; =20 --=20 2.51.1