From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A73853359F; Wed, 16 Sep 2026 15:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789572783; cv=none; b=qjwuUSP4ecZIvZPJuM6YSnhbqTM+hiiMhyrHV1nArVoCcLPikNUi0exL4B41wTAECuBKIxH8W5HrYGxxz4Wtw+hJ+JaS5sXoWKuoMha/7pboBd+D+JuE/LQmTv7pw7sOXSyxzl3Sa1op+fy/xiiqCqTyv6HwLBIKL4bu1xit24A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789572783; c=relaxed/simple; bh=g327Lt1Wa7i5zRuwpE68v025f5tdq+5vIvxaHeUZQ4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UvXVVul6DMjQCEVHtRmgk7J7rkL1IaXviOeWA90aOtpUFztI0IbfksFABEM4F+149oETfNVck/SPNDsF37y3RGb7o/oJ25gs0ywlszNE8Xlu49d9FFlp5+VcQoi8V8gJ7qL5srlo0HRIFRPAgU2LG1M0PZ8++JJPODv77pIWgak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LUfbySdY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LUfbySdY" Received: by smtp.kernel.org (Postfix) with ESMTPS id DA6E9C2BD04; Wed, 16 Sep 2026 15:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1789572780; bh=g327Lt1Wa7i5zRuwpE68v025f5tdq+5vIvxaHeUZQ4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LUfbySdYCtXC82qRA2oGqfhf1GIUbmlEhiv441NSy9sLwFjk3GUtYFmvH09YeYN19 oLjnLvgF/OMoAv5DtSzkLu8DmQdgqxOUPMYnz35QVRM1ftw1L1VhkSO3DVzFTdW+2q hxJRDCHyB5pqVZYFFkfrYSe2mlCeZhsA0fpByhIWbpEMgCQFdFEsqphCU10tx/imJo kRvUGey6MBYPMidJeP7sVleBRRqZDlNHl5UUBK7Qk0rePCliS0ffhbLO64gA2wCH+d 9I//qJDKbr1U8cuGMzAMT6QGQJPlSzqXRopWfYNe2D7yALuLXZYVfwlO/WP6FTSd+L 5kGTttuVftsyA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5178C982C4; Wed, 16 Sep 2026 15:33:00 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Wed, 16 Sep 2026 09:33:06 -0600 Subject: [PATCH v10 14/38] dyndbg: Bind callsites and classmaps to DDEBUG_MODNAME 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: <20260916-dd-cmap-part2-clean-v10-14-af4cf4767707@gmail.com> References: <20260916-dd-cmap-part2-clean-v10-0-af4cf4767707@gmail.com> In-Reply-To: <20260916-dd-cmap-part2-clean-v10-0-af4cf4767707@gmail.com> To: Jason Baron , Shuah Khan , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Jonathan Corbet , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier , Shuah Khan , Randy Dunlap , "Rafael J. Wysocki" , Pavel Machek , Len Brown Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-pm@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1789572777; l=5456; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=QBYHFOAGtPUZQ0XtQfqknu+wV/y2/uE7ShWvPiZO9qg=; b=UBn3jzJiK8zgbFC+xg1+b0mfu0MV0P6ogZrSO9KhMbgJN3fmX3t1Ckby9SBoVGQbUb2xySmUT wPCVCh19BSuABrXQCh6w3mrUrd0KkNkohzY3imdW5yTotY8VgOllM9c X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com From: Jim Cromie Currently, dyndbg binds KBUILD_MODNAME directly into callsite and classmap declarator macros. For built-ins, KBUILD_MODNAME defaults to the basename of the source file. For many subsystems, this fragments what should be a single module into separate file basenames: kernel/power/ produces "main", "suspend", "hibernate", "snapshot", and "swap" when all should be "power". Conversely, multiple unrelated built-in files across the tree (init/main.c, kernel/power/main.c) all collide under "main". While consolidating these fragments into unified subsystem names is desirable for query targeting and classmaps, attempting a bulk heuristic renaming across Kbuild introduces broad churn and disrupts control file output across the kernel. Module naming should remain under explicit maintainer control instead. Define DDEBUG_MODNAME in include/linux/dynamic_debug.h guarded with #ifndef, defaulting cleanly to KBUILD_MODNAME. Bind DDEBUG_MODNAME into callsite and classmap declarator macros instead of hardcoding KBUILD_MODNAME. This establishes an opt-in hook allowing subsystem maintainers to consolidate their module fragments if desired (e.g. via ccflags-y += -DDDEBUG_MODNAME='"power"' in a subsystem Makefile) while preserving existing module-name invariants by default. What's Unchanged: - Default module names remain strictly identical to KBUILD_MODNAME. - Zero callsite memory overhead or layout changes in struct _ddebug. - dynamic_debug/control output remains unchanged across the tree. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 12 +++++++-- .../selftests/dynamic_debug/dyndbg_selftest.sh | 29 +++++++++++----------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index baf5c0853f45..85863e24ad13 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -10,6 +10,14 @@ #define __DDEBUG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +/* + * DDEBUG_MODNAME: Subsystem/module name hook for callsites and classmaps. + * Defaults to KBUILD_MODNAME. + */ +#ifndef DDEBUG_MODNAME +#define DDEBUG_MODNAME KBUILD_MODNAME +#endif + /* * An instance of this structure is created in a special * ELF section at every dynamic debug callsite. At runtime, @@ -121,7 +129,7 @@ struct ddebug_class_param { static struct ddebug_class_map __aligned(8) __used \ __section("__dyndbg_classes") _var = { \ .mod = THIS_MODULE, \ - .mod_name = KBUILD_MODNAME, \ + .mod_name = DDEBUG_MODNAME, \ .base = _base, \ .map_type = _maptype, \ .class_names = _var##_classnames, \ @@ -160,7 +168,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name = { \ - .modname = KBUILD_MODNAME, \ + .modname = DDEBUG_MODNAME, \ .function = __func__, \ .filename = __FILE__, \ .format = (fmt), \ diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 972f12c70a8e..09a8dbf239dc 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -267,34 +267,35 @@ function FT_grammar_errs { ddcmd =_ } -# these queries run against the builtin module: params, and change -# flags. The control file state-of-interest is found by path, -# kernel/params.c, to avoid module keyword entirely +# these queries run against the builtin file: kernel/params.c, and change +# flags. The control file state-of-interest is found by path $f, +# perfectly binding the stimulus scope to the observation slice. function FT_basic_queries { v_echo "${GREEN}# BASIC_TESTS ${NC}" if [ $LACK_DD_BUILTIN -eq 1 ]; then - echo "SKIP - test requires params, which is a builtin module" + echo "SKIP - test requires dynamic_debug built into kernel" return fi + local f='kernel/params.c' ddcmd =_ # zero everything - ddcmd "module params +mf" 'kernel/params.c' - ddcmd "module params +l" 'kernel/params.c' - ddcmd "module params -m" 'kernel/params.c' - ddcmd "module params =_" 'kernel/params.c' + ddcmd "file $f +mf" "$f" + ddcmd "file $f +l" "$f" + ddcmd "file $f -m" "$f" + ddcmd "file $f =_" "$f" # multi-query commands split on ; on a single line - ddcmd "module params +mf ; module params func parse_args +sl" 'kernel/params.c' + ddcmd "file $f +mf ; file $f func parse_args +sl" "$f" # verify multi-cmd input, newline separated, with embedded comments ddcmd =_ # reset before multiline query to capture full transition - ddcmd "module params =_ # clear params - module params +ml # set flags - module params func parse_args +fs # set other flags" \ - 'kernel/params.c' + ddcmd "file $f =_ # clear params + file $f +ml # set flags + file $f func parse_args +fs # set other flags" \ + "$f" # clear flags and verify - ddcmd "module params =_" 'kernel/params.c' + ddcmd "file $f =_" "$f" } # Built-in Feature Tests (Can run on any CONFIG_DYNAMIC_DEBUG kernel, modular or monolithic) -- 2.55.0