From nobody Thu Apr 2 20:21:29 2026 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 329F53F077F for ; Thu, 26 Mar 2026 18:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551302; cv=none; b=nvmQ+qEGEBlKZbYwUssQUJ7+ea0dfaf4VN/XPYWsP+jyg8LMif1qpFqTa6yfQdzAV8YIMWk7bFtWfrboHy8QQL6pZHiH7wEsv8Mi0JT9Gi9QgFbBri278AOgNdnnecE1R4UX333vlKtAomk2cHgqo3F9wfgsYbTeWQ5PDw64vks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551302; c=relaxed/simple; bh=uTEcJBYelrIyG2JjPn794qG9UfDtJUTMKVd8a0G5KCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JNOdD9lyMUnr/Hj+lqryhz0hIezMjb+eQQBjkRNbkS3RmZtBO1QEWlNUjsIduc4TALHfCFwXQa4b0n09OuaekVGZl+EQ4V++jZMxHTyW2hhTuj8lVxIBRFQLmE4qdTHGYNye+ghAb4GTsFeMsfV3srq67BcPaNcDto6McaEAK6I= 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=rFwi2FW+; arc=none smtp.client-ip=209.85.160.45 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="rFwi2FW+" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-40f0e14b9f9so935509fac.1 for ; Thu, 26 Mar 2026 11:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774551300; x=1775156100; 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=aZtEJyK8+Vy+6RrLQt/6TVbqc7gTE0xdy0M1pjWQpWg=; b=rFwi2FW+emMF7inj9GeFvruD3+VLWgexS8w8OK4AnZo5HsZir/8o+vn6Tb5kL7r86t Ik5RhF0EL7p+BXVHLznnoRUSRptwmrgAFBe5F7v5uJHXq5ZA/PZx2d81lweEmxHsLGX9 icLjjjQvq5x/31N9bp56E95uArIHevL7/WFajyr80BZ7rX9OT4GstfhOg7yajgrQWgBE EJPK4+oU+2V61PQa7wUmRlL1esIQWbvofy5kIsV3/HK6q8XTbEpx9SopMA51oWRD33Hf Ds+qnqM8dTH9buV2iRIJ4ZIcagnxMiZ6eUdC9njPPmpQU8YOiEA8Fxk8A6TorrZtjLrM 08lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774551300; x=1775156100; 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=aZtEJyK8+Vy+6RrLQt/6TVbqc7gTE0xdy0M1pjWQpWg=; b=jCHqRQJ9qO5VRHZXeF/GBRhtRhv6J9aBXUa53h/QvJ6usBZmLeymwlSLJsiwlOgqyM aPUFQg6CWjnhwAIG2MKYFWoRw8tFQSERKqSouTPxhtgFE33oJRdVytA54WEJd1NjsdRy nCYDgWgwFUIA66AgI/qim6NIT9oRyXRLLP9hoqpX7/5uQzdFZXoZS9muwMbAWKa2WsOu XZr69795hbbIbCt0nIvpryXuYZINAgy0es+cASHfa915CR2zdm6v+YK1WNmGys02KCOX qXPhSeb3fqgyVLCE9B9CdX1IHSIOegVZKCd8ReysKt0bqT+Sq0Y0et+gxmkD2jOqpK3C gW4w== X-Gm-Message-State: AOJu0Yz3S+MZdUoAO44AVCyEWlKTy2AwYFhk4niIJhaqaTUXGv8NhQG3 HIRAqJI7ztvQ8cSUYA+UNSq3M1B22N+xPwntb5B7OxOx6JTSXZgj8/uwvcgn5Q== X-Gm-Gg: ATEYQzxwKdZykF0heQhqS7vbeVHwBH4Os3O6kjNdO9J0St8kiRSTrG96+52xLFCdvYs O4K9BdA5HlISlJ7wzH4A3qcU+39LPafhdBzUphtUElyWFujXuwUuF/BGIOhXlNYtZZ/Bd89/7oi 2fmFoEgPbnSC49Dh87/MpqW4JuoAJNcQ5RsP75ajwEZ7nQ9js1tJmlT+0aIVd0i3CQdw53TwM2R H2Ocsp+CPYMCjg3clntcgVkiiK1fp0fFiiMXlC1v7nWbrTeejB0xX2sTldUXDbUxJ1v4PHPGBwA YvAncIElY2+wmQndKON1Q1davByW6kVC1PAxgBTF8zgnrkhQs2mNdvt0R85gAM1YJcXMf8qrr29 /bt+VWiT2aIxmATifMAhHSl3+hMvrO2W5awdN/vrvf6/QrEY39IAaWznFT9IExZXoQ7mRFInsGg WjrQqRpyX6sDOrCSbeqn5HyfzoDLxq3zQofJ4mmv+Gy3+m/Oxz X-Received: by 2002:a05:6870:9a22:b0:417:4888:327e with SMTP id 586e51a60fabf-41ca6de200bmr4549072fac.13.1774551299790; Thu, 26 Mar 2026 11:54:59 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 586e51a60fabf-41cc7760c08sm3075171fac.4.2026.03.26.11.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:54:59 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: jim.cromie@gmail.com, mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v12 20/69] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Date: Thu, 26 Mar 2026 12:53:24 -0600 Message-ID: <20260326185413.1205870-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260326185413.1205870-1-jim.cromie@gmail.com> References: <20260326185413.1205870-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. 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 5429315ada8e..a262a9862f2b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -108,6 +108,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 f47fdb769d7a..21ba5cb3b406 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 @@ -1256,7 +1256,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_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 ddebu= g_table *dt, struct _ddebug } if (nc) { dt->info.maps.len =3D 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); } } =20 @@ -1275,27 +1275,26 @@ static void ddebug_attach_module_classes(struct dde= bug_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; =20 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_obj(*dt); 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); @@ -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); =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 @@ -1370,7 +1369,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; @@ -1390,7 +1389,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; @@ -1488,7 +1488,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 @@ -1499,7 +1500,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.53.0