From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 6C43A386543 for ; Wed, 8 Apr 2026 20:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678561; cv=none; b=qQhlWHEeaLXQCQHfv3pXOIHZtbzyHUhgxtRdbzQohM1g7hD5PapDjPyLCUMDKKcnzpJv3563tShA1TrBdNc6X3JLoaYilbVyonl0A+huIUMxemFFpbkzgWWJ4Et2IoI96F7kAvR5jfhzRBpOLKTrQjs0gGCGvZk+us9MiPFu/s0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678561; c=relaxed/simple; bh=uTEcJBYelrIyG2JjPn794qG9UfDtJUTMKVd8a0G5KCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u6xu9xXt2ThcvjZVj44OeZPwuv2SapAFV7bS4qNzB+rAI8jxJQXgcfHYOoQ5kq0hIqzl6e0chrYNj3sJq6UysRsTzITtYkuwGbX7gLvASwSWAeQ3WS1oaTjixiq0WL7i8e5iRkONcS6j+TAHBN5YWl7+Yncey/h0xbxPK12AzfQ= 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=U8/znCn0; arc=none smtp.client-ip=209.85.161.44 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="U8/znCn0" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-688ae78999bso64823eaf.3 for ; Wed, 08 Apr 2026 13:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678556; x=1776283356; 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=U8/znCn0DPKSaKPT8buo5iebHsRelI8pziAmZvzpnRyXJLO2/pgMbYiAWzpMKmOsV0 ySBLmn6pTXR1Ldhl+mrEAYrVFbYkqHFFTooo3yu221iW9uDNF3s1Azh8w6Ra7Ia9qFnO r5BWXAn796IolKc3AYfW7FEXSHKE/ZIupZJ7NlDNcphe0r3KIdl70T3GLVEeMh8q1gYs jU/ELK7kJWYHgqK1+dU6m7UVBqEpzEmNWP4uWf4MohHAKc57VvN/1A2zhx3QUL4RK2SF kE2ELyE9bY4f9CqSeuCk1dNddfdH4yQG2xf6AQEYXCq7zrMfN1fJgj9A0Hzq9oXxOu3U nYtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678556; x=1776283356; 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=orbIHHG6qs6H22h36x+iMVTabmmlGKIjonJn83fwpp2MpL7O5OAovsY3M5yafZbjZ9 g3eTrSmLrkA5WnvMYqBX4JrKohu+5dCLhTVl8v0JrHua4x7yKvp84846T+G/fWJvkSze AXBnuEubnRGgkmz+Pqo4Lewnr3eRjaev/SnuhkdrjIvAH4ATR08svgA59vqKZbnCJc9K RNNo/uLIps3E8Ec18DT6J0Vgv0OTvSJkLZ+4rcYQHPHEMbKUO4oKmhYxrPyH1FCtbhmg mNteB4yBR7xISjiGbuayobx32VGDD09jvRKHMxYc7r07810q4mx/NuyTUkQDa/W2aoOi nSbQ== X-Gm-Message-State: AOJu0YyRvXuZ4VbSa9f3K/dhnPn9iWF+L5zDGdq26YUwuM3/MEtnFwcI mBawyj/GO5Sc5ULcu4VzLvIj/8Wn0hOuEp7OJ3QxBpjNzHibcDBIKEnibvk4xw== X-Gm-Gg: AeBDiev1C45yucm5GLOCx4phAC4gM44KdfYHmSDA4cCEfn5ZDfjEonjUWQSf2cjujx0 6a+2uJpGnWfQ+jN7Fh8X0xwT9zJzg/UnivXcFGhl6oS5PT3UogXUpmi+huSCFELOpAea3ORFSzT vVgJhV53UFxU7gnxMFWQI7eldDsAPpTvv8QtUU8Vtl/HTE3AtjfRrms33QmS8nMBq7BJytuCHkY 55EIYxa65F4mJA5TJVrOFml/sn0EPQOEiE65agbWuQRl/tcYPCLbw078LLJOlcJblJns10GWNJJ Y3lFAwdcycbs9NZMCeyl3cYaiikXF02IyEMnU5FVIyR6Ye89geCHi8FsN17DhAESdlNVEGNjL8G ARJ2UVH1CiomFVju28Ab0ZKERc+vddcKlO1O07scSqjQLUS5775ontoQmcCp+5hgyPHqotUbP0k Br8VJaxKpjv2DYDmtmCPh4WhS3I53OMN+S1B1QAl3Hp6JcfNIk38/30JZqCybe0H4UA5tk7EEVO Zg= X-Received: by 2002:a05:6820:2223:b0:682:cac0:1ad6 with SMTP id 006d021491bc7-682cacf98c4mr10537863eaf.14.1775678555990; Wed, 08 Apr 2026 13:02:35 -0700 (PDT) Received: from frodo.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 006d021491bc7-680a63c7fd1sm12254208eaf.8.2026.04.08.13.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:35 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v13 20/36] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Date: Wed, 8 Apr 2026 14:01:55 -0600 Message-ID: <20260408200211.43821-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408200211.43821-1-jim.cromie@gmail.com> References: <20260408200211.43821-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: 8bit 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 { }; 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_maps[]; 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.53.0