From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 42ACF2F12D3 for ; Wed, 14 Jan 2026 01:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768355927; cv=none; b=GjZlSu/Vlj2ZjbnrV77owHsBxqoRbRu7Clf9+epHWJZmgsMkUWBXDZOHRp9Gru5WOlwTBo4qHBdjVUjT+qZdZL2IZZ9f2XoBnNh0A/0ONmDiPot7g26/WXKQmqpy5jQgsPdkPZT31EJUJcCFFVQ5kwbk5EEt92CPdMg1tkIbWSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768355927; c=relaxed/simple; bh=aPKvrimU3xatybfkmmEJGCuwfRE75IK26HvPJc9sxM8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=mrovuPWArfb5Wj+OeDk8eF25f2+Vcf7nouLjxiqpEXNhU8kAK8UaBpDUSVAD6u67fhywKSBdQG+VI8T88T39pffPMMk/N0FlITznXQJy2Em2/GGcbZUwHFkIXFWwxEthVPaNZXAEeoKhnL/+dQUkz+vj5bkdlJ7MU2Qr2yaB7Zo= 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=BvgLnpFF; arc=none smtp.client-ip=209.85.167.173 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="BvgLnpFF" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-459fa8b6044so5433081b6e.2 for ; Tue, 13 Jan 2026 17:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768355924; x=1768960724; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=teYKKbLkZbUHHb5EH1qkAwDiVubshmdqathiyRgte04=; b=BvgLnpFFxhosxNZ6BF0Q1Q7SKLxkOrZ0l0zAxBovlfeFvTR7CWpXgZTLdxMwpKeyj4 klOs0eSD1/AOREsp37AGaI7CXSnZTFtTaQh75FzAUWKM71+ysRzRr8sgzCceirbvS8Cg DZXKm+zYYCDB+m78PS4QMKcUhDUmrT9mG81K3CqHotvjhMm0Poa3DFfjjS59lPmIYqqc I4Q8/7B0wIHkJWrblGzEYNTiQm7zFiR3//U5wW69Av5BErs0MfHPbGU2siJCUzdqORRF lcS8Vkpz9kEkQNcbH9YbMZFAVuTQFzpaXguw9pcLfOs/m9PWML2QTZs10YBoF8wVYa2L MBgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768355924; x=1768960724; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=teYKKbLkZbUHHb5EH1qkAwDiVubshmdqathiyRgte04=; b=aw/dEgWcSc6JwrfQJDulVh/j0AT9mAW8SPKiG5zi72qM85dJzOiGdtM4yPwoeXmOfJ mfIb8XHdNpT/5FrpIBEaQ9mB/cfpEMdPRS3rgWtg6sUziCKPYRW3RQBjhjumIP6DlG+6 TnTu0g4suO6ePK/iQ5usxswXeJlFa9IbeoT7y92/yYygy5m2wqw8nycU+GU6qA26kTBZ nKdHxMNXJT2vwaheMdrmDNRWeRvi8fUmpcsVfrBb/E9PL+5fZQ19Bk+TIz9TqF7lorCi N/YdnKTjP3RXKKc906ITcvx8IErqjUoW/i3BcmQc0CUvCWsCVfU9asqrNFOmNGInwZ8G fv7g== X-Forwarded-Encrypted: i=1; AJvYcCXk+ZZnAZvob4UaiexJ2kVrnwAMtRIVHpUDUYtoFB2JulMMjUQU+2ScQ/9CKaYu6WXspyzevAf7g9zzQmw=@vger.kernel.org X-Gm-Message-State: AOJu0YwFsEHsnBjuitBu/IJC8+pNu/Pjs3zZzBgpWDhHEnOKvmDz0BPL 2g3AoKN9lPV0yPtGtNPs/8O6xTCDod1cyMg1nQeJM96+3v5L78Pmtn4I X-Gm-Gg: AY/fxX6WPtgOmoxH7pR7rGpZ9GeC19yUyMq6X07YV7mSFmKKOVYIKXj/ZLd+aG4HQpQ klIXfyGlkFw9QvKD6DXlHkB3BfwVPPePTobtVhLvqWCsAsrjFLt79lPGM8HjqWHnioBARCesbra zjq8m+GD/2u7M0yCtxhnlKOZG0g3lTIVxx+bVcJT58+S+LV9YqF4Jt5mgO81YbLS22UAOO/3syp 09IrOXlkzAG1lFp7OFm7Z5/vMJCQd36wli66WMqc3R8NDDZFP6MHgNAoaZlnCQ+1VvVbzIJxXkK CjpQH2R8gsmTLA4C0fbcUr6OtKECkVnRicQvTo7k+R56XXlfn919iuv+Gpav9iFlv+nSGXoAaqk 6emcHm9WT0xUDU/CAHISGUfafA2HG7+IDenV/kShbElUirU9bC4CXDprkQ7DXtLuSsIr/K+lfrw stgFL2saBtjgSE8HIIR5JCZvsTOPPmGjfpgLnf X-Received: by 2002:a05:6808:50a2:b0:459:bcc4:d6d3 with SMTP id 5614622812f47-45c7115a02cmr683734b6e.0.1768355924022; Tue, 13 Jan 2026 17:58:44 -0800 (PST) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 46e09a7af769-7ce478af8b2sm16131037a34.15.2026.01.13.17.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 17:58:43 -0800 (PST) From: Jim Cromie To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie , Jason Baron , =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Louis Chauvet , Bagas Sanjaya , Dave Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Petr Mladek , Shuah Khan , linux-doc@vger.kernel.org, Steven Rostedt , "Liam R. Howlett" Subject: [PATCH v8 00/31] dyndbg: fix dynamic-debug regression in DRM Date: Tue, 13 Jan 2026 18:57:16 -0700 Message-ID: <20260114015815.1565725-1-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 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: 8bit commit aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") added dyndbg's "classmaps" feature, which brought dyndbg's 0-off-cost debug to DRM. Dyndbg wired to /sys/module/drm/parameters/debug, mapped its bits to classes named "DRM_UT_*", and effected the callsite enablements only on updates to the sys-node (and underlying >control). Sadly, it hit a CI failure, resulting in: commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken") The regression was that drivers, when modprobed, did not get the drm.debug=0xff turn-on action, because that had already been done for drm.ko itself. The core design bug is in the DECLARE_DYNDBG_CLASSMAP macro. Its use in both drm.ko (ie core) and all drivers.ko meant that they couldn't fundamentally distinguish their respective roles. They each "re-defined" the classmap separately, breaking K&R-101. My ad-hoc test scripting helped to hide the error from me, by 1st testing various combos of boot-time module.dyndbg=... and drm.debug=... configurations, and then inadvertently relying upon those initializations. This series addresses both failings: It replaces DECLARE_DYNDBG_CLASSMAP with - `DYNAMIC_DEBUG_CLASSMAP_DEFINE`: Used by core modules (e.g., `drm.ko`) to define their classmaps. Based upon DECLARE, it exports the classmap so USE can use it. - `DYNAMIC_DEBUG_CLASSMAP_USE`: this lets other "subsystem" users create a linkage to the classmap defined elsewhere (ie drm.ko). These users can then find their "parent" and apply its settings. It adds a selftest script, and a 2nd "sub-module" to recapitulate DRM's multi-module "subsystem" use-case, including the specific failure scenario. It also adds minor parsing enhancements, allowing easier construction of multi-part debug configurations. These enhancements are used to test classmaps in particular, but are not otherwize required. v7 added: . WARN_ONCE when classmap isn't found for a class'd callsite, JBaron . reorder macro args to match kdoc, JBaron . Doc formatting fixes, by Bagas v8 adds: . CC's for tools/testing, DRM, others . p21: change _ddebug_class_user.base name to offset, for p30 . p30: amend commit-msg to explain untested, speculative nature Thank you for your review(s) and/or Tested-by:s P.S. Id also like to "tease" some follow-on work: 1. DRM adaptation patches, tested on my HW/boxes. 2. patchset to send pr_debugs to tracefs on +T flag allows 63 "private" tracebufs, 1 "common" one (at 0) "drm.debug_2trace=0x1ff" is possible from Lukasz Bartosik NB: the private tracebufs allow test scripts to verify log content, not just counts of changed pr_debugs. 3. patchset to save 40% of dyndbg's memory footprint move (modname,filename,function) to struct _ddebug_site save their values & descriptor intervals to 3 maple-trees add 3 accessors to fetch on descriptor, from trees move __dyndbg_sites __section to INIT_DATA. NB: Despite the new accessors, `cat control` is just as fast. Cc: Greg Kroah-Hartman Cc: Jason Baron Cc: Ɓukasz Bartosik Cc: Louis Chauvet Cc: Bagas Sanjaya Cc: Dave Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: Petr Mladek Cc: Shuah Khan Cc: linux-doc@vger.kernel.org Cc: Steven Rostedt (ftrace/logging tease) Cc: Liam R. Howlett (maple-tree tease) Jim Cromie (31): fixes, cleanups, simple stuff:: dyndbg: factor ddebug_match_desc out from ddebug_change dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP docs/dyndbg: update examples \012 to \n docs/dyndbg: explain flags parse 1st test-dyndbg: fixup CLASSMAP usage error dyndbg: reword "class unknown," to "class:_UNKNOWN_" dyndbg: make ddebug_class_param union members same size dyndbg: drop NUM_TYPE_ARRAY dyndbg: tweak pr_fmt to avoid expansion conflicts dyndbg: reduce verbose/debug clutter callchain grooming, re-structs, code simplify/dedup by macros:: dyndbg: refactor param_set_dyndbg_classes and below dyndbg: tighten fn-sig of ddebug_apply_class_bitmap dyndbg: replace classmap list with a vector dyndbg: macrofy a 2-index for-loop pattern dyndbg,module: make proper substructs in _ddebug_info dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module dyndbg: move mod_name down from struct ddebug_table to _ddebug_info dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code selftests-dyndbg: add a dynamic_debug run_tests target dyndbg: change __dynamic_func_call_cls* macros into expressions core fix, detect api misuse errors, etc:: dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP dyndbg: detect class_id reservation conflicts dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time dyndbg-test: change do_prints testpoint to accept a loopct dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API dyndbg: treat comma as a token separator dyndbg: split multi-query strings with % selftests-dyndbg: add test_mod_submod dyndbg: resolve "protection" of class'd pr_debug dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) docs/dyndbg: add classmap info to howto Jim Cromie (31): dyndbg: factor ddebug_match_desc out from ddebug_change dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP docs/dyndbg: update examples \012 to \n docs/dyndbg: explain flags parse 1st test-dyndbg: fixup CLASSMAP usage error dyndbg: reword "class unknown," to "class:_UNKNOWN_" dyndbg: make ddebug_class_param union members same size dyndbg: drop NUM_TYPE_ARRAY dyndbg: tweak pr_fmt to avoid expansion conflicts dyndbg: reduce verbose/debug clutter dyndbg: refactor param_set_dyndbg_classes and below dyndbg: tighten fn-sig of ddebug_apply_class_bitmap dyndbg: replace classmap list with a vector dyndbg: macrofy a 2-index for-loop pattern dyndbg,module: make proper substructs in _ddebug_info dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module dyndbg: move mod_name down from struct ddebug_table to _ddebug_info dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code selftests-dyndbg: add a dynamic_debug run_tests target dyndbg: change __dynamic_func_call_cls* macros into expressions dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP dyndbg: detect class_id reservation conflicts dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time dyndbg-test: change do_prints testpoint to accept a loopct dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API dyndbg: treat comma as a token separator dyndbg: split multi-query strings with % selftests-dyndbg: add test_mod_submod dyndbg: resolve "protection" of class'd pr_debug dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) docs/dyndbg: add classmap info to howto .../admin-guide/dynamic-debug-howto.rst | 187 ++++- MAINTAINERS | 3 +- include/asm-generic/vmlinux.lds.h | 5 +- include/linux/dynamic_debug.h | 302 +++++-- kernel/module/main.c | 15 +- lib/Kconfig.debug | 24 +- lib/Makefile | 5 + lib/dynamic_debug.c | 776 +++++++++++------- lib/test_dynamic_debug.c | 198 +++-- lib/test_dynamic_debug_submod.c | 21 + tools/testing/selftests/Makefile | 1 + .../testing/selftests/dynamic_debug/Makefile | 9 + tools/testing/selftests/dynamic_debug/config | 7 + .../dynamic_debug/dyndbg_selftest.sh | 373 +++++++++ 14 files changed, 1465 insertions(+), 461 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c create mode 100644 tools/testing/selftests/dynamic_debug/Makefile create mode 100644 tools/testing/selftests/dynamic_debug/config create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh -- 2.52.0