From nobody Tue Apr 7 12:55:30 2026 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 0557839B971 for ; Fri, 13 Mar 2026 13:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408215; cv=none; b=ei+tdtqRElWStzimhVWYOdiMLTyHFIStp04p2ZF/8TFRgcO6r+P2pccIX1IrY6tVoAJXxShPgKduD/mE7Ms+J3SGrp62eAJjKAwnZGGxaaw1ASdt0yVrhascnlEHBIxjh++F3V4AKxZdIvczWdlC76n8EE1gHgqS+gunawBQ0Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408215; c=relaxed/simple; bh=4O8EaX5XnNoPvjOdiASMSgJbPgA6ST4ey21C1nqFksI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bzqs/x2RhzN4zsGkbvrYMV0sXe4X4bGjfjL0RfqcncVI63edbqrpNzUK0Ct/dT1ZQpGTKoeQqs5FBc5CP6HuuIkVEy5ZvzCFpm29LQ5j5OtIUq+IPfVUHeOYH0amMtKGZAVvlFv3EjU20gwrjktDWKVfyW/TkHvOnzc/nq9FKqE= 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=JaNjXGzc; arc=none smtp.client-ip=209.85.167.174 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="JaNjXGzc" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-464bc03efd8so1514748b6e.2 for ; Fri, 13 Mar 2026 06:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408213; x=1774013013; 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=1Wq1T+ME15CeT+ENLeTMFVu27KuUi0eR6wJ/aa9tW5E=; b=JaNjXGzcQv29nkyMsrD39QfHl3njnw8vtuBVCC/ZALqZbB8Y7k5EDfnqEvyH1CQTxn fBf8yHHRs7Q6tc6RSgowJ+rBGdltreIM3jP4X6LLlkEFq83TdGzrILobuTPt9eiUE3VT 1EABgs4l7BMbz7JuhYs7VgG21AvxIHpI6kw8/0F1MWjkRWEaNudyS1+xvAYfbJJPgeAv apezbNfXwhx52x5mctz2TvEG9B8LCuOwFcBh1GZ4tjyQEeLnPhjQUr4oJU/sQrjDzmMZ 823vYuB0kl07g+RqxxX6o1WrelJgfMI0lvmUXh9qkTum7MGbrIBtODFWL+guxPLVJmUt gGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408213; x=1774013013; 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=1Wq1T+ME15CeT+ENLeTMFVu27KuUi0eR6wJ/aa9tW5E=; b=QPxVQqleYimq4Uol4/2dwm+rIUwqJFHzi7tsHZ4hWz45WCYYs8lYPT45Cai1hzn3b+ Hmv9Y9DwomJM+d0vZetp2vB1aNqHU/cuBVjXu6vtvJjria8LImvdfrR4UiKNrhUZQA6O h0335ZTD5pORS5HdrbwieTbW5h5ObAAhfy6yByJWP5KOjzYLytULlwz4pTNmQgWLbAjL crQs20H05NhJ2+xY/OwvcwptGnrGjQrUANwSd1cd38xYs2xNDkjBii2ixYu5bh9T2/g1 aNhcHrQqDtSmSxnXT+FEDRFRRDcM0H5HyEpzzABa/AoTSx4RaTaGlGiWIoWzkhT1OQ3X FKTA== X-Forwarded-Encrypted: i=1; AJvYcCVTwhNLKPArPieXLc6Ss4N73csg99PxH/NElxOh6s9hL9zVJhWKimD0lXbr/IAk2SLQDPMApWuG2N44mIw=@vger.kernel.org X-Gm-Message-State: AOJu0YyhzT/4tI0gn5GyO2C0xgUXMgxZGVhqK7lcSHXeH3QvQeaBacT7 HnegQm2YUyEqg+jQBFpcuwO6OJofsYDusugMFRfknowa2VkaqcZgeQF1 X-Gm-Gg: ATEYQzyxe7Vo32mDEAnCqmTc1I5L+DRJjzD0J8cCOi7NTCIIq/E3iXU7xZ5fyPzFwD+ jia6XXlkF5QzLV+wC4agfgrFE7np9G6M5wY5qzs4igL+I+fwGlYaE8AFyec2+zmI570W5taHzPD Sxy2mrGKjk8Fk9tecPCoFi23Ofq/6MkVB+yEKDcKqldRexRCVERrYqkoGuPpk/tZBDdnGXZCpE1 9q9wpnGR+2tgWaiLRGaZcrHJ0GGjBXs8rBkmgHCoat+FmjQpF0KCF+QnrEVKYddj2YcuteH5Qol WUjjawNq+NPqkeInsPun9k3mQ1xfbLUZ/5RkTp+jpVem9IKibnPWAyo9ihRHvmfxdGftZkkonMI pJsbtg4T1gofWY54P+oAXjRcJzVHVPLULdTPUiSugsDNElwmu1jebXzD+feYTjXm76UUjvhEd0Q 7+3A7IAGrcslHXE++5yqm2RAj+onZmeNnLQyotBnxR2CML2lne X-Received: by 2002:a05:6808:2386:b0:450:89ee:922c with SMTP id 5614622812f47-467570dd9e9mr1671520b6e.27.1773408212826; Fri, 13 Mar 2026 06:23:32 -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 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:23:32 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Jim Cromie , Andrew Morton , linux-kernel@vger.kernel.org Cc: 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 v11 18/65] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Date: Fri, 13 Mar 2026 07:19:43 -0600 Message-ID: <20260313132103.2529746-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-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 --- 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 b84518b70a6e..34dbca0beaf8 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 df7223532cf5..34297f658bc8 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_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); @@ -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.53.0