From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 561E2334C2F for ; Wed, 8 Apr 2026 20:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678540; cv=none; b=XLQwUVe9RSBwW1vr3lR0r56iRi2FyGasSC77UD2+mMjnTAPD6qRjnT8dZ0bJ6GnMK9OVcj5bUza5KiHdT0wtYk1zVZ3WJefSjgQ38uT2MGeooeyrNLc8BZkLDHUMCfX4VPHv2czEE1GUzbGkl+n+IY585Db+GSH1HBYeatx13Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678540; c=relaxed/simple; bh=mL3eQ5I+NpnVGpIpXZD2MNW+j/Qf6zw5KKDmKMjenuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CmQTnNTvHqBhbp8g87LAktyEhGW4i0otDkn2rnSqIhOzAQQTpkms4kko80tynCRmK4K7W4m3tve2na9EXRsNaM6rmM+60vrIebCVC5ojxUBbsheduUChWojfUAFuTItqGVjVOsH8qyrbmWuYhcqmCLe9MI68QGr835AuEHubeiQ= 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=QOT1Hhm8; arc=none smtp.client-ip=209.85.161.41 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="QOT1Hhm8" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-689e6737446so85393eaf.1 for ; Wed, 08 Apr 2026 13:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678538; x=1776283338; 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=gYmxGb7uQeQFtcBU/KNsuA+yly7Rfm4LYjwUpGocOHU=; b=QOT1Hhm8nQBr5JAnJBHiw4/6iWgUO3ZQmEQPpAOenRGk8I5PL0hKdCcmqBFNZXIwNR 7fibSD8SSqLVt1VSNi3vvD39zp7B+HST4PQwQ9gEku4O2b4BYCumet5i2CNxkXAhREi3 Pw62UgNLKpGuhSlvnT/zWT5VBR9VoJdMY/GHXFKqwbiHxeDdK+eMiX05YgCKhG3Y7wtq j6yQ4AUrQLBTHrZQTkRlVpfggn7ifYsxgaWNakXDfyzPnZtDg6kDLCN5OIKv1neS6UDf DrJL3h9NpJBpGCS0eHqL3EBtAmAJkvYSxcDeHoav8AFhxaWKTKM+J+6Iwexi6JbNVVoW BD4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678538; x=1776283338; 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=gYmxGb7uQeQFtcBU/KNsuA+yly7Rfm4LYjwUpGocOHU=; b=k6OtOUnYwtjo+URedGiju5ndnzvl/9GkTbhlSHJU6kg1cAbt2+i/65uj+Oa4IxU+22 dQRtbJErEM8l5gv4qv7+broYyMu1U+hY8/dom3zrDfV8/5FpEHVxW0S69QkTeydagsJr 3TX+gUnoj0/OYTRGNFe0JAl9/qNlsckJtyFA+qlVTk7Sme9Y3AAhWLDUACOE5dxOiLGg mBRK7hay5lNIsyyafvBBlCIVGCubMymC9V8wK3wv01RVKDveYrRi3ToDZzYx7wKGGkJ3 HG1kHs24GOr2X3LxQ6k5gGHQ7AbY1+DCntYsPq/KYv57H3FVwuDS6VRMhS8TIATZMHZZ 6pUA== X-Gm-Message-State: AOJu0Yz0brMny62vq3w+tWryPkvkMtheu+w1FBuEtGxLgoelLMJKpIOX z9obMDjYu9pSfkUoIEwR66felHE9pwLZUhx+GavdQBu5tZmNjXB0JOABTZQeRw== X-Gm-Gg: AeBDieuXrLwChPJyePpRS2YbjX95DRa+Fa0RMsxViooJw48AUoUvHcGaucLWTOk76y4 k7HW6XXpK4qVv36B703LJ0pjlz8JCCSTgDeEkMY8ezMh8Yo6xWPTqScN0MpH1UlyUX9ReKxmCNu ouYGFdqQCiqMinhaKGK2WSUg1Ei0fW5GKf6RBxdJENxAIXt07jhHt9chTw9Jo4Q03IvkrDXbkdi p4wYeNZFaoMh+zmkORYUo6tqLqIeJ9oqUrW1J1FaSqrGue3XgTLpCR6V+/BQmeCzZ+sqvcU3BBg eTL02GTKDiIjwjRx+T6Ecjb/2kJ7SO1iuEljWgdY4oUz+sDVtJ/6FDGyvHw1SR4bPM3TUtTreu9 TuiGf1bqMn2goPRPiVm/Em7twDsnM6ocgjoP8GK1tfV2GXUlmFh4uGc8djAhK5MWH7w9B0Z3VaO xhdo+Lyln3ntYPvXqBc+ew+404iIvIhSVMLStQciyNh+aNrjvY8P/z8hTm5chOehXIDaLk9MBOq tM= X-Received: by 2002:a05:6820:c86:b0:680:57b4:9068 with SMTP id 006d021491bc7-6821d83c55fmr12256265eaf.17.1775678537892; Wed, 08 Apr 2026 13:02:17 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:17 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , kernel test robot Subject: [PATCH v13 01/36] dyndbg: fix NULL ptr on i386 due to section mis-alignment Date: Wed, 8 Apr 2026 14:01:36 -0600 Message-ID: <20260408200211.43821-2-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: quoted-printable Content-Type: text/plain; charset="utf-8" When dyndbg classmaps get used (later in this series), the __dyndbg_classes section (which has 28 byte structs on i386), causes mis-alignment of the following __dyndbg section, resulting in a NULL pointer deref in dynamic_debug_init(). Fix this by: Adding ALIGN(8) to the BOUNDED_SECTION* macros. This aligns all sections using those macros, including the problem section above. Almost all the other macro uses are already ALIGN(8), either directly or by being below one. Removing BOUNDED_SECTION* uses in ORC_UNWINDER sections. These explicitly have smaller alignments, and using the modified macros here would override that aligment, which scripts/sorttable.c does not tolerate. Move __dyndbg section back above __dyndbg_classes, restoring its orignal position. This is cosmetic, given the alignment added to the macros. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202601211325.7e1f336-lkp@intel.com Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 1e1580febe4b..58daa551420b 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -212,11 +212,13 @@ #endif =20 #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + . =3D ALIGN(8); \ _BEGIN_##_label_ =3D .; \ KEEP(*(_sec_)) \ _END_##_label_ =3D .; =20 #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + . =3D ALIGN(8); \ _label_##_BEGIN_ =3D .; \ KEEP(*(_sec_)) \ _label_##_END_ =3D .; @@ -869,15 +871,21 @@ #ifdef CONFIG_UNWINDER_ORC #define ORC_UNWIND_TABLE \ .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_header, _orc_header) \ + __start_orc_header =3D .; \ + KEEP(*(.orc_header)) \ + __stop_orc_header =3D .; \ } \ . =3D ALIGN(4); \ .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \ + __start_orc_unwind_ip =3D .; \ + KEEP(*(.orc_unwind_ip)) \ + __stop_orc_unwind_ip =3D .; \ } \ . =3D ALIGN(2); \ .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind) \ + __start_orc_unwind =3D .; \ + KEEP(*(.orc_unwind)) \ + __stop_orc_unwind =3D .; \ } \ text_size =3D _etext - _stext; \ . =3D ALIGN(4); \ --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 5C6383537D0 for ; Wed, 8 Apr 2026 20:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678541; cv=none; b=Srr9prAvEPCRc8CIUawRYrXVoqGvdnXoSS+1hfJ+tPUyUF5MoO+c6rdX8YVJqA8RQ6wfXf9p164I0V5Pl3nnK9z3jjz3BgcIR7DPEK0iY+J+Jp81a6iXJjMgSDZwuHF+62tFz8s7Kau9ZPhTYGCtWVXjbg0uvLApbGvhKxJukMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678541; c=relaxed/simple; bh=M7qGYFcYxQ1ijPO4FPbquaFZxM7YrcQnkWktshoCzb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O8iUlKpEfwRV/q0+hKGe/9C+yUf8L0pbveqPlvIvzvnWJ9gmXsvJQsCMae2HW6x1zcE19W0+kDBlj+cpHuHLAEis4GO6xq7NtUZVbTWaweZ5+NEJVe94flgRfY5aTWSX9I1h853QB0zp0tmMyBiS8inzCkmAFfsIC8VXjxDbNkc= 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=LJpm+CZr; arc=none smtp.client-ip=209.85.161.42 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="LJpm+CZr" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-6841e6a5e51so81675eaf.3 for ; Wed, 08 Apr 2026 13:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678539; x=1776283339; 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=Jl0zqIzGDZsFGD9VB82Xk4qavMNkml4BIjsBRoCBMtY=; b=LJpm+CZrKgc5Ajof8yBVvsRqq87Bhd9Y+aoOq6JS0RScv0bwHtPTHCvk1laz96fFbC 5I1yOO7OkV10ubOkF620r8hLLaN7+t/DoDD0HMhUyGkDg8/pUJVfXonYcynG4/GBaqr4 W7p7S6BOMHlFmUBBplSXiK4za2B0g9U2Bp22fum50Aw8WzaRn/9tJRvycWuyn7RMoGVQ hq7GwKr4dFMMmy6loeQvQMkKD2qFcBXHucWlByjP/tYdPPKjlaTN5kcE15He6ERjtBBc cRd3GUotJutWP0Q1QPPrZqblFVJp2/Fr0DrsRVilGQqPhZBbrLCkjtB0pLjiQPGjVY26 Q9Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678539; x=1776283339; 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=Jl0zqIzGDZsFGD9VB82Xk4qavMNkml4BIjsBRoCBMtY=; b=PcG3PnT2wFixD8Zwo8R9a6vHZRyTAFnt6Uo0yHrqNtJ1qaHWrhMLNY5o1wKN3O4sxA 3CM3Z9Ii39C4+7uoP3IHF6KSqZ420kGDlbu8t7910QWvTbsNdKaUU4gn6bQmH+NME642 +77T19H76JLgnx4CgmFwPNq062qaKO4MvQy87veAuZPww6ujf/V73/n/WTn6UIUQju2U yVLuezQg1lmRBYGj7KoIOzYHjRuT3lwH6YNI0SVMkkfd8AlPvsbiF+hWubrDwGX4ip03 WyJzETysq2VWaPR4l6Da8AXepRmId725RWET6/0dNIxYW6XYgO2ync9y4NW57YVcayk0 O50A== X-Gm-Message-State: AOJu0YyCYbmCUoTZc3SEh0ZkscxCpkWO6nCRYYtacT2gMeEUPE/yRbP7 W6g2x2m2hTDf0Rsf8yF5y8FhZ8XFEud/fP1KY0hL6DXaHecx3z1vnjYQ5nKkfQ== X-Gm-Gg: AeBDietJ5aK9BOeCCKo9G5cJsfszSiC2YUnKsgc71ihD1b5ohOI9nrLnlbTAx7Cz+3d JQI40vuEjbS8ahgYOSP0PoUb3P1anMOCqkQeEeqcSGEsMWh/R+FMq5cvO36/Ldo6jVOzv/fVgnc Sdafkn865xFLZb0djAHW0tfeP27j1TMECiF/TOiAs7OR5OHWrr+dOo+qDqGOuam0NmxaxUutoTc Z0jaodGd3TLWf13RZccRx52QwU/6HF9mxpUbcH0AzveSL2q4uqkTLBGQbnbrrSjIoUa3AxldXye j9Q1rkvTsfJTgthclNV9Foicy+wz7gxu1rbga+ojfTvursVYjWtHV/s10O5fq+NMOzxfdXbijpj n7WjLMxVoPtxUt63l09GoMoJyrFoaLfjhp+lffOwseolbfMVqqAYskU3mqYTvqRVqyUhU/XkuSe 4e8l53/hl8XZESht0f+KVdZm36tB4bcYxQEmrfWCkCYqct+MjcMj0QtVMWIiEsik4aoUY4Gur6R ls= X-Received: by 2002:a4a:edce:0:b0:680:3739:650 with SMTP id 006d021491bc7-68a63c89b82mr570950eaf.60.1775678539047; Wed, 08 Apr 2026 13:02:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:18 -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 02/36] vmlinux.lds.h: move BOUNDED_SECTION_* macros to reuse later Date: Wed, 8 Apr 2026 14:01:37 -0600 Message-ID: <20260408200211.43821-3-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: quoted-printable Content-Type: text/plain; charset="utf-8" Move BOUNDED_SECTION_* macros to a new helper file: include/asm-generic/bounded_sections.lds.h and include it back into vmlinux.lds.h This allows its reuse later to fix a future problem with modules failing to keep dyndbg sections in some circumstances. Signed-off-by: Jim Cromie --- include/asm-generic/bounded_sections.lds.h | 36 ++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 32 +------------------ 2 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 include/asm-generic/bounded_sections.lds.h diff --git a/include/asm-generic/bounded_sections.lds.h b/include/asm-gener= ic/bounded_sections.lds.h new file mode 100644 index 000000000000..280a893bbe29 --- /dev/null +++ b/include/asm-generic/bounded_sections.lds.h @@ -0,0 +1,36 @@ +#ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H +#define _ASM_GENERIC_BOUNDED_SECTIONS_H + +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + . =3D ALIGN(8); \ + _BEGIN_##_label_ =3D .; \ + KEEP(*(_sec_)) \ + _END_##_label_ =3D .; + +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + . =3D ALIGN(8); \ + _label_##_BEGIN_ =3D .; \ + KEEP(*(_sec_)) \ + _label_##_END_ =3D .; + +#define BOUNDED_SECTION_BY(_sec_, _label_) \ + BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) + +#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) + +#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ + _HDR_##_label_ =3D .; \ + KEEP(*(.gnu.linkonce.##_sec_)) \ + BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) + +#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_)= \ + _label_##_HDR_ =3D .; \ + KEEP(*(.gnu.linkonce.##_sec_)) \ + BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) + +#define HEADERED_SECTION_BY(_sec_, _label_) \ + HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) + +#define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) + +#endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 58daa551420b..462f124ad457 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -211,37 +211,7 @@ # endif #endif =20 -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ - . =3D ALIGN(8); \ - _BEGIN_##_label_ =3D .; \ - KEEP(*(_sec_)) \ - _END_##_label_ =3D .; - -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ - . =3D ALIGN(8); \ - _label_##_BEGIN_ =3D .; \ - KEEP(*(_sec_)) \ - _label_##_END_ =3D .; - -#define BOUNDED_SECTION_BY(_sec_, _label_) \ - BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) - -#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) - -#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ - _HDR_##_label_ =3D .; \ - KEEP(*(.gnu.linkonce.##_sec_)) \ - BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) - -#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_)= \ - _label_##_HDR_ =3D .; \ - KEEP(*(.gnu.linkonce.##_sec_)) \ - BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) - -#define HEADERED_SECTION_BY(_sec_, _label_) \ - HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) - -#define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) +#include =20 #ifdef CONFIG_TRACE_BRANCH_PROFILING #define LIKELY_PROFILE() \ --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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 6F9EC322522 for ; Wed, 8 Apr 2026 20:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678542; cv=none; b=kG9XeiiTSVzoKeQAQ3zY70DAuuUrt3gE1rc/iBpWkwddDkqGsea9YLT2LT3m6NsDBYhRUZ4MKy8001c6Ui8hUDxfJP4LbGifVptHeKPymA1rgFW3VXAfeJ8CcxjHKSPiLWx2Qp+1GAxFBOWNIQczR7DTnz8kr9IRKGFpWaKGySc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678542; c=relaxed/simple; bh=BBEPtf+MkETNuagrJrkwWSnSZr8x+EAveVod63of4Us=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S/XVzxZ/2NfbzonlewDPFylnAUdCIebaLHwGPZ3tVP4Jl8/bxBWBSvSdnQGJlEqtBiRXHXC38/bvS8Re7zFUhKmG4t/O+fl1+KzWeXZznR9BQT0V+SIviPYPt9FQe/Djdy9+RQNc2tlCfKOP+yqLBofPjiOhkYKaDKiB8kBOZPE= 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=DhomcSMp; arc=none smtp.client-ip=209.85.161.52 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="DhomcSMp" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-68244d317e5so86755eaf.0 for ; Wed, 08 Apr 2026 13:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678540; x=1776283340; 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=OqKdylESk9B/a6b5Oi5X2s5Hl7NPYjGcR39u69Tcphw=; b=DhomcSMpkuqU8h0d/tq3veUO8QGWvWEYKtEZ338GBDBQmcbylCLcBU9hDbaa5Tksvf x1ER2d3zyf8/sAw+kjnP3USmgt7TV6r7O8EQwQJyJqmYhYmO2AGLW0yV6tG2FHGqQa8S HS6cnv4VzbAdLc8kZUxY/zyTcNGJUJWBna/nwkHkGEcv4VDGIgm8/Gz4N5+pq/dMba2D sn6mNeDqoP3lU6dzw/mlPg5HM6L47UK/Ky90kadvlO07BARes7F8ChAu135SQfpKG4pt uhAF8BL5Anz2l2C6E4GZinpbjsueaO2kOBK2Zd/+etXxdlMOH/Yk793QKlWVuBWToj4Z m1Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678540; x=1776283340; 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=OqKdylESk9B/a6b5Oi5X2s5Hl7NPYjGcR39u69Tcphw=; b=r9cRCjhb9J+NX/p9S5sLwCSaLypHtTc3a6X0li1FfQqERceoyc598V7XLimWUfZkyr Fyw1QNBSDQCjna8wPiicwI+isSmLPpF5f1NAOavFvz9y00OC3chbonuysqjbpLt8+GlU BJy5wQQvQ1nD7rahlgfwWaq1Sh9rIF34J1WbpbVctBm/1jPrN0SM3rMn52nw7/5dmCCy AdM2kGEpWz5Vyq3cQY83kekJuxqSlMnxZBTMkFU+q+bs9qbnDmf0YdQ1J6ZHNLHonvEv CS8dOO5vU4UZ1D2A56VJ/Q7xyMCmTzA4PzFRTzemEzQmVAQwh2/wr70u0itk7PY3VnZb jgGw== X-Gm-Message-State: AOJu0Yx26goZoaN9OOX8mTY8GzBKfa1Gay/dTl2a4gOxChiwNlyfjwIh QM51S99qzwp465BrMi7mJkIQt0owhZ9h9WmRpiG4a9sn9XZjXrJc3DD13e22yA== X-Gm-Gg: AeBDieu2oBlbA1pKze1a1O54AtGTbhKdgHvoRgkz6g1ot/PHQ5eQucflgq3FITckX8X 4uhVa7ktN/daB/JzP7FC2qrsFoyxTysGejY+fpMii+9q6qn5VDHkofXU36srhr8W8DiAVwUKaA1 rWoYNkWQaoSZysPXzPjN42b2FwcKVOZip1cAZOKYAtxZalrT5wd8YLvAeFcWzaMbTRCAMGxpMBI DnVGpsUkmoFBhb7M70z42maFBXqvR/6CG5DkzYaN6UzoLbmv6fw1sZ2EPDfwKp21QlgyrnG8opr wD5MISbmjtMQpwuhZ5AxPcWPGsIaMDFiVIQaO1qa9ZXNeg+6mOQDocFdZrF0kmkHsOpt7iVI768 m+/troZq3o4xt5kMqwchU9mu1mH0DEL2MUOHiWiHEAiGZ+eIf8Kax8n6AoNJ2Fkj7sHdcvWyXCi 73FHrqzgEQDwHY1xlvT7yFmfa1NAqoAF+WSw6+Hg1I1EdsbKyxhO2OnN4Dcst4h85wi+ryRu5Fy QA= X-Received: by 2002:a05:6820:4c07:b0:67c:c44:1e8f with SMTP id 006d021491bc7-6821db69541mr12588668eaf.17.1775678540015; Wed, 08 Apr 2026 13:02:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:19 -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 03/36] dyndbg.lds.S: fix lost dyndbg sections in modules Date: Wed, 8 Apr 2026 14:01:38 -0600 Message-ID: <20260408200211.43821-4-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: quoted-printable Content-Type: text/plain; charset="utf-8" In an (unused) experimental variation of this series, I had trouble with __dyndbg* sections getting lost in drm drivers. While it didn't happen in this series, it exposed a non-obvious weakness. So fix it, by following the model demonstrated in codetag.lds.h. Introduce include/asm-generic/dyndbg.lds.h, with 2 macros: DYNDBG_SECTIONS moves the 2 BOUNDED_SECTION_BY calls from DATA_DATA in vmlinux.lds.h, which now includes the file and calls the new macro. MOD_DYNDBG_SECTIONS also has the 2 BOUNDED_SECTION_BY calls, but wraps them with output section syntax to keep them as known and separate ELF sections in the module.ko. dyndbg.lds.h includes (reuses) bounded-section.lds.h scripts/module.lds.S: now calls MOD_DYNDBG_SECTIONS right before the CODETAG macro (consistent with their placements in vmlinux.lds.h), and also includes dyndbg.lds.h This isolates vmlinux.lds.h from further __dyndbg section additions. Signed-off-by: Jim Cromie --- include/asm-generic/dyndbg.lds.h | 19 +++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 6 ++---- scripts/module.lds.S | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 include/asm-generic/dyndbg.lds.h diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.= lds.h new file mode 100644 index 000000000000..f95683aa16b6 --- /dev/null +++ b/include/asm-generic/dyndbg.lds.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DYNDBG_LDS_H +#define __ASM_GENERIC_DYNDBG_LDS_H + +#include +#define DYNDBG_SECTIONS() \ + . =3D ALIGN(8); \ + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) + +#define MOD_DYNDBG_SECTIONS() \ + __dyndbg : { \ + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + } \ + __dyndbg_classes : { \ + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ + } + +#endif /* __ASM_GENERIC_DYNDBG_LDS_H */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 462f124ad457..b59f343818b0 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -340,6 +340,7 @@ /* * .data section */ +#include #define DATA_DATA \ *(.xiptext) \ *(DATA_MAIN) \ @@ -353,10 +354,7 @@ *(.data..do_once) \ STRUCT_ALIGN(); \ *(__tracepoints) \ - /* implement dynamic printk debug */ \ - . =3D ALIGN(8); \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + DYNDBG_SECTIONS() \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 054ef99e8288..8a7b0741bf8d 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -10,6 +10,7 @@ #endif =20 #include +#include =20 SECTIONS { /DISCARD/ : { @@ -60,6 +61,7 @@ SECTIONS { *(.rodata..L*) } =20 + MOD_DYNDBG_SECTIONS() MOD_SEPARATE_CODETAG_SECTIONS() } =20 --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 5E90C3630AE for ; Wed, 8 Apr 2026 20:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678543; cv=none; b=pJyXMEB0//JzANZbrxItcwNFw2tOenylPF3/qujnljMe+iGV7PFFmwwkS2pT5E0AFWAxdB0ZdoD1a22WYBShf2jZjpKzGdz45JHRIQ8yvF4lcnq1w6q4LvI8TsmZx5wp99dA0iDzZ8Z5xLnounFWyIcZuup0UBClRzwAfr7SHwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678543; c=relaxed/simple; bh=Rpykejp+/jHMXqcimX2Kxzi0M6+Sc3B0AXTd2qBRqns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d0V4HU9AUC+DsywqOk8o4me0P7Laa0yZPuxICEDJw93CZJJS68G9KIo5pyjhF+Pn+iSC4Y7LquQNitIfPzIDR2kvj2MHnpRGyTjzKBmdetVr+LFPIWxSDAMtOD/PjpfqqAbTjmLYwiJjqA9EzBp2RJPZdIIgdyIEZDNH2zKjzL8= 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=sjuzUYZy; arc=none smtp.client-ip=209.85.161.51 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="sjuzUYZy" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-688a8e5fc2eso102121eaf.0 for ; Wed, 08 Apr 2026 13:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678541; x=1776283341; 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=TvJTZGwFnKZj+neDJ4vh0DEg0/Ks/7VePFt3kMjVxDw=; b=sjuzUYZyA6OASE8qo1oosU9BSLSnAfEI46AIanTsb3rmu1N8WalNzHWMXFjv5SYQPH XG/LusySwm6CWZwCdkUGacsFlblWeWjijBz/VY0ZZ8U4WibD/ycNZR6C1NncB9xleIwP RRV9ZdNDPL2LRQo1lprcyeSGGvrAGyQxi/IxMHz0I8cOFbHi5ntvRYwwegKKWfs6l3O7 edZoOkL6/6I75eCP24Hoz8sO6zMN+3BQpUu22gIfhIYgsc4NbDyYUTJnkXgWY0iYufm+ QR00tgJLlewtbjKoNE087QRvtZgNaxnSBvkPc5XeOr9SsabXmYzjbLJgFMmfh3McZymG HSaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678541; x=1776283341; 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=TvJTZGwFnKZj+neDJ4vh0DEg0/Ks/7VePFt3kMjVxDw=; b=s9wl+8xyC5rLhunm7R+IrFzegeRR8WAu68AI/5BdDrz1091/zEvrPV/v+wB9PUNWjJ 2j4zTjkqTp/L3nGq982xcuL5Nu6nJ9APd7WIY0BpiOuyLtJ/8V+pycx1PwMi5DAYqdVF 9sIckhn2U4UacMtgdpCS6InOMepoJbdkF5JAjGEgKnANYU+EAeTnBfU/QgH4BPoARHo3 uUPFeegMOCXBCkQgczso6c5WAndDScRfLo9d5DF1XZc96yJo5IvgUqyr8ZOHIvdmIepZ E1h5gDYt+Vmv/8BL4eH/yMcvokOv1+OipOAV6t5p+BHve+CTI9Kdcfuq6J67YyfjN+7W KPwA== X-Gm-Message-State: AOJu0YzimSy0auH4vQvG8KENurLYfRtVLNMHXQVOXfAVmuc6LxzS5Xs8 6ahLGvXENnm9zn06q8MyyZhgmLOU6EVOHqiU+S31LwTz1KqFbFrbFQ3/G1yO/g== X-Gm-Gg: AeBDiesmSGRonXuLBY3xacJcF1tDnVvUoMp+wn0OvdemnHU+PL1ymq5J1CVnE9stTT6 ST3VZjYoccVxYbc+JwjUE0gJSL9M4vAsSwFdHM2HoLGkAKK75DbTume/OOj8e1mAlVCoaGNfZQT FY6I7BzqvrRAMKfZNHnC2usWMjm9ZcV0sTm7gW17CBXsHd9ARka4GBWB6peek7NQNIgyGt6Yhbr 6F35mPP/qtAXhGyHH2t1UjDuDlGeQJnnZBldqliNk9toHeLVpyWXVnmalKcn+qoXvMi7vVTBWQN 5Y7/mjPfxIrLwMxkDC3ab4dtr2+2qG8LeLEzDbgvbgaQaiAy9/YVEu1e+wMBdZAykfpFLBv5cy6 rPyC2gHcJMqLZTb4dpsHVSOJ36E+rosR2nZzgnlPHmr5Ae0dvA2ZDvOfaFu4KNGWhuu8yYxxOD9 472S3eUztyILyTTvSSZJCltCog5ogSbW99jNuiC6Y99cvY8pKnoA/7bhGw1BtAH2Uzndy9+rhvt 78= X-Received: by 2002:a05:6820:f08:b0:684:dd1d:5b8f with SMTP id 006d021491bc7-684dd1d6029mr8584556eaf.0.1775678541058; Wed, 08 Apr 2026 13:02:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:20 -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 04/36] vmlinux.lds.h: drop unused HEADERED_SECTION* macros Date: Wed, 8 Apr 2026 14:01:39 -0600 Message-ID: <20260408200211.43821-5-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: quoted-printable Content-Type: text/plain; charset="utf-8" These macros are unused, no point in carrying them any more. NB: these macros were just moved to bounded_sections.lds.h, from vmlinux.lds.h, which is the known entity, and therefore more meaningful in the 1-line summary, so thats what I used as the topic. Signed-off-by: Jim Cromie --- include/asm-generic/bounded_sections.lds.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/include/asm-generic/bounded_sections.lds.h b/include/asm-gener= ic/bounded_sections.lds.h index 280a893bbe29..416b2e6f6788 100644 --- a/include/asm-generic/bounded_sections.lds.h +++ b/include/asm-generic/bounded_sections.lds.h @@ -18,19 +18,4 @@ =20 #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) =20 -#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ - _HDR_##_label_ =3D .; \ - KEEP(*(.gnu.linkonce.##_sec_)) \ - BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) - -#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_)= \ - _label_##_HDR_ =3D .; \ - KEEP(*(.gnu.linkonce.##_sec_)) \ - BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) - -#define HEADERED_SECTION_BY(_sec_, _label_) \ - HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) - -#define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) - #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */ --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (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 4CEF73815DC for ; Wed, 8 Apr 2026 20:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678544; cv=none; b=M1WwjRSEWCCLyFIWj+LY0nm25WYEFTUNgsr32yEx5v4gYlP1p3/FC+sHLMiatfQ73qMCvvi/iLJTc7OKMwH8Bb7tQYXtqKX7CsJdH6NvzLqrxsTaR3xsf4JC8RYAbyqJfk5bFHHwNLzCmqY7p8RJedGUt10rS9AfNS77a2/AFo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678544; c=relaxed/simple; bh=aSp2tGGV4u70JIzjXLhhj/itWzrqvlxUbbmMGC8eIxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=odWd/wqcsUdy9vwMFtj1gH7DDTGHy2BKzYUdUJN/88DyhJwbG8GWE3OjVXsyaBkL4ROlrRljg2wzLtqV47CVUKGolT3DLDjAVzy3XwkjgjY/Z9o3z5b4m11NWAFfs0Y2gscoCgUUAcdrEK06P0/TQ3JNiVCeQydZ7rC7ZFcsyrs= 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=K7CA14QC; arc=none smtp.client-ip=209.85.161.53 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="K7CA14QC" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-67fdb2afaf5so81669eaf.1 for ; Wed, 08 Apr 2026 13:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678542; x=1776283342; 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=aHUGvvDPJX5utgpnBEa/SBdGHOtXvC1eEVKqa9t2R0g=; b=K7CA14QCuDnkbJ8r8/ysaZa5I64QPzr/umEczsQcGBWXPEyA/F1K9XN0B9RWu0Lz6U RQwQX26/V4W7gj0gBGrhhAt8sk4VbqpY57C8ovua3dZzMT0aM5Ib9lHhDFiDqTTb4GT9 Q/DEW0D8JkJqonUMNM2aFkEfGvf23wPRL+xz+DEZUgjl7/iExE+Tiax+Uqj8l0JeT6NS rIyr03G39MgCcYS/A8hkgnyB39a8PR7ca4nViXzpsNePbuxk0+8ZRc6qSrV6VGDsoaTi 3vBqk0WJMLBiXD7SeSwFSHvtoNXA7H98mns8EPhQXi7IHiNHKFp6uIGTu9s2GvFmuMqD SExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678542; x=1776283342; 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=aHUGvvDPJX5utgpnBEa/SBdGHOtXvC1eEVKqa9t2R0g=; b=DrUwZ44GxPixJbXfd2a13Yc571lw7LZN931is33rLgXZgzIFFH7VZvUx58SDN/nUU3 J+IH5Os8d6N3WL1FZAeAr3G4WfdGrRTz6bvDgkKUmVOtsYceIaGsZUStUeii2/xx5ES2 UHA1CC4DCm5TJrbSjSO0ExK9q+XYRg85AY1/SlcCdJ6AwRpn0Htyf5B4RIe3g1VqlkY+ ZeuTrgJop1+cOA0/fFaCcbXLzLtI9hhaMcsL9M222M9C1QALh1yc1x0PV7SGgoEgOcD2 xE8nKxrnpvxMmGjChDcll7xUM/3KgFFDTVzu48FqaXeR/eIQj2N3S6x0CG97NdxMuN/S R9/A== X-Gm-Message-State: AOJu0YyBACZCnIAWaZzGog20YL4IBVJ4J6Zfv7TETdj88JlQA/bt4ejT 0xCXjif6SeM4PtlSwQlFkL6sBtOkqFfIpZTLjuKF0nsGLVYs0ePGVpvq8QE9Ww== X-Gm-Gg: AeBDieucpHwxgRI+BDUMOGlcuYKYhjSCZeaaD2x2aUAg2D8g0hU6lmIFM8YXQfgW82p GekIvANbFb4JBDw/hRhqQfQWRVQ3YJbVHE74BZwwgcU3OT3SByaI+hGNmYgB9wz/q9FwtIUWAe2 HspECx34SO0FIF6VKAlh2VcBe9ss39LXbavLVhwHWvy9xyvckNMbkcIUAGyjXDf/U6b3g15odqj WFWuEwURSIZe1a5BkByZt9IR0w61BhE98kocVkvHPdkt/U1IQaX69ugwtHNAhKW5hZUNJGV137N n019SVUJgDYwdItf3HqBKaeaHG4T9qWl6A/w9GquEL7BB/rijKL8s9D1yTZYElKaQFxn9/selj6 MGlnmnPZPqEXyV3ytQhLppuvswLe72dLEw2SfUrTj+KvHmY8ugvMv19Usm99PVTx2IWlB5bcNcX KUkIYbvxAu+LoacpCdCaqOV7u8qespLzRm75p9UEteXiHaa3rXo68u5Z2hUlD+gmGi14ikJOYFj OQ= X-Received: by 2002:a05:6820:906:b0:688:93a0:85e3 with SMTP id 006d021491bc7-68893a08f67mr3629216eaf.60.1775678542034; Wed, 08 Apr 2026 13:02:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:21 -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 05/36] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Wed, 8 Apr 2026 14:01:40 -0600 Message-ID: <20260408200211.43821-6-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: quoted-printable Content-Type: text/plain; charset="utf-8" ddebug_change() is a big (~100 lines) function with a nested for loop. The outer loop walks the per-module ddebug_tables list, and does module stuff: it filters on a query's "module FOO*" and "class BAR", failures here skip the entire inner loop. The inner loop (60 lines) scans a module's descriptors. It starts with a long block of filters on function, line, format, and the validated "BAR" class (or the legacy/_DPRINTK_CLASS_DFLT). These filters "continue" past pr_debugs that don't match the query criteria, before it falls through the code below that counts matches, then adjusts the flags and static-keys. This is unnecessarily hard to think about. So move the per-descriptor filter-block into a boolean function: ddebug_match_desc(desc), and change each "continue" to "return false". This puts a clear interface in place, so any future changes are either inside, outside, or across this interface. also fix checkpatch complaints about spaces and braces. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 83 +++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 18a71a9108d3..6b1e983cfedc 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -172,6 +172,52 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons * callsites, normally the same as number of changes. If verbose, * logs the changes. Takes ddebug_lock. */ +static bool ddebug_match_desc(const struct ddebug_query *query, + struct _ddebug *dp, + int valid_class) +{ + /* match site against query-class */ + if (dp->class_id !=3D valid_class) + return false; + + /* match against the source filename */ + if (query->filename && + !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, + kbasename(dp->filename)) && + !match_wildcard(query->filename, + trim_prefix(dp->filename))) + return false; + + /* match against the function */ + if (query->function && + !match_wildcard(query->function, dp->function)) + return false; + + /* match against the format */ + if (query->format) { + if (*query->format =3D=3D '^') { + char *p; + /* anchored search. match must be at beginning */ + p =3D strstr(dp->format, query->format + 1); + if (p !=3D dp->format) + return false; + } else if (!strstr(dp->format, query->format)) { + return false; + } + } + + /* match against the line number range */ + if (query->first_lineno && + dp->lineno < query->first_lineno) + return false; + if (query->last_lineno && + dp->lineno > query->last_lineno) + return false; + + return true; +} + static int ddebug_change(const struct ddebug_query *query, struct flag_settings *modifiers) { @@ -204,42 +250,7 @@ static int ddebug_change(const struct ddebug_query *qu= ery, for (i =3D 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp =3D &dt->ddebugs[i]; =20 - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - continue; - - /* match against the source filename */ - if (query->filename && - !match_wildcard(query->filename, dp->filename) && - !match_wildcard(query->filename, - kbasename(dp->filename)) && - !match_wildcard(query->filename, - trim_prefix(dp->filename))) - continue; - - /* match against the function */ - if (query->function && - !match_wildcard(query->function, dp->function)) - continue; - - /* match against the format */ - if (query->format) { - if (*query->format =3D=3D '^') { - char *p; - /* anchored search. match must be at beginning */ - p =3D strstr(dp->format, query->format+1); - if (p !=3D dp->format) - continue; - } else if (!strstr(dp->format, query->format)) - continue; - } - - /* match against the line number range */ - if (query->first_lineno && - dp->lineno < query->first_lineno) - continue; - if (query->last_lineno && - dp->lineno > query->last_lineno) + if (!ddebug_match_desc(query, dp, valid_class)) continue; =20 nfound++; --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 7002E37AA96 for ; Wed, 8 Apr 2026 20:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678545; cv=none; b=cGUCW7vZ9JK8hqARpR/6NMctG7DpyCnUGm5vJObB5U4LZ+5HMiQCGdhIM5JSlNWjnX6Jujx3ZWnLiyGOisBddUYuMSm76oyQpj80NBElfZ1JP6HLkxcGBgBSN+7k2hbA7m5KmEoggKSn8twD3tX+JNPAnocCZE0YyPrCh7wEw/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678545; c=relaxed/simple; bh=+qoPaqFMZANZ5GO9HKrP/DwHGbD+bYFDH9gWrXYcZT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DsnE8TSSTiQ1xEeJjNNpndHbtmOw6e0LfclTCsXL9HgPC6HJ95DmYHNirrowhyx3cQbjLt/R8wcS9AbE4imirgEmPVaDQwKD1mqvqdRKxsmEXi3UjpsTn/qazRIJQhs+f82n7uQFGPBGk21fjPyx29OJVjgrv7b3gqeCgGuxvQo= 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=muxB8RFj; arc=none smtp.client-ip=209.85.161.51 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="muxB8RFj" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-68470763896so83321eaf.1 for ; Wed, 08 Apr 2026 13:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678543; x=1776283343; 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=AAl9+PvQAj0gWNHtBaTmlj5ZgTYMrxMbOjBXxAyMQwA=; b=muxB8RFjfKYt2iNSbS8ouAt0ZCBcl0ncjUR71WK9ndNtZpcUrT6ckQN4cD2G4sGvDT 0x23gEzJ7YZ0aiPk9ncBa8Wn+2fRk4coIL2GbYHTyFnFJlSEm5tgmS6K8wgVCf4wExCQ qvymbZixYf+dF5/2WiI88kp/HF77t4wZ9EoDTHZPNJDY6cYeIRgB6H+gdltCzSnT7hO9 5dqGo77cay7IPmSRMXR8eiRyqmWChSQbGXmrn5D2zFnvSJe5a0c8Pv3pZTOYpUI4Ap7u soz+tNdFeh6tAN0O1Hg9uIkjT/Bd1P4KqAYf0eMA43AKLUU9v1BVYl6DaX2npc8d1CXf pnPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678543; x=1776283343; 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=AAl9+PvQAj0gWNHtBaTmlj5ZgTYMrxMbOjBXxAyMQwA=; b=QtjcVZZkPPuXecC0CZCnKbJGvhxp0mtGkJXqNWjJM7srbMVC7wwmkldT+SiP6RhBpq h78YZJ4D9hWw1+0xiVMOZh47zz6UsXPmKMRBay/tinl0GY0zf6ztYG9siqsDAVXmnPCV 0op1Pn7u+RVpubYfQqlSZ0GND2Isdt8KCqc1N9cDK+eLFj9qDyPcTerPWw+HZTynycCb qHpPyI5hXB/YhMfvhW0pQoda1fkytlBuQ3Kb01ClWNycLw8ue9WJANL874wjPPTFnw+3 DY4o5v9KSWt8RcH/ogwzdtE/J1w1ldLvjLJTgaplmQEGKrfVbDn5OFjreCB2xemuZZtP hERQ== X-Gm-Message-State: AOJu0Yw523RMhkK9oBp9uFkvInDUo9snqO1GieA+uBn1dxdLCYROxU66 QZohk1fsew2dTTQscV8um4gJxkPV85kBIGOqlMUpbn+n1v5zAhI9jtfegRl2iA== X-Gm-Gg: AeBDiesgSbyBr17ErqqWlzAY5Vkrocp+joYgeronzuZF7+hVoMAcN54QPS+b6Wd2x77 UUFF/TgInPbTimtPmYLcRdQ5gCvX1DSVmnjviz69fNmnVu0YJ9PfX8U87FAL9Svuc5USz6l2tnC Jdw1BMYXIUtlzSzXa4V1w4AGSW4UOkOVyS6dgKvzoBH+GV+KkJAJZz4koTSNi3Tv1CR9PCNjhqq tlYX+YV1heY0T+GdtLY5teiOiACgeMlmJ3JR3RHtw1yDEbuqM+3hUfXxptRVOF42gs4PTIt1OyE gHFisNoUHVy64sRM5KFxlXqnxGAW+90oAHwpjLMUQfD3LcNlxQNNueE7KXKv1YvZa/fpUF2gaCb Q+AUBKXJRc7RDOQ160Yyf9c0bv4sKqpg0wMrnzWqP7I9AGht7y+NogfzNu4mMgFEqfTnAICrOlN Rt9W9muXVp9VlAHX2sUGY/10Tmgf8KLUwmZ+XQGW4PK88OsUKuJpxu0QpGMFq3aQ69L9ZEsCJq/ 7E= X-Received: by 2002:a05:6820:16aa:b0:67e:1380:a046 with SMTP id 006d021491bc7-6821e261943mr12218146eaf.30.1775678542993; Wed, 08 Apr 2026 13:02:22 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:22 -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 06/36] dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP Date: Wed, 8 Apr 2026 14:01:41 -0600 Message-ID: <20260408200211.43821-7-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: quoted-printable Content-Type: text/plain; charset="utf-8" Add the stub macro for !DYNAMIC_DEBUG builds, after moving the original macro-defn down under the big ifdef. Do it now so future changes have a cleaner starting point. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 05743900a116..a10adac8e8f0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -93,27 +93,6 @@ struct ddebug_class_map { enum class_map_type map_type; }; =20 -/** - * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module - * @_var: a struct ddebug_class_map, passed to module_param_cb - * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic - * @_base: offset of 1st class-name. splits .class_id space - * @classes: class-names used to control class'd prdbgs - */ -#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ - static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ - static struct ddebug_class_map __aligned(8) __used \ - __section("__dyndbg_classes") _var =3D { \ - .mod =3D THIS_MODULE, \ - .mod_name =3D KBUILD_MODNAME, \ - .base =3D _base, \ - .map_type =3D _maptype, \ - .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ - .class_names =3D _var##_classnames, \ - } -#define NUM_TYPE_ARGS(eltype, ...) \ - (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) - /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; @@ -138,6 +117,27 @@ struct ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) =20 +/** + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module + * @_var: a struct ddebug_class_map, passed to module_param_cb + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names used to control class'd prdbgs + */ +#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + static struct ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_classes") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D _base, \ + .map_type =3D _maptype, \ + .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .class_names =3D _var##_classnames, \ + } +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype)) + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -314,6 +314,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false +#define DECLARE_DYNDBG_CLASSMAP(...) =20 #define dynamic_pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 456893859C5 for ; Wed, 8 Apr 2026 20:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678546; cv=none; b=jhyX4rIfXBfe4lYJxlXNJI2JTpccV6YWBrpZkpQcgGnd54/uiGLGRuFynBSZgs1kNBu2k/t45QHQ6Oh/hVYpIgsRVmr/62+ESpOSOWAmJV68FxPV6Fa/TOyiLpWi0N/uXTMfDM91rNIZCyKvGqN7eLsq2kxYQnRBnx+ysDU5fH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678546; c=relaxed/simple; bh=cyuCHdINxAxB3Q6Ll+XuNXFb67j/pcTpl5AcamKnQbE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVKFMsjWp12d2/mdM0N3wC8HkcYiTLuF2662u3yQZ81JTYOSiIphk+XnNxcXnCuvCfsOFEVMToO0zqEAK6OgppPbpRxwVMCpq9czcdlG5hnCQGHtt4NkduA2iXH9nILMyL488ZtGvFPMuerRcXzCrlMVGGCFZcJR18OfUjY6Rr0= 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=fa571+Lv; arc=none smtp.client-ip=209.85.161.42 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="fa571+Lv" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-6841e6a5e51so81750eaf.3 for ; Wed, 08 Apr 2026 13:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678544; x=1776283344; 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=vld9IFfyvePqt5M1J9/OwioGOqjnLV2rFk+KzTunpXM=; b=fa571+LvcUj48anuJiKjxTwXFtEI/ExP+D/HyExZCEiuoL76L4vpwDN8BfegIc0Fcx nuVcwycLVzDF8ItRBdZPEvOosFbtvkoOO8dlE29xyoZASZVZ8ACcH4d7w3XIRWUu5mLy 45qzD535O36HJljfb8cZuv5PdEC5vZhMh8bzidKFRkSxfs/VVW9ssET0ZSsEXZZj+lH4 cIOJ7pDgeCwmOSV0wEiD53Y7d0Bq+sh6QnwNxe0oNJ06C3zdqqp9QDOxCNUjxI77XVGP Dm4oxh7AgpJlJAb2lw7mkmEy73zpgfnHozLdpCkfyMii18gWzEUmol2/bLLxDfFKWx+k 6TyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678544; x=1776283344; 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=vld9IFfyvePqt5M1J9/OwioGOqjnLV2rFk+KzTunpXM=; b=Twq9mmLRpBiUnHzQ9vC//f7pX+gUhAeUak3kEanvPQVc8F/3h5DuGizV065DTkC75/ hiecbw96kHCx2CPpdKcs4Cd//i8YHRHSYMLhwzob3+C3Evi6lBJhjHOtppVgW42gctcs 4uSk4yiwpHz5WET/wiK8AKQbwcNRJwFc9b1q3ayF0xYJxcdLMPYrOrpCNIoGH9/lwh4s dv6gYy0deMzx0K9tJVvfL8y5v3vfCZKVUO4vYxhLlYFOG9gTlBHa/5qCgfyqtjRQ4AG6 QtnjrMVdGJsLKQsYDOo0k8/Imte5akVj7IqEjb4doHYgCM2blka9MtEhHScPL3LR58fh MKTQ== X-Gm-Message-State: AOJu0YxuyXGAZKN7AbHYqk+WXMG1EL4e21Vbph3DNNJv8ChXUoFkfWwt dKFD3djHm3iM858rcsb5ajebJTBZCn8YAoDUBzUxwghOAAHMsWtjD9jVjSQByw== X-Gm-Gg: AeBDieswhnj+AK9wJeLTl1VaWg2EkAD8lunreGUASRJzUBxyXPfkVMjoOKnEjPbxKA0 BhbZpbm6stkSvJzjZZXXny1/LMWNPGAhH0pro358Lev2yMIbRjb7a9oLg4KAG6dwp/ZwTetB950 hwrj+WFtbklaSU1ap6c33FZUQVC7spZ1sZVD5oGByZvS5tiZ5ohgjsvWHqD4IVS9v8xc7PgEAga zqn+OgW//U5KtFFyFK0EOTQ2p6OMNMEv+EXE28rPbTofMUefS0rmWA8q2OUfj45nI1OJBRQWSGS cQOGlNCnv75qyGe4WFlw0ohuHCxAkrH1/BIb/ucpH1mPay8B+O6S73nCxh9QbaXIwozE9TjOQ4e a7xZIgpqFyE22qdssTaLz7t2uslHUgu4QM9BGsRR84JF711KWhL38kFDEb4H+XyV+hg4xSPDlrf TauGOI79Dk1RmPBgPrgDWHT6T7ui35t3qluFcD+TSM+DhvhIpiFslOtShQAHLeyCvSgDbEnsOy8 R8JIwMQkx/X9Q== X-Received: by 2002:a05:6820:3302:b0:684:92a9:a2e2 with SMTP id 006d021491bc7-68a62af3988mr358469eaf.39.1775678543937; Wed, 08 Apr 2026 13:02:23 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:23 -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 07/36] docs/dyndbg: update examples \012 to \n Date: Wed, 8 Apr 2026 14:01:42 -0600 Message-ID: <20260408200211.43821-8-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: quoted-printable Content-Type: text/plain; charset="utf-8" commit 47ea6f99d06e ("dyndbg: use ESCAPE_SPACE for cat control") changed the control-file to display format strings with "\n" rather than "\012". Update the docs to match the new reality. Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 095a63892257..4b14d9fd0300 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -38,12 +38,12 @@ You can view the currently configured behaviour in the = *prdbg* catalog:: =20 :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format - init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \012 - init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\012" - init/main.c:1424 [main]run_init_process =3D_ " with arguments:\012" - init/main.c:1426 [main]run_init_process =3D_ " %s\012" - init/main.c:1427 [main]run_init_process =3D_ " with environment:\012" - init/main.c:1429 [main]run_init_process =3D_ " %s\012" + init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \n" + init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\n" + init/main.c:1424 [main]run_init_process =3D_ " with arguments:\n" + init/main.c:1426 [main]run_init_process =3D_ " %s\n" + init/main.c:1427 [main]run_init_process =3D_ " with environment:\n" + init/main.c:1429 [main]run_init_process =3D_ " %s\n" =20 The 3rd space-delimited column shows the current flags, preceded by a ``=3D`` for easy use with grep/cut. ``=3Dp`` shows enabled callsites. @@ -59,10 +59,10 @@ query/commands to the control file. Example:: =20 :#> ddcmd '-p; module main func run* +p' :#> grep =3Dp /proc/dynamic_debug/control - init/main.c:1424 [main]run_init_process =3Dp " with arguments:\012" - init/main.c:1426 [main]run_init_process =3Dp " %s\012" - init/main.c:1427 [main]run_init_process =3Dp " with environment:\012" - init/main.c:1429 [main]run_init_process =3Dp " %s\012" + init/main.c:1424 [main]run_init_process =3Dp " with arguments:\n" + init/main.c:1426 [main]run_init_process =3Dp " %s\n" + init/main.c:1427 [main]run_init_process =3Dp " with environment:\n" + init/main.c:1429 [main]run_init_process =3Dp " %s\n" =20 Error messages go to console/syslog:: =20 --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 33D9C386565 for ; Wed, 8 Apr 2026 20:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678548; cv=none; b=QdW/sDzVFGt2hm1gIwAmiO8leKRDG8jti9p+vcLWT0Bf52c4U5IOJoT7Qn38bHr3eLgPIUjOc3qQR1M5FWM8utXrLa/1LdfoTUbHsB+C1kQIMBJRisV0i/h/f45FFdvZkKTrCX5uP99ay5ugnxNmZ9/z+Tzv+/tZ8kMNsIodM24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678548; c=relaxed/simple; bh=E1VF4T7M7c35q9Qypwa46ANAajyN9sx88/WRdouByGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RkBhSz0k+qiXJ6vOp4EiaUQgOpdxYpXsudKdo0h2R/Q7ZvfC2RbVEKW81mRAdFgU1NgjMe8MM3bfHRG/WbbY2fzE2smuHhI3wbxwm9KGMsJlV+5Qp9cj0okNFzBiWnexEmD5+2lsDrUxDcrdGfD59mswl27YcD/YzZW+P8eb85U= 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=lC5H+HsB; arc=none smtp.client-ip=209.85.161.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="lC5H+HsB" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-68470763896so83339eaf.1 for ; Wed, 08 Apr 2026 13:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678545; x=1776283345; 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=4wIIBK2xLHmy9ZZczWpP2RzFmOx4bELZz7aMw+RGO2w=; b=lC5H+HsB7LjjlA9mRpxkvYVRssBvFBiq40kbqZGSv59ZpCYnwzW5hwIEpSrnU3Ls6A bG0ejlRFSnYDu93tO0wdTnVzXsQ9dPdz6DvmrGhVes/x34zGxH7/YW2AZMS6bKxzNhOM i2OXCzziFoGscl8Dc0hQP5M330soJ2BvBEFxlAz0fs89ewJY6KkupjuYZxRoZy7WXYqr QNnmIRsi+TOp6pB2iGj0XiFuOqt93wz6BS7ud+b/2dD7SWEMMnILXJeqmRKaKFaztGJE 4B/OkQmBkh9EpS8uIdaUoGx7plkLBtiBEi8pniIGY3gg666NKmewLgXyZl45dCOlw7MI xq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678545; x=1776283345; 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=4wIIBK2xLHmy9ZZczWpP2RzFmOx4bELZz7aMw+RGO2w=; b=V41/g07BIByv3kTk/3IzSsZvX8O/mBr4aklsySC41iw1SEhliJGGJTUUEUnXt7M0gq 9oE16jbiqi6gwQiKtTwSsikP/UpdnsOrXvFVUqWF7dglw2hnNr0RPCpv2mT9a9McIFRW pYKZOKGLF3YMYbO6IlSqJuOE0+RbyLHG0aXfhZLDLoF6eWocwzDdsDuRQ1tPWb7poem1 sAQQ5Du8x9ywGL3Z2yT9kiqRdSKgOrL9MSkAgPQwXyhJVp7B3GrsOppH0tPK1t3Pk3cT V/XSV+pqWO8tgj4opCkj487w1Vo4e8HUq5OpzEaFMQzF8HHw0mQZBQcId1lKteN7CT3d k25g== X-Gm-Message-State: AOJu0YzYMLyPwBz8Rlllek8GZwu1CHxoVEVn+rQETs3vMe7LoWvWL4V3 /RR5wxil+qF19fsHcwW9wAiCedQMnmBdRApreHNU5PUgcD7nlwFpJpghZx4rvg== X-Gm-Gg: AeBDiesJoaffOXFxRXwxsCbK1CIAp0S6g6ZVEhk4rCCI1YgUYbyOSboiY1PCb7Fley/ arWTXS8V8JgXABXy8vvZcEFl1CQcnP8VCPzC7zV/7iFK5lwSSW4wI8/P9Lvk1HQuLfIZY/b2zC7 gJ1UVMzWRNocZw9KtKLvzj85630rtCBE9/0he0iwQ/g/V8MYiQ8knPJuLgLNhmUoRFTF3U2SUUV lzTUPDUW6K/IQ5jqawdMe1nS9WOHo0+J6Sxw47J4SWsuH+qvMutc41J8OdGR+gNhF7kM9b1I57I Wez9AmXxcQkfr+JUQhGou6iDrB641HqKJX7pGCiuHHB7pCWLG3Vx+zObd25jgozXkpQxxV+PcAS no48ZaJ3rsO4BbpSltrA3aXXtXT3sfFlftM+dn3mBeyWXtFqOBo7rzqUAF1HXfSOZ0BNHMg6m71 LX011CtdKHVt0qV9rL8FeYsvinHBqR+6v/z5HNQZN10uBuwG+ySMiCwh9yMvLA+Himc8V9VBT69 Do= X-Received: by 2002:a05:6820:2004:b0:682:644b:ba03 with SMTP id 006d021491bc7-682644bbbaamr12449783eaf.16.1775678544819; Wed, 08 Apr 2026 13:02:24 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:24 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v13 08/36] docs/dyndbg: explain flags parse 1st Date: Wed, 8 Apr 2026 14:01:43 -0600 Message-ID: <20260408200211.43821-9-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: quoted-printable Content-Type: text/plain; charset="utf-8" When writing queries to >control, flags are parsed 1st, since they are the only required field, and they require specific compositions. So if the flags draw an error (on those specifics), then keyword errors aren't reported. This can be mildly confusing/annoying, so explain it instead. cc: linux-doc@vger.kernel.org Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 4b14d9fd0300..9c2f096ed1d8 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -109,10 +109,19 @@ The match-spec's select *prdbgs* from the catalog, up= on which to apply the flags-spec, all constraints are ANDed together. An absent keyword is the same as keyword "*". =20 - -A match specification is a keyword, which selects the attribute of -the callsite to be compared, and a value to compare against. Possible -keywords are::: +Note that since the match-spec can be empty, the flags are checked 1st, +then the pairs of keyword and value. Flag errs will hide keyword errs:: + + bash-5.2# ddcmd mod bar +foo + dyndbg: read 13 bytes from userspace + dyndbg: query 0: "mod bar +foo" mod:* + dyndbg: unknown flag 'o' + dyndbg: flags parse failed + dyndbg: processed 1 queries, with 0 matches, 1 errs + +So a match-spec is a keyword, which selects the attribute of the +callsite to be compared, and a value to compare against. Possible +keywords are:: =20 match-spec ::=3D 'func' string | 'file' string | --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 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 29129386C3F for ; Wed, 8 Apr 2026 20:02:27 +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=1775678548; cv=none; b=WoHBI4PpiZGdKAbj/msAUOUnTdcqwJlXfVau21ol0Ix0sR8W5Uv/LZp29mmPJkOqT93QlPNPeC5KIM+r/VsBsV0Fu9k8VitD0MHUlnC77jVaGmd1sDA6JULuPOAJDZb7bpARnrx9HTfVAVuR/PDqhPMsxoApleI3A5a1dUEbXb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678548; c=relaxed/simple; bh=6qEnUlc0QW37ApD+4VV5gg8sRlLcSuU7c6UrMPZMZns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S/29YQA4LEVPAzlVe2hJr3qRuQh3yb3Gn1rE8sXxwBtP31SHau4cPy3/Q5pB32NqtRN+OZO1OHucXq7Ypwzu4e6CLH3UkjwZ+5WTKIRqvX7V3f0pnmU4U7vWDzivjWZc5QqpIlQS1b4zSe1RmE2YSFdSYFppJPVVGiomazym3N8= 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=N1N220ks; 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="N1N220ks" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-68a3b605bdcso96430eaf.2 for ; Wed, 08 Apr 2026 13:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678546; x=1776283346; 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=R/SjSwC+RMF8YRDI51sil3K6xHtCNjZlX0uljPPVd8o=; b=N1N220kslP6QEk+4QmMsqer9mTEM9dOO3aZQ++cj60HhY/oBjdyvHmZVOOyr7l37PC k19ITF0uj+WwxvOZCXmrMABg1cS6U+bP80Hc8onIBV3LEOc5O70fGlSF4D4yhgB+HXZ5 d3maCulqQDOgOVPNXLK9VgPKf85AN3mZqoxNFYKbhiqKnhQ5B7LhhjQsbO3Qo7uJpfUH AmhMZFbfXixgXq5Mh+sS7uSeX48qIHIsv16AOPzAhCeXs0NWd2Ua06oTxuSRfctVRLI2 XjnSPsCNOQrAAQK75jOBd8SFXlAZYgrbrfAA4wUuo2x/4cV7pd5S1QgmNYFlyVmLxvZX ezfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678546; x=1776283346; 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=R/SjSwC+RMF8YRDI51sil3K6xHtCNjZlX0uljPPVd8o=; b=N8sRXTUg2bgw1Ns6nt/pm3vEQlB9YE70W6WsHZRbRVL2/IBOF7/6xhfagQ3AFLuHkT pAmaXNhqRzuoGODQaibANxoxtFshTNDJlTXKqruVe/HwLR80swDMsvFr5CLpBkxR+9nZ Z8K5Wdb7tN7WyVF3tntOY5Ak3/IPeDOPPgIjOzol46g21X0bsgCAAGHw5OqNfBY6qKbh GIxC0FQLCV0FaDpO+gcOKXNo5aFj4V+/EBcgD6wxX9Hl7IutxkeMfo85Tlx9lgMfIdFu /6WQHTi6OCD8H0WLS8bJeXoJnbxvc5Fzgyi5JTKEJt2J/NsSkV3KRcJ0nw2u5ZAOq1nZ gk/w== X-Gm-Message-State: AOJu0YwNtr/H/pTmNaHNQyJb8MeYCkpmArhvaldQQMPKAh6cZm019Niy gK6Pemxj4f1vhPoGY+eyHiwDA/jiwooe1pNmU5Dmly6I7GHOjs5+1OX7UjN8RA== X-Gm-Gg: AeBDietqTaE/MgkZmVjEtWxjbL4bM4OH7+Hg1uTgkwDTqIksDGqT8lJRsH+NGuaGBNF p9q58rUPa42M7AqONHDvZXB02vqH4dbak2BHk+9bFQ/9qhDBcz+KvpH6J5zRtAMkBTzUl2xsIDZ mh6WHEhsTFapIayyCEqarAy+Jsv4FNs6vPvbKdeMzjq+I3/R0SA2m4+i3lpcCJMtR5fA1pw05tE NZwKISCifotQQCd0ExIZGBtEN2P//4RnZ1wuCWC+DkaFQxGFSGG2yn2W+s1rt0aHNzUqLTlbMqU WCn+E6H7WS1tMs2OUDTVXvGb6LsDDhWbGNB5rAr6j5YH/mjel7xN1GsFXXQ+4tY14fPUD4DY9Aw w4gz0Q6QLpPEcraTQcuuvF+/lq4Qw6OOXuYxVUV8Zj0dAs4S+W9GmlcAmb/MDlnknmyU06KwX1s bsCutU4Zk1HrD6PS9jQgQ0Px7i4rMGg2n6D4j8qhStK25YXcEYYjWnCMZmmTgkt3xw0ozxkYVU4 gI= X-Received: by 2002:a05:6820:180d:b0:67e:882:b04b with SMTP id 006d021491bc7-6821dd7801fmr12426154eaf.16.1775678545954; Wed, 08 Apr 2026 13:02:25 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:25 -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 09/36] test-dyndbg: fixup CLASSMAP usage error Date: Wed, 8 Apr 2026 14:01:44 -0600 Message-ID: <20260408200211.43821-10-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: quoted-printable Content-Type: text/plain; charset="utf-8" commit 6ea3bf466ac6 ("dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes") A closer look at test_dynamic_debug.ko logging output reveals a macro usage error: lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =3Dp "LOW msg\n" c= lass:MID lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =3Dp "MID msg\n" c= lass:HI lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =3D_ "HI msg\n" cl= ass unknown, _id:13 107 says: HI is unknown, and 105,106 have a LOW/MID and MID/HI skew. DECLARE_DYNDBG_CLASSMAP() _base arg must equal the enum's 1st value, in this case it was _base + 1. This leaves HI class un-selectable. NB: the macro could better validate its arguments. Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 77c2a669b6af..396144cf351b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 /* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 11, MID, HI }; +enum cat_disjoint_names { LOW =3D 10, MID, HI }; DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, "LOW", "MID", "HI"); DD_SYS_WRAP(disjoint_names, p); --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 0FDF335E94F for ; Wed, 8 Apr 2026 20:02:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678549; cv=none; b=R+RWrBfCXpTDbgDtq82yUwNnKOv5vD2Px/aCMGlZZ3nQGK9abP4mpDzg0jR1zVRyCcwfO/wC/3+pclFksxjJ5kDxlrl9KE+V5bWyOJrIUNMd6UJEWiKvlEdOFrpp/Q/3ibmUkmqJIWIrN6yiN1vhCa5246Fm39UqcY7GlI+jq7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678549; c=relaxed/simple; bh=jvrncrmm4HxGPm4Djs0mIKZWZzF44X90wc3C8KMjy10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7KqTbanbnQkRAfGrcVRLE5N0bK3uIx775m897I21RPQ2cblC4ftexJjj/utdwXjPnBfVSZIHs4tsGj8ng5pjhZJ2DZF8H8SCsg8yVYNFuekCgjZ4XYtZy2pJfmihGZI+3BOKbUTdf4bQax81SLGAWgIF3igAZfW34SpZJ7VeeM= 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=gIh/05KS; arc=none smtp.client-ip=209.85.161.51 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="gIh/05KS" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-679f6ee3fb0so64413eaf.2 for ; Wed, 08 Apr 2026 13:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678547; x=1776283347; 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=Q0sBYQSvT/W3L1mc7F8xF1oVUSz9OX/m/AEikTG2UrU=; b=gIh/05KSXbyAB0lCEjjto0NnEAfNz6YjfP6HMMr5BPULpf2FH0xaUhlIoIQ4batFkP oUjjd3RXFAfOJ00e2ARaBWKGYSfnbm+0uOmvR8oHUDx3tBuZ7GKqMy+ERhwQXl2HLJeX JN76Ee5406br6MhjRgSDz+/WJyPlw0JtvRt5hMeAAQBu0wUW67vtUvg5GV2dQ/wg0oIH R+0kAKZdIgdpXNNLTVZnSK/Imktfka5wuVFA6PywboRhRLaffNPHJ1hJWf/UG2S5sxTB k7t1mWA9sJt3zB0NsJkZDeRCUASVXvHukVPI7e9MTuRXNEGTps74UnKjY0/K0ldt2rLe 1NOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678547; x=1776283347; 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=Q0sBYQSvT/W3L1mc7F8xF1oVUSz9OX/m/AEikTG2UrU=; b=YsCeKMr+NNKpEUmByDQh/bbqVUvlH7z7W21gh603QA5jknKXTeJCWQW8n/xDWDViNQ VcMXiERT3BVH1Hyxm4VhGW2r0l2SE/E+gz84TorEpJ5g47b0MhOiDXBz09xLds2tbiO/ Zj79fVI9iorVLRYVl28zXxOdOVwuBpnMPU7qanlWQx17hr/1aIckb+waJ2r9XUilkGjD ivTybsSYTEq/VIpnXerXb/TTQAw2JkGHonp3BwEOekwRfEd/3mnBb/CpW+OqK3xeIbiZ RNPagGgwAzjbQrd/AD/jANuwOdQIiZ8Eh5f+wCrRohlj2raQKism2CZycjFnUrizqsec CDEw== X-Gm-Message-State: AOJu0Yz17/XbBfQxfAp3QT7BnRb1w29db7kPiDllvsKCDVFXGhpPEQjU ry5ejcLSGJFjeuCQQvZ3y112gd5OAfEi1YG4FW9Hhtkn0wvIbjld9XF7xkiX1g== X-Gm-Gg: AeBDies3tRay73WDwbwlX01ryciwuY0g8aESCjegrJZtTXmbAeAHotqnR2w8hh9NfXY qRlp6ACf31lYfrAhGa2fCHAXXyg7O0yWXsOPoYhqbb2uqT7CnLc5B12SGgWjDCDwgqsvzYf9fKD JDEaGdnK33w9UvfSUxLqBND4LwX7xLZlv8KG+jO47Jh5lYC2rXAkv39mC4c9BirVIPJ4zkmCySv 2RgQjI3sZ2meQ5fyLfHWKV7uQ/T/2Il0co8YgUVa2qP9JQXobab8Iu1rxDDnOBqeXdm5HzF9u5n d0/Lzt6sYiRgAo0pb3EHeZwfGsiI7MH5l8RaVrVkJzLLp9DEH01KP/i8bAR21tAVcFMYtlV1Uk5 zD29z2bD3tPvvjEqMiEbBUL5k70KVwE6LHAdQPg2FfgpFmlYmCjMoeGpVy4pJ8Q1w+hb3IgjKtE rnKYYfb7HrK+DvcPCS5dGrSZgcIGCb45zJTN55vqQe4y0W6IoLl/5XHBDEaGJVHPhBYpJ5Fk7TY 3E= X-Received: by 2002:a05:6820:4d0b:b0:67d:f53c:9ede with SMTP id 006d021491bc7-68a63b90c9dmr474900eaf.60.1775678546815; Wed, 08 Apr 2026 13:02:26 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:26 -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 10/36] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Date: Wed, 8 Apr 2026 14:01:45 -0600 Message-ID: <20260408200211.43821-11-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: quoted-printable Content-Type: text/plain; charset="utf-8" When a dyndbg classname is unknown to a kernel module (as before previous patch), the callsite is un-addressable via >control queries. The control-file displays this condition as "class unknown," currently. That spelling is sub-optimal/too-generic, so change it to "class:_UNKNOWN_" to loudly announce the erroneous situation, and to make it uniquely greppable. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6b1e983cfedc..a9caf84ddb22 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1166,7 +1166,7 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) if (class) seq_printf(m, " class:%s", class); else - seq_printf(m, " class unknown, _id:%d", dp->class_id); + seq_printf(m, " class:_UNKNOWN_ _id:%d", dp->class_id); } seq_putc(m, '\n'); =20 --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 F3CA038737C for ; Wed, 8 Apr 2026 20:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678550; cv=none; b=rbruf3iQuFwf+hN64jWlTGOJ9w28Yk8iYmPq9VxSuoduILGlrk+3hIBgeXXs8Z35frcbhQG8uZPldcBJBJCdVMKIaFr+wzbTZyiXiW0SyaDuiTKizm/BPfs/qg6yl/TSk/FV+4LEzciFdz2g3794YAR6IZ2BqvgJk1AbQoSJnUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678550; c=relaxed/simple; bh=nT2X+0ltTDZpc2Ke/Nts5WB2aC9+0FZsv4JIXPNa2T0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WyGkn9MRlJmyTRsCWMxXyD22q3kN/s/RFtowzL6RiotTvNWoans6zorhORA5RglbAt43ix5lAAx6aPzXSTGdL7672Nd00XyQBiTQNPPNsCRkCZQtf1zwYUNlCgKKaraqiWfrhFJQxL+TVswrz8Wf8MqwYMk27pd5/J7YM3Df8NQ= 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=ZQEjQ78y; arc=none smtp.client-ip=209.85.161.47 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="ZQEjQ78y" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-67c250805ccso62764eaf.1 for ; Wed, 08 Apr 2026 13:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678548; x=1776283348; 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=6DJe7q9AzKIA5JE9j9dS7BkLMe6yLjsp/ulkOtgleYM=; b=ZQEjQ78yH0b7zLihoAvH8Yyr+aZd0i7Zuv8pDTylgazJO7IK44dfJGmiloP+XnMg4d dJqktUMRkjh++YaBrYrJykiWkxyve4N/1JZDhWrbt7pJInaSx1j3B/ud0vJ185ZC/YP5 NsSQy+71B6VKhsTgtWGaum+OebsqCa/Tl74J68dCxAn7RHKNMjEiTH+LBOJjn8e5HRIK 7NQvRmekakHhb7/R44ZUQTueuTuDRzMkNnTN38xQ78gI/scbztje6wmsIgA3Oot03zBJ lbN6Y6n4zRW4aGhoejkTbZgWGDmHkj70C+ln/d1fdTVQWbtiOxfJ7nfiJOj8FK/lB46D HKPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678548; x=1776283348; 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=6DJe7q9AzKIA5JE9j9dS7BkLMe6yLjsp/ulkOtgleYM=; b=qHtiyXJkRA4wgluof/OyA7qsFuT84RPn9cotUoTQdQ1GtGSqJ9cEwBlCovmx4cKGJW TV/VcZGOLqx46Doi/0VP1JG/HcrqGsVJQ6/2SUaP2WieapZuTsd5CURBjIiWNRWBRqCC sd4/J0UwpI4GtNIzpUfNOC/V895vmjdEsO4sz/BrefLOGIYek9hbH1IFeBw7T1eq8VPz XlVnLJ/TMhHsD+IVV7WqONRVQZ2ZKmBCnhFfVml5nAfguLorziOcu9UwheYpT/BGdUmo Pxh9mqN+VyQNUFVlShHOPvS3TVFdvthEc0Sp0w+mTFimnAflPKU8/LoxGd8tE7bklMMM KB3g== X-Gm-Message-State: AOJu0Yx/7uVfUCLAw+a+iQy0IWWWgIAyp7HQXF1kwyg5oK1wmGdokLDE 19VXAM5lPbUiYZhsb0KcLhzdSmY/xK9hVbGff5TybybijuZScANUWLI1RoWw1w== X-Gm-Gg: AeBDiesGCNcDEMXzNzNQY+ySNP9AlIh3DAVduHOamaJmEwFxK7UapLls3kVfXRAtRFR o3dz7uAyik2YTexO1MGvGjwRQIvVx8j1QkMPYtorKHffQ9Ox2flGjBuSkNmQI9srCyYexwN5uyr CRQ44+1sUrAT51xuXZD6xmJUaTJd9tLUhKx+OsMXKiUC+COde604s6ecu6aWVUfEuHPI6mAkbBF bcWGSO6S6YkYj0cr0qFRr3ghKVNIT5Ux/JejT3cokl2zbZdSp3zvH1cGKYNUTuwKILQi5grz8fk hRgjvS4+d1hHnny6n2HdubEOfwjcGClfgNM6IDyxruB/dXkm6pPtNhuuMsIng1344EkXGZldZSy S90Dv+2cLFC7VV9wiF+TB+mVNdidLdtNePpFqz/tAPLOjJ15czib9OxpieEoZw/bsReKz8ulPyF ImFA0ElXyf2pnG+ovHDPYk4vrOcvexVMFjodsWJxExHpeKlS9dbgGOYCTxubQ0GxAXr1DmSsYAc c0yppF4ji+eNQ== X-Received: by 2002:a05:6820:1628:b0:680:89db:fd78 with SMTP id 006d021491bc7-68a6177f993mr553030eaf.1.1775678547711; Wed, 08 Apr 2026 13:02:27 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:27 -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 11/36] dyndbg: make ddebug_class_param union members same size Date: Wed, 8 Apr 2026 14:01:46 -0600 Message-ID: <20260408200211.43821-12-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: quoted-printable Content-Type: text/plain; charset="utf-8" struct ddebug_class_param keeps a ref to the state-storage of the param; make both class-types use the same unsigned long storage type. ISTM this is simpler and safer; it avoids an irrelevant difference, and if 2 users somehow get class-type mixed up (or refer to the wrong union member), at least they will both see the same value. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- lib/dynamic_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a10adac8e8f0..441305277914 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -104,7 +104,7 @@ struct _ddebug_info { struct ddebug_class_param { union { unsigned long *bits; - unsigned int *lvl; + unsigned long *lvl; }; char flags[8]; const struct ddebug_class_map *map; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a9caf84ddb22..ffa1cf7c2c72 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -811,7 +811,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) =20 case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: return -1; } --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 0925F35F190 for ; Wed, 8 Apr 2026 20:02:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678552; cv=none; b=YflayX+CC0sj4R+4IIh23Qxhsi2Lic4Ssv/mZ68a89xvFUrTISgMTsW4bmQ1EAf4b4AWmj16y8gVAJZAcnIDOhu1C1nuPToJrrbigOR1r4ISnRGr6sSh3UNfR/2MLx9Cg2qNIgzfIQhPICPbc26NKotmwk0gGBy2mDw3jwxgFQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678552; c=relaxed/simple; bh=SLkxALPzv5MuO/ZLVMcQnhi3lAgSVUDUGPYbYC6Snk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nA+tUyUJvSqg1iHBCXewLypCPmGxpiP5p9Sldpgm6bEnoHIUmrIZXS9O7G0xXnF+vuoxhsc+kxjJmgOQNHIYv2r/JW/gtMQxsJOJekIvZvcyB+3QvBE0B2QlPstzUphTACoX+rHpJ5tWV4iRioUCyVd2XoSlCyuPnGR7VenKPCw= 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=c8GIr7Ao; arc=none smtp.client-ip=209.85.161.48 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="c8GIr7Ao" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-68397b9840cso74092eaf.3 for ; Wed, 08 Apr 2026 13:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678549; x=1776283349; 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=q4prZoq+o67W5OQsgLrKexlAzQC80y9w+24uEfnXM5Y=; b=c8GIr7AovMHmimhzmbHbDER6FcAki5nzElB7wTNDQijWnsHQ/r0ONgG+dkvDE4Gczw kkzZEbQEjG1bxKFOb7atE9pRQ4NzWjxYMV+PEdhEs1QV+ndo+tuvvDYQ6LNmo8N0eFZG dj75sddXm4Tilnq39e0bdemcntO95DwGUvaRDGo5JTZwarukb4yxxnIf7xw6D884WV7J 81Ylg8Yioc+Kz8sEHJjr0+u2r0qlssPqurUcvf7j7ot8jEteJ7QLz3ZbISp42hx6VN97 mSX7q2L0cFzzyqfk0XL66+sPkTZ65xBYmGABnv5L3GkQD+1Mju4xjc6YfYsuvvsbiOvG NhEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678549; x=1776283349; 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=q4prZoq+o67W5OQsgLrKexlAzQC80y9w+24uEfnXM5Y=; b=S0Gb/nxvhBh7pV5gvgBgiwxjH9cKkhYyMOMC/idbDjB1vuseDv3vjIBcf98hFW6mY6 d053U7cKMpwIUW7ETgpVYI+feICcQLmcLXL3AoGoD48RMnMDDJFdYJ6HGdya6p+ENVNP siE8B5B5Hf1ply05altiAio+lovaVErAYp/OFAQgpyY2b8v6FrZ+X8E/ejiClkCB+7a9 OqReG98YbPPQKVJH7nvCJg2red5Ff81lNHN3Lz4OIoHU1dIWCS0AWGDsP3ui/mbHtr9Y TbuwMLefwosifbAy7cXkPpacFNUh8S9kuX/Kj4feYslPZQ7wERZUTmsf/eZaH1MgU9Ho 19Mg== X-Gm-Message-State: AOJu0YzEY3PjQk4sRA+mjS6/FsVyOattouEQ67RGk2qQ0qRaegAvPMGY UgjOlHOlBme+cHoQBxJTFHIhYraqTTEMFrST+ZMOu0YKRknnFJKNwkOc5L7Ujw== X-Gm-Gg: AeBDiet+Lr6sjvZLyhdjUJRMM2ZiwpXQDp+xy1nRWbh3fGi+YF6DRUh1h7uLN0m4BEg yR1rGQt6dBoDQRNBqYLNkGPCTqhFXpnbqHY2ZW24EJrMA8bCrnpVrBXh6Rg9G3js5SAcKVuUNmU uDcKmzB3kWC/oC1xhI5APChxzMin0bk8gDRdtL3TeHy9u9rgQanuegAV7dE+rnZKO4/RhR+OKbq kHCErs6C8ckZ3l4k1BCn04N2tmzuxWyVKipi3c+jNkpMBU/Z2CmnjFTrOBQH2FS5e+BELYdFkMe oaM9T50VDbgBx8hOOUwwzAPsxW55h8FJOsOt+mMAZs2iSpQrpqHjIXDfqCP3kER4zXOjVRkured Qt9H6MPl1gh8fdl9z8JyM/jS+nM2uE/DgXq8YID6ovMLXoyrjg5si6h+D1rVJonpk/5sNqT9xzU /1y/j0eu9Os6a2YbCAq+mx7F+Zdq4vjz8g113Pk7jyPGR3AlcyA/LZfHqbKnEcMA2rc8Qhx4g75 x4= X-Received: by 2002:a05:6820:c82:b0:67b:f13d:cf9b with SMTP id 006d021491bc7-68a651f0f41mr544573eaf.61.1775678548846; Wed, 08 Apr 2026 13:02:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:28 -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 12/36] dyndbg: drop NUM_TYPE_ARRAY Date: Wed, 8 Apr 2026 14:01:47 -0600 Message-ID: <20260408200211.43821-13-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: quoted-printable Content-Type: text/plain; charset="utf-8" ARRAY_SIZE works here, since array decl is complete. no functional change Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 441305277914..92627a03b4d1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -132,11 +132,9 @@ struct ddebug_class_param { .mod_name =3D KBUILD_MODNAME, \ .base =3D _base, \ .map_type =3D _maptype, \ - .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .length =3D ARRAY_SIZE(_var##_classnames), \ .class_names =3D _var##_classnames, \ } -#define NUM_TYPE_ARGS(eltype, ...) \ - (sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype)) =20 extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 16D78377004 for ; Wed, 8 Apr 2026 20:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678553; cv=none; b=IwBKcBtenpuXPjeqKfBkaAFXXH2Pmk3x2wbhTUEb8lax/2CvmMKQZlB+1npnvAb8j2hBBzMhUB5OpV7WpwuACSELhe1HHkBvoybx8l6EFrcOn2HWKBDhHjOmjzYOeliuF9h/RrxHc7qzwoRjDpey3QvZIU6l5aBcXfyWkBCoG5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678553; c=relaxed/simple; bh=A7NW1lcioeZvkxFMDB5jn7b/13wAFRirdZ/+LAy3Fqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hI1rEw8I2clVQhd9NR5f3AA2yWH1SFvc1WLXcIfmpq8qq6hfnuhRFw8zoHoiv0rxhOfp+TUwzquiizQ7MzKhRL2zab867NXEZX5/oggawaHb9ath6Cl/UbaFJLJBmYDcXnyANGZ71Lw9Athwqi0M6ZRJVu+thaDkoRTXMrLDWCY= 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=JVISBrIq; arc=none smtp.client-ip=209.85.161.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="JVISBrIq" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-688a8e5fc2eso102269eaf.0 for ; Wed, 08 Apr 2026 13:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678550; x=1776283350; 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=z18RPkW2IZoeg5aoWLW/CvDoUPtyLf/KFWO8hAB/+ds=; b=JVISBrIqKL3S+4jPgMSXr0jHjZ56xgEItUpXnWzPZY7Mv41/ILLDQV1F9039HQaTrz dRihgttkVMBDOg0aPEyWEHBE/l+ojHrcUHY0Z64Si81OdgT1kXKx1CNh/x4rcH44Jysw HBnI8iCy6SLdD5y01kVhAyQTegTRKjmPd/6SaiTZZ/bGlBh/cVYo+91JJ5Y5NaNPsNIF MPuBI2wOyPWJPJxy4QMKqUF50BJoJjXPcSjmdsxgsoyrrpOmbQchmlzT3gYy9AvPUPKs u5n19l3YLYr+F9Vvrpdtt4Pe7tdzzleIpE6dyRKl3/PqrZQftd4M18aS7WMOyIPrGWPd gdPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678550; x=1776283350; 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=z18RPkW2IZoeg5aoWLW/CvDoUPtyLf/KFWO8hAB/+ds=; b=YmoUm2M3nxvyFixjHNtx9u3SrFCLg70JevLUcdXUuYhBBtcdn9XCrzyNxsJgSp9Pde 5iTKXBKYDG4gu9TSYA2LOLzqeMJgb8uBYRzwcC9GwndI3lOhtwMWHkIKr/5t1GBSVkC+ JkItKSO4zuiQlAd+PJweJMh385HYo8364rX6oPsY6tr18Y6cA5vU66DqJ9JrC/2WEGzW fuj8e9Os6wHTMYbnVg5o4ZLxm41iHZ2IyHi/UVl9ksob2gFCPN0vI//okpp9W7iSJIiS vMuZFR16j0trEfXYscExuRfXOtsrCDsMm9vtBTaFmqw5A6eOE3C/u3dST1mfdbLPNkoR i/lw== X-Gm-Message-State: AOJu0YwVpwlGd1YD7opLRbfCGoDDeNboqJCuIiTVN6/VHIeUAaf+s0/F FtJFvBZF+VA+F6/Rg7c8FjAgDRioGLEty2EoSZh4kVgXNxOMqdheJPMXc0iFCA== X-Gm-Gg: AeBDietP1xKcfE8/Oa3X7yk/AOG9dWC2CCu4skavSzaazQpa+ABPcmyNwr5s3hVGbSt LeVYROULY/ayoBNVerorvcGtjkKsnvNtPlTZDqSCrFdVHVJl09G0ng1yFT2fmd1qKgVsJ8u31Sj QdtHkxZlzaAdwkO1eOCKP+btKGR1QtvY63Rg426KIoJ+tW4f0sTdTMfMHGusulTX1v9T1UblOwA uuHn8FO2GUicisQfJZSZWQV0O5ego12PYAKch+hPHkKe9f281W0wgW109IuLdms617bRr4ZsFr3 j7ymXU84me8UAWz47QaeQJtlg1TSMhCPSyXAi5b8i43GH++ZlG0EIreMXjbJv2lb4BJJTNWuVfR chytcRyquxM5Ip6ye9TzPzUKJ5VztEWgDuhw9RBYeCynnbmfAldmMGIaFifbOYAgrDCLpUoo/QI cAWmguwA6UiAYhLIC3GDgkWtSW0/HOcwZCHBht57lQwx4SWDhv96tOURW23wdF81aHaAcrxhzCv 7M= X-Received: by 2002:a05:6820:1a0e:b0:686:c7a9:d64c with SMTP id 006d021491bc7-686c7a9e5ebmr5577886eaf.43.1775678549858; Wed, 08 Apr 2026 13:02:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:29 -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 13/36] dyndbg: tweak pr_fmt to avoid expansion conflicts Date: Wed, 8 Apr 2026 14:01:48 -0600 Message-ID: <20260408200211.43821-14-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: quoted-printable Content-Type: text/plain; charset="utf-8" Disambiguate pr_fmt(fmt) arg, by changing it to _FMT_, to avoid naming confusion with many later macros also using that argname. no functional change Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ffa1cf7c2c72..9575b92a8deb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -11,7 +11,7 @@ * Copyright (C) 2013 Du, Changbin */ =20 -#define pr_fmt(fmt) "dyndbg: " fmt +#define pr_fmt(_FMT_) "dyndbg: " _FMT_ =20 #include #include --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 3FCF138736C for ; Wed, 8 Apr 2026 20:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678553; cv=none; b=JLTDMKTirWn0iWLsu2ifYZu+KReTW2HSvqiMDRXoVKFNniOQrtqw/Kh+9YbiVzuAXsYAi48uPWT3bQ8xYO5UQaYyJIH6VTfzi1RxHyK2G7+QHU6beiGZcuJPYBi7ZtatFBRvkepoR7ce6XmmFh/IEt9QOvA4QCUsl16ikjxyIFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678553; c=relaxed/simple; bh=S6gUrn6AElwN551VfXZR8sAzEWfpnwUQMkcCkNtZGhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hbnAnfSgFUuV59QOwn9gLUe+iGFVftgw0gWnMHb1zPBtxQzYtUC9tLh3GTWQzjyfGJCGkk9lwQJvIrP/MDXuKuoIFyCrURBZohFqII7vgzd26hd2b6C8yNZWAePGiAs8PYSOK5OtHDOSZ6oFfNw7LPdITCdTyUzrY/PUotxM3b0= 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=buN7LjIB; arc=none smtp.client-ip=209.85.210.42 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="buN7LjIB" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7d7e9b97a73so80671a34.0 for ; Wed, 08 Apr 2026 13:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678551; x=1776283351; 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=sNdSdlXltBKavjCpq8HaVo39jGQFAT2gyMj0g9RRu6w=; b=buN7LjIBdDwGxsZU9pZuoI7WSRkxu6bpS4G0Pygr3K4T7PTQufffvzpwSrYm7+N2T1 c6ktwd2iISdF3g37tKE6CaLQeitjMMCO4txTqJk6gzBG1vzUUUlNGOACydAqaB6jNYuT F/Y8+RsGkKSPDb5AM3HB0Xo5fl4+F/1M18zl0nLFwaSq6gX4eGJ7h0Q2OoRGXCqVPsOX RfaOn4/KwLoX9qOzfPD3ngFsQJFOePGnMKo1VI1827s3iMdiQBB8CY8JInXUqBJi8jGA V/Ls83HpF1ka9gZHGmZdBplZl35G+cCh582qbGxKUCWByDKdzCj98drBopbWYrZOAzmS xiKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678551; x=1776283351; 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=sNdSdlXltBKavjCpq8HaVo39jGQFAT2gyMj0g9RRu6w=; b=hky+SX3AIx5HUffjtoA3phR/8dcbQUc/DjV/6e8TZ+FcxMXYNZnwraKCfXR04DiHqa 3zME/msOQo1t06OP+6Pn6T4F4UAiOkgIfivTN89Y8dZGms1K8qiDw0IS1d9mWxma8IkM YDJ1cwYiumSrOC6uns9vN5HFCgIkNewkDdaDkN51U3mqqO7Pr8PsFscQWHgzIHdYitah 27jR4mY3shgcjwdb8ceG2oRoJDzotb7vVVJKBKTCA19GeUmNWNVG8wk1YJZkajeRnyZ7 MgrK8oy2dkqH7AZyCL/DG7afiRY0pH+RIjqBkcMyCU9tNUBxwjEW9VC+9m4h7EN8vYQj enrA== X-Gm-Message-State: AOJu0YyzaR/95CjadXOlJRmBxLu8xMNu395b6PsAzA4Fw3ONcjq9wzIH lvsPGl8+eErRgRgeoe1roBgvAAEwxeNl+WBHUQON2R4o33w8tniqp3qdUo41Zw== X-Gm-Gg: AeBDieuorYGXWTbSe+gR8YeL2jAs6ThOo/JZFyX4kt83uLW6gJVcGda5ThJQZTC6ng7 S+y0y5ne2bbDDPisTTkZ+PiaIKzU03ZDwe4SDGE1PzvHrSUGIg6d+d8TbCv7g/QHN4jHs/y9AZH RbvsJMi57n5GaBC7Cv56/a08/nkm5vuI/EshyLS4gAEvhRSVb++tfvNDRGLgAx86qWeV1nd0GmP rcv4goHLA212xz5XPUtm6n0+3PtX9YM71DF+i3rkTqMZf0Cuu23pmA8Baxkrd29UdaQxp/cKXU2 WmQgSR7TBzNhP+ZFyyQChZrUvsHY+JENXbNNjXpdcoPPnNdOjF5wY6i7FqUHREV7Q68rJQ7l6SW NzCp1awFFXHlWwsr2l4EFOaUcooz5p7Q2fLb3zS2rXsh9xLl0fM29Wkn9YDUWR1P17ctV1TJLxf pMwno/8cQgGNcqkjBs8UGcdqEes25fVr6KqWcFv2Im8i2NMTBneDtthf0nFZnLUpLaXs0A6gjhh jk= X-Received: by 2002:a05:6820:2908:b0:688:e883:8846 with SMTP id 006d021491bc7-68a69fdf054mr413117eaf.9.1775678550818; Wed, 08 Apr 2026 13:02:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:30 -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 14/36] dyndbg: reduce verbose/debug clutter Date: Wed, 8 Apr 2026 14:01:49 -0600 Message-ID: <20260408200211.43821-15-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: quoted-printable Content-Type: text/plain; charset="utf-8" currently, for verbose=3D3, these are logged (blank lines for clarity): dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' dyndbg: flags=3D0x1 dyndbg: *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: parsed: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0 c= lass=3D... dyndbg: no matches for query dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs That is excessive, so this patch: - shrinks 3 lines of 2nd stanza to single line - drops 1st 2 lines of 3rd stanza 3rd line is like 1st, with result, not procedure. 2nd line is just status, retold in 4th, with more info. New output: dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' flags=3D0x1 *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs Also reduce verbose=3D3 messages in ddebug_add_module When modprobing a module, dyndbg currently logs/says "add-module", and then "skipping" if the module has no prdbgs. Instead just check 1st and return quietly. no functional change Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 9575b92a8deb..3ae9ecabdad1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -276,9 +276,6 @@ static int ddebug_change(const struct ddebug_query *que= ry, } mutex_unlock(&ddebug_lock); =20 - if (!nfound && verbose) - pr_info("no matches for query\n"); - return nfound; } =20 @@ -511,7 +508,6 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) pr_err("bad flag-op %c, at start of %s\n", *str, str); return -EINVAL; } - v3pr_info("op=3D'%c'\n", op); =20 for (; *str ; ++str) { for (i =3D ARRAY_SIZE(opt_array) - 1; i >=3D 0; i--) { @@ -525,7 +521,6 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) return -EINVAL; } } - v3pr_info("flags=3D0x%x\n", modifiers->flags); =20 /* calculate final flags, mask based upon op */ switch (op) { @@ -541,7 +536,7 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) modifiers->flags =3D 0; break; } - v3pr_info("*flagsp=3D0x%x *maskp=3D0x%x\n", modifiers->flags, modifiers->= mask); + v3pr_info("op=3D'%c' flags=3D0x%x maskp=3D0x%x\n", op, modifiers->flags, = modifiers->mask); =20 return 0; } @@ -551,7 +546,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) struct flag_settings modifiers =3D {}; struct ddebug_query query =3D {}; #define MAXWORDS 9 - int nwords, nfound; + int nwords; char *words[MAXWORDS]; =20 nwords =3D ddebug_tokenize(query_string, words, MAXWORDS); @@ -569,10 +564,7 @@ static int ddebug_exec_query(char *query_string, const= char *modname) return -EINVAL; } /* actually go and implement the change */ - nfound =3D ddebug_change(&query, &modifiers); - vpr_info_dq(&query, nfound ? "applied" : "no-match"); - - return nfound; + return ddebug_change(&query, &modifiers); } =20 /* handle multiple queries in query string, continue on error, return @@ -1246,11 +1238,10 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) { struct ddebug_table *dt; =20 - v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); - if (!di->num_descs) { - v3pr_info(" skip %s\n", modname); + if (!di->num_descs) return 0; - } + + v3pr_info("add-module: %s %d sites\n", modname, di->num_descs); =20 dt =3D kzalloc_obj(*dt); if (dt =3D=3D NULL) { --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (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 11543386543 for ; Wed, 8 Apr 2026 20:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678554; cv=none; b=darjwRgHq0htQg/GqzLqDnxS5n1JdpDbNrgDS5k2qj6kpB2TKsQSeqEHLspER2etTbsdF9QVaAu5Xl6kgvLGORgP5aCIdPyKi81N0eR3LKb6bI/4MF+0S3XEpwE8OK3U55dhrRevU5EUSidqXvfGo5QOb6EiEtcEVCfkZdqLw7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678554; c=relaxed/simple; bh=SoyzrIXTJl0zhkZLXioIJtb1P9eJp/0gNMCq5+HdwEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zffp+SyPoE6VgArnc/cT2Jh+bHj4Zyqxe+BtitkFXolSh+cm2I3Gic1lVekRpGVErOi7agPf4RBXag+LYCz9Zu2YcMtmWc0hOSFAgSO9L1LS1sU0GQPZ8D6jxDodogU//FzrHoFOvuYXK0L3pdPKfNlBsf6EM7qNRAWD7i4+5sk= 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=mpx2+WLv; arc=none smtp.client-ip=209.85.161.43 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="mpx2+WLv" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-68481c9e067so60709eaf.0 for ; Wed, 08 Apr 2026 13:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678552; x=1776283352; 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=pjtw7mSJYIyVbZmpiBkB/+QzGUfrkH1ZfSuml/KOt4o=; b=mpx2+WLvpaUmfaSHemfbva2/JcfTM/TcmApbHKQO5IB2HCedbEWtzTw0O1eVNtUOe5 Xf9l1S0AG6wMMKxRih8rtNjdEjtqTB9CEP1CoIyuNuxtWIQ3YxkIDUacg/GL8Ta5nuEO widy4JCluTC/plbjK2jm1KS6OZS17KeoD7FEpMlrhnF7w9BjLR0iRPBv3ABW8fBG+1YQ 4+OUfumdjLvcP8A3p0blnnXKL2SaGGzvmpenEfDfh/eM0XP3S+aPQlIHkShwgswIM/vP eJjqH1UO3MCYg/guQAuc3JmTsYm85o3FrMGuCH/7DLJ5jsuyWw35ZbGuUqbhuhNaluWs M8ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678552; x=1776283352; 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=pjtw7mSJYIyVbZmpiBkB/+QzGUfrkH1ZfSuml/KOt4o=; b=sa1Yr59X+ixmlpnPW6xRZFwK+TXxvYePG/JwhFZj8dXGLNFg2ZLMhkaDP0l7OtLP0K buKNRyyn9uzcGiL9DdocuSvU1LjHqPnuYqKh7h1q0TFySR7WNzlWhOP0O9ZVH/rdnmFm yT9kQP5KKHjjk2ZXT32wLin1nTDxw5/PxhF1/bgV33QEAVusQVYLaQkkfFRxQoGsm6yV 8FCva2eZcybRmnjWbXbEhB7NddHplzAvE/Cmicdtz8zG68Y8ClsUaBD8n9uNwZdLZ0qu m4k/R09giJ1gD/mJFenX+raKbSe/E0YvRSrEI67h+fiIEhGR3wF2ewzQLXFWUksUuMQo /j8A== X-Gm-Message-State: AOJu0YzbAQulmOj6RH1WGOlSJs0NVT/ZbYH4m0S1wjB60H0xgt8WDRrR o5qzpfrNIDmyFdvF5HMqsdPtOEFH0iyci3tQVqFh3wT04QPPNgkkKVTxkCEM0Q== X-Gm-Gg: AeBDieuD+WAy76lOFLEidxsrABCo4+CHwuwPz9fM5n7NUl7Pfjv5lWDM5l4TfM//HxT AqrJMblsH17bkJFca6od+xkAvYAO878rxBkpU5rxPZtVz2XUwCRSUwngTjDRe6l5IXRJsNzzOsW CHwtgaUW+1Fn/+EwaTkrhIEhZZXI+nbUlZBN+8P7iPvkBryhyXsz/nzgOvu6OA1YwYfZUCoie1U l9Cn+AWjVZq1HxoF1RNb7bDP1oyxWr5F539ORJaj5QshiVWt5+N4klhsKCEwmBx9v3Vk31AHGgT ZmtlDEf3YVQd3qFwl1BWslRoH/hpAryIPxH1DwM+YjOxyMbvVUrSArkRbW5KXvPTAiG0AufUu5q n4Gcx8H/pWzd9pBWZIPkac7OMnZtB3NQQC9nkzB52A3sehDKtMFsl0rZCd/I6P+cWEMXO+/aNEN L6JTsgvH5C0nSpcQmpsI7/76B5LV3c8EY5uZkewodswQI4uDEAUNKQI66mgWn6JdQBIVkF+sMDd dRnuMR9rWyRIA== X-Received: by 2002:a05:6820:199b:b0:67e:295e:42a7 with SMTP id 006d021491bc7-68a60faa741mr567672eaf.16.1775678551642; Wed, 08 Apr 2026 13:02:31 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:31 -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 15/36] dyndbg: refactor param_set_dyndbg_classes and below Date: Wed, 8 Apr 2026 14:01:50 -0600 Message-ID: <20260408200211.43821-16-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: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor callchain below param_set_dyndbg_classes(1) to allow mod-name specific settings. Split (1) into upper/lower fns, adding modname param to lower, and passing NULL in from upper. Below that, add the same param to ddebug_apply_class_bitmap(), and pass it thru to _ddebug_queries(), replacing NULL with the param. This allows the callchain to update the classmap in just one module, vs just all as currently done. While the sysfs param is unlikely to ever update just one module, the callchain will be used for modprobe handling, which should update only that just-probed module. In ddebug_apply_class_bitmap(), also check for actual changes to the bits before announcing them, to declutter logs. No functional change. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3ae9ecabdad1..4313c8803007 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -605,9 +605,10 @@ static int ddebug_exec_queries(char *query, const char= *modname) return nfound; } =20 -/* apply a new bitmap to the sys-knob's current bit-state */ +/* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits) + unsigned long *new_bits, unsigned long *old_bits, + const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; @@ -615,7 +616,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, int matches =3D 0; int bi, ct; =20 - v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + if (*new_bits !=3D *old_bits) + v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); =20 for (bi =3D 0; bi < map->length; bi++) { if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) @@ -624,12 +627,16 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], test_bit(bi, new_bits) ? '+' : '-', dcp->flags); =20 - ct =3D ddebug_exec_queries(query, NULL); + ct =3D ddebug_exec_queries(query, query_modname); matches +=3D ct; =20 v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } + if (*new_bits !=3D *old_bits) + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); + return matches; } =20 @@ -684,7 +691,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -694,7 +701,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -708,18 +715,9 @@ static int param_set_dyndbg_classnames(const char *ins= tr, const struct kernel_pa return 0; } =20 -/** - * param_set_dyndbg_classes - class FOO >control - * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type - * - * Enable/disable prdbgs by their class, as given in the arguments to - * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative - * levels by bitpos. - * - * Returns: 0 or <0 if error. - */ -int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +static int param_set_dyndbg_module_classes(const char *instr, + const struct kernel_param *kp, + const char *mod_name) { const struct ddebug_class_param *dcp =3D kp->arg; const struct ddebug_class_map *map =3D dcp->map; @@ -756,8 +754,8 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); inrep &=3D CLASSMAP_BITMASK(map->length); } - v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -770,7 +768,7 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name= ); *dcp->lvl =3D inrep; break; default: @@ -779,16 +777,33 @@ int param_set_dyndbg_classes(const char *instr, const= struct kernel_param *kp) vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); return 0; } + +/** + * param_set_dyndbg_classes - classmap kparam setter + * @instr: string echo>d to sysfs, input depends on map_type + * @kp: kp->arg has state: bits/lvl, map, map_type + * + * enable/disable all class'd pr_debugs in the classmap. For LEVEL + * map-types, enforce * relative levels by bitpos. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +{ + return param_set_dyndbg_module_classes(instr, kp, NULL); +} EXPORT_SYMBOL(param_set_dyndbg_classes); =20 /** - * param_get_dyndbg_classes - classes reader + * param_get_dyndbg_classes - classmap kparam getter * @buffer: string description of controlled bits -> classes * @kp: kp->arg has state: bits, map * - * Reads last written state, underlying prdbg state may have been - * altered by direct >control. Displays 0x for DISJOINT, 0-N for - * LEVEL Returns: #chars written or <0 on error + * Reads last written state, underlying pr_debug states may have been + * altered by direct >control. Displays 0x for DISJOINT classmap + * types, 0-N for LEVEL types. + * + * Returns: ct of chars written or <0 on error */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 DB86638E5CA for ; Wed, 8 Apr 2026 20:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678555; cv=none; b=d7wIvMA3xPBtiBOCsePcNKJYTDUF9o4W38jEXcJuzuwwEMPyW0u/Zf1y6zWnSnsuOxZMKBLsQ36IOMRjHfkvIc1ZVbCaS32t5ewAUupP1vQ/3MQ66mH4KBjodGzOs4f+cuIZdS9PaNn8Wbmxlu250IW+gwHNtyLkzFahW7gWIuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678555; c=relaxed/simple; bh=PBAFi7y3YRuwq9TlfBtroorgB24BQAwGr2rvA4abp3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ASidWd/iEsFgNkUQQA5ZUCqwGVoxMPPgtp5xRrCZUkHrdB0zMfdvjrhsZDYEHYEOAY0YFwcLRm8/fdYRBkd6VxxRrN/FVKcLRcJhY8Gk41Ar6PJmJHVCGikLtj7XDeczTXQMuuWCayvEEu5Pb+dXzax0x56kqR+rLJgYyoBQkkU= 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=J91GyajP; arc=none smtp.client-ip=209.85.161.51 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="J91GyajP" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-68a3b605bdcso96526eaf.2 for ; Wed, 08 Apr 2026 13:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678552; x=1776283352; 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=Lr3BXrtiuAvHSgc8/DPsjTxu/hA/+WXgrNkg64S657g=; b=J91GyajP7/qnnCpS/MvULOMc30s1nYAQc0drWYUf3NoaX6iBgC0wczeCjD0gqyzJsx 4axBHw64UBfsV+JMQv8fNsdAcvU8khjw+SrdPdOdrLWJgjQlW8mJcF6UjPNdNZwysvGb seORmxRSNpShxUBCGBsELrh8ioIrndcetzFz3MLzgI3ikk9zt58Ssh6DxSrLOtD5PTl8 CqUCqt7qsRRRDOLvAvcTotFOIlQ/oNpeYR+zgqsyzuuuqWerc7RRrEWqzGRgqIpglKTv zvWzO0DBopYjEBxi5P/m59E0EZYB7t6I+LHI2j4ibG0gyXjqpsoaT267Kdbf+xAc28Zm JH9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678552; x=1776283352; 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=Lr3BXrtiuAvHSgc8/DPsjTxu/hA/+WXgrNkg64S657g=; b=WQJ2BpUUhsMJrZszBPezo61yVmaUVJL4izn2V5YoYF2XAWw4j3xjIIEN47IBvA5aqN 1cqTqWmsqoK41izl+2xEHfgD3QD9CX8/v/rs6730P8RYQ3v0HpTTklXsJlbqR94e2g0R Hb/Js4T5VCHhCsbsmTIibHLo5jdS14MYRfaj3yHnw/vVJFhBGIYH0fdqVKC13nG2E0NZ FKMkbYaUWMQfrmRMwVD6873kMwvIc8kPW6o6ME3UIjrwSsp7O3ufEQaXpmtjOlth6FW9 UPtclyqmw7VNkHZ7UGKgMeX4oRNeFEMLwQAju2AoFbPsp04qEjd1tm387vMfOOTFy8tI RLJg== X-Gm-Message-State: AOJu0Yx5NbmPyGIfbgEW/0ipVoGKhKKKZoVKAmvOuTdah91PT0kAnOPf MKtbtCoOMNdCD8Gxxy2a6I18fBKVakFJKa5df264qcT/OjqlOjjArPXSvVV8Kw== X-Gm-Gg: AeBDiestXMRovdoVVIYm3/o0hKFRhoTY3uG69eGUC2XgEbQ/JzO2WIzNaml9JFVjYjp zxbjBqADJhiAaPDdPSCqHZgXAWpTiuUcbuIG+bkdyZZVUazd46lEN67fFMW5k4cwOtSliB9enn3 jeSb0PTMSpyk8WYW9qXzjre1l97UMyKpTqntywo306DvNAVxP5vyJHStRliwdLpa2WCO3BxlaBO eWXWzhvAQMLhOOj0x7Pmi0OcaFTdC8BHNtZXmpgMKRrQSRrVFcKd8Mii8H3lWl6nCmrycf57QFV HwezdUOftFe7RjZguWsurWoyFc3dWtU6YKg2UxrCgVxcQN5U6bDLlk1JnpfRMag5pN8tHAD/6ae JKB6rBpTWKazYEb/aOTKHEjHHI1DyJ/SgCRRUVFBw33uHxQsTR+Rz8rrrhGzhyrz/08uQMAaK6r QDU+bY4OM84TnL6kAdQt3MRy8OKvz+VjeiYdOC2RL8we4yHQmmKq1W1KB+fmaKe/UdDh8707YNh yg= X-Received: by 2002:a05:6820:1b19:b0:67e:2c9b:54f7 with SMTP id 006d021491bc7-6821fe60f6cmr11214082eaf.33.1775678552546; Wed, 08 Apr 2026 13:02:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:32 -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 16/36] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Wed, 8 Apr 2026 14:01:51 -0600 Message-ID: <20260408200211.43821-17-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: quoted-printable Content-Type: text/plain; charset="utf-8" old_bits arg is currently a pointer to the input bits, but this could allow inadvertent changes to the input by the fn. Disallow this. And constify new_bits while here. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 4313c8803007..a18f4bc63473 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -607,7 +607,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) =20 /* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits, + const unsigned long *new_bits, + const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 @@ -616,12 +617,12 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, int matches =3D 0; int bi, ct; =20 - if (*new_bits !=3D *old_bits) + if (*new_bits !=3D old_bits) v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); =20 for (bi =3D 0; bi < map->length; bi++) { - if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) + if (test_bit(bi, new_bits) =3D=3D test_bit(bi, &old_bits)) continue; =20 snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], @@ -633,9 +634,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } - if (*new_bits !=3D *old_bits) + if (*new_bits !=3D old_bits) v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); =20 return matches; } @@ -691,7 +692,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -701,7 +702,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -755,7 +756,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, inrep &=3D CLASSMAP_BITMASK(map->length); } v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -768,7 +769,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name= ); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, mod_name); *dcp->lvl =3D inrep; break; default: --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 B2F0038F23B for ; Wed, 8 Apr 2026 20:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678556; cv=none; b=qaPkKIYbdo+yHkOiNRZc2UjxvM/J6K6i3as6+vq26pGVqBgFc1ddeM2TixulZZ2Vj2cJSpfPHyCMBv9WlNpKfblbdXp/zT76C9v/WsIvRxT9SNMZmZlL+BQC5v5PXhw2giFjqUmtE+irakg35M6XK7fChAoeHfUHaJouDkiNAuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678556; c=relaxed/simple; bh=NxQl7h9bWLiIoq2p4gJ9qOg7QnNWnUPnOXXB1pgHnho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QaAOi3n3dX59h4QewnWwkQW9PjDuWGcRte8+I/qiO+3RXrESMNjEcMsXyNfa4BD2LqkP7WYvMauf4isfT4arodB4gXQ1p+0c+Tq5cqDmR38/FaZGGNoeNqlTTH5SAZNqfGHL2F634dH2hMw5/bl0oFqiaPd4Rt2akXVQni70HaY= 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=Hcjj9w7V; arc=none smtp.client-ip=209.85.161.47 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="Hcjj9w7V" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-685013eb590so89308eaf.1 for ; Wed, 08 Apr 2026 13:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678553; x=1776283353; 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=MC2lsh0Qhp0IwkFoRFt/G0LqEbae5jgNK4VV9aW2FC4=; b=Hcjj9w7VLwwRdWvacuYn4hSg+TOGAH15qDbWfxcWPcwTgNQGYYQ7yQZ8z7VsLyR0IH JyEF3KYl2CgKkCs4GsqUPnwAjlN1eoAXCQgBSfIhLKN9VvnfTjtfiMIm15nylmViSp7X r4aCBPdkgXQ5AJc31m73+CabnMzW1BL8RJKv57dr/HatHjlOkAnh2j1YD/OKn93eUxJ/ H7X+Us8Sruz1fDG2KN01jyii3WDoEPMs4XxVxSml5Fyow6iQwMsTaTz+mNUbSK9XzM3R ueWrPT4LT7UR1165Lx7aZD0rSEfpjOEnS/Au4rxc3f8ewWQ3MYsYbrjpxaYVNQ8kPIhF PIBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678553; x=1776283353; 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=MC2lsh0Qhp0IwkFoRFt/G0LqEbae5jgNK4VV9aW2FC4=; b=cDO4YD8wPkeWrGvDIuOP1+umMOAHm3Aa00sCXawjv7InoXbwIJh/0nr8XE2ifa2zLe 7RPSWM2kHboIZ6DYba1OIxAjFY36l7lQr8o5ZNDxvhCL0lnwT4sHcwaCiVxOsWAIt8P+ kyDJOcXgSihlW1KGuu5SGIq97jPZzQkc+AfZKjma6VMigvRnp3lNbBjG5r+l9YF5FjmH NeyiHC0haTtOGW29CseMK77md6UE4hqSHUsT3gEFnynXRLnjIRWOrqMu7ngqrNEoPagx qnTj7xZYZYw6x+9jAMeUFfIHdQMDstVmI5AjLzHQKaQWzVFDd3T55N694Babmu0YHSuS YihA== X-Gm-Message-State: AOJu0YwRSGUmaR5yMo72rTkZazfhP0xQxesC0VpIXS0ytG6vdiKtkFqo NHF3RethjJ5lvEtguqfGGNFFMRe2O5FvwrntgvPTDituoit7qfUNla0EhrCMXw== X-Gm-Gg: AeBDiet/feviX7eF2xyEsDNCuNYqdGuXPHKiPcRwn+pfYfLbnH4BCi6jReD7hdlz7fJ id3W3R1W4jZiUzA7HpqUpz48eXXyrpl5cgV4p0osODeeZsfcnbvivemDqpikOy2P3+ZZxt82Vff WEEwKHMPfiPc+KS9Uy+brP4HcWeOuwn4pFO3L55NorkC/MlEZR001bQf1krHDvFZ8V6kF/p2pvE 3zXhQsQP04NOq50eWSfs64hzF6wiYgUiZdx72UtZJecOZzKQrJ2rhG1jf7jP8JjYGmOFtF/lUVA q0oQRBuP8X4AAmVswuIuPthDE6RB26bWvIkkj3XkWgrskWSrSQJM3AuOyaKn0RTSQla5TLI726m Ootbd2Ih0oI+kPEnG5xoDDT+MAru8yLORuQINFAthm4KOhFY15tasZCmDDWa/UUiX7S69kMgfgA roiH2bbfRO4YJONlfEmcXI6qdqRs5GG3xKVNq0s2JA/PgaEpTNIX5R/r1Kt8nE2kgg5go8a8AIl L8= X-Received: by 2002:a05:6820:209:b0:688:6d55:189 with SMTP id 006d021491bc7-68a6a7b40aamr423338eaf.18.1775678553418; Wed, 08 Apr 2026 13:02:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:33 -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 17/36] dyndbg: replace classmap list with a vector Date: Wed, 8 Apr 2026 14:01:52 -0600 Message-ID: <20260408200211.43821-18-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: quoted-printable Content-Type: text/plain; charset="utf-8" Classmaps are stored in an elf section/array, but currently are individually list-linked onto dyndbg's per-module ddebug_table for operation. This is unnecessary. Just like dyndbg's descriptors, classes are packed in compile order; so even with many builtin modules employing multiple classmaps, each modules' maps are packed contiguously, and can be treated as a array-start-address & array-length. So this drops the whole list building operation done in ddebug_attach_module_classes(), and removes the list-head members. The "select-by-modname" condition is reused to find the start,end of the subrange. NOTE: This "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie at least one step closer to ddebug_init(2), which already splits up pr-debug descriptors into subranges by modname, then calls (1) on each. (2) knows nothing of classmaps currently, and doesn't need to. For now, just add comment. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 62 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 92627a03b4d1..9fd36339db52 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -84,7 +84,6 @@ enum class_map_type { }; =20 struct ddebug_class_map { - struct list_head link; struct module *mod; const char *mod_name; /* needed for builtins */ const char **class_names; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a18f4bc63473..94a66c8537ab 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,10 +45,11 @@ extern struct ddebug_class_map __start___dyndbg_classes= []; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 struct ddebug_table { - struct list_head link, maps; + struct list_head link; const char *mod_name; - unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct ddebug_class_map *classes; + unsigned int num_ddebugs, num_classes; }; =20 struct ddebug_query { @@ -149,12 +150,13 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) } =20 static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, - const char *class_string, int *class_id) + const char *class_string, + int *class_id) { struct ddebug_class_map *map; - int idx; + int i, idx; =20 - list_for_each_entry(map, &dt->maps, link) { + for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -165,7 +167,6 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return NULL; } =20 -#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -227,7 +228,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map =3D NULL; - int __outvar valid_class; + int valid_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -1134,9 +1135,10 @@ static void *ddebug_proc_next(struct seq_file *m, vo= id *p, loff_t *pos) =20 static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) { - struct ddebug_class_map *map; + struct ddebug_class_map *map =3D iter->table->classes; + int i, nc =3D iter->table->num_classes; =20 - list_for_each_entry(map, &iter->table->maps, link) + for (i =3D 0; i < nc; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1220,30 +1222,31 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, - struct ddebug_class_map *classes, - int num_classes) +static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { struct ddebug_class_map *cm; - int i, j, ct =3D 0; + int i, nc =3D 0; =20 - for (cm =3D classes, i =3D 0; i < num_classes; i++, cm++) { + /* + * Find this module's classmaps in a subrange/wholerange of + * the builtin/modular classmap vector/section. Save the start + * and length of the subrange at its edges. + */ + for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { =20 if (!strcmp(cm->mod_name, dt->mod_name)) { - - v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, - cm->mod_name, cm->base, cm->length, cm->map_type); - - for (j =3D 0; j < cm->length; j++) - v3pr_info(" %d: %d %s\n", j + cm->base, j, - cm->class_names[j]); - - list_add(&cm->link, &dt->maps); - ct++; + 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); + dt->classes =3D cm; + } + nc++; } } - if (ct) - vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); + if (nc) { + dt->num_classes =3D nc; + vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + } } =20 /* @@ -1275,10 +1278,9 @@ static int ddebug_add_module(struct _ddebug_info *di= , const char *modname) dt->num_ddebugs =3D di->num_descs; =20 INIT_LIST_HEAD(&dt->link); - INIT_LIST_HEAD(&dt->maps); =20 if (di->classes && di->num_classes) - ddebug_attach_module_classes(dt, di->classes, di->num_classes); + ddebug_attach_module_classes(dt, di); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1391,8 +1393,8 @@ static void ddebug_remove_all_tables(void) mutex_lock(&ddebug_lock); while (!list_empty(&ddebug_tables)) { struct ddebug_table *dt =3D list_entry(ddebug_tables.next, - struct ddebug_table, - link); + struct ddebug_table, + link); ddebug_table_free(dt); } mutex_unlock(&ddebug_lock); --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (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 A27563793AD for ; Wed, 8 Apr 2026 20:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; cv=none; b=Ka2z/j0tu6kHmsmymmlo2r9QGzji5lJrgXeVe3q4FU4jVLd9kQfGL6Ggw+4LE1YbIED8wP//Us+tJcXUpT6UgkqEDvWYgTmgP1mt956KNy6++k2Nz0em1RBy4hgP1WstXTGsmMJ5JFJfHhRjOF1GMj6bs//sdWQBWMZgmVvK7uI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; c=relaxed/simple; bh=S44qNaJnprSPGtSX9jhfIgwHHExOvS0QRFBglJsEsKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OaE0XsEc2K0lElxDgILi86api6li76qu/F9+TFruEIU/OQuIsOmf1O+bW3ckQIFYgKePaOiYulERNnuJtCcWjPoSwvfX6/eg3bD2gqx+GcsIV0G5s62NfMJYfP2xibszG/XKWdZ2nhwLcf6bVYNVKZkYhSUN5faU137Dp9SF6WI= 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=hf1xAs4n; arc=none smtp.client-ip=209.85.161.43 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="hf1xAs4n" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-68481c9e067so60744eaf.0 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=1775678554; x=1776283354; 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=R72DzlYh9MokOK1r/XXtR9MDuFmHujj2u63MvUuPRVY=; b=hf1xAs4nfDCER+ewQRgvy+R6OpDDmaVouGvz5Bo8gu/2+gdq+g6Gcx21KxxZZgkjj2 DBp+ZIRNeC/chFbEg72XvuvQHnwGNhAvtuTgShDqAYtKyEJGQyT6/kudGTbOidLVBBV7 dbrIh/47EebINomJUPTkAupuIMngb2hwp/583p995zMrnFX2VAHPBt5AReH1Q2MeFq5U m+77Bw/iDZFw8YT0Kc1lXA8jvqlFSDeeGplpUPqKofoKmToRhNDLiFRRWGfwjHfC196/ mrl2/LqK/JOZu+8GRrgqzyRm87nHHM1dLmF+oAbV614iWOC0xsQI2nrOqSqevhlY50ry d7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678554; x=1776283354; 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=R72DzlYh9MokOK1r/XXtR9MDuFmHujj2u63MvUuPRVY=; b=sgF2tQFxfZLNh33D7qls9TgZsQ15RRRgRWHXo64CBPa0obe9j0xspq0ylYPV7WnCIe uEW9O7gYhgRwccFfUYrKNNuNX0kgoEjmGjjgH4XEd3STJHaECxYjqyBCboIPiizEr30o mvc4p4os8bN+AmuKRWNqGf+3IVBOfVO37XQNeoazFXo8/7iM6GWeMZL2+gWCRAzYHnK1 7dJDTSn6hYAXxyVe/6fC0szy/CFGnj7Mks6S9qvJyuvmqjmf8DjJ/oTwAwUt2AH3cuzg uMRvzGaeMlnc18uvvTolCmWDGyCxu2FFpUCfx52Oygtx2qDj6/bB5Mf+NNnvwQsN+UaJ uV+A== X-Gm-Message-State: AOJu0Yx0zVADIm5UNYlx+HQPQee9+D2duZK8h+SV0XAfwvLphxGIWKnh BoJ8gryKSzJWhYkfaSYL+bGg/r7hxKN8sYAjBZwEpH8nnOtQl8sQ7vhcQ2ZpFA== X-Gm-Gg: AeBDievxwkZnagdBcVMwv/WOuXNjB44VbggKRYjw8QiCYsmqF/6M1Q9n/B/H+9xhtgT TmN42+vsj1+M/C85oTGpTSgCzViIoqWzs3H8/2vNv/ELxsTvY4a1loY9HMyuE7kJX9yy0cSzAJQ HYjj10DFBmBWUDqVkZ1BL57vVI90DAzZ1aGN7IKb1lwO/3M6c8cAF01SFT1u/Fu1a6kj9TB0tkj xhCI9ZnmK1akP4mZJoNTLbAQ5Hr9yrEiki5ev4x8mzD1yDc3bqh82IPvtOIpwdn+ChGBMqynzeF 4OEBpOTpQGgHpulRIfbgx2MLeOSVz9UXOqxc7JoOiWMbM7lsSIo7eRNBjsfYkVulrIzlRGFSlYn 6FD74Me9WHNJarNRnUEDbrUoF2YxWgZyJBOpkCA5hR8SAkAY6fJw9trElD25ag7on8YwGMqV+d4 S54djYJlsgvoig+P7JNwhu7P2yYKIJcM6ghTiQNZa00doIc1AMr6lMOq7pku9wPDXPLfc5tItcv ir1U4JQR9lTBQ== X-Received: by 2002:a05:6820:2908:b0:688:87fc:6dac with SMTP id 006d021491bc7-68a632c4cbfmr517678eaf.43.1775678554266; Wed, 08 Apr 2026 13:02:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:33 -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 18/36] dyndbg: macrofy a 2-index for-loop pattern Date: Wed, 8 Apr 2026 14:01:53 -0600 Message-ID: <20260408200211.43821-19-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: quoted-printable Content-Type: text/plain; charset="utf-8" dynamic-debug currently has 2 __sections (__dyndbg, __dyndb_classes), struct _ddebug_info keeps track of them both, with 2 members each: _vec and _vec#_len. We need to loop over these sections, with index and record pointer, making ref to both _vec and _vec_len. This is already fiddly and error-prone, and will get worse as we add a 3rd section. Lets instead embed/abstract the fiddly-ness in the `for_subvec()` macro, and avoid repeating it going forward. This is a for-loop macro expander, so it syntactically expects to precede either a single statement or a { block } of them, and the usual typeof or do-while-0 tricks are unavailable to fix the multiple-expansion warning. The macro needs a lot from its caller: it needs 2 local vars, 1 of which is a ref to a contained struct with named members. To support these requirements, add: 1. __ASSERT_IS_LVALUE(_X): ie: ((void)sizeof((void)0, &(x))) 2. __ASSERT_HAS_VEC_MEMBERS(_X, _Y): compile-time check that the _Y "vector" exists ie: _X->_Y and _X->num_##_Y are lvalues. The for_subvec() macro then invokes these in the initialization of the for-loop; they disappear at runtime. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 94a66c8537ab..8f614eba8ace 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -129,6 +129,28 @@ do { \ #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) #define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) =20 +/* + * simplify a repeated for-loop pattern walking N steps in a T _vec + * member inside a struct _box. It expects int i and T *_sp to be + * declared in the caller. + * @_i: caller provided counter. + * @_sp: cursor into _vec, to examine each item. + * @_box: ptr to a struct containing @_vec member + * @_vec: name of a member in @_box + */ +#define __ASSERT_IS_LVALUE(x) ((void)sizeof((void)0, &(x))) +#define __ASSERT_HAS_VEC_MEMBER(_box, _vec) \ + (void)sizeof((_box)->_vec + (_box)->num_##_vec) + +#define for_subvec(_i, _sp, _box, _vec) \ + for (__ASSERT_IS_LVALUE(_i), \ + __ASSERT_IS_LVALUE(_sp), \ + __ASSERT_HAS_VEC_MEMBER(_box, _vec), \ + (_i) =3D 0, \ + (_sp) =3D (_box)->_vec; \ + (_i) < (_box)->num_##_vec; \ + (_i)++, (_sp)++) /* { block } */ + static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { /* trim any trailing newlines */ @@ -156,7 +178,7 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons struct ddebug_class_map *map; int i, idx; =20 - for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { + for_subvec(i, map, dt, classes) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -1232,8 +1254,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { - + for_subvec(i, cm, di, classes) { if (!strcmp(cm->mod_name, dt->mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 898CE38F94A for ; Wed, 8 Apr 2026 20:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678561; cv=none; b=Urs9jHotIXDGib36A4w1taubtcuH7gW0L05Vm48+kw2UHV9JseuF/usKUt7LvD73he9NwGZZZyjsB1fU5G/E5eS2Hm2LoyntjSWMo1UorbSpVbkX77iunYMRzyzv/+Q4n0L+p+CTlRyGJiQrC3mf7sh8fI9old4STZk6ZHoBlCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678561; c=relaxed/simple; bh=3hfEX4bPIErfOAnk4GOb4hOzqvLmI/c9/6dXl4YdakM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uU1fnVpH7LchyF/EEVWyfeYJ/GyviqhepIp0oF4uYry017xd7VkBkMnAWqWpg/AFy9yJg4dWSCvaQZuikWLwqHQeNFGvtctcCYAlbuOLK+EmWus3Ha8T3yiKVQFN7gv4oDATIdXK7jYZHGgn+yWscz0EJrEYjhDcj9E9zbmLqek= 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=B6+BHATQ; arc=none smtp.client-ip=209.85.161.47 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="B6+BHATQ" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-66ee7b9af94so63024eaf.0 for ; Wed, 08 Apr 2026 13:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678555; x=1776283355; 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=zxXMt35u3X3VtMu3QbosUQTDTh3RhUOIrPQ9QC83BFo=; b=B6+BHATQ7+SK9bQfqn3QEWOfySEWYDsxP5auyl+v7lVr+a9DHDkZoqOBfsfNOnODKP lhGt6pEtFOW9CX7ytKtAyQ1p1r4ok1QJMTgG08ijwQlBRrZOu5ny/bJLUf3xZzHtxcyf XI91BChKCZ0d/nx28xslWjwJ69bZIDh31duzP2CmWv0oeKmYosIzPfGQefIjQkdul+Mc XP2sk6aaikMaCtaUS/DDYKHylFHPF3iWPZan17W1s03TKGucAi1i2J6ZSSXEs6XSyUKm r9mRekvLSKCgxXgeNuxWlIZ6sdYyCODeSqoRv1546YXcC4YznxySMIijQn/JJ/+llfJD dq6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678555; x=1776283355; 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=zxXMt35u3X3VtMu3QbosUQTDTh3RhUOIrPQ9QC83BFo=; b=TKKHRLxihKM8dJmkbs30Ot5476AiyPdpCLrm8r/wu8oCeypIWgCcaOU880E+Xj0zmW wQdR9X/Abdl5I4gXP4SDcMhfePPEaIu6wtrJ1Rkf4XmdMGIiAUL9RC2wbYvELyPRIA9u jHPTaE8o8Z7fMCC1m1kBEXWO2MBGzwsifMiJWxlltRs6j8UnfI5CXaGENIKuEGz71m/F ch1JWegjT1fYy4UH3F6e4YdYllk7CoZodelriYdPcIiVngWbdtQvmoUrqBeG8iEpVKHd YAN1nQMSm7BSZSTHt7BvaLihycARQ7oJ1M/bdxTSpUh/it106zXi78xHGtp9yVOu+1tm W3xw== X-Gm-Message-State: AOJu0YwXTji5V08bH0QLAl2lFZbq+OeVQV9h9dCQhL4EXnmNS1hmWKdH RQDQhrF8CFRemhSwDWY90Ju7pD6e/oHZ0A0WCsfURPjg2qHiMd4C+AbOV/2Giw== X-Gm-Gg: AeBDietTMx1VV4wKg/WKNsNDA3/ZeR0ucF8R7vw9cOCgwwAlDYzdivSt5wL6aOqDd0v AEoiY1/SdEHlVj6L4NW0d7X8PH5pIDekQKESZwN1rdsZcVG3vudSLEvoLmyIk7ZhZ0hFqB6DbVN 8hViUyeF9RaWXzvtCRq/QkaK+V0HgmsnkDhB+u8RNRvzyQ6gukA4FzuZxDqVIJghcsMv98n8bz1 CdFgBFuLmKSXkeHf9nzu7jVhmPOP8vwwy/l2cVfr2y5ImSzexnFkFOu4dAq/bfgnNXpN+2V18DE ipLIDhwkxRod+ufp8e7SHH4wsAiSom+FKb3IWnfMJ0dET3OvwwUaDKs15NgQ0ERM8xNK4iJohCS Nu7uiBNfiuu9mP35YzXG8bFMlqo/PFf18GjKui/L0FSWP0xZqFfRme0f2Rt35/Ar5ADLtVOGTSP xhM1uJ7UR9KPwGmIYtByzJ4Ux3g5vWTemNt0lNQ/LFt+uJ29BEAzSw5DTunCjABXKT+XCjxGW8M QIfY1TAEyIglg== X-Received: by 2002:a05:6820:825:b0:685:110:5572 with SMTP id 006d021491bc7-68501105943mr8485971eaf.29.1775678555115; 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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:34 -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 19/36] dyndbg,module: make proper substructs in _ddebug_info Date: Wed, 8 Apr 2026 14:01:54 -0600 Message-ID: <20260408200211.43821-20-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: quoted-printable Content-Type: text/plain; charset="utf-8" recompose struct _ddebug_info, inserting proper sub-structs. The struct _ddebug_info has 2 pairs of _vec, num_##_vec fields, for descs and classes respectively. for_subvec() makes walking these vectors less cumbersome, now lets move those field pairs into their own "vec" structs: _ddebug_descs & _ddebug_class_maps, and re-compose struct _ddebug_info to contain them cleanly. This also lets us get rid of for_subvec()'s num_##_vec paste-up. Also recompose struct ddebug_table to contain a _ddebug_info. This reinforces its use as a cursor into relevant data for a builtin module, and access to the full _ddebug state for modules. NOTES: Fixup names: Normalize all struct names to "struct _ddebug_*" eliminating the minor/stupid variations created in classmaps-v1. Modify __section names: __dyndbg to __dyndbg_descriptors, and __dyndbg_classes to __dyndbg_class_maps. This better matches the new struct names, and makes room for forthcoming _ddebug_class_user(s) structs and section. Invariant: These vectors ref a contiguous subrange of __section memory in builtin/DATA or in loadable modules via mod->dyndbg_info; with guaranteed life-time for us. struct module contains a _ddebug_info field and module/main.c sets it up, so that gets adjusted rather obviously. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/asm-generic/dyndbg.lds.h | 18 ++--- include/linux/dynamic_debug.h | 40 +++++++---- kernel/module/main.c | 12 ++-- lib/dynamic_debug.c | 120 +++++++++++++++---------------- lib/test_dynamic_debug.c | 2 +- 5 files changed, 103 insertions(+), 89 deletions(-) diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.= lds.h index f95683aa16b6..8345ac6c52b7 100644 --- a/include/asm-generic/dyndbg.lds.h +++ b/include/asm-generic/dyndbg.lds.h @@ -3,17 +3,19 @@ #define __ASM_GENERIC_DYNDBG_LDS_H =20 #include -#define DYNDBG_SECTIONS() \ - . =3D ALIGN(8); \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) +#define DYNDBG_SECTIONS() \ + . =3D ALIGN(8); \ + BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ + BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) =20 #define MOD_DYNDBG_SECTIONS() \ - __dyndbg : { \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + __dyndbg_descriptors : { \ + BOUNDED_SECTION_BY(__dyndbg_descriptors, \ + ___dyndbg_descs) \ } \ - __dyndbg_classes : { \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ + __dyndbg_class_maps : { \ + BOUNDED_SECTION_BY(__dyndbg_class_maps, \ + ___dyndbg_class_maps) \ } =20 #endif /* __ASM_GENERIC_DYNDBG_LDS_H */ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 9fd36339db52..5429315ada8e 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -83,8 +83,8 @@ enum class_map_type { */ }; =20 -struct ddebug_class_map { - struct module *mod; +struct _ddebug_class_map { + struct module *mod; /* NULL for builtins */ const char *mod_name; /* needed for builtins */ const char **class_names; const int length; @@ -92,21 +92,33 @@ struct ddebug_class_map { enum class_map_type map_type; }; =20 -/* encapsulate linker provided built-in (or module) dyndbg data */ +/* + * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * For builtins, it is used as a cursor, with the inner structs + * marking sub-vectors of the builtin __sections in DATA. + */ +struct _ddebug_descs { + struct _ddebug *start; + int len; +}; + +struct _ddebug_class_maps { + struct _ddebug_class_map *start; + int len; +}; + struct _ddebug_info { - struct _ddebug *descs; - struct ddebug_class_map *classes; - unsigned int num_descs; - unsigned int num_classes; + struct _ddebug_descs descs; + struct _ddebug_class_maps maps; }; =20 -struct ddebug_class_param { +struct _ddebug_class_param { union { unsigned long *bits; unsigned long *lvl; }; char flags[8]; - const struct ddebug_class_map *map; + const struct _ddebug_class_map *map; }; =20 /* @@ -125,8 +137,8 @@ struct ddebug_class_param { */ #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ - static struct ddebug_class_map __aligned(8) __used \ - __section("__dyndbg_classes") _var =3D { \ + static struct _ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_class_maps") _var =3D { \ .mod =3D THIS_MODULE, \ .mod_name =3D KBUILD_MODNAME, \ .base =3D _base, \ @@ -166,7 +178,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ - __section("__dyndbg") name =3D { \ + __section("__dyndbg_descriptors") name =3D { \ .modname =3D KBUILD_MODNAME, \ .function =3D __func__, \ .filename =3D __FILE__, \ @@ -253,7 +265,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * macro. */ #define _dynamic_func_call_cls(cls, fmt, func, ...) \ - __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS_= _) + __dynamic_func_call_cls(__UNIQUE_ID(_ddebug), cls, fmt, func, ##__VA_ARGS= __) #define _dynamic_func_call(fmt, func, ...) \ _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) =20 @@ -263,7 +275,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * with precisely the macro's varargs. */ #define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ - __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(_ddebug), cls, fmt, \ func, ##__VA_ARGS__) #define _dynamic_func_call_no_desc(fmt, func, ...) \ _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ diff --git a/kernel/module/main.c b/kernel/module/main.c index c3ce106c70af..a0fe6c7aab75 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2717,12 +2717,12 @@ static int find_module_sections(struct module *mod,= struct load_info *info) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); =20 #ifdef CONFIG_DYNAMIC_DEBUG_CORE - mod->dyndbg_info.descs =3D section_objs(info, "__dyndbg", - sizeof(*mod->dyndbg_info.descs), - &mod->dyndbg_info.num_descs); - mod->dyndbg_info.classes =3D section_objs(info, "__dyndbg_classes", - sizeof(*mod->dyndbg_info.classes), - &mod->dyndbg_info.num_classes); + mod->dyndbg_info.descs.start =3D section_objs(info, "__dyndbg_descriptors= ", + sizeof(*mod->dyndbg_info.descs.start), + &mod->dyndbg_info.descs.len); + mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", + sizeof(*mod->dyndbg_info.maps.start), + &mod->dyndbg_info.maps.len); #endif =20 return 0; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8f614eba8ace..f47fdb769d7a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -39,17 +39,15 @@ =20 #include =20 -extern struct _ddebug __start___dyndbg[]; -extern struct _ddebug __stop___dyndbg[]; -extern struct ddebug_class_map __start___dyndbg_classes[]; -extern struct ddebug_class_map __stop___dyndbg_classes[]; +extern struct _ddebug __start___dyndbg_descs[]; +extern struct _ddebug __stop___dyndbg_descs[]; +extern struct _ddebug_class_map __start___dyndbg_class_maps[]; +extern struct _ddebug_class_map __stop___dyndbg_class_maps[]; =20 struct ddebug_table { struct list_head link; const char *mod_name; - struct _ddebug *ddebugs; - struct ddebug_class_map *classes; - unsigned int num_ddebugs, num_classes; + struct _ddebug_info info; }; =20 struct ddebug_query { @@ -136,19 +134,19 @@ do { \ * @_i: caller provided counter. * @_sp: cursor into _vec, to examine each item. * @_box: ptr to a struct containing @_vec member - * @_vec: name of a member in @_box + * @_vec: name of a vector member in @_box */ #define __ASSERT_IS_LVALUE(x) ((void)sizeof((void)0, &(x))) #define __ASSERT_HAS_VEC_MEMBER(_box, _vec) \ - (void)sizeof((_box)->_vec + (_box)->num_##_vec) + ((void)sizeof((_box)->_vec.start + (_box)->_vec.len)) =20 #define for_subvec(_i, _sp, _box, _vec) \ for (__ASSERT_IS_LVALUE(_i), \ __ASSERT_IS_LVALUE(_sp), \ __ASSERT_HAS_VEC_MEMBER(_box, _vec), \ (_i) =3D 0, \ - (_sp) =3D (_box)->_vec; \ - (_i) < (_box)->num_##_vec; \ + (_sp) =3D (_box)->_vec.start; \ + (_i) < (_box)->_vec.len; \ (_i)++, (_sp)++) /* { block } */ =20 static void vpr_info_dq(const struct ddebug_query *query, const char *msg) @@ -171,14 +169,14 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, +static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, const char *class_string, int *class_id) { - struct ddebug_class_map *map; + struct _ddebug_class_map *map; int i, idx; =20 - for_subvec(i, map, dt, classes) { + for_subvec(i, map, &dt->info, maps) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -249,7 +247,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - struct ddebug_class_map *map =3D NULL; + struct _ddebug_class_map *map =3D NULL; int valid_class; =20 /* search for matching ddebugs */ @@ -270,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->num_ddebugs; i++) { - struct _ddebug *dp =3D &dt->ddebugs[i]; + for (i =3D 0; i < dt->info.descs.len; i++) { + struct _ddebug *dp =3D &dt->info.descs.start[i]; =20 if (!ddebug_match_desc(query, dp, valid_class)) continue; @@ -629,14 +627,14 @@ static int ddebug_exec_queries(char *query, const cha= r *modname) } =20 /* apply a new class-param setting */ -static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, +static int ddebug_apply_class_bitmap(const struct _ddebug_class_param *dcp, const unsigned long *new_bits, const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_map *map =3D dcp->map; int matches =3D 0; int bi, ct; =20 @@ -672,8 +670,8 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, /* accept comma-separated-list of [+-] classnames */ static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long curr_bits, old_bits; char *cl_str, *p, *tmp; int cls_id, totct =3D 0; @@ -743,8 +741,8 @@ static int param_set_dyndbg_module_classes(const char *= instr, const struct kernel_param *kp, const char *mod_name) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; =20 @@ -831,8 +829,8 @@ EXPORT_SYMBOL(param_set_dyndbg_classes); */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { =20 @@ -1083,8 +1081,8 @@ static struct _ddebug *ddebug_iter_first(struct ddebu= g_iter *iter) } iter->table =3D list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx =3D iter->table->num_ddebugs; - return &iter->table->ddebugs[--iter->idx]; + iter->idx =3D iter->table->info.descs.len; + return &iter->table->info.descs.start[--iter->idx]; } =20 /* @@ -1105,10 +1103,10 @@ static struct _ddebug *ddebug_iter_next(struct ddeb= ug_iter *iter) } iter->table =3D list_entry(iter->table->link.next, struct ddebug_table, link); - iter->idx =3D iter->table->num_ddebugs; + iter->idx =3D iter->table->info.descs.len; --iter->idx; } - return &iter->table->ddebugs[iter->idx]; + return &iter->table->info.descs.start[iter->idx]; } =20 /* @@ -1152,16 +1150,19 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) return dp; } =20 -#define class_in_range(class_id, map) \ - (class_id >=3D map->base && class_id < map->base + map->length) +static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +{ + return (class_id >=3D map->base && + class_id < map->base + map->length); +} =20 -static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) +static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddeb= ug *dp) { - struct ddebug_class_map *map =3D iter->table->classes; - int i, nc =3D iter->table->num_classes; + struct _ddebug_class_map *map; + int i; =20 - for (i =3D 0; i < nc; i++, map++) - if (class_in_range(dp->class_id, map)) + for_subvec(i, map, &dt->info, maps) + if (ddebug_class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 return NULL; @@ -1194,7 +1195,7 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) seq_putc(m, '"'); =20 if (dp->class_id !=3D _DPRINTK_CLASS_DFLT) { - class =3D ddebug_class_name(iter, dp); + class =3D ddebug_class_name(iter->table, dp); if (class) seq_printf(m, " class:%s", class); else @@ -1246,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) { - struct ddebug_class_map *cm; + struct _ddebug_class_map *cm; int i, nc =3D 0; =20 /* @@ -1254,18 +1255,18 @@ static void ddebug_attach_module_classes(struct dde= bug_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for_subvec(i, cm, di, classes) { + for_subvec(i, cm, di, maps) { if (!strcmp(cm->mod_name, dt->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); - dt->classes =3D cm; + dt->info.maps.start =3D cm; } nc++; } } if (nc) { - dt->num_classes =3D nc; + dt->info.maps.len =3D nc; vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); } } @@ -1278,10 +1279,10 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) { struct ddebug_table *dt; =20 - if (!di->num_descs) + if (!di->descs.len) return 0; =20 - v3pr_info("add-module: %s %d sites\n", modname, di->num_descs); + v3pr_info("add-module: %s %d sites\n", modname, di->descs.len); =20 dt =3D kzalloc_obj(*dt); if (dt =3D=3D NULL) { @@ -1295,19 +1296,18 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) * this struct ddebug_table. */ dt->mod_name =3D modname; - dt->ddebugs =3D di->descs; - dt->num_ddebugs =3D di->num_descs; + dt->info =3D *di; =20 INIT_LIST_HEAD(&dt->link); =20 - if (di->classes && di->num_classes) + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); + vpr_info("%3u debug prints in module %s\n", di->descs.len, modname); return 0; } =20 @@ -1454,10 +1454,10 @@ static int __init dynamic_debug_init(void) char *cmdline; =20 struct _ddebug_info di =3D { - .descs =3D __start___dyndbg, - .classes =3D __start___dyndbg_classes, - .num_descs =3D __stop___dyndbg - __start___dyndbg, - .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, + .descs.start =3D __start___dyndbg_descs, + .maps.start =3D __start___dyndbg_class_maps, + .descs.len =3D __stop___dyndbg_descs - __start___dyndbg_descs, + .maps.len =3D __stop___dyndbg_class_maps - __start___dyndbg_class_maps, }; =20 #ifdef CONFIG_MODULES @@ -1468,7 +1468,7 @@ static int __init dynamic_debug_init(void) } #endif /* CONFIG_MODULES */ =20 - if (&__start___dyndbg =3D=3D &__stop___dyndbg) { + if (&__start___dyndbg_descs =3D=3D &__stop___dyndbg_descs) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); return 1; @@ -1478,16 +1478,16 @@ static int __init dynamic_debug_init(void) return 0; } =20 - iter =3D iter_mod_start =3D __start___dyndbg; + iter =3D iter_mod_start =3D __start___dyndbg_descs; modname =3D iter->modname; i =3D mod_sites =3D mod_ct =3D 0; =20 - for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + for (; iter < __stop___dyndbg_descs; iter++, i++, mod_sites++) { =20 if (strcmp(modname, iter->modname)) { mod_ct++; - di.num_descs =3D mod_sites; - di.descs =3D iter_mod_start; + di.descs.len =3D mod_sites; + di.descs.start =3D iter_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1497,8 +1497,8 @@ static int __init dynamic_debug_init(void) iter_mod_start =3D iter; } } - di.num_descs =3D mod_sites; - di.descs =3D iter_mod_start; + di.descs.len =3D mod_sites; + di.descs.start =3D iter_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1508,8 +1508,8 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); =20 - if (di.num_classes) - v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + if (di.maps.len) + v2pr_info(" %d builtin ddebug class-maps\n", di.maps.len); =20 /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 396144cf351b..8434f70b51bb 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -41,7 +41,7 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 06= 00); */ #define DD_SYS_WRAP(_model, _flags) \ static unsigned long bits_##_model; \ - static struct ddebug_class_param _flags##_model =3D { \ + static struct _ddebug_class_param _flags##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 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: 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 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 26F3E362157 for ; Wed, 8 Apr 2026 20:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; cv=none; b=aV398y4LKGArGdv9MV8zIM/g3X4s2GNicSyfXEYu0L5viZM+wNDMi5BQ3qKiLvwqTeeH1YrlRTBAU4jSZ3aZ4cZ3qae8Vvm72CUfl6zWiVL4Dcix8PDaXIZJzSvPUN52U2355sjbh9QiFeL9PDdK1jVHT2CHvQw2L318yVdGhps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; c=relaxed/simple; bh=uocxdG/7/3dQ4Cvc1k0X43etAxjGMK8KCSQSXA4knnk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFnIUEP77AybKIZzyxzOJYAiZrdqyLEEw4QyZRLdQJwPbXosWhNRfW2+JWSenaiEAqMQu2z3Qt9uKU+zwBb5q35zyvleHUSoesGh6a14Jg0+wQx+UmZGuTEMwq9kZoGYOqbta3yFaXsTFaLWfZPDbwc40dRV1hMZFxUbbrWzlIw= 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=FWTtryTa; arc=none smtp.client-ip=209.85.161.41 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="FWTtryTa" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-67fdb2afaf5so81870eaf.1 for ; Wed, 08 Apr 2026 13:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678557; x=1776283357; 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=NLjFx8xvoYU6I9e8U5366NO9qUPUvtME5XDnhqfKA8c=; b=FWTtryTa5h0MXUA8sObx+DTXdgpAI7sKcquNLh1/sZGwDOjyf2FZ24AIkfRKxovCTz NGsxfNlnIK6K9Y5LZfOaClfGjlsQentohuJsHsj8q8I9U0igL0P6Z/EiVv83dj5d5Ett tXDI+QAt0LIQvRdOJFbP3ZWzq5zPlyd1VSpqozm6vhbHRXMCmrvQXh5ROrjoSWgwYq0G E0bB6JyF4W1a78uYSNdHrn5Ej8k98nBt4SMmbYOjQbzUmgBlWTJkVbpTgsVmvTnZ/W/T 0MOZZILQzuysxTWN4SPC2XFoDFPycIJzM5ZjLz00ABZQNv7DQrUW+QxHglXGtbyVpv07 nwSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678557; x=1776283357; 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=NLjFx8xvoYU6I9e8U5366NO9qUPUvtME5XDnhqfKA8c=; b=iKFap6u7RCH7nMG52W1lFNpZP6ifLRHjxFPH32PxdMLu0ReyeznicysA1F9xvdAo42 mphN46F9Cm+SCiKatfHEOu5K8HJjwa0lsj/mLzOSLuvhZd9hdCzYgdgoB235zOhYkmmL +QX/OspYg6YiKxHi5IjVVfoWWZkJdTjy6cz7KgMHpIHMtROr9WLIOqsK9hU7SBuGxYup LuSj5yLigo5XU5TKFBrOFQoLWl1Yw4vzGuFSsd3w2TjRnAA6wMSsvGSDEPPzj4PuMChL aqSt5VPUkvMjjO00PfsJ6jbtH7+jHeHA/XVNcMWTdOgbEclNd7e4c4La7ogAeHMakofB B3Rg== X-Gm-Message-State: AOJu0Yz7LS3RHydqkPvrhFl/twGGvBHoQk3xpY2ukjR9qquPNyjJE1Et nHrKgzTm4nybZN0rYZWs5KHe+M7cLZV19+ISc4lCNTiJrfrC0PJsNqo6Jdk8hA== X-Gm-Gg: AeBDiet2zj3lIYGnwwRWQpxL1ya6PBAoLZ1jH5O0+wVcytx/StC84q5A5YA+YFUS4TE JPEjaH36cEIsUbLqm4Z45ImLX44dHB2ccEJANimTCrn3bs54lUCBaCvt0fG6G79OkoEj1whGOvM sh1h5eCSy7CNrU3XhzjM20M3uU/WMwzgka9Xghi805dhO0HF7FLdm88ApUV2zY8ITzwoEaP6lPE NYB4M73p54TATfywwGkI/93R11Am2qTWW8a4XrIVV3VftGA8qeO4ydkOCgFSIWr4UJgjGQ9Dqvx LCHiuR88hPwL+g47T0WtsNEo2eKm/L6wXsYQJEZv9Nt4Xf13uB6zWlVwUKSzZP5S6+PbFFIPFjc jXO3ru5wmv+dgKvHXpilqxwMfSvuX1THfzIthCJZlhna/LLMjdaZRs2RkZTkk1D0L21d57P6Iu+ kGFk64KwG80K+PnlsNVJRE1lrH4Kh8tp/frWieoRG2BxWt6VPGyLJIKeBVKr2JTUypsnO3JON5o DU= X-Received: by 2002:a05:6820:190a:b0:67e:1c07:15fb with SMTP id 006d021491bc7-6822152e58bmr10022892eaf.52.1775678556811; Wed, 08 Apr 2026 13:02:36 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:36 -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 21/36] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Wed, 8 Apr 2026 14:01:56 -0600 Message-ID: <20260408200211.43821-22-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: quoted-printable Content-Type: text/plain; charset="utf-8" The body of ddebug_attach_module_classes() is dominated by a code-block that finds the contiguous subrange of classmaps matching on modname, and saves it into the ddebug_table's info record. Implement this block in a macro to accommodate different component vectors in the "box" (as named in the for_subvec macro). We will reuse this macro shortly. And hoist its invocation out of ddebug_attach_module_classes() up into ddebug_add_module(). This moves the filtering step up closer to dynamic_debug_init(), which already segments the builtin pr_debug descriptors on their mod_name boundaries. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- v10?- reordered params to match kdoc v12- refactor/rename: s/dd_mark_vector_subrange/dd_set_module_subrange/ 1. Renamed the macro from dd_mark_vector_subrange to dd_set_module_subrange to better reflect its purpose of narrowing a vector to a module-specific subrange. 2. Simplified the arguments by removing the redundant _dst, as the _di pointer already provides access to the target _ddebug_info struct. 3. Refactored for Clarity: Instead of overwriting the struct's start pointer while the for_subvec loop is using it to iterate, I introduced a temporary __start variable. This avoids the "subtle" side effect and makes the logic easier to follow. 4. Updated Documentation: Improved the comment block to explicitly state that the macro scans for the first match and counts contiguous elements. --- lib/dynamic_debug.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 21ba5cb3b406..443f0fd6e8c4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -169,8 +169,8 @@ static void vpr_info_dq(const struct ddebug_query *quer= y, const char *msg) } =20 static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) + const char *class_string, + int *class_id) { struct _ddebug_class_map *map; int i, idx; @@ -1271,6 +1271,35 @@ static void ddebug_attach_module_classes(struct ddeb= ug_table *dt, struct _ddebug } } =20 +/* + * Narrow a _ddebug_info's vector (@_vec) to the contiguous subrange + * of elements where ->mod_name matches @__di->mod_name. + * + * This scans the @_di->_vec for the first element matching the module + * name, and counts contiguous matches to define the subrange. + * + * @_i: caller-provided index var + * @_sp: cursor into @_vec + * @_di: pointer to the struct _ddebug_info to be narrowed + * @_vec: name of the vector member (must have .start and .len) + */ +#define dd_set_module_subrange(_i, _sp, _di, _vec) ({ \ + struct _ddebug_info *__di =3D (_di); \ + typeof(__di->_vec.start) __start =3D NULL; \ + int __nc =3D 0; \ + for_subvec(_i, _sp, __di, _vec) { \ + if (!strcmp((_sp)->mod_name, __di->mod_name)) { \ + if (!__nc++) \ + __start =3D (_sp); \ + } else if (__nc) { \ + break; /* end of consecutive matches */ \ + } \ + } \ + if (__nc) \ + __di->_vec.start =3D __start; \ + __di->_vec.len =3D __nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1278,6 +1307,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; =20 if (!di->descs.len) return 0; @@ -1299,6 +1330,8 @@ static int ddebug_add_module(struct _ddebug_info *di) =20 INIT_LIST_HEAD(&dt->link); =20 + dd_set_module_subrange(i, cm, &dt->info, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 EFA1D38F945 for ; Wed, 8 Apr 2026 20:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678562; cv=none; b=ICqMvsq11c1hHOpyPSjUDljxPyasfrrh0gh5bbiTE6L6zQmu93DlT41KjSXtw3ryGiaOhvOqE7DExSrlk81RihnentshdGm3/63a8hzlKrdA6JVSvnpkoZ45/BpUT+/2VlkQm1PPNSn3mDn8Ev5iJVnGAXEc0HAEBIDl6u0VjIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678562; c=relaxed/simple; bh=we58PLtiVwTc6e4YAUWE6VtDxVS3XfGSJjWb473Cgrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oLxRaofS2ks2LnVpOiZ7Y0Ppcky5iPLxu2GMLw218OaGGJZzApMs5ETy408ISxkCnBgHgeG7DUmobS7JnpleIQD1liVOsavyARg0nwMrKT27LuG/G5UvBzpIWZtKEB8pncZkvW+Tno9nacFOZ8Lh5ho0gW9UsVVxSMb6WhdI/k8= 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=NLhf7iUW; arc=none smtp.client-ip=209.85.161.42 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="NLhf7iUW" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-6841e6a5e51so82010eaf.3 for ; Wed, 08 Apr 2026 13:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678558; x=1776283358; 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=OQemtEriWFNTwe8i/pi3edXLDDfArgFSunjHJVzmDyM=; b=NLhf7iUW4ZyjVHjHSkhj0I0aEweDAsJ/DgQ/gDd6AOaOcCa5nWUU07vwdyacFX7vj1 7ml9FSrSyrkTpfR9q1rLlvvx/92RL4S9IKz7aqLvEErZtafKzdXhXWE6KF177Y/TnyNt CuR/lUKoxKui1hZN17yGjKi6/80MHpkcemxK89UOURW2rNuauDpPtolhj0cCPvYzPH2b c9w44yA3in0LQ66aZjrTQuxDg7iMA6KKa5gH5UlR7tIs3qmGnxrYjTyupY5tMLs/6wnR lFmqnF/wzlsCf/ut0n+eNqF8ZVs/UBIUEy6WfT2s6yIZlVdl7IwFQ7BFqV7dsLuVtz3B xEdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678558; x=1776283358; 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=OQemtEriWFNTwe8i/pi3edXLDDfArgFSunjHJVzmDyM=; b=sov8KlZPYYaMNIqJ/dTu2p6Ms7nMHfqB5vYANzOYN3UbGJ0KEoo22BNye/PO7DoC2p sZomaZPTMjQJhxZzlhhqVpuQAaVrbsIMuBIxLbPc5cO4naLNN+X5rt9ba/utZUkl1e3P o1Sw4x/a4mAAcUW0lvXmy02Q3fD9OxXM/ROvmHCZy71h29arkceBcu62SKBcpwqAkYOX jMB6b7XCUtqp0tIlXZjDiBfZpSrJmmUgJB/SsqI0mQZTNFZShpQSDrE40yVADK/trl3e T+bFVZep69m/qNndrCoR2Sy1B75de9Vr4zmlejwXyib89qw2BtHpUacQWnO1+pwj6OTr C3nA== X-Gm-Message-State: AOJu0YyY5aX/umR0CF4xPRzWtxQB3w8zP0DIBG0MBcrPxsCJSHDdQyJ0 nV1GuNsbNUanGonOypxOYTyO7RM/9uio3nZsKU7TEtql5VilrZTSMbLxXlC1pA== X-Gm-Gg: AeBDietDukuTWAB6o4zOSLfQ9eyvG7IVMsoU2cNANZrNYtX+3vpErucI5C3rOIWtq+2 3ghX7s9VgBMWAkprIg33WONCaM9Wogj7Wr9D5nDDcVYYUj6Qs/99/VkHT7GPzlqgO517VQxIeV7 VDJhiw8bnY3oQkr8Bj4vm1X0rHbvKZwe6g9zobvmU16NG6AyvIkDHBunjNaR06HcCjDihljNnOn ZqDL+FW0VwOLrM2COJuTel2CzZHcFiYTTedup5wU2YurBdDURlyMcMtNVyhnvNqeKmTr5Egrv8g QIpzUOuPBOV3wljTgEpskeMHSXISxkM8Wpf8YmJk5USPv08KpnkbU9K8Ec904r3wEjMWKgkZTig eKxCTsTqnuogS3RygZCNuM2hcpoMGRxaYN3/9SiC41MOOsEceVBmBa33ATX8A2zwg13HLnlO7K2 au126+WO0ENIM25SgyCTi+nnBPG40pGKZgp/7oftpINSx+I2Mm1jzdKJQziAmw8qj+DHfTyi4Hn 1A= X-Received: by 2002:a05:6820:81c1:b0:67e:160c:36b2 with SMTP id 006d021491bc7-68a61b65984mr573820eaf.28.1775678557756; Wed, 08 Apr 2026 13:02:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:37 -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 22/36] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Date: Wed, 8 Apr 2026 14:01:57 -0600 Message-ID: <20260408200211.43821-23-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: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the DD_CLASS_TYPE_*_NAMES classmap types and code. These 2 classmap types accept class names at the PARAM interface, for example: echo +DRM_UT_CORE,-DRM_UT_KMS > /sys/module/drm/parameters/debug_names The code works, but its only used by test-dynamic-debug, and wasn't asked for by anyone else, so reduce LOC & test-surface; simplify things. Also rename enum class_map_type to enum ddebug_class_map_type. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 23 ++------ lib/dynamic_debug.c | 102 +++------------------------------- lib/test_dynamic_debug.c | 26 --------- 3 files changed, 14 insertions(+), 137 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a262a9862f2b..3939b294c647 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -59,27 +59,16 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 -enum class_map_type { +enum ddebug_class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, /** - * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit. - * expecting hex input. Built for drm.debug, basis for other types. + * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, mapped to bits[0= ..N]. + * Expects hex input. Built for drm.debug, basis for other types. */ DD_CLASS_TYPE_LEVEL_NUM, /** - * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N. - * N turns on just bits N-1 .. 0, so N=3D0 turns all bits off. - */ - DD_CLASS_TYPE_DISJOINT_NAMES, - /** - * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES, - * classes are independent, like _DISJOINT_BITS. - */ - DD_CLASS_TYPE_LEVEL_NAMES, - /** - * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES, - * intended for names like: INFO,DEBUG,TRACE, with a module prefix - * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug + * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0..N. + * Input N turns on bits 0..N-1 */ }; =20 @@ -89,7 +78,7 @@ struct _ddebug_class_map { const char **class_names; const int length; const int base; /* index of 1st .class_id, allows split/shared space */ - enum class_map_type map_type; + enum ddebug_class_map_type map_type; }; =20 /* diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 443f0fd6e8c4..b8983e095e60 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -667,76 +667,6 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 -/* accept comma-separated-list of [+-] classnames */ -static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) -{ - const struct _ddebug_class_param *dcp =3D kp->arg; - const struct _ddebug_class_map *map =3D dcp->map; - unsigned long curr_bits, old_bits; - char *cl_str, *p, *tmp; - int cls_id, totct =3D 0; - bool wanted; - - cl_str =3D tmp =3D kstrdup_and_replace(instr, '\n', '\0', GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - /* start with previously set state-bits, then modify */ - curr_bits =3D old_bits =3D *dcp->bits; - vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); - - for (; cl_str; cl_str =3D p) { - p =3D strchr(cl_str, ','); - if (p) - *p++ =3D '\0'; - - if (*cl_str =3D=3D '-') { - wanted =3D false; - cl_str++; - } else { - wanted =3D true; - if (*cl_str =3D=3D '+') - cl_str++; - } - cls_id =3D match_string(map->class_names, map->length, cl_str); - if (cls_id < 0) { - pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); - continue; - } - - /* have one or more valid class_ids of one *_NAMES type */ - switch (map->map_type) { - case DD_CLASS_TYPE_DISJOINT_NAMES: - /* the +/- pertains to a single bit */ - if (test_bit(cls_id, &curr_bits) =3D=3D wanted) { - v3pr_info("no change on %s\n", cl_str); - continue; - } - curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); - *dcp->bits =3D curr_bits; - v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, - map->class_names[cls_id]); - break; - case DD_CLASS_TYPE_LEVEL_NAMES: - /* cls_id =3D N in 0..max. wanted +/- determines N or N-1 */ - old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); - curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); - - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); - *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); - v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, - map->class_names[cls_id], old_bits, curr_bits); - break; - default: - pr_err("illegal map-type value %d\n", map->map_type); - } - } - kfree(tmp); - vpr_info("total matches: %d\n", totct); - return 0; -} - static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -745,29 +675,17 @@ static int param_set_dyndbg_module_classes(const char= *instr, const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; - - switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: - case DD_CLASS_TYPE_LEVEL_NAMES: - /* handle [+-]classnames list separately, we are done here */ - return param_set_dyndbg_classnames(instr, kp); - - case DD_CLASS_TYPE_DISJOINT_BITS: - case DD_CLASS_TYPE_LEVEL_NUM: - /* numeric input, accept and fall-thru */ - rc =3D kstrtoul(instr, 0, &inrep); - if (rc) { - pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); - return -EINVAL; - } - break; - default: - pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + char *nl; + + rc =3D kstrtoul(instr, 0, &inrep); + if (rc) { + nl =3D strchr(instr, '\n'); + if (nl) + *nl =3D '\0'; + pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } =20 - /* only _BITS,_NUM (numeric) map-types get here */ switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: /* expect bits. mask and warn if too many */ @@ -833,12 +751,8 @@ int param_get_dyndbg_classes(char *buffer, const struc= t kernel_param *kp) const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: case DD_CLASS_TYPE_DISJOINT_BITS: return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); - - case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 8434f70b51bb..9c3e53cd26bd 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -74,13 +74,6 @@ DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE= _DISJOINT_BITS, 0, DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 -/* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 10, MID, HI }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, - "LOW", "MID", "HI"); -DD_SYS_WRAP(disjoint_names, p); -DD_SYS_WRAP(disjoint_names, T); - /* numeric verbosity, V2 > V1 related */ enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, @@ -88,13 +81,6 @@ DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEV= EL_NUM, 14, DD_SYS_WRAP(level_num, p); DD_SYS_WRAP(level_num, T); =20 -/* symbolic verbosity */ -enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, - "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); -DD_SYS_WRAP(level_names, p); -DD_SYS_WRAP(level_names, T); - /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 @@ -102,10 +88,6 @@ static void do_cats(void) { pr_debug("doing categories\n"); =20 - prdbg(LOW); - prdbg(MID); - prdbg(HI); - prdbg(D2_CORE); prdbg(D2_DRIVER); prdbg(D2_KMS); @@ -129,14 +111,6 @@ static void do_levels(void) prdbg(V5); prdbg(V6); prdbg(V7); - - prdbg(L1); - prdbg(L2); - prdbg(L3); - prdbg(L4); - prdbg(L5); - prdbg(L6); - prdbg(L7); } =20 static void do_prints(void) --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 E7599387583 for ; Wed, 8 Apr 2026 20:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678567; cv=none; b=aCugLOaIA+NC3F9/8RggGUzlFoJ+1tDnhYWgPIFsw9GGc+P71BEfkv/MiHvLhdfvcSXzUIE8GclWmaKycla8yfyxePqY4QsvNc7xWXMA6VP9A2PM7kVgzlkTQUfC+L28PmQYf4uDMeKdKK7iGKDrokJA7j8d2ywQnx7vd6A2f9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678567; c=relaxed/simple; bh=E58YzPGQP8pIRFsrSo5ywgYdgTvChl1tGOXYYXpMjsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HB6e63vuP8jNMg3N57l5gKGTxVZp3vN4EO2l7i2I0UV6llg3EHMh0+rxi4c50DiMEaPrzRIP5kzoyMwowWnzJ1atgF4cp4104hjH3LBh+wa3b9RtjDuGS3nGzseWrl1vsRlrFqfgasXyMKxkCvxlv+RMTWgW6K4Y2e9KX7aZHlk= 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=qQmcLce1; arc=none smtp.client-ip=209.85.161.47 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="qQmcLce1" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-688a8e5fc1cso93930eaf.1 for ; Wed, 08 Apr 2026 13:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678559; x=1776283359; 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=W1s25N4HphKkSAcYYGv0RU+9Yoh6i7m+AUfER/7BZBM=; b=qQmcLce1Zd5N8G44QLG4TpfvSbB/5zncrJ/JJUtrD8uA04LfQ9r6f84g/rceuXesDX lmGvakS6YKJziH9B0UVJVaXcNNuN8tECtOzk/vQFzDs6JnnByxVAGn+yLmu/+yCgwhdx 0S6AJGurhja3rg5cnCcJ7qAPboCm14k/+S0dfOsz7LQrWpKy489GMbQYO0pnXjGYJYcP rDxPniH/W/MGtsaF6JeLsI7kAs0Buj9isdT8Sgaq9HjiqY1qNEg9JKYYMP/N/ZBBM/Mo Bvj5aZM/ceNZ4V5QIXWwhLh/PGYytySbwJdNU8gflXEgJf5O4yHyy4zcWrUUoMVuwTd3 baHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678559; x=1776283359; 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=W1s25N4HphKkSAcYYGv0RU+9Yoh6i7m+AUfER/7BZBM=; b=rJhXIvfkKE+4YybCC1FdgkKwgetuJt3DOafiSMWlO1uKhe4kR4+G8MNjrVAc3vegPH FXGD81NKwCPRTckTTZ2M11X7mLvyRE1RYMH4n1UPTUlSCPU5thC1yFlxS6yTL9GhYGIH gOSisM9nzMEZHhLhfHwdIR+I+2ba6X20AxAc52xYEVwOC/4SJo/Nx082cYKpnVRSgt5G nskGKdtNs2nmxdaj/S7L/i1922J9yzF0z4qg5JApFOZPT66kPA8h5DIzGRgl9+DTutGE NpqxrANQx24fnQFJmJvJjJI2Efc8nxIpv38iec6kUeflW/NI1ikEtKWBbbUq4gI3c4HD OpcA== X-Gm-Message-State: AOJu0Yw84KpSMfwCq3WvGh2x/zMGig6CkyS3YztbwAC+4sKy6ql2GZED 6JktaAFrDW+/gmXB36xuFeGEwSfQ7SkgvaJ9q3CarZXLBwiqeXV+t1GZPcop7g== X-Gm-Gg: AeBDievIWZMVk2HTPIW1SFndiEJyVCqZg5UkMqH32CJ5mMTfFavN6cL8YDCSOW41gan n4+9c2lTgSUdW7qhSQw/v8WHzfNNs9rbPW0oGVJhPznVEAaelT5eLTjhpzn8+XNAX8+p3chrzrx 12Lun+U8de7HJzEnvmx8yajL4susMiWVGH6JPCnF3OHzRbYDQlZZipCO5MjRtejn8jc1XoIxo5s Mdi3IT1Gq8Jfnk6q+IXeP3dH0n2ujUSUttENKy3yPCGnuPoBwgD8vJW0ee36aQVIB7lyr7db71j jzs8FuRT5m+AcMypJBAefrLY9CP1T0Z6PW6DBp0lFPKAyUuINIcXOYCjpVAFzbjquOTDjLVqXeM jAWwfqXbn1NDH8pZ3iJrWofDp+UbxqJmSueIIMdkVrkby9jv3QTgHL2aBXWbZThLpY/qk2a5hOs 4PkjgThdu9W+ttUYYQcXUGul05Nl+t6+O0OTEHQO/3qNLTTziyLPB9nCnOBWP0BHWZvpsufs0nD Io= X-Received: by 2002:a05:6820:168b:b0:68a:678f:4331 with SMTP id 006d021491bc7-68a678f449fmr504091eaf.59.1775678558662; Wed, 08 Apr 2026 13:02:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:38 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , =?UTF-8?q?=C5=81ukasz=20Bartosik?= Subject: [PATCH v13 23/36] selftests-dyndbg: add a dynamic_debug run_tests target Date: Wed, 8 Apr 2026 14:01:58 -0600 Message-ID: <20260408200211.43821-24-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a selftest script for dynamic-debug. The config requires CONFIG_TEST_DYNAMIC_DEBUG=3Dm and CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm, which tacitly requires either CONFIG_DYNAMIC_DEBUG=3Dy or CONFIG_DYNAMIC_DEBUG_CORE=3Dy ATM this has just basic_tests(), which modify pr_debug() flags in the builtin params module. This means they're available to manipulate and observe the effects in "cat control". This is backported from another feature branch; the support-fns (thx Lukas) have unused features at the moment, they'll get used shortly. The script enables simple virtme-ng testing: [jimc@gandalf b0-ftrace]$ vrun_t virtme-ng 1.32+115.g07b109d doing: vng --name v6.14-rc4-60-gd5f48427de0c \ --user root -v -p 4 -a dynamic_debug.verbose=3D3 V=3D1 \ -- ../tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh virtme: waiting for virtiofsd to start .. And add dynamic_debug to TARGETS, so `make run_tests` sees it properly For the impatient, set TARGETS explicitly: [root@v6 selftests]# make TARGETS=3Ddynamic_debug run_tests make[1]: Nothing to be done for 'all'. TAP version 13 1..1 # timeout set to 45 # selftests: dynamic_debug: dyndbg_selftest.sh # # BASIC_TESTS 95.422122] dyndbg: query 0: 0"=3D_" mod:* ... NOTES check KCONFIG_CONFIG to avoid silly fails Several tests are dependent upon config choices. Lets avoid failing where that is noise. The KCONFIG_CONFIG var exists to convey the config-file around. If the var names a file, read it and extract the relevant CONFIG items, and use them to skip the dependent tests, thus avoiding the fails that would follow, and the disruption to whatever CI is running these selftests. If the envar doesn't name a config-file, ".config" is assumed. CONFIG_DYNAMIC_DEBUG=3Dy: basic-tests() and comma-terminator-tests() test for the presence of the builtin pr_debugs in module/main.c, which I deemed stable and therefore safe to count. That said, the test fails if only CONFIG_DYNAMIC_DEBUG_CORE=3Dy is set. It could be rewritten to test against test-dynamic-debug.ko, but that just trades one config dependence for another. CONFIG_TEST_DYNAMIC_DEBUG=3Dm As written, test_percent_splitting() modprobes test_dynamic_debug, enables several classes, and counts them. It could be re-written to work for the builtin module also, but builtin test modules are not a common or desirable build/config. Reviewed-by: Louis Chauvet Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik Signed-off-by: Jim Cromie --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + .../testing/selftests/dynamic_debug/Makefile | 9 + tools/testing/selftests/dynamic_debug/config | 7 + .../dynamic_debug/dyndbg_selftest.sh | 257 ++++++++++++++++++ 5 files changed, 275 insertions(+) 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 diff --git a/MAINTAINERS b/MAINTAINERS index c3fe46d7c4bc..0f4c2f182d63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9035,6 +9035,7 @@ S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c +F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Mak= efile index 450f13ba4cca..e4fc4dd80cf9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -27,6 +27,7 @@ TARGETS +=3D drivers/net/team TARGETS +=3D drivers/net/virtio_net TARGETS +=3D drivers/platform/x86/intel/ifs TARGETS +=3D dt +TARGETS +=3D dynamic_debug TARGETS +=3D efivarfs TARGETS +=3D exec TARGETS +=3D fchmodat2 diff --git a/tools/testing/selftests/dynamic_debug/Makefile b/tools/testing= /selftests/dynamic_debug/Makefile new file mode 100644 index 000000000000..6d06fa7f1040 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# borrowed from Makefile for user memory selftests + +# No binaries, but make sure arg-less "make" doesn't trigger "run_tests" +all: + +TEST_PROGS :=3D dyndbg_selftest.sh + +include ../lib.mk diff --git a/tools/testing/selftests/dynamic_debug/config b/tools/testing/s= elftests/dynamic_debug/config new file mode 100644 index 000000000000..0f906ff53908 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/config @@ -0,0 +1,7 @@ + +# basic tests ref the builtin params module +CONFIG_DYNAMIC_DEBUG=3Dm + +# more testing is possible with these +# CONFIG_TEST_DYNAMIC_DEBUG=3Dm +# CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh new file mode 100755 index 000000000000..465fad3f392c --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -0,0 +1,257 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +V=3D${V:=3D0} # invoke as V=3D1 $0 for global verbose +RED=3D"\033[0;31m" +GREEN=3D"\033[0;32m" +YELLOW=3D"\033[0;33m" +BLUE=3D"\033[0;34m" +MAGENTA=3D"\033[0;35m" +CYAN=3D"\033[0;36m" +NC=3D"\033[0;0m" +error_msg=3D"" + +[ -e /proc/dynamic_debug/control ] || { + echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=3Dy ${NC}" + exit 0 # nothing to test here, no good reason to fail. +} + +# need info to avoid failures due to untestable configs + +[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=3D".config" +if [ -f "$KCONFIG_CONFIG" ]; then + echo "# consulting KCONFIG_CONFIG: $KCONFIG_CONFIG" + grep -q "CONFIG_DYNAMIC_DEBUG=3Dy" $KCONFIG_CONFIG ; LACK_DD_BUILTIN= =3D$? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG=3Dm" $KCONFIG_CONFIG ; LACK_TMOD=3D= $? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm" $KCONFIG_CONFIG ; LACK_= TMOD_SUBMOD=3D$? + if [ $V -eq 1 ]; then + echo LACK_DD_BUILTIN: $LACK_DD_BUILTIN + echo LACK_TMOD: $LACK_TMOD + echo LACK_TMOD_SUBMOD: $LACK_TMOD_SUBMOD + fi +else + LACK_DD_BUILTIN=3D0 + LACK_TMOD=3D0 + LACK_TMOD_SUBMOD=3D0 +fi + +function vx () { + echo $1 > /sys/module/dynamic_debug/parameters/verbose +} + +function ddgrep () { + grep $1 /proc/dynamic_debug/control +} + +function doprints () { + cat /sys/module/test_dynamic_debug/parameters/do_prints +} + +function ddcmd () { + exp_exit_code=3D0 + num_args=3D$# + if [ "${@:$#}" =3D "pass" ]; then + num_args=3D$#-1 + elif [ "${@:$#}" =3D "fail" ]; then + num_args=3D$#-1 + exp_exit_code=3D1 + fi + args=3D${@:1:$num_args} + output=3D$((echo "$args" > /proc/dynamic_debug/control) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 5 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function handle_exit_code() { + local exp_exit_code=3D0 + [ $# =3D=3D 4 ] && exp_exit_code=3D$4 + if [ $3 -ne $exp_exit_code ]; then + echo -e "${RED}: $BASH_SOURCE:$1 $2() expected to exit with code $= exp_exit_code" + [ $3 =3D=3D 1 ] && echo "Error: '$error_msg'" + exit + fi +} + +# $1 - pattern to match, pattern in $1 is enclosed by spaces for a match "= "\s$1\s" +# $2 - number of times the pattern passed in $1 is expected to match +# $3 - optional can be set either to "-r" or "-v" +# "-r" means relaxed matching in this case pattern provided in $1 is= passed +# as is without enclosing it with spaces +# "-v" prints matching lines +# $4 - optional when $3 is set to "-r" then $4 can be used to pass "-v" +function check_match_ct { + pattern=3D"\s$1\s" + exp_cnt=3D0 + + [ "$3" =3D=3D "-r" ] && pattern=3D"$1" + let cnt=3D$(ddgrep "$pattern" | wc -l) + if [ $V -eq 1 ] || [ "$3" =3D=3D "-v" ] || [ "$4" =3D=3D "-v" ]; then + echo -ne "${BLUE}" && ddgrep $pattern && echo -ne "${NC}" + fi + [ $# -gt 1 ] && exp_cnt=3D$2 + if [ $cnt -ne $exp_cnt ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO check failed expected $= exp_cnt on $1, got $cnt" + exit + else + echo ": $cnt matches on $1" + fi +} + +# $1 - trace instance name +# #2 - if > 0 then directory is expected to exist, if <=3D 0 then otherwise +# $3 - "-v" for verbose +function check_trace_instance_dir { + if [ -e /sys/kernel/tracing/instances/$1 ]; then + if [ "$3" =3D=3D "-v" ] ; then + echo "ls -l /sys/kernel/tracing/instances/$1: " + ls -l /sys/kernel/tracing/instances/$1 + fi + if [ $2 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does exist" + exit + fi + else + if [ $2 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does not exist" + exit + fi + fi +} + +function tmark { + echo $* > /sys/kernel/tracing/trace_marker +} + +# $1 - trace instance name +# $2 - line number +# $3 - if > 0 then the instance is expected to be opened, otherwise +# the instance is expected to be closed +function check_trace_instance { + output=3D$(tail -n9 /proc/dynamic_debug/control | grep ": Opened trace= instances" \ + | xargs -n1 | grep $1) + if [ "$output" !=3D $1 ] && [ $3 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not opened" + exit + fi + if [ "$output" =3D=3D $1 ] && [ $3 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not closed" + exit + fi +} + +function is_trace_instance_opened { + check_trace_instance $1 $BASH_LINENO 1 +} + +function is_trace_instance_closed { + check_trace_instance $1 $BASH_LINENO 0 +} + +# $1 - trace instance directory to delete +# $2 - if > 0 then directory is expected to be deleted successfully, if <= =3D 0 then otherwise +function del_trace_instance_dir() { + exp_exit_code=3D1 + [ $2 -gt 0 ] && exp_exit_code=3D0 + output=3D$((rmdir /sys/kernel/debug/tracing/instances/$1) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 3 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function error_log_ref { + # to show what I got + : echo "# error-log-ref: $1" + : echo cat \$2 +} + +function ifrmmod { + lsmod | grep $1 2>&1>/dev/null && rmmod $1 +} + +# $1 - text to search for +function search_trace() { + search_trace_name 0 1 $1 +} + +# $1 - trace instance name, 0 for global event trace +# $2 - line number counting from the bottom +# $3 - text to search for +function search_trace_name() { + if [ "$1" =3D "0" ]; then + buf=3D$(cat /sys/kernel/debug/tracing/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/trace | head -1 | sed -e = 's/^[[:space:]]*//') + else + buf=3D$(cat /sys/kernel/debug/tracing/instances/$1/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/instances/$1/trace | head= -1 | \ + sed -e 's/^[[:space:]]*//') + fi + if [ $2 =3D 0 ]; then + # whole-buf check + output=3D$(echo $buf | grep "$3") + else + output=3D$(echo $line | grep "$3") + fi + if [ "$output" =3D "" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO search for '$3' fai= led \ + in line '$line' or '$buf'" + exit + fi + if [ $V =3D 1 ]; then + echo -e "${MAGENTA}: search_trace_name in $1 found: \n$output \nin:${= BLUE} $buf ${NC}" + fi +} + +# $1 - error message to check +function check_err_msg() { + if [ "$error_msg" !=3D "$1" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error message '$error_m= sg' \ + does not match with '$1'" + exit + fi +} + +function basic_tests { + echo -e "${GREEN}# BASIC_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP" + return + fi + ddcmd =3D_ # zero everything + check_match_ct =3Dp 0 + + # module params are builtin to handle boot args + check_match_ct '\[params\]' 4 -r + ddcmd module params +mpf + check_match_ct =3Dpmf 4 + + # multi-cmd input, newline separated, with embedded comments + cat <<"EOF" > /proc/dynamic_debug/control + module params =3D_ # clear params + module params +mf # set flags + module params func parse_args +sl # other flags +EOF + check_match_ct =3Dmf 3 + check_match_ct =3Dmfsl 1 + ddcmd =3D_ +} + +tests_list=3D( + basic_tests +) + +# Run tests + +ifrmmod test_dynamic_debug_submod +ifrmmod test_dynamic_debug + +for test in "${tests_list[@]}" +do + $test + echo "" +done +echo -en "${GREEN}# Done on: " +date +echo -en "${NC}" --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 7CEFA3909BD for ; Wed, 8 Apr 2026 20:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678564; cv=none; b=KtAbejnMEPMbueHePpkTsQr7F/cHXffaO4XUP4wDSXu1ZrCi+umMBNzHyW1rIFe+Zim1TGs0zhmfxM48LC0FBGAf31JqVYyAeHGhbKfJwPLz9mpBOK/Zzp0SOmOSWb/lmbABvofirgSlYAz6pcEBXVSvxmkzEDsHbEjjKe2+KI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678564; c=relaxed/simple; bh=hIKjF0ZA4fn0lNnk1oWbQpUQeAju5ZRz2ynTKZbuZAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H2bDJ4VM43Jcsasij0Z9EnjqVwv+rpEpikNikfQCJpprpFjYHtgAhjdtdgh5NdVBa720d4dJNSLI5ZjKnlTMuPswdtUpO3Zd+g173mxwCE1uX296wsRQNE2LWMsrostWB5FGFJQHqlM8kRSIYufOIJlpQEcfg9lKiwVWc8wQeqg= 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=pI/EYs0n; arc=none smtp.client-ip=209.85.161.48 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="pI/EYs0n" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-688c2235cd4so92953eaf.0 for ; Wed, 08 Apr 2026 13:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678559; x=1776283359; 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=BtzYjTItScPv3ZPv5u0hQB8QpwmveJQikTbqnzcN8xo=; b=pI/EYs0nClUhdoFRzvla5H02AvimbAECOW8ssvPsRXdHJkF9mi+Yq8x6GIxVM28iz9 cpwhBU5FyMiN4NgbD/gV8XtLOez4jJtrsbGCP/2Pz8Er2dOSTYVFnlkdRoG6yi6bLH3j fgudGYAErVI4DIR55P/93iRcOt1fm7uiyG3Ibc946oOxYYyRkeOGjuYSsbIpUO3pGo6n BbH6PXO3sigvC6u05sNl8M3t57pPqhk3uOGtimf+HJzhEe6nbqgyqvvcnVYCnd5QV+Hh rqZBi1pq0BaIDryRpbUiZXAYcgbHlfcN3atVJCIPstW7RQEp0GiLsNn12ZED9aGk69Cl v3VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678559; x=1776283359; 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=BtzYjTItScPv3ZPv5u0hQB8QpwmveJQikTbqnzcN8xo=; b=LjUkBSMbmYGjbiX94h1G0LtA6JsCZEgG4qITmTwKYu6PXxBF4BXbIIcaRzqWhk8knm PWtkL0yllD/F41KzcPb1V9DxmWEi4nGaXsAcgBrre9pFNDA+fN7e+RukHnVycUBvZfed 60SCipOfvv5p4SDVq5Th8f62p4sw0Tx5lDIpICSyoLuRk42Jxk7VxnJZUN4KoAWcYnnh gT3aTH7TIpzc/CLMPup2vIa0Jcsv/4aJaDm/MCIdKCUbzuP9V4TjOGSvcBctT8b9NaJk MrUViDq9jOuqllUlkc3dAt0SpOQgsfnSTh29RBuD0q54rD+qclR//vYSjvfOHIGvHsjq aHLg== X-Gm-Message-State: AOJu0YxPVF+xHGPmHBIKVVPnYY/2q/Jx7WHszq8YMl8b5UWIqN7iOIVL KZAc8/O+HxmS3LTmB9w2uFdNs5Mk68FPOAzSDiTr8gB08JvfnFxY5ZPubFMjvA== X-Gm-Gg: AeBDieuYp6ipF65Y+J/BRPiFkXHk0dfFxd/yui7vxdkzZ7dREsQ7wGpS9Ll/363DknM k8ZDRV6ughgQihC69Ja+KawAtBCzASvsGdrx54ynTrnKEJZ+Ld1FIVxLvzfFZJwR6c7UpZ4eWcb r461yg2Y0KJoOBJUWlJGd7LZ1Wi7t8uK6Z3EFYSomakWViJ//yLh3Y2B7tZLPP6JD0nlLBcu0fe TXdr/K5ARTDBYQqMFisW74dcsm5SDkHRXRBGAv5iTZp6WXdGD9lWDWOQ7B3J11cRsCgrPb6OYeV Hul9Z9DgBM5wqLfvSc0FHv18K9PWxEjBJCrf21cZeFW0owxgCe6QEC211Qey5We3Ne1WG0I5ItJ ds3niqKU7t0yLOSxFCtGY2jmkqRIQ82yt5EpyX1ChbUqypH3v5OltMDmcPQOCqYegnw555aA5dn RTTL7LRCnUk2PVhvu2HGn76jNvq7ZiOmaLDkvaWlGUTg5irx60AG5FMhqcPiFwhTIm2pa8buqbt So= X-Received: by 2002:a05:6820:4b0b:b0:680:1a99:6be2 with SMTP id 006d021491bc7-6821a03c4c9mr12101836eaf.0.1775678559490; Wed, 08 Apr 2026 13:02:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:39 -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 24/36] dyndbg: change __dynamic_func_call_cls* macros into expressions Date: Wed, 8 Apr 2026 14:01:59 -0600 Message-ID: <20260408200211.43821-25-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: quoted-printable Content-Type: text/plain; charset="utf-8" The Xe driver's XE_IOCTL_DBG macro calls drm_dbg() from inside an if (expression). This breaks when CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy because the invoked macro has a do-while-0 wrapper, and is not an expression. if (cond && (drm_dbg("expr-form"),1)) { ... do some more stuff } Fix for this usage by changing __dynamic_func_call_cls{,_no_desc} macros into expressions, by replacing the do-while-0s with a ({ }) wrapper. In the common usage, the trailing ';' converts the expression into a statement. drm_dbg("statement form"); Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 3939b294c647..33291abd8971 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -224,24 +224,24 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * (|_cls): adds in _DPRINT_CLASS_DFLT as needed * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) */ -#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) ({ \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) { \ func(&id, ##__VA_ARGS__); \ __dynamic_dump_stack(id); \ } \ -} while (0) +}) #define __dynamic_func_call(id, fmt, func, ...) \ __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ func, ##__VA_ARGS__) =20 -#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ +#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) ({ \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) { \ func(__VA_ARGS__); \ __dynamic_dump_stack(id); \ } \ -} while (0) +}) #define __dynamic_func_call_no_desc(id, fmt, func, ...) \ __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ fmt, func, ##__VA_ARGS__) --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 7F0E73909BF for ; Wed, 8 Apr 2026 20:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678566; cv=none; b=ZBImREhofirOO+or8B7p4mnJ8F5kg4GC2udNHvVc3EqnBfqljP/aJMBVIgghkVEZzTHzsU2+MidCJ/PzFmoj35uKIZRZtfTQTYy2ooElTIBv3pWtf3djjvDE3oOhkcmJ1I+sN0Ae1l/DZd41jv60kqdQRuFW0+UNtPU/O0na5C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678566; c=relaxed/simple; bh=AQZj8vYeMLdLY+upt1XmMAmGk07MaklE9/Oy6vLnT9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f4M0uQhK6maHObQ2p2ALeKTRMAxma5dUqZZ/tR0fUs27NiVD3RLB/H7M+h0E4ccpeUw5Tplo6KBeafv0Oi/6o/TyGXngkeX0DmJIT/vfGYShx0GUpyItqcK3BC9GA11o95Jhgs0JDQnHQ81OogKqz6BrePuI6mBXpuuvIyt62dg= 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=caHN7mG8; arc=none smtp.client-ip=209.85.161.47 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="caHN7mG8" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-682d981b025so89023eaf.3 for ; Wed, 08 Apr 2026 13:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678561; x=1776283361; 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=C44DgH2JP8lq64/cFMeg7xtczdkU2X+9d3ozrss1Zi0=; b=caHN7mG8jx2A4Tc/5gMrlpnjG8NF+Lt+8Jmgt5QEvJO0/BDXlVTLyUOsK/N0pr1g/0 lgXX5+ezMZS7r37tRuir0BekY6PYuXnMmcyVL9F+CEwqDFNeMVaDHFGLjWMPEkCmUB+k HMdird6hAz6xZINjIbA6a+6HKQypwfUdubkY24N1qSGntVP7BIOTNABWSapxdbODn5tW 1ZcXy0eZcdB9jjkwxkdIuQTNOwCAW2HO44oL0Y8j9Amdfa+Q/JBGbZrlq7OBPtdN3gTw AiUyy/OOMz2JwAuelXU9M/uckWl/Y8/A18ywJ2Bld4y3NlSfOHaID7Tdbn+xFk7tZ0Mg uFkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678561; x=1776283361; 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=C44DgH2JP8lq64/cFMeg7xtczdkU2X+9d3ozrss1Zi0=; b=Ms+Ust4+BNzah+jNaG0V7gDPuK6+7QCugULi2AxWH4HkhLErpTprjyO08o20pXPQWX aFQNmNp0U7yWZ8Z75/MsUBiLc1tcYbNjhaSQocwfacEuzxOGmXbboG2uGPNnNJhb0JQA zHuGKyBy9OTeqCJrKjIPeTRJYpmhdxs17A71f2t/X2ntoTaqlsIUhFqvIzsNPBLR8gG8 7AS4LRbQoZF4+LHj6TVMKggG4BYS16Z0eR+p5eNyb/v0TBljd2I8cL85AABdPMaSkOZM Nw3mkjVMctAyM6vuHNsCBdI1QLRZMFYLjAG2guVTSgVFCqfcenf8oLziEbUPOUgd0oZi JSFA== X-Gm-Message-State: AOJu0Yxp84sYc4iZHaIbVvYc6x4L43wxnytaUhpPxXw1znP6icY5rLNt DAaPoUWJt4Q5JPMHzcdnIoA/KgxQCswBZ0spmWWS7XFAtTHKPCvzrdrrKzjpCw== X-Gm-Gg: AeBDieugVYui7FXfE6BXFPsd8Ww52nmmFFQHKClKSwlIKkCdoNx+Z3+CW7rb+f2aRvO B+26XBRqhT80fLkSR5hozSzvuBkfQ+1nU20FEnmwOdru3zBhYEbUTkFgOevWnpcuoeOS5d+G/n5 HTNpuj2xK0FV8QNJZo2toGgN3RHNDPcxmSkiKSYRTnQgx6KT56jRywShszYa2qAILggLUxJgMBA rv8u+1XxRC1ANU6nCjerJvO63oiLPe/CIst3iqnByFow8VKrST7tcjE14mVEasSyEFNugVwjozW BwaLAiFY9qmCDJGoA+g7w7ciLhi8iPJ1QW8Fsz1vFQZWMoNQExgifn++LLWFtUuYNknUM3WM6hl my/x7Y4mAhH5PNB66wqflyHowO4i62QQtczAdsgZo7E3Bc0CuRsHL1DCrdzE39xDITdui7BHwc8 AhV4aUFEN/aJE3i7UsXzyRXKOAnBUtV+drHk7GVCU6TEg6QtsvpJix4fX++3mu/V4siPQEwTrk2 9o= X-Received: by 2002:a05:6820:2d04:b0:681:22fd:a584 with SMTP id 006d021491bc7-6821d83c357mr12509270eaf.16.1775678560611; Wed, 08 Apr 2026 13:02:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:40 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v13 25/36] dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP Date: Wed, 8 Apr 2026 14:02:00 -0600 Message-ID: <20260408200211.43821-26-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: quoted-printable Content-Type: text/plain; charset="utf-8" commit aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic K&R rule: "define once, refer many times". When CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, it is used across DRM core & drivers; each invocation allocates/inits the classmap understood by that module. They *all* must match for the DRM modules to respond consistently when drm.debug categories are enabled. This is at least a maintenance hassle. Worse, its the root-cause of the CONFIG_DRM_USE_DYNAMIC_DEBUG=3DY regression; its use in both core & drivers obfuscates the 2 roles, muddling the design, yielding an incomplete initialization when modprobing drivers: 1st drm.ko loads, and dyndbg initializes its drm.debug callsites, then a drm-driver loads, but too late for the drm.debug enablement. And that led to: commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken") So retire it, replace with 2 macros: DYNAMIC_DEBUG_CLASSMAP_DEFINE - invoked once from core - drm.ko DYNAMIC_DEBUG_CLASSMAP_USE* - from all drm drivers and helpers. NB: name-space de-noise DYNAMIC_DEBUG_CLASSMAP_DEFINE: this reworks DECLARE_DYNDBG_CLASSMAP, basically by dropping the static qualifier on the classmap, and exporting it instead. DYNAMIC_DEBUG_CLASSMAP_USE: then refers to the exported var by name: used from drivers, helper-mods lets us drop the repetitive "classname" declarations fixes 2nd-defn problem creates a ddebug_class_user record in new __dyndbg_class_users section new section is scanned "differently" DECLARE_DYNDBG_CLASSMAP is preserved temporarily, to decouple DRM adaptation work and avoid compile-errs before its done. The DEFINE,USE distinction, and the separate classmap-use record, allows dyndbg to initialize the driver's & helper's drm.debug callsites separately after each is modprobed. Basically, the classmap initial scan is repeated for classmap-users. dyndbg's existing __dyndbg_classes[] section does: . catalogs the module's classmaps . tells dyndbg about them, allowing >control . DYNAMIC_DEBUG_CLASSMAP_DEFINE creates section records. . we rename it to: __dyndbg_class_maps[] this patch adds __dyndbg_class_users[] section: . catalogs users of classmap definitions from elsewhere . authorizes dyndbg to >control user's class'd prdbgs . DYNAMIC_DEBUG_CLASSMAP_USE() creates section records. Now ddebug_add_module(etal) can handle classmap-uses similar to (and after) classmaps; when a dependent module is loaded, if it has classmap-uses (to a classmap-def in another module), that module's kernel params are scanned to find if it has a kparam that is wired to dyndbg's param-ops, and whose classmap is the one being ref'd. To support this, theres a few data/header changes: new struct ddebug_class_user contains: user-module-name, &classmap-defn it records drm-driver's use of a classmap in the section, allowing lookup struct ddebug_info gets 2 new fields for the new sections: class_users, num_class_users. set by dynamic_debug_init() for builtins. or by kernel/module/main:load_info() for loadable modules. vmlinux.lds.h: Add a new BOUNDED_SECTION for __dyndbg_class_users. this creates start,stop C symbol-names for the section. TLDR ? dynamic_debug.c: 2 changes from ddebug_add_module() & ddebug_change(): ddebug_add_module(): ddebug_attach_module_classes() is reworked/renamed/split into debug_apply_class_maps(), ddebug_apply_class_users(), which both call ddebug_apply_params(). ddebug_apply_params(new fn): It scans module's/builtin kernel-params, calls ddebug_match_apply_kparam for each to find any params/sysfs-nodes which may be wired to a classmap. ddebug_match_apply_kparam(new fn): 1st, it tests the kernel-param.ops is dyndbg's; this guarantees that the attached arg is a struct ddebug_class_param, which has a ref to the param's state, and to the classmap defining the param's handling. 2nd, it requires that the classmap ref'd by the kparam is the one we've been called for; modules can use many separate classmaps (as test_dynamic_debug does). Then apply the "parent" kparam's setting to the dependent module, using ddebug_apply_class_bitmap(). ddebug_change(and callees) also gets adjustments: ddebug_find_valid_class(): This does a search over the module's classmaps, looking for the class FOO echo'd to >control. So now it searches over __dyndbg_class_users[] after __dyndbg_classes[]. ddebug_class_name(): return class-names for defined OR used classes. test_dynamic_debug.c, test_dynamic_debug_submod.c: This demonstrates the 2 types of classmaps & sysfs-params, following the 4-part recipe: 0. define an enum for the classmap's class_ids drm.debug gives us DRM_UT_<*> (aka ) multiple classmaps in a module(s) must share 0-62 classid space. 1. DYNAMIC_DEBUG_CLASSMAP_DEFINE(classmap_name, .. "") names the classes, maps them to consecutive class-ids. convention here is stringified ENUM_SYMBOLS these become API/ABI if 2 is done. 2. DYNAMIC_DEBUG_CLASSMAP_PARAM* (classmap_name) adds a controlling kparam to the class 3. DYNAMIC_DEBUG_CLASSMAP_USE(classmap_name) for subsystem/group/drivers to use extern created by 1. Move all the enum declarations together, to better explain how they share the 0..62 class-id space available to a module (non-overlapping subranges). reorg macros 2,3 by name. This gives a tabular format, making it easy to see the pattern of repetition, and the points of change. And extend the test to replicate the 2-module (parent & dependent) scenario which caused the CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy regression seen in drm & drivers. The _submod.c is a 2-line file: #define _SUBMOD, #include parent. This gives identical complements of prdbgs in parent & _submod, and thus identical print behavior when all of: >control, >params, and parent->_submod propagation are working correctly. It also puts all the parent/_submod declarations together in the same source; the new ifdef _SUBMOD block invokes DYNAMIC_DEBUG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer. These 2 modules are both tristate, allowing 3 super/sub combos: Y/Y, Y/M, M/M (not N/Y, since this is disallowed by dependence). Y/Y, Y/M testing once exposed a missing __align(8) in the _METADATA macro, which M/M didn't see, probably because the module-loader memory placement constrained it from misalignment. Fixes: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") cc: linux-doc@vger.kernel.org Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- -v? replace di with &dt->info, since di becomes stale fix dd_mark_vector_subrange macro param ordering to match kdoc s/base/offset/ in _ddebug_class_user, to reduce later churn -v12 - squash in _USE_ and refinements. A: dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) Allow a module to use 2 classmaps together that would otherwise have a class_id range conflict. Suppose a drm-driver does: DYNAMIC_DEBUG_CLASSMAP_USE(drm_debug_classes); DYNAMIC_DEBUG_CLASSMAP_USE(drm_accel_xfer_debug); If (for some reason) drm-accel cannot define their constants to avoid DRM's drm_debug_category 0..10 reservations, we would have a conflict with reserved-ids. In this case a driver needing to use both would _USE_ one of them with an offset to avoid the conflict. This will handle most forseeable cases; perhaps a 3-X-3 of classmap-defns X classmap-users would get too awkward and fiddly. B: dyndbg: refine DYNAMIC_DEBUG_CLASSMAP_USE_ macro The struct _ddebug_class_user _varname construct is needlessly permissive; it has a static qualifier, and a unique name. Together, these allow a module to have 2 or more _USE(foo)s, which is contrary to its purpose, and therefore potentially confusing. So drop the unique name, and the static qualifier, and replace it with an extern pre-declaration. Construct the name by pasting together the _var (which is the name of the exported ddebug_class_map), and __KBUILD_MODNAME (which is the user module name). This allows only a single USE() reference to the exported record, which is all that is required. Signed-off-by: Jim Cromie --- MAINTAINERS | 2 +- include/asm-generic/dyndbg.lds.h | 7 +- include/linux/dynamic_debug.h | 159 +++++++++++++++++++++++--- kernel/module/main.c | 3 + lib/Kconfig.debug | 24 +++- lib/Makefile | 5 + lib/dynamic_debug.c | 185 ++++++++++++++++++++++++------- lib/test_dynamic_debug.c | 132 ++++++++++++++++------ lib/test_dynamic_debug_submod.c | 14 +++ 9 files changed, 433 insertions(+), 98 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c diff --git a/MAINTAINERS b/MAINTAINERS index 0f4c2f182d63..31c945228fab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9034,7 +9034,7 @@ M: Jim Cromie S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c -F: lib/test_dynamic_debug.c +F: lib/test_dynamic_debug*.c F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.= lds.h index 8345ac6c52b7..6e38d0f1d00b 100644 --- a/include/asm-generic/dyndbg.lds.h +++ b/include/asm-generic/dyndbg.lds.h @@ -6,7 +6,8 @@ #define DYNDBG_SECTIONS() \ . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ - BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) + BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) \ + BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users) =20 #define MOD_DYNDBG_SECTIONS() \ __dyndbg_descriptors : { \ @@ -16,6 +17,10 @@ __dyndbg_class_maps : { \ BOUNDED_SECTION_BY(__dyndbg_class_maps, \ ___dyndbg_class_maps) \ + } \ + __dyndbg_class_users : { \ + BOUNDED_SECTION_BY(__dyndbg_class_users, \ + ___dyndbg_class_users) \ } =20 #endif /* __ASM_GENERIC_DYNDBG_LDS_H */ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 33291abd8971..71c91bc8d3a6 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -72,19 +72,30 @@ enum ddebug_class_map_type { */ }; =20 +/* + * map @class_names 0..N to consecutive constants starting at @base. + */ struct _ddebug_class_map { - struct module *mod; /* NULL for builtins */ - const char *mod_name; /* needed for builtins */ + const struct module *mod; /* NULL for builtins */ + const char *mod_name; /* needed for builtins */ const char **class_names; const int length; const int base; /* index of 1st .class_id, allows split/shared space */ enum ddebug_class_map_type map_type; }; =20 +struct _ddebug_class_user { + char *mod_name; + struct _ddebug_class_map *map; + const int offset; /* offset from map->base */ +}; + /* - * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * @_ddebug_info: gathers module/builtin __dyndbg_ __sections + * together, each is a vec_: a struct { struct T start[], int len }. + * * For builtins, it is used as a cursor, with the inner structs - * marking sub-vectors of the builtin __sections in DATA. + * marking sub-vectors of the builtin __sections in DATA_DATA */ struct _ddebug_descs { struct _ddebug *start; @@ -96,10 +107,16 @@ struct _ddebug_class_maps { int len; }; =20 +struct _ddebug_class_users { + struct _ddebug_class_user *start; + int len; +}; + struct _ddebug_info { const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; + struct _ddebug_class_users users; }; =20 struct _ddebug_class_param { @@ -118,12 +135,81 @@ struct _ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) =20 +/* + * dyndbg classmaps is modelled closely upon drm.debug: + * + * 1. run-time control via sysfs node (api/abi) + * 2. each bit 0..N controls a single "category" + * 3. a pr_debug can have only 1 category, not several. + * 4. "kind" is a compile-time constant: 0..N or BIT() thereof + * 5. macro impls - give compile-time resolution or fail. + * + * dyndbg classmaps design axioms/constraints: + * + * . optimizing compilers use 1-5 above, so preserve them. + * . classmaps.class_id *is* the category. + * . classmap definers/users are modules. + * . every user wants 0..N + * . 0..N exposes as ABI + * . no 1 use-case wants N > 32, 16 is more usable + * . N <=3D 64 in *all* cases + * . modules/subsystems make category/classmap decisions + * . ie an enum: DRM has DRM_UT_CORE..DRM_UT_DRMRES + * . some categories are exposed to user: ABI + * . making modules change their numbering is bogus, avoid if possible + * + * We can solve for all these at once: + * A: map class-names to a .class_id range at compile-time + * B: allow only "class NAME" changes to class'd callsites at run-time + * C: users/modules must manage 0..62 hardcoded .class_id range limit. + * D: existing pr_debugs get CLASS_DFLT=3D63 + * + * By mapping class-names at >control to class-ids underneath, and + * responding only to class-names DEFINEd or USEd by the module, we + * can private-ize the class-id, and adjust class'd pr_debugs only by + * their names. + * + * This give us: + * E: class_ids without classnames are unreachable + * F: user modules opt-in by DEFINEing a classmap and/or USEing another + * + * Multi-classmap modules/groups are supported, if the classmaps share + * the class_id space [0..62] without overlap/conflict. + * + * NOTE: Due to the integer class_id, this api cannot disallow these: + * __pr_debug_cls(0, "fake CORE msg"); works only if a classmap maps 0. + * __pr_debug_cls(22, "no such class"); compiles but is not reachable + */ + /** - * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module - * @_var: a struct ddebug_class_map, passed to module_param_cb - * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic - * @_base: offset of 1st class-name. splits .class_id space - * @classes: class-names used to control class'd prdbgs + * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. + * @_var: name of the classmap, exported for other modules coordinated u= se. + * @_mapty: enum ddebug_class_map_type: 0:DISJOINT - independent, 1:LEVEL = - v2>v1 + * @_base: reserve N classids starting at _base, to split 0..62 classid s= pace + * @classes: names of the N classes. + * + * This tells dyndbg what class_ids the module is using: _base..+N, by + * mapping names onto them. This qualifies "class NAME" >controls on + * the defining module, ignoring unknown names. + */ +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + extern struct _ddebug_class_map _var; \ + struct _ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_class_maps") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D (_base), \ + .map_type =3D (_mapty), \ + .length =3D ARRAY_SIZE(_var##_classnames), \ + .class_names =3D _var##_classnames, \ + }; \ + EXPORT_SYMBOL(_var) + +/* + * XXX: keep this until DRM adapts to use the DEFINE/USE api, it + * differs from DYNAMIC_DEBUG_CLASSMAP_DEFINE by the lack of the + * extern/EXPORT on the struct init, and cascading thinkos. */ #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ @@ -137,6 +223,44 @@ struct _ddebug_class_param { .class_names =3D _var##_classnames, \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. + * @_var: name of the exported classmap var + * + * This tells dyndbg that the module has prdbgs with classids defined + * in the named classmap. This qualifies "class NAME" >controls on + * the user module, and ignores unknown names. This is a wrapper for + * DYNAMIC_DEBUG_CLASSMAP_USE_() with a base offset of 0. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0) + +/** + * DYNAMIC_DEBUG_CLASSMAP_USE_ - refer to a classmap with a manual offset. + * @_var: name of the exported classmap var to use. + * @_offset: an integer offset to add to the class IDs of the used map. + * + * This is an extended version of DYNAMIC_DEBUG_CLASSMAP_USE(). It should + * only be used to resolve class ID conflicts when a module uses multiple + * classmaps that have overlapping ID ranges. + * + * The final class IDs for the used map will be calculated as: + * original_map_base + class_index + @_offset. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _offset) \ + extern struct _ddebug_class_map _var; \ + static_assert((_offset) >=3D 0 && (_offset) < _DPRINTK_CLASS_DFLT, \ + "classmap use offset must be in 0..62"); \ + extern struct _ddebug_class_user __aligned(8) \ + __PASTE(_var ## _, __KBUILD_MODNAME); \ + struct _ddebug_class_user __aligned(8) __used \ + __section("__dyndbg_class_users") \ + __PASTE(_var ## _, __KBUILD_MODNAME) =3D { \ + .mod_name =3D KBUILD_MODNAME, \ + .map =3D &(_var), \ + .offset =3D _offset \ + } + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -298,12 +422,18 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 -/* for test only, generally expect drm.debug style macro wrappers */ -#define __pr_debug_cls(cls, fmt, ...) do { \ +/* + * This is the "model" class variant of pr_debug. It is not really + * intended for direct use; I'd encourage DRM-style drm_dbg_ + * macros for the interface, along with an enum for the + * + * __printf(2, 3) would apply. + */ +#define __pr_debug_cls(cls, fmt, ...) ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ "expecting constant class int/enum"); \ dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ - } while (0) +}) =20 #else /* !(CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_D= EBUG_MODULE)) */ =20 @@ -311,6 +441,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include =20 +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(...) @@ -357,8 +489,7 @@ static inline int param_set_dyndbg_classes(const char *= instr, const struct kerne static inline int param_get_dyndbg_classes(char *buffer, const struct kern= el_param *kp) { return 0; } =20 -#endif - +#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 extern const struct kernel_param_ops param_ops_dyndbg_classes; =20 diff --git a/kernel/module/main.c b/kernel/module/main.c index a0fe6c7aab75..8a3fc98d8a4c 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2723,6 +2723,9 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", sizeof(*mod->dyndbg_info.maps.start), &mod->dyndbg_info.maps.len); + mod->dyndbg_info.users.start =3D section_objs(info, "__dyndbg_class_users= ", + sizeof(*mod->dyndbg_info.users.start), + &mod->dyndbg_info.users.len); #endif =20 return 0; diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 93f356d2b3d9..302bb2656682 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -3106,12 +3106,26 @@ config TEST_STATIC_KEYS If unsure, say N. =20 config TEST_DYNAMIC_DEBUG - tristate "Test DYNAMIC_DEBUG" - depends on DYNAMIC_DEBUG + tristate "Build test-dynamic-debug module" + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help - This module registers a tracer callback to count enabled - pr_debugs in a 'do_debugging' function, then alters their - enablements, calls the function, and compares counts. + This module exercises/demonstrates dyndbg's classmap API, by + creating 2 classes: a DISJOINT classmap (supporting DRM.debug) + and a LEVELS/VERBOSE classmap (like verbose2 > verbose1). + + If unsure, say N. + +config TEST_DYNAMIC_DEBUG_SUBMOD + tristate "Build test-dynamic-debug submodule" + default m + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on TEST_DYNAMIC_DEBUG + help + This sub-module uses a classmap defined and exported by the + parent module, recapitulating drm & driver's shared use of + drm.debug to control enabled debug-categories. + It is tristate, independent of parent, to allow testing all + proper combinations of parent=3Dy/m submod=3Dy/m. =20 If unsure, say N. =20 diff --git a/lib/Makefile b/lib/Makefile index 1b9ee167517f..19ab40903436 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -83,6 +83,9 @@ obj-$(CONFIG_TEST_RHASHTABLE) +=3D test_rhashtable.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD) +=3D test_dynamic_debug_submod.o +obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o +obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o =20 obj-$(CONFIG_TEST_BITMAP) +=3D test_bitmap.o ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy) @@ -206,6 +209,8 @@ obj-$(CONFIG_ARCH_NEED_CMPXCHG_1_EMU) +=3D cmpxchg-emu.o obj-$(CONFIG_DYNAMIC_DEBUG_CORE) +=3D dynamic_debug.o #ensure exported functions have prototypes CFLAGS_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug_submod.o :=3D -DDYNAMIC_DEBUG_MODULE =20 obj-$(CONFIG_SYMBOLIC_ERRNAME) +=3D errname.o =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b8983e095e60..ce512efaeffd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -29,6 +29,7 @@ #include #include #include + #include #include #include @@ -43,6 +44,8 @@ extern struct _ddebug __start___dyndbg_descs[]; extern struct _ddebug __stop___dyndbg_descs[]; extern struct _ddebug_class_map __start___dyndbg_class_maps[]; extern struct _ddebug_class_map __stop___dyndbg_class_maps[]; +extern struct _ddebug_class_user __start___dyndbg_class_users[]; +extern struct _ddebug_class_user __stop___dyndbg_class_users[]; =20 struct ddebug_table { struct list_head link; @@ -168,20 +171,37 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) +#define vpr_di_info(di_p, msg_p, ...) ({ \ + struct _ddebug_info const *_di =3D di_p; \ + v2pr_info(msg_p "module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \ + _di->mod_name, _di->descs.len, _di->maps.len, \ + _di->users.len); \ + }) + +static struct _ddebug_class_map * +ddebug_find_valid_class(struct _ddebug_info const *di, const char *query_c= lass, int *class_id) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i, idx; =20 - for_subvec(i, map, &dt->info, maps) { - idx =3D match_string(map->class_names, map->length, class_string); + for_subvec(i, map, di, maps) { + idx =3D match_string(map->class_names, map->length, query_class); if (idx >=3D 0) { + vpr_di_info(di, "good-class: %s.%s ", map->mod_name, query_class); *class_id =3D idx + map->base; return map; } } + for_subvec(i, cli, di, users) { + idx =3D match_string(cli->map->class_names, cli->map->length, query_clas= s); + if (idx >=3D 0) { + vpr_di_info(di, "class-ref: %s -> %s.%s ", + cli->mod_name, cli->map->mod_name, query_class); + *class_id =3D idx + cli->map->base - cli->offset; + return cli->map; + } + } *class_id =3D -ENOENT; return NULL; } @@ -238,8 +258,7 @@ static bool ddebug_match_desc(const struct ddebug_query= *query, return true; } =20 -static int ddebug_change(const struct ddebug_query *query, - struct flag_settings *modifiers) +static int ddebug_change(const struct ddebug_query *query, struct flag_set= tings *modifiers) { int i; struct ddebug_table *dt; @@ -260,7 +279,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, continue; =20 if (query->class_string) { - map =3D ddebug_find_valid_class(dt, query->class_string, &valid_class); + map =3D ddebug_find_valid_class(&dt->info, query->class_string, + &valid_class); if (!map) continue; } else { @@ -590,7 +610,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) =20 /* handle multiple queries in query string, continue on error, return last error or number of matching callsites. Module name is either - in param (for boot arg) or perhaps in query string. + in the modname arg (for boot args) or perhaps in query string. */ static int ddebug_exec_queries(char *query, const char *modname) { @@ -721,7 +741,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, /** * param_set_dyndbg_classes - classmap kparam setter * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type + * @kp: kp->arg has state: bits/lvl, classmap, map_type * * enable/disable all class'd pr_debugs in the classmap. For LEVEL * map-types, enforce * relative levels by bitpos. @@ -758,6 +778,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) default: return -1; } + return 0; } EXPORT_SYMBOL(param_get_dyndbg_classes); =20 @@ -1073,12 +1094,17 @@ static bool ddebug_class_in_range(const int class_i= d, const struct _ddebug_class static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i; =20 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 + for_subvec(i, cli, di, users) + if (ddebug_class_in_range(dp->class_id, cli->map)) + return cli->map->class_names[dp->class_id - cli->map->base - cli->offse= t]; + return NULL; } =20 @@ -1159,32 +1185,87 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) +#define vpr_cm_info(cm_p, msg_fmt, ...) ({ \ + struct _ddebug_class_map const *_cm =3D cm_p; \ + v2pr_info(msg_fmt "%s [%d..%d] %s..%s\n", ##__VA_ARGS__, \ + _cm->mod_name, _cm->base, _cm->base + _cm->length, \ + _cm->class_names[0], _cm->class_names[_cm->length - 1]); \ + }) + +static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { - struct _ddebug_class_map *cm; - int i, nc =3D 0; + const struct _ddebug_class_param *dcp =3D kp->arg; =20 - /* - * Find this module's classmaps in a subrange/wholerange of - * the builtin/modular classmap vector/section. Save the start - * and length of the subrange at its edges. - */ - for_subvec(i, cm, di, maps) { - 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); - dt->info.maps.start =3D cm; - } - nc++; - } + /* clamp initial bitvec, mask off hi-bits */ + if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { + *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); + v2pr_info("preset classbits: %lx\n", *dcp->bits); + } + /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ + ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp; + + if (kp->ops !=3D ¶m_ops_dyndbg_classes) + return; + + dcp =3D (struct _ddebug_class_param *)kp->arg; + + if (map =3D=3D dcp->map) { + v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); + vpr_cm_info(map, " %s maps ", mod_name); + ddebug_sync_classbits(kp, mod_name); + } +} + +static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +{ + const struct kernel_param *kp; +#if IS_ENABLED(CONFIG_MODULES) + int i; + + if (cm->mod) { + vpr_cm_info(cm, "loaded classmap: %s ", mod_name); + /* ifdef protects the cm->mod->kp deref */ + for (i =3D 0, kp =3D cm->mod->kp; i < cm->mod->num_kp; i++, kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); } - if (nc) { - dt->info.maps.len =3D nc; - vpr_info("module:%s attached %d classes\n", dt->info.mod_name, nc); +#endif + if (!cm->mod) { + vpr_cm_info(cm, "builtin classmap: %s ", mod_name); + for (kp =3D __start___param; kp < __stop___param; kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); } } =20 +static void ddebug_apply_class_maps(const struct _ddebug_info *di) +{ + struct _ddebug_class_map *cm; + int i; + + for_subvec(i, cm, di, maps) + ddebug_apply_params(cm, cm->mod_name); + + vpr_di_info(di, "attached %d class-maps to ", i); +} + +static void ddebug_apply_class_users(const struct _ddebug_info *di) +{ + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, cli, di, users) + ddebug_apply_params(cli->map, cli->mod_name); + + vpr_di_info(di, "attached %d class-users to ", i); +} + /* * Narrow a _ddebug_info's vector (@_vec) to the contiguous subrange * of elements where ->mod_name matches @__di->mod_name. @@ -1214,6 +1295,22 @@ static void ddebug_attach_module_classes(struct ddeb= ug_table *dt, struct _ddebug __di->_vec.len =3D __nc; \ }) =20 +static int __maybe_unused +ddebug_class_range_overlap(struct _ddebug_class_map *cm, + u64 *reserved_ids) +{ + u64 range =3D (((1ULL << cm->length) - 1) << cm->base); + + if (range & *reserved_ids) { + pr_err("[%d..%d] on %s conflicts with %llx\n", cm->base, + cm->base + cm->length - 1, cm->class_names[0], + *reserved_ids); + return -EINVAL; + } + *reserved_ids |=3D range; + return 0; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1222,6 +1319,7 @@ static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; struct _ddebug_class_map *cm; + struct _ddebug_class_user *cli; int i; =20 if (!di->descs.len) @@ -1234,26 +1332,29 @@ static int ddebug_add_module(struct _ddebug_info *d= i) pr_err("error adding module: %s\n", di->mod_name); return -ENOMEM; } + INIT_LIST_HEAD(&dt->link); /* - * 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. + * For built-in modules, di-> referents live in .*data and are + * immortal. For loaded modules, di points at the dyndbg_info + * member of its struct module, which lives at least as + * long as this struct ddebug_table. */ dt->info =3D *di; - - INIT_LIST_HEAD(&dt->link); - dd_set_module_subrange(i, cm, &dt->info, maps); - - if (di->maps.len) - ddebug_attach_module_classes(dt, di); + dd_set_module_subrange(i, cli, &dt->info, users); + /* now di is stale */ =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->descs.len, di->mod_name); + if (dt->info.maps.len) + ddebug_apply_class_maps(&dt->info); + if (dt->info.users.len) + ddebug_apply_class_users(&dt->info); + + vpr_info("%3u debug prints in module %s\n", + dt->info.descs.len, dt->info.mod_name); return 0; } =20 @@ -1403,8 +1504,10 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di =3D { .descs.start =3D __start___dyndbg_descs, .maps.start =3D __start___dyndbg_class_maps, + .users.start =3D __start___dyndbg_class_users, .descs.len =3D __stop___dyndbg_descs - __start___dyndbg_descs, .maps.len =3D __stop___dyndbg_class_maps - __start___dyndbg_class_maps, + .users.len =3D __stop___dyndbg_class_users - __start___dyndbg_class_user= s, }; =20 #ifdef CONFIG_MODULES diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 9c3e53cd26bd..6c4548f63512 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -6,11 +6,30 @@ * Jim Cromie */ =20 -#define pr_fmt(fmt) "test_dd: " fmt +/* + * This file is built 2x, also making test_dynamic_debug_submod.ko, + * whose 2-line src file #includes this file. This gives us a _submod + * clone with identical pr_debugs, without further maintenance. + * + * If things are working properly, they should operate identically + * when printed or adjusted by >control. This eases visual perusal of + * the logs, and simplifies testing, by easing the proper accounting + * of expectations. + * + * It also puts both halves of the subsystem _DEFINE & _USE use case + * together, and integrates the common ENUM providing both class_ids + * and class-names to both _DEFINErs and _USERs. I think this makes + * the usage clearer. + */ +#if defined(TEST_DYNAMIC_DEBUG_SUBMOD) + #define pr_fmt(fmt) "test_dd_submod: " fmt +#else + #define pr_fmt(fmt) "test_dd: " fmt +#endif =20 #include =20 -/* run tests by reading or writing sysfs node: do_prints */ +/* re-gen output by reading or writing sysfs node: do_prints */ =20 static void do_prints(void); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) @@ -29,24 +48,39 @@ static const struct kernel_param_ops param_ops_do_print= s =3D { }; module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); =20 -/* - * Using the CLASSMAP api: - * - classmaps must have corresponding enum - * - enum symbols must match/correlate with class-name strings in the map. - * - base must equal enum's 1st value - * - multiple maps must set their base to share the 0-30 class_id space !! - * (build-bug-on tips welcome) - * Additionally, here: - * - tie together sysname, mapname, bitsname, flagsname - */ -#define DD_SYS_WRAP(_model, _flags) \ - static unsigned long bits_##_model; \ - static struct _ddebug_class_param _flags##_model =3D { \ +#define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) + +/* sysfs param wrapper, proto-API */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ + static unsigned long bits_##_model =3D _init; \ + static struct _ddebug_class_param _flags##_##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_m= odel, 0600) + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ + &_flags##_##_model, 0600) +#ifdef DEBUG +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) +#else +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) +#endif + +/* + * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. + * + * To comport with DRM debug-category (an int), classmaps map names to + * ids (also an int). So a classmap starts with an enum; DRM has enum + * debug_category: with DRM_UT_. We use the enum + * values as class-ids, and stringified enum-symbols as classnames. + * + * Modules with multiple CLASSMAPS must have enums with distinct + * value-ranges, as arranged below with explicit enum_sym =3D X inits. + * To clarify this sharing, declare the 2 enums now, for the 2 + * different classmap types + */ =20 /* numeric input, independent bits */ enum cat_disjoint_bits { @@ -60,26 +94,51 @@ enum cat_disjoint_bits { D2_LEASE, D2_DP, D2_DRMRES }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "D2_CORE", - "D2_DRIVER", - "D2_KMS", - "D2_PRIME", - "D2_ATOMIC", - "D2_VBL", - "D2_STATE", - "D2_LEASE", - "D2_DP", - "D2_DRMRES"); -DD_SYS_WRAP(disjoint_bits, p); -DD_SYS_WRAP(disjoint_bits, T); - -/* numeric verbosity, V2 > V1 related */ -enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, - "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); -DD_SYS_WRAP(level_num, p); -DD_SYS_WRAP(level_num, T); + +/* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ +enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; + +/* recapitulate DRM's multi-classmap setup */ +#if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) +/* + * In single user, or parent / coordinator (drm.ko) modules, define + * classmaps on the client enums above, and then declares the PARAMS + * ref'g the classmaps. Each is exported. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, + D2_CORE, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, + V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); + +/* + * now add the sysfs-params + */ + +DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); + +#else /* TEST_DYNAMIC_DEBUG_SUBMOD */ + +/* + * in submod/drm-drivers, use the classmaps defined in top/parent + * module above. + */ + +DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); +DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); + +#endif =20 /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") @@ -115,6 +174,7 @@ static void do_levels(void) =20 static void do_prints(void) { + pr_debug("do_prints:\n"); do_cats(); do_levels(); } diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c new file mode 100644 index 000000000000..672aabf40160 --- /dev/null +++ b/lib/test_dynamic_debug_submod.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +/* + * clone the parent, inherit all the properties, for consistency and + * simpler accounting in test expectations. + */ +#define TEST_DYNAMIC_DEBUG_SUBMOD +#include "test_dynamic_debug.c" --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 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 387F43890FD for ; Wed, 8 Apr 2026 20:02:43 +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=1775678564; cv=none; b=qiwNo3rifJYcgErerKI3IJShexAJt9Mbxu+yPKCdep76Pi25tAqbAM2PfAElLibv2raDpCQnTc2mmPBawQLT6rFi60qphp6PPLjrID5DReteGMa/xGPHHzUtnPXqNrbd439ZPf0lf6ezJdWnmug2KZmXNYDLwnGoEoYE8GctHh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678564; c=relaxed/simple; bh=Zzx4Sn733ZM1tO7JuXAJ/z8qin9BcfpX6BljoYIv/Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sfuaI/huFa/I2dw9g83bP+38FjAnNlOgg2LFlvSSg7GRWt4/i/BJ2NHGwVzmN9Aewv2hYU1w1kVH3MI6TfI3kkM566250o5fmq6MJ/whL90r/nYENT4Gs8NrIGTpPmtrVYCn6l0iVNBgUv7OpM+GfhxbUvmaGaWzhMxqoM3EmuE= 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=ZtZtD3L0; 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="ZtZtD3L0" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-6894c5dc5a3so63690eaf.1 for ; Wed, 08 Apr 2026 13:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678562; x=1776283362; 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=fhkUA1UVesD8yNrP4RsQIbF+Lt6WpQrbgggJ/VjIv9U=; b=ZtZtD3L0QS0Eks7EfYsa45ORxVrDQAaY9KZW33Xh+VM/VxnlFymvippYRqcHnTqqdq lwP2C+XM8fW6bGkRH49hfigAiJMfcLNnhio6dXTjtO0I2w4AnJkdhlU8NWRXfZCvBaCe rgRv2Llog02tI7n8liubVhibUa+6JFQ5eY9H1UFRNVmg6AyuiON3WfWllfttWZeuruMZ OkwW0zPYJKhMa/AQNc0McsYmyfaEhvGxZPnZvJgnxhiROgoH4TmVBqOhV2NHs0vLHbux AN/V8fRTeJQ2rYtvSsjufV5fzrfqDdjBkbnso+NmJfPatla+8PpzBzEy25ffdrZWdfzC wy4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678562; x=1776283362; 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=fhkUA1UVesD8yNrP4RsQIbF+Lt6WpQrbgggJ/VjIv9U=; b=MVUovERrf/KUNElcDoi/N8hgzYvQoDtxuloC5R7qOm4U22gJy00t2n098EqaLXuiLo w4eJq21mgA/ecbYSEklJFWrzCeHOtQoKU3mYJjWa4l5onFHo1BLvFH7dQmjjsTQe4ktz GiEsT2ks3c6LK/NVfeSL6DfbH08Bt82yMGONmb3fjMf0Njte5v5X6zst75coU3BlqiO2 qtayj5rEPuF7w7M1pHX+82fxY+U+CwTlAL/9KQT/YsyOqDQAOPV1PprAy3kUpsM1nLqD 9BDgjS8wcPPipoH22+otCGfIUJ1b7EnrWe6SV6mZuiYshFqwHwUcjEdc6bMoM/wMctNl ZwkA== X-Gm-Message-State: AOJu0Yx1ShPLoNVYfXcD4FfilMU1/CtgyhPRi4bt7ufFLhAzpqxK+Knu gsib9+av1jG62Koz9FMd4yhtX0Ffq85yWhrJHR4RDze5YX9Nlu2tDP7bOJpdaw== X-Gm-Gg: AeBDietvZZR8cy7CPLC28qcxwiRxewp0NjcXXGYwYyywU+RhZ3pXtXFEqPbhecMc+F7 NGMiWeq3Xczigy79c9I1Ls8qR8WU6cScUnx97V8ouX1w74NkkTPdRZPZ+TK4aUxBs35B2FP48aX v6WMJjq0gbXcNVnlU1bvHxP8n398JIFuWV7+O+M7d55bQVbTtNSXA9TCcxdCl/b6ITg72RN3Wiq 2MyfsoDCYiRXC0gEA2sNdV9EpOKlo/mwyVitodO96aj4jMQSYK1zs8nc7H0z20yLlmFd3LbvlPZ +j0Ph2oCuMWQc0ODDRjHVHwuGgAKcZVaeR1Wj8ifee2b0CQs+9lIv05l2d8HZuUquX79R0wXnZp Crh0J6CW/0q7R0RkUa4hwz6bX1F0OuTQlfmkGr/COlAHkvdOBjCD8mLzlwhcgnu5j7J3Wqd8+fk dlN7Pi6LocOShSXkPgyvkZD+d408sPlOoXpn0Ij7ZqOMLOk7YekofIDJLZMPA31++nm7UdbKOf8 tY= X-Received: by 2002:a05:6820:134d:b0:685:7d77:27 with SMTP id 006d021491bc7-68a62903705mr498721eaf.33.1775678561946; Wed, 08 Apr 2026 13:02:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:41 -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 26/36] dyndbg: detect class_id reservation conflicts Date: Wed, 8 Apr 2026 14:02:01 -0600 Message-ID: <20260408200211.43821-27-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: quoted-printable Content-Type: text/plain; charset="utf-8" If a module _DEFINEs 2 or more classmaps, it must devise them to share the per-module 0..62 class-id space; ie their respective base,+length reservations cannot overlap. To detect conflicts at modprobe, add ddebug_class_range_overlap(), call it from ddebug_add_module(), and WARN and return -EINVAL when they're detected. This insures that class_id -> classname lookup has just 1 answer, so the 1st-found search in find-class-name works properly. test_dynamic_debug.c: If built with -DFORCE_CLASSID_CONFLICT, the test-modules invoke 2 conflicting DYNAMIC_DEBUG_CLASSMAP_DEFINE() declarations, into parent and the _submod. These conflict with one of the good ones in the parent (D2_CORE..etc), causing the modprobe(s) to WARN and fail. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- v9 - fix WARN() by adding new 1st arg 1. v12 - drop maybe_unused on range-overlap fn --- lib/dynamic_debug.c | 25 +++++++++++++++++++------ lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ce512efaeffd..a7f67ecbc4d7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1085,12 +1085,17 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) return dp; } =20 -static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +static bool ddebug_class_map_in_range(const int class_id, const struct _dd= ebug_class_map *map) { return (class_id >=3D map->base && class_id < map->base + map->length); } =20 +static bool ddebug_class_user_in_range(const int class_id, const struct _d= debug_class_user *user) +{ + return ddebug_class_map_in_range(class_id - user->offset, user->map); +} + static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; @@ -1098,11 +1103,11 @@ static const char *ddebug_class_name(struct _ddebug= _info *di, struct _ddebug *dp int i; =20 for_subvec(i, map, di, maps) - if (ddebug_class_in_range(dp->class_id, map)) + if (ddebug_class_map_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 for_subvec(i, cli, di, users) - if (ddebug_class_in_range(dp->class_id, cli->map)) + if (ddebug_class_user_in_range(dp->class_id, cli)) return cli->map->class_names[dp->class_id - cli->map->base - cli->offse= t]; =20 return NULL; @@ -1295,9 +1300,7 @@ static void ddebug_apply_class_users(const struct _dd= ebug_info *di) __di->_vec.len =3D __nc; \ }) =20 -static int __maybe_unused -ddebug_class_range_overlap(struct _ddebug_class_map *cm, - u64 *reserved_ids) +static int ddebug_class_range_overlap(struct _ddebug_class_map *cm, u64 *r= eserved_ids) { u64 range =3D (((1ULL << cm->length) - 1) << cm->base); =20 @@ -1320,6 +1323,7 @@ static int ddebug_add_module(struct _ddebug_info *di) struct ddebug_table *dt; struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; + u64 reserved_ids =3D 0; int i; =20 if (!di->descs.len) @@ -1344,6 +1348,11 @@ static int ddebug_add_module(struct _ddebug_info *di) dd_set_module_subrange(i, cli, &dt->info, users); /* now di is stale */ =20 + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, &dt->info, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1356,6 +1365,10 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE(1, "dyndbg multi-classmap conflict in %s\n", di->mod_name); + kfree(dt); + return -EINVAL; } =20 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 6c4548f63512..fc599bbe605e 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -128,6 +128,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_= TYPE_LEVEL_NUM, DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); =20 +#ifdef FORCE_CLASSID_CONFLICT +/* + * Enable with -Dflag on compile to test overlapping class-id range + * detection. This should warn on modprobes. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_= CORE"); +#endif + #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ =20 /* --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 09B8838945C for ; Wed, 8 Apr 2026 20:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678565; cv=none; b=FkTeTeXm6jH2Yga85LMtLOUf4MYB2ExPBmKUQ+9qA5MY4GowWG3VXCa3PW+h5czKmKtKsAAoBJHigrfpZis4ln2yqCctUJBreOXpXp56OWJRUbxDbED0085UfxqcK1Zdjuth+h3HnG5nY1yHrTaEZjtXsxuVCTP91d+PkeQUsX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678565; c=relaxed/simple; bh=TGuK4f1UM45/H+IsUuQY5J92vcz+KDOlcyVCzi1Py6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rHoQ0pCU1s5gBjmtSnS3VtmWmJiA46IpXCuba2jxDCz8WYNT/hG5Wur6oaI5gE5vuIcRDuVGlaFsX/xyVBcOLVlxCaLbum/ebIc6QnFmp2b+qSPDiK/iyA39Cij9kwg1rYqSW6RY+aly0iLKZKuWnlOvUvqqV9nAszHPFm7ql00= 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=pWyEUbUa; arc=none smtp.client-ip=209.85.210.42 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="pWyEUbUa" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7d9b21d1461so134548a34.1 for ; Wed, 08 Apr 2026 13:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678563; x=1776283363; 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=QxjKnnBNYEdtR7pwXQlRHXWp+HB+wKE5cSJl7LbWWbM=; b=pWyEUbUaSaA7gPLgpUTHviK+np+e7FQiaivLHgaDzcGO3stEm1P1tPrskc1PNCYVFX zP5VrHQxnyxCXzQLYKy8vIEwPyjVHjD3wXoeXDFs2dxSITa1SbgVGIBCVkLhxEEnFXu5 ZePEnOgr+Pj6KWvw/OQC5rhxX39t8jAu0jk1itdNTGGACr5Q6/dQair2xLG0nNjQV4uq A7qHpkj/YKt+ih5CaE9grghjQj3ysFnKIiaw+VjndHNOLfWoz26d2aJIH3zkG9BFUrr+ 03MShKyj0ScM3c1MXQHjZxdeq2maKUDTBop9TnDzofoeV28oXvm1TZMPxVLzZbKi+VwZ ZpEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678563; x=1776283363; 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=QxjKnnBNYEdtR7pwXQlRHXWp+HB+wKE5cSJl7LbWWbM=; b=QwemEpGYmJx/hiV0PhclrpRlbp8NPfqWdcL9BtEjK8M7DWwEzqS6uosyYP57SmdDFi laVQmukpPlWrdTTya9ATPmfIVaWCq7b8xQK7cbCMCcgBfGH4WeZM8chyb0MozumOyPgy A4NloMcaxEu0OdV4Tqp+4Kkxnl05LCjddjwBYdjZHnFQMQe4XNNF0JXnz8lkNJTiNryw OAtXP/m5MMSvdDo6ZbGt2Y/ja/lBkjH1b/0nbZf5GpuZuVVDN0NgGsI0eKDjOza6VZGJ 6VElw59eCbVs7jWlAaycxjaE61KD34WESn36dkRRLxMtlStKgAcVNud/OmaowVAG/rOA aW2Q== X-Gm-Message-State: AOJu0YzRM0u587IOiLIULYl4cGe2zroddUPSTw5B/I059Y/pTTPll82D FNSqDLjQ6xlmfdjEEUF/Ok3rvfot88c4ulWinfT7sH2JnlkfYnSXsJbVLvo7PQ== X-Gm-Gg: AeBDietIEvT/tn2TI8u7aQpqUGbbwFM7APclSduGQLykKKmJnfmw67Z5sMoLgBYOjdj mkdOaHBuTGW84kkNyuKAevvyNwXfsTotrLlLZjnDWuhUalhS19h3QS+Dz8fMr2m40LquIs+BPzd lr9M7ad5m+2+Km9xkz7ihTaL1qwB7uSk2BvKd235qaIfjKPmyHew7boNoz/hu5GeVmKwH2EvhX3 eBJ4d319ecPK/aYY9RUzQzMOCfBM/nDXwM0WRSJuwdOwJ9kG/4FEaWh6XTkDXMcK/nnxm/PYpBA +C9XLJ5c1hbYE66fNt/pbIy/Ld/D7+LUW62hsyvw06PgScDJxchlvwQP4G32wcZfC230TdnTZG1 OuNULmO3xxBdSAqxXssMrXMqOXOGyjP0dCOwx6T7dhKTGKt2C3ORzWa/0u2PS6xeC7SQXt+24Fr Zm1ecb0J2hi0obI3wlNxw8XgydhbI72LhfubzhEJS3G8AyemhwiS6+Gb7MGZdrnpFUiD2MJRqnd a0= X-Received: by 2002:a05:6820:828:b0:682:ecb8:c2b with SMTP id 006d021491bc7-68a6961950emr454250eaf.6.1775678562710; Wed, 08 Apr 2026 13:02:42 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:42 -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 27/36] dyndbg: check DYNAMIC_DEBUG_CLASSMAP_{DEFINE,USE_} args at compile-time Date: Wed, 8 Apr 2026 14:02:02 -0600 Message-ID: <20260408200211.43821-28-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: quoted-printable Content-Type: text/plain; charset="utf-8" Add __DYNAMIC_DEBUG_CLASSMAP_CHECK to implement the following arg-checks at compile-time: 0 <=3D _base < 63 class_names is not empty class_names[0] is a string (class_names.length + _base) < 63 dd-map-type is known value These compile-time checks will prevent several simple misuses, and will issue obvious errors if violated. 4 such examples are added to test_dynamic_debug_submod.ko, and will fail compilation if -DDD_MACRO_ARGCHECK is added to cflags. This wouldn't be a useful CONFIG_ item, since it breaks the build. Signed-off-by: Jim Cromie --- -v13 reword 2 failing tests (active only when -DDD_MACRO_ARGCHECK is passed to cc) to better identify what error is being tested against -v12 check map-type at compile-time make base+len(classnames) check more explicit dyndbg-test: add more tests of compile-time CHECKs add 3 tests of static-asserts added to 2 macros: DYNAMIC_DEBUG_CLASSMAP_{DEFINE,USE_} _DEFINE(): 1- validates maptype, 2- validate classmap.length + base-offset < 63 _USE_(): 3- validate user-offset < 63 As before, these tests fail when activated: make KCPPFLAGS=3D"-DDD_MACRO_ARGCHECK" lib/test_dynamic_debug_submod.o NOTE: _USE_() cannot test classmap.length, since its a property of the referent, not the macro itself. dyndbg-test: verify DYNAMIC_DEBUG_CLASSMAP_USE_() compile-time CHECK Add another failing use-case, this time to verify that _USE properly rejects an offset > 62. This is an incomplete test; the proper test is: classes.length + base + offset < 63, but the macro cannot test classes.length at compile-time. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 12 ++++++++++++ lib/test_dynamic_debug.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 71c91bc8d3a6..a1c75237abaa 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -181,6 +181,17 @@ struct _ddebug_class_param { * __pr_debug_cls(22, "no such class"); compiles but is not reachable */ =20 +#define __DYNAMIC_DEBUG_CLASSMAP_CHECK(_clnames, _base, _mapty) \ + static_assert(((_base) >=3D 0 && (_base) < _DPRINTK_CLASS_DFLT), \ + "_base must be in 0..62"); \ + static_assert(ARRAY_SIZE(_clnames) > 0, \ + "classnames array size must be > 0"); \ + static_assert((ARRAY_SIZE(_clnames) + (_base)) < _DPRINTK_CLASS_DFLT, \ + "_base + classnames.length must be <=3D 62"); \ + static_assert(((_mapty) >=3D DD_CLASS_TYPE_DISJOINT_BITS) && \ + ((_mapty) <=3D DD_CLASS_TYPE_LEVEL_NUM), \ + "unknown class_map_type") + /** * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. * @_var: name of the classmap, exported for other modules coordinated u= se. @@ -194,6 +205,7 @@ struct _ddebug_class_param { */ #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + __DYNAMIC_DEBUG_CLASSMAP_CHECK(_var##_classnames, (_base), (_mapty)); \ extern struct _ddebug_class_map _var; \ struct _ddebug_class_map __aligned(8) __used \ __section("__dyndbg_class_maps") _var =3D { \ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index fc599bbe605e..2107d4821019 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -146,8 +146,23 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict, = 0, D2_CORE + 1, "D3_CORE") DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 +#if defined(DD_MACRO_ARGCHECK) +/* + * Exersize compile-time arg-checks in DYNAMIC_DEBUG_CLASSMAP_DEFINE. + * These will break compilation. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_neg, 0, -1, "NEGATIVE_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_big, 0, 100, "TOOBIG_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_str_type, 0, 0, 1 /* not a string */); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_emptyclass, 0, 0 /* ,empty */); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_maptype, 3, 10, "no such type"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_len, 0, 60, + "base", "plus", "classes", "length", "too-big"); +DYNAMIC_DEBUG_CLASSMAP_USE_(fail_offset_big, 100); #endif =20 +#endif /* TEST_DYNAMIC_DEBUG_SUBMOD */ + /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 B6A75390CB1 for ; Wed, 8 Apr 2026 20:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678566; cv=none; b=NkIhOPPmELcLPl/mVbZeCZlz/JEs/uvFaCDihwkUFoPFjq6hF8ALxLdeD65eea/lw25HafZe4ZC55BZigRa1t4digTUoErUKm3u3rJHxgYHP0VQI23pQD/P7oYY/nSn0UNQKic3BBcfUu9FeNS8eHk1C7HSEyow0fqjFCTXYgyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678566; c=relaxed/simple; bh=uiNIAcOiEtF1AqkDumYo9fJYFWzJ7a0D0XK/AWxnvzQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uQYRfqhhIh2fkMZHD3gHf8m1db20h5RG47MkacYwocaSkTd8g8qsh0c8ZZFFjrA8gMPMS8nXosuLYc8vQOX2PTVDMXYRnE24kdRzxBX3EkPh1iHK9mQsYbUPA29IKQe8qxgSUar5DqFw3BXE1eJnTb3t2IlF4piVUoQ7zX4M8wA= 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=tNxaql+Y; arc=none smtp.client-ip=209.85.161.47 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="tNxaql+Y" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-673ee2a98b1so86780eaf.0 for ; Wed, 08 Apr 2026 13:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678563; x=1776283363; 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=FygXuDEb3j1cPIriIzSH6F7yJ+2Hqlzzz7TzyFPnXyk=; b=tNxaql+YPmYpkPWzUo4x08np2AsOtKlzDbEq+Bj9aIx0ZRlHhamUkH9lT9UauQDbY4 0BKbrLISQIE3lCTcaSTd53BOaXT2DsMAxE+C1GB5laVMx0Sb1hXqixjjptdMQdPaYzFU VaW+Ov1Q5SJ1d97Zfxpvzv9yhJZ3K6BNo1tPleZ5LX8VPL5nT/8OyD7XbBAJX7jzrQk/ KlXgI3+ZCZMnLS58XLUuYAkhVxbBH4zAfrBx49oNhJX1Wkn3JoJ94oYR6UW59/94L/nm fjkN8ndjny73zckeAp1Gtpn+FdLwWfs9vHgDcubB1uIfTdEBbM2RySzvSxfJdIzlRcNd R9rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678563; x=1776283363; 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=FygXuDEb3j1cPIriIzSH6F7yJ+2Hqlzzz7TzyFPnXyk=; b=MsGyxIalPf+DIq50zktBZW1iCc7sNYLFoRjg+u1UAhA4twSX9pbZd8oVQJYV4V2AbK xHIHYV/ULG59LSgCT+CO+RtG7RXAjtzs+Sl2MRRCy3TOddNguZsGkzTrZERrK60hKZfW 0t7+K4ZDh+Z65TjfFYG80hb2VE4yBwjjA7I3hH+2hUNV4bkeHxhuSCTTcWJb3GkxQJS8 QnHBSUDjQRbXgCN3efv4cRgRY5OD3n5bV1/o/w+1QPT9KFVwnVmonyv/TrQHnB8JcqAc lIE4+wM6cfYbjSDijhw1SgJGdCwQ2Fx4T7PXWAW2h5PhNQMfmYsVgFzM4p42iYSMm2Tk 5CWA== X-Gm-Message-State: AOJu0YzBXIhKLFSJfo7KshlV4S65nfR/MqxxwlZzIxH2adLqTRIl61XD UTmFHqb2sSW8Zkwbeppt5uA2NzWcNFIwxirdYSB28YEmcvR0xFqqJOXTKuyPHA== X-Gm-Gg: AeBDieu4hBvrye92H7bl1bG0dWnN6V/40tPD2kqewRmUcefXtjuYWj59nb5Q986CP+y iTa7WmsFFk864CErjt7EITrGW2sX656MTWIPvXpK+0yvqF+pnJEn43kdV5gSbNNJj4vq9lvYxSu cs8OyfdAx0oO8ujhEz2d+lAaDz5vugWQPyCPZevJzGvyjYa++V+8hisXzfG3j6oW6Cb+NEYZGO/ VcuUSuWxDD8totHBmO5Z2PRcTn72mcuy+RhRi20tzHd4i4hIgDFgImLknt4dzoCUkoDFhv5iVRl Yj9TvDLaHZF14h7HMm+zpqrGRiDpJktTJx5BI9pdsNwCtur9lmsgKvYBEj+S7C6IpE+njVT35DC mY7RV6Fu/+/BLnchuEhKtRUJ2LVPQVhDhltWjN/kwf/EFccmEiOjxN7XBuM5mjfHlNPfKvhJRhh h+iSRIkeHVQNtICJhls39vgt4xzfBf9mR3TrcK0em9H0PstnXQigy2Ac2qfofvqHwhpong6MqQL Uo= X-Received: by 2002:a05:6820:81cf:b0:67f:1ad6:344e with SMTP id 006d021491bc7-68a63c8a867mr550417eaf.61.1775678563465; Wed, 08 Apr 2026 13:02:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:43 -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 28/36] dyndbg-test: change do_prints testpoint to accept a loopct Date: Wed, 8 Apr 2026 14:02:03 -0600 Message-ID: <20260408200211.43821-29-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: quoted-printable Content-Type: text/plain; charset="utf-8" echo 1000 > /sys/module/test_dynamic_debug/parameters/do_prints This allows its use as a scriptable load generator, to generate dynamic-prefix-emits for flag combinations vs undecorated messages. This will make it easy to assess the cost of the prefixing. Reading the ./do_prints node also prints messages (once). Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 2107d4821019..5de839f13c8b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -29,18 +29,25 @@ =20 #include =20 -/* re-gen output by reading or writing sysfs node: do_prints */ - -static void do_prints(void); /* device under test */ +/* re-trigger debug output by reading or writing sysfs node: do_prints */ +static void do_prints(unsigned int); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) { - do_prints(); + int rc; + unsigned int ct; + + rc =3D kstrtouint(instr, 0, &ct); + if (rc) { + pr_err("expecting numeric input, using 1 instead\n"); + ct =3D 1; + } + do_prints(ct); return 0; } static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { - do_prints(); - return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); + do_prints(1); + return scnprintf(buffer, PAGE_SIZE, "did 1 do_prints\n"); } static const struct kernel_param_ops param_ops_do_prints =3D { .set =3D param_set_do_prints, @@ -195,17 +202,20 @@ static void do_levels(void) prdbg(V7); } =20 -static void do_prints(void) +static void do_prints(unsigned int ct) { - pr_debug("do_prints:\n"); - do_cats(); - do_levels(); + /* maybe clamp this */ + pr_debug("do-prints %d times:\n", ct); + for (; ct; ct--) { + do_cats(); + do_levels(); + } } =20 static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); + do_prints(1); pr_debug("init done\n"); return 0; } --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 D9CE038F230 for ; Wed, 8 Apr 2026 20:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678568; cv=none; b=l0nLJ3zPC/Bt3PYxO4DWRYHxS9Awl2LoQiDsClOniSsMcAr1Kv500XYMYbD8hJYbbd2By0pTIw1JqB358ZlmaOyR4Qd6r7oiF2PcppK45y8++iczDaB7GnpLP4qchoumRsZCnOQDghPwrsRJp1J+SETkrIlv5OP+gqYERhC3yIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678568; c=relaxed/simple; bh=uzk/Uz16G+P21gF80eiAc7MCZBQftZT7FKz2B9SLJ3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t0loJlOsLj9jhQqUU9plXnlhNtaMgbR8ZooLvx3Vj+ZuruXbDYc4aEzW7acrWI1MOxmIrB52AETV9+/FQg9pIwiMaeG8A8C0bhHP3j16ESE+yb6DVKWU7pDm8SlP4DUU2P44jV8TOOQsqD+NtsM1dltZX4/xHihPGoQuKtzHJpI= 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=stiuFkKv; arc=none smtp.client-ip=209.85.161.42 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="stiuFkKv" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-68397b9840cso74368eaf.3 for ; Wed, 08 Apr 2026 13:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678565; x=1776283365; 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=r3lJmo3eMKjk/jZ9JKeuvFRBsJICqSD+ey/zv5e1roE=; b=stiuFkKvaFf6gfCa3T0jJN6xgjU71cBJpSfcnMyH75VsDUCdoB88/7n8ZHiJqtkORV RQsYw+ivma1JRuWRPfcEarJ6FVRF/ybUWzOk9OEt6S8CggWOM7+7iXYLIq8ugmV9Z6PF wXm5pjWGZgUM/bcVSRWCGOlo4YGOuoSLsk5sk83mDY5RmAybwPKzwe2XXGq+/drE/eQn SNyzUMD/BFVnI9vlQbjxtl7YzdCwC6atnT10ly2wa0t5K+ux4SHJYi2KXbw4DcrmTZsE ztEV5pYOt26YGt/AGyA7zHl0q/tvfVZFRmBQIQ27IBejA17lH2I12PY/UiE+K2jPJ3c8 iAhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678565; x=1776283365; 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=r3lJmo3eMKjk/jZ9JKeuvFRBsJICqSD+ey/zv5e1roE=; b=Zu4gMfXMQsEr//NACHe0Ubq/0EWZPzrk9PRriYIuW9moBVxvmpDmzDUGYB5Xbyo3T8 TxDzLpScNnOOyxzl3EPCCYBQWuoZoQ4SSdsZVGD+D7ZO9ddCvqVMHFqRWhxpNgrdmZ7w eNqqngYu/B1EE0/NUBLtj3wMg8OvZoIu7umZRhcIIOHdX/w16GsqppEbZPCCFAgTgg7J tYEINjpET7Dw+UNyh8zlbHuhdkegSG1Y2dJEPmhJUBuUhE7Oh6xk2eaeK0pIvalskq2L uSUUZW33u4EB+D4ZcX2/mQLDWEJiI6wANS2bb2sv6FKmOwG7wjRIA0ciTa+Nj47flKBp RasQ== X-Gm-Message-State: AOJu0YwLoNc2yWZEkKsyOfYaPKEShC7KcD1ppO+YojfrA9EtJ6faxU2U CdGrjuTHillXFHEnIpzbaTrd4ZRqnA+faRvJaDp/WT+oF9aBC4mlsSm0Qts7pQ== X-Gm-Gg: AeBDieuf8AjON0KHulc2m5lzrGJS4sTMqUm7yx2RAhaWA6kGFMlfCpCMCETOBX2NmIM /tb+VqgBz7Y3L28f+QIyvcCrdNkyhzjtItQkjNTjrsK+VsJjQv5CufNmi5cjz6CoRRsIYd1aaPg 4D1iK5lfaB95HXeB1abg8tRBCTTG7cDab1beQyHCjZL7MoAi6AvG2JMsiLXTiHSId83ADBTNNSq gUgfEaHDyARWk1rVgg3dYHCxrlJvfvjbgrxbXKF7Q+hv0x0Zo0QL9VzadlMDRe6tu88iv4wo8Z5 QruL50h8Du9KHl5cXNYAAgqdqJwbYObnM6Zk1ry6xkGiVHMSBi0nOFlDnjR8YetC7HpoH5KFnSH SaL5xJNifLdURxyOayUX592tTGdx/JxANP1+cxwOJO3C7Y4BVYZ2Cb2BiU5uzuEuANazfOiCZDn djCrUJhxt6/UGkFYlueA4igsZ3nDc485xbB1HlRMya6mGohHVtOPsvqCGFOb5NvxX1NVjekbLC7 +FaT4fWvaNy7A== X-Received: by 2002:a05:6820:907:b0:688:f082:c73f with SMTP id 006d021491bc7-68a6280c87dmr509971eaf.27.1775678564520; Wed, 08 Apr 2026 13:02:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:43 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v13 29/36] dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API Date: Wed, 8 Apr 2026 14:02:04 -0600 Message-ID: <20260408200211.43821-30-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: quoted-printable Content-Type: text/plain; charset="utf-8" move the DYNAMIC_DEBUG_CLASSMAP_PARAM macro from test-dynamic-debug.c into the header, and refine it, by distinguishing the 2 use cases: 1.DYNAMIC_DEBUG_CLASSMAP_PARAM_REF for DRM, to pass in extern __drm_debug by name. dyndbg keeps bits in it, so drm can still use it as before 2.DYNAMIC_DEBUG_CLASSMAP_PARAM new user (test_dynamic_debug) doesn't need to share state, decls a static long unsigned int to store the bitvec. __DYNAMIC_DEBUG_CLASSMAP_PARAM bottom layer - allocate,init a ddebug-class-param, module-param-cb. Modify ddebug_sync_classbits() argtype deref inside the fn, to give access to all kp members. Also add stub macros, clean up and improve comments in test-code, and add MODULE_DESCRIPTIONs. cc: linux-doc@vger.kernel.org Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 40 ++++++++++++++++++++++ lib/dynamic_debug.c | 60 ++++++++++++++++++++++----------- lib/test_dynamic_debug.c | 47 ++++++++++---------------- lib/test_dynamic_debug_submod.c | 9 ++++- 4 files changed, 106 insertions(+), 50 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a1c75237abaa..1cae9a2f32d7 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -273,6 +273,44 @@ struct _ddebug_class_param { .offset =3D _offset \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM - control a ddebug-classmap from a sys-par= am + * @_name: sysfs node name + * @_var: name of the classmap var defining the controlled classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported classmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in a private long int. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ + static unsigned long _name##_bvec; \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _name##_bvec, _var, _flags) + +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM_REF - wrap a classmap with a controlling s= ys-param + * @_name: sysfs node name + * @_bits: name of the module's unsigned long bit-vector, ex: __drm_debug + * @_var: name of the (exported) classmap var defining the classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported clasmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in user @_bits. This lets drm check + * __drm_debug elsewhere too. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) + +#define __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) \ + static struct _ddebug_class_param _name##_##_flags =3D { \ + .bits =3D &(_bits), \ + .flags =3D #_flags, \ + .map =3D &(_var), \ + }; \ + module_param_cb(_name, ¶m_ops_dyndbg_classes, \ + &_name##_##_flags, 0600) + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -455,6 +493,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) #define DYNAMIC_DEBUG_CLASSMAP_USE(_var) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _var, _flags) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(...) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a7f67ecbc4d7..c6f3b0452dfa 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -687,6 +687,30 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 +static void ddebug_class_param_clamp_input(unsigned long *inrep, const str= uct kernel_param *kp) +{ + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; + + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + /* expect bits. mask and warn if too many */ + if (*inrep & ~CLASSMAP_BITMASK(map->length)) { + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", + KP_NAME(kp), *inrep, CLASSMAP_BITMASK(map->length)); + *inrep &=3D CLASSMAP_BITMASK(map->length); + } + break; + case DD_CLASS_TYPE_LEVEL_NUM: + /* input is bitpos, of highest verbosity to be enabled */ + if (*inrep > map->length) { + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", + KP_NAME(kp), *inrep, map->length); + *inrep =3D map->length; + } + break; + } +} static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -705,26 +729,15 @@ static int param_set_dyndbg_module_classes(const char= *instr, pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } + ddebug_class_param_clamp_input(&inrep, kp); =20 switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: - /* expect bits. mask and warn if too many */ - if (inrep & ~CLASSMAP_BITMASK(map->length)) { - pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", - KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); - inrep &=3D CLASSMAP_BITMASK(map->length); - } v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: - /* input is bitpos, of highest verbosity to be enabled */ - if (inrep > map->length) { - pr_warn("%s: level:%ld exceeds max:%d, clamping\n", - KP_NAME(kp), inrep, map->length); - inrep =3D map->length; - } old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); @@ -1200,15 +1213,24 @@ static const struct proc_ops proc_fops =3D { static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { const struct _ddebug_class_param *dcp =3D kp->arg; + unsigned long new_bits; =20 - /* clamp initial bitvec, mask off hi-bits */ - if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { - *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); - v2pr_info("preset classbits: %lx\n", *dcp->bits); + ddebug_class_param_clamp_input(dcp->bits, kp); + + switch (dcp->map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + v2pr_info(" %s: classbits: 0x%lx\n", KP_NAME(kp), *dcp->bits); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0UL, modname); + break; + case DD_CLASS_TYPE_LEVEL_NUM: + new_bits =3D CLASSMAP_BITMASK(*dcp->lvl); + v2pr_info(" %s: lvl:%ld bits:0x%lx\n", KP_NAME(kp), *dcp->lvl, new_bits= ); + ddebug_apply_class_bitmap(dcp, &new_bits, 0UL, modname); + break; + default: + pr_err("bad map type %d\n", dcp->map->map_type); + return; } - /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ - ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); - ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); } =20 static void ddebug_match_apply_kparam(const struct kernel_param *kp, diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 5de839f13c8b..d65fa3f3ef9e 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems like DRM. * * Authors: * Jim Cromie @@ -57,24 +58,6 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0= 600); =20 #define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) =20 -/* sysfs param wrapper, proto-API */ -#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ - static unsigned long bits_##_model =3D _init; \ - static struct _ddebug_class_param _flags##_##_model =3D { \ - .bits =3D &bits_##_model, \ - .flags =3D #_flags, \ - .map =3D &map_##_model, \ - }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ - &_flags##_##_model, 0600) -#ifdef DEBUG -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) -#else -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) -#endif - /* * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. * @@ -105,12 +88,15 @@ enum cat_disjoint_bits { /* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; =20 -/* recapitulate DRM's multi-classmap setup */ +/* + * use/demonstrate multi-module-group classmaps, as for DRM + */ #if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) /* - * In single user, or parent / coordinator (drm.ko) modules, define - * classmaps on the client enums above, and then declares the PARAMS - * ref'g the classmaps. Each is exported. + * For module-groups of 1+, define classmaps with names (stringified + * enum-symbols) copied from above. 1-to-1 mapping is recommended. + * The classmap is exported, so that other modules in the group can + * link to it and control their prdbgs. */ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, D2_CORE, @@ -129,11 +115,13 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS= _TYPE_LEVEL_NUM, V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); =20 /* - * now add the sysfs-params + * for use-cases that want it, provide a sysfs-param to set the + * classes in the classmap. It is at this interface where the + * "v3>v2" property is applied to DD_CLASS_TYPE_LEVEL_NUM inputs. */ =20 -DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); -DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_disjoint_bits, map_disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_level_num, map_level_num, p); =20 #ifdef FORCE_CLASSID_CONFLICT /* @@ -144,12 +132,10 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict,= 0, D2_CORE + 1, "D3_CORE") #endif =20 #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ - /* - * in submod/drm-drivers, use the classmaps defined in top/parent - * module above. + * the +1 members of a multi-module group refer to the classmap + * DEFINEd (and exported) above. */ - DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 @@ -228,6 +214,7 @@ static void __exit test_dynamic_debug_exit(void) module_init(test_dynamic_debug_init); module_exit(test_dynamic_debug_exit); =20 +MODULE_DESCRIPTION("test/demonstrate dynamic-debug features"); MODULE_AUTHOR("Jim Cromie "); MODULE_DESCRIPTION("Kernel module for testing dynamic_debug"); MODULE_LICENSE("GPL"); diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c index 672aabf40160..3adf3925fb86 100644 --- a/lib/test_dynamic_debug_submod.c +++ b/lib/test_dynamic_debug_submod.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems, like DRM, + * which defines its drm_debug classmap in drm module, and uses it in + * helpers & drivers. * * Authors: * Jim Cromie @@ -12,3 +15,7 @@ */ #define TEST_DYNAMIC_DEBUG_SUBMOD #include "test_dynamic_debug.c" + +MODULE_DESCRIPTION("test/demonstrate dynamic-debug subsystem support"); +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 BA54C391853 for ; Wed, 8 Apr 2026 20:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678568; cv=none; b=dLNTER736HWB11fNsESQGJCEBQuGCZCkjSXJpxhz7Cw+u5EQ2ihy8HZfXHE21bikaL/o9oeqRPuNwR7LfVzorVlYVlTmlTnhwzIkUd33PSOI5rKlbbTXBHqT9m8dSarHK9fxEJLOZpbTzQVPifftzMNV3jXqZvQz80zGOfU7AqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678568; c=relaxed/simple; bh=9ethbFA+3sG+Yt9H6ZFtM83MzmnmFw3XXUtYcrjFgG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kHMVNAjc7kixo1kyUXCMtmRvkbanMwRvL4KxQ9sKTV5EUnrg6gKfCJFU/8N84PVAGtKQJtZtmoYJHcyBkovDhEiLIhBGZ9llLCJa/VxqyPdDPMrBEzQeiGfOFcjmh+RuNOB0xsNL6ZU6TOhfL8Po/imuvXaN0okdzMI8GXVVeVo= 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=rJh3hUEY; arc=none smtp.client-ip=209.85.210.50 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="rJh3hUEY" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-7d55b97f358so104235a34.3 for ; Wed, 08 Apr 2026 13:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678565; x=1776283365; 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=Op8z6BF2VC082oV6Way2DdykcbiTU1bYqkraAfxcvx0=; b=rJh3hUEYt62u1+mXXNGPY9vXmxP07pfcTZBIV6+sLihzHueR4YUM0HyZj37/rwvjbK iUVTneUPcFPR5c2xwfRu42RZ9rDx1twBWwLS8xFCO+tUzwfQS602r2FwD/pC9iMVp7+2 rwsLS5kX+evFAdFD9V1mcRO2q/gIYtwl+b5+gJ1mfnhUjHdnAegMONPjuIsF2UKkDVAw RR3Ms1f1F2aXc0bYQJUvZLMV8lnXAyx6C3OcVJWLj3kCmG7hbN8tjaUyUje5wVCE0NqY NOIaWkm6rYhIL/mpElVxGtEl8RwN0fAfV9epnaYi9MMKIQ3gBz99qYRuEk6SWW1R642k Cd1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678565; x=1776283365; 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=Op8z6BF2VC082oV6Way2DdykcbiTU1bYqkraAfxcvx0=; b=eYixnRvp8rzsfOTDpg1UO2jOnrHgr7yNBGhVEFMybBy9QiDnnbnjbO/hu4QN2xTmRx tTf3hIYOvUGNKqAJouJdJ+CHPjL0bL6oCKaB92j37AKPrydpNYf1C7zvjOeP+0l9KeKO q6wIIkqfYcZh2KFbhJhNXP9geVGFaRkuwITb27KozVFcdG2dfzeV2W4qTwNtqrA2l4km 8AQy4qRdFOvqlMSAHSTxTn62/Q4+5tySipjE7DDfIqmJ5BCfS236YVGNT8ex0C2uzaKN oiUQwLCCYEW9doV8vUrgYFpJIHgyqXD+IYlgknw21Ax2CS2SNu2z1WyV7YtYwb0RwhH1 EKiw== X-Gm-Message-State: AOJu0Yxe8gDBhtZV9ihQ36e957FNhb1nf3u+sv6W4WN52MGkDmvTrYO9 ZLuZMMGNpv1nqRaTaXRMlt+CF2vtq3H8u4piGx5IzHl7qid0YnKwbRz7Ouggtw== X-Gm-Gg: AeBDieujMoNiiAtElUn6pRUcCVTDQBtCWjaKKmhWH7VloQ0vRU0osO53yAA4Kd8Ck0J sWmSF0bmiTgIdRul1TrrbtN0HPYQ+p3q4Dco+6l2L7vfCmS+gsYrvaEev/iWZnQCe2tPzV+Ftgs 51GhGyBqCPzaxadzUb98t2zzZmtmKno4Thrx2lb276N6rIPZWpyzFcVECqSeoMQehQDEVdxaWWn JlxGwqCRxQbkKYB5LBVdwCFbdQhRAjZZ33iuN6kJ5Vf78gvmUf3cKYqNbZobipJUe5gemYQDfKx sZQfRfQyrIU8N2AogwtGgHAADgF1c+0K0xiRyUVG2zY4LE0gzuTNANalpq3E3EA2dq+fC2/kA7Z 0d4IuyuFqF7ydBFtTsVsGTj3LKRfQq+UNxatKL8ynrXxBKj5iLG1G+67qCp7OOznaeJa7bRevNc eo8IonRwFfsqzwCeV/6Vq0CUSrKbbBZeSUUJJYc08JSMWOUoEyTIaFnAjVnl263klVXFdR1umYl r0= X-Received: by 2002:a05:6820:81c4:b0:67b:b8d0:a7d5 with SMTP id 006d021491bc7-6822024fab7mr13382144eaf.53.1775678565380; Wed, 08 Apr 2026 13:02:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:44 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , =?UTF-8?q?=C5=81ukasz=20Bartosik?= Subject: [PATCH v13 30/36] dyndbg: treat comma as a token separator Date: Wed, 8 Apr 2026 14:02:05 -0600 Message-ID: <20260408200211.43821-31-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed: :#> modprobe drm dyndbg=3Dclass,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p or as a boot arg: drm.dyndbg=3Dclass,DRM_UT_CORE,+p # todo: support multi-query here Given the many ways a boot-line +args can be assembled and then passed in/down/around shell based tools, this may allow side-stepping all sorts of quoting hassles thru those layers. existing query format: modprobe test_dynamic_debug dyndbg=3D"class D2_CORE +p" new format: modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+p ALSO selftests-dyndbg: add comma_terminator_tests New fn validates parsing and effect of queries using combinations of commas and spaces to delimit the tokens. It manipulates pr-debugs in builtin module/params, so might have deps I havent foreseen on odd configurations. Reviewed-by: Louis Chauvet Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 9 +++++--- lib/dynamic_debug.c | 17 +++++++++++---- .../dynamic_debug/dyndbg_selftest.sh | 21 ++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 9c2f096ed1d8..dbf901150587 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -78,11 +78,12 @@ Command Language Reference =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 At the basic lexical level, a command is a sequence of words separated -by spaces or tabs. So these are all equivalent:: +by spaces, tabs, or commas. So these are all equivalent:: =20 :#> ddcmd file svcsock.c line 1603 +p :#> ddcmd "file svcsock.c line 1603 +p" :#> ddcmd ' file svcsock.c line 1603 +p ' + :#> ddcmd file,svcsock.c,line,1603,+p =20 Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: @@ -167,9 +168,11 @@ module The given string is compared against the module name of each callsite. The module name is the string as seen in ``lsmod``, i.e. without the directory or the ``.ko`` - suffix and with ``-`` changed to ``_``. Examples:: + suffix and with ``-`` changed to ``_``. =20 - module sunrpc + Examples:: + + module,sunrpc # with ',' as token separator module nfsd module drm* # both drm, drm_kms_helper =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c6f3b0452dfa..16cff6c3b81a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -320,6 +320,14 @@ static int ddebug_change(const struct ddebug_query *qu= ery, struct flag_settings return nfound; } =20 +static char *skip_spaces_and_commas(const char *str) +{ + str =3D skip_spaces(str); + while (*str =3D=3D ',') + str =3D skip_spaces(++str); + return (char *)str; +} + /* * Split the buffer `buf' into space-separated words. * Handles simple " and ' quoting, i.e. without nested, @@ -333,8 +341,8 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) while (*buf) { char *end; =20 - /* Skip leading whitespace */ - buf =3D skip_spaces(buf); + /* Skip leading whitespace and comma */ + buf =3D skip_spaces_and_commas(buf); if (!*buf) break; /* oh, it was trailing whitespace */ if (*buf =3D=3D '#') @@ -350,7 +358,7 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end =3D buf; *end && !isspace(*end); end++) + for (end =3D buf; *end && !isspace(*end) && *end !=3D ','; end++) ; if (end =3D=3D buf) { pr_err("parse err after word:%d=3D%s\n", nwords, @@ -622,7 +630,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) if (split) *split++ =3D '\0'; =20 - query =3D skip_spaces(query); + query =3D skip_spaces_and_commas(query); + if (!query || !*query || *query =3D=3D '#') continue; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 465fad3f392c..c7bf521f36ee 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -216,7 +216,7 @@ function check_err_msg() { function basic_tests { echo -e "${GREEN}# BASIC_TESTS ${NC}" if [ $LACK_DD_BUILTIN -eq 1 ]; then - echo "SKIP" + echo "SKIP - test requires params, which is a builtin module" return fi ddcmd =3D_ # zero everything @@ -238,8 +238,27 @@ EOF ddcmd =3D_ } =20 +function comma_terminator_tests { + echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP - test requires params, which is a builtin module" + return + fi + # try combos of spaces & commas + check_match_ct '\[params\]' 4 -r + ddcmd module,params,=3D_ # commas as spaces + ddcmd module,params,+mpf # turn on module's pr-debugs + check_match_ct =3Dpmf 4 + ddcmd ,module ,, , params, -p + check_match_ct =3Dmf 4 + ddcmd " , module ,,, , params, -m" # + check_match_ct =3Df 4 + ddcmd =3D_ +} + tests_list=3D( basic_tests + comma_terminator_tests ) =20 # Run tests --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 C3C273921FA for ; Wed, 8 Apr 2026 20:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678569; cv=none; b=Lziz/Z+MByg6XCYLgUS0jsnCVN8vpDlANHJfrHbHoPt1NwlIyrEEBiIKUnELTHwWnPzO/qHmNRWlqtaKP+j7GM9Lt84Ed8454juz7gim0IIPTOhmIAl6qaLcRZSFeuakvEGjaX0GuGTvGY+4Yk7joFjz5ot+tcvRAvjAZ1jLb5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678569; c=relaxed/simple; bh=gSLOnEPV+jvjPNA5x/nZIZ9K0KOd+BB7WmwBOrzaITU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JFNoqKfZ9mDe1EXQN6dCOLR4f+f86zqZmEK4aJEwJLFqBA4FfbwyjIKqegfTe4e6Lr13IFUiD29Od4VsPnIGg2uN+mhXbEOpImClYPlIGvWMsahFhnxPGkvZOZkzrk6wG1RdKiKG7TIsgNsQPIfMATajORLm4V8k99WJeIW4vrE= 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=N2ZSaGVn; arc=none smtp.client-ip=209.85.161.51 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="N2ZSaGVn" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-67e0d3f288aso97859eaf.0 for ; Wed, 08 Apr 2026 13:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678566; x=1776283366; 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=wYQBxHr3Fa2/s6UIiugIdxA7TpYQIjo73GyHI23/HiM=; b=N2ZSaGVn9WE/7U9DVJU14kr2WH8oytvSLPFR36oPQSuhIM0O06JJ/mXHSPCEGAWTcH n9bkLwJa8SKGqp1MNzHhTTZDWDS8lpenCXC0w3A/DWNBrKjtBjjVwHzjbjpDzlHqAV5G CKl8WwgoQOPbCbXogUPS6NB+MqAzW7CCJjBfAJ4dT/Pm0LACvSjB+0e5GK0rXZanWQTf XXBCd//0uN+9PwlSsTOSPB3JX7oVpCr/2RgO/S1+UCLDv4MFv5SLvr7gf624Pd6wGPRl htv4Vp8IjwgAiBeGie+/pyRj2SnbbG0170jnRRiUI+DNu3rgSYeoeJHuhWzrcqjlvlIN g6pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678566; x=1776283366; 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=wYQBxHr3Fa2/s6UIiugIdxA7TpYQIjo73GyHI23/HiM=; b=sg8KNsCP4MPTcQdMCySLIWXmlV5RueFcJcEf8QzjC8K2THhw7pXKqD6axhwfxEQ7tW T96WN8MsfeMCnun8ZDdLNeG2sJfnsDlGeV9B6u8GmiXxoUoRcGWZ4AyJRVfqDE8USJN2 8c2nUGubF/FfhCInU3Sjfvmba7DucLRYoillFGOmJ/pwoVmZYRFfti22/xO4ebqswGb3 PgJTZl6qzXhVSARpnLfIYsOxIs1reJkfKAuvALDRdRpLtzngU2qbq1B7qBk1vz9N3U6h BWlzaIWyPlJ/Mil+9p8o8xwdtM68654CptTF2wBLewhakdO/Ih89yGaET4wOk4FMQKbQ hNRw== X-Gm-Message-State: AOJu0YzzrRtnIcdkUS2tcOPHtpquSknkjge6sIA96C88Jo7DH/oa6umk 4COLSOylKE/wsi+M+x0P1HLhA6rGycbEDNHNd6fqoQuMlNFpZEXI+L8ZZrCwkw== X-Gm-Gg: AeBDiev6TEOd1yH4PJWCtNPxkvuoFMVVHH8/iXQz3zmWnPkqjtOgs5hdjboOr4ksDxM bpvVkeezLOm6hKR+vh1I3rwkvBlARZ2xUreJbahGqefhMlwW/qjLrOHWR3A3JEKDdZoS58RdQuR 4utFD2wAELJkqfLXtMyXbOOuosVsL1f0q+V8haY2yIsxd0l4GNkv0HMcY+FXj37D6tZtQ2zxyxO 9R1BNiejppYz9zPs7MEuiueHk4QVWZ+SnbWwHpA0vsCVUivRC0ONizuUb8IICZcEMTnQbaBtaYL mUUnJ+HZQSy9DhOdoYTHxQo64hSWTF3GJ4pM+f3CDtcv9HjMrrs5bRoSgAlHW70CJ7CRK7BAnrV ZmD275lebpJm+3xHpidnxBk1Wpy6C40DUqACYpOwtlzARNZXtiNRsRwL5ktRm//jf21HDe73TF5 etYWb62jsmFEACMYykObAFqQBB4KjkEFTTfpx1wR2z/znoctEwcpJ08jErFdoGr3B/u9PfKgM3u s+lp2+RlilyBw== X-Received: by 2002:a05:6820:1513:b0:67e:3967:16a6 with SMTP id 006d021491bc7-6821f6793f6mr12310642eaf.39.1775678566509; Wed, 08 Apr 2026 13:02:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:45 -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 31/36] dyndbg: split multi-query strings with % Date: Wed, 8 Apr 2026 14:02:06 -0600 Message-ID: <20260408200211.43821-32-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: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit 85f7f6c0edb8 ("dynamic_debug: process multiple debug-queries on a line") Multi-query commands have been allowed: modprobe drm dyndbg=3D"class DRM_UT_CORE +p; class DRM_UT_KMS +p" modprobe drm dyndbg=3D< [ 203.902703] dyndbg: query parse failed [ 203.902871] dyndbg: processed 2 queries, with 0 matches, 2 errs bash: echo: write error: Invalid argument The '%' splits the input into 2 queries, and both fail. Given the limited utility of matching against the working parts of a format string "foo: %d bar %s", nothing is actually lost here. selftests-dyndbg: test_percent_splitting This does basic testing of classmaps using '%' separated multi-queries. It modprobes test_dynamic_debug with several classes enabled, and counts to verify that the expected sites show the enablement in the control file. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 8 ++++--- lib/dynamic_debug.c | 2 +- .../dynamic_debug/dyndbg_selftest.sh | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index dbf901150587..0a42b9de55ac 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -85,10 +85,12 @@ by spaces, tabs, or commas. So these are all equivalen= t:: :#> ddcmd ' file svcsock.c line 1603 +p ' :#> ddcmd file,svcsock.c,line,1603,+p =20 -Command submissions are bounded by a write() system call. -Multiple commands can be written together, separated by ``;`` or ``\n``:: +Command submissions are bounded by a write() system call. Multiple +commands can be written together, separated by ``%``, ``;`` or ``\n``:: =20 - :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd func foo +p % func bar +p + :#> ddcmd func foo +p \; func bar +p + :#> ddcmd "func foo +p ; func bar +p" :#> ddcmd <<"EOC" func pnpacpi_get_resources +p func pnp_assign_mem +p diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 16cff6c3b81a..6430f77c7b9c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -626,7 +626,7 @@ static int ddebug_exec_queries(char *query, const char = *modname) int i, errs =3D 0, exitcode =3D 0, rc, nfound =3D 0; =20 for (i =3D 0; query; query =3D split) { - split =3D strpbrk(query, ";\n"); + split =3D strpbrk(query, "%;\n"); if (split) *split++ =3D '\0'; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index c7bf521f36ee..513f6cb1db1d 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -256,9 +256,33 @@ function comma_terminator_tests { ddcmd =3D_ } =20 +function test_percent_splitting { + echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on= % ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+p= t%class,D2_ATOMIC,+pm + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + check_match_ct test_dynamic_debug 23 -r + # add flags to those callsites + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + check_match_ct test_dynamic_debug 23 -r + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests comma_terminator_tests + test_percent_splitting ) =20 # Run tests --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 C27CE392C50 for ; Wed, 8 Apr 2026 20:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678570; cv=none; b=Xsgs9o0DqItIecxqVeagIeZmcgIeziu8eFTZXMp4++sDnDjKmiN3Ke1VTtoMfWf6z6YLCCkLyolhVIcYWHbviW6OFVmkK3HayWpLrW1EjyzxNSGpBUb4W0OS+HMDWDNo2xZvrmaJD5uU31kmO6EYbJRBYCWy30bA5FaIhZ2AuTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678570; c=relaxed/simple; bh=o9XAvjSs/yDZQc7WmR2T+j5cz0yKThRjVBgsLtPQWN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=njOjyQ3RCw6qym+mC9KiMTVt9nrzCxjWOByokTYy8SEUkjiJxiNeBrQ0vsA1JI8zZoV4AlrEvDDSzlGxA3LX3gDknVBrnsxIT4csuarZ3ZCLDTCmSW2RtljCIyvKR8TN9LX9MsCjh1Q6XpP1mUykZRJ+4y83eH7oPV0c3cAwCok= 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=VLGj/ACf; arc=none smtp.client-ip=209.85.161.47 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="VLGj/ACf" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-688c2235cd4so93079eaf.0 for ; Wed, 08 Apr 2026 13:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678567; x=1776283367; 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=ZxTkOltoVAiRQNIiLPEo11+229bHMC78x0TMXlU2wIM=; b=VLGj/ACfhoYhfAAVbMmL2R3aUboES3UESczpsSOBe4SlGUJJTc2gsHbn2Hu9C3ilOm p8xFszvla97jZ4pAn5LzPmJaAsdVDUmeQbf4FP67j2+43xzCC7ADg3c2nRJzZ4+WSEvr si3iCOfmH3Pa7H303AmcuDzIfSQhXfeijkkwc3Hl8PQMooohPzy+JXYnLTDVnOcCjKc8 UbyQ3i4OqpcqraA2QG9voYgIVA2a+kH527DjGR9V0pTusSWlaCsWKpwhv3sx0PhfBD7c FdH3Bgy+J3w/Z95RJIudwmV+SAyNURaz9ZyTnXsfXB/nxMv+1Hoxq0V4jsHNf7bR6Ol2 v2VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678567; x=1776283367; 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=ZxTkOltoVAiRQNIiLPEo11+229bHMC78x0TMXlU2wIM=; b=aVEt1/Z0F2mf/8ABVIymCGovJZzVqoYjWQt4ZUUd130gihu/hEXgur1ebxh0J4KkDM gmo5xKwfv+RTz2JUfjH9j1W5Mn4sJzs+HSiYDnspIVy5sbcBd3JczLbN3k/cwTIgs6pa 3tf+4UN8R6aEQ2RhqhdTAAlA/Bif9+VmivK3PbLqyrvNnx4U173dbiPG9otlxGF8U2XL 7y4/jVYbIU0Bd5e1Zhegrbquayn0KsNajCOdDpKBWVux8QgcufRYnbv0WTUipg+akoEX VBzE7R31Vpnmm9tf4Af/+S0hKIdc7MwNonfHFcLaA3u5PqKtCVVyB34GBPryK9jthAlH 706g== X-Gm-Message-State: AOJu0YxH191SBmqrcy6EvSQ9dX7D8JEAvB6CsRzxGTLdxtu/J9LnBfHI 2VYmVufoizTstc9MgSq0aB25FC07/7duFk5MKfwEzkbDYVT1NIvWw08gwcQ8jw== X-Gm-Gg: AeBDiesEN2bqokHj4Yu+gobWVymhlUvpfm/7nZPs88mHcxcm4x8ZRV34yGZ+qOmIEyd PZnMVHRvCr/WJBsf9t2xuVuMpNnJqzGg+TOfwwoAalSxspDFYzlGxhR4NCEiidSkwqaVtXheZTq okylXf7GAsXVUvEBugjhnZgDVzoKZfKH86RdsOKtNsnk6RNOUjY0BVzS0XTkxYQ69pY6eN9/k2S r8n5MR+U2gHwoKBIyo+9R/skbuhz0OdgBCeL8ZiyGw9koVCYXr+w/Jr58FzSGK7TefaRdmx91iK Dw8lmatPJC5Nf72Rc6Pr9uO0Tfe87+QJeRbEsBrqAn0THi5jiud+YmZimPqVResmZlFKmK2yKeV OxnqVkOHVZ/gg/tdtB1EQMA2hmolk7SDcVIF2vqi3ZrQ7vWmnn4D463Z3Flj0r+ZLKv5jhsruaH pspCu1aOk1wyEJ1Nc2ADRPBhpklNLYfI0iv/51SICLWpMkE/n5REGYVPaX9FS26h6FqdvjIskss +o= X-Received: by 2002:a05:6820:1b09:b0:68a:8fc7:6444 with SMTP id 006d021491bc7-68a8fc767damr156418eaf.27.1775678567554; Wed, 08 Apr 2026 13:02:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:47 -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 32/36] selftests-dyndbg: add test_mod_submod Date: Wed, 8 Apr 2026 14:02:07 -0600 Message-ID: <20260408200211.43821-33-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: quoted-printable Content-Type: text/plain; charset="utf-8" This new test-fn runs 3 module/submodule modprobe scenarios, variously using both the generic dyndbg=3D modprobe arg, and the test-module's classmap-params to manipulate the test-mod*'s pr_debugs. In all cases, the current flag-settings are counted and tested vs expectations. The 3rd scenario recapitulates the DRM_USE_DYNAMIC_DEBUG=3Dy failure. 1. 2 modprobes (super then sub), with separate dyndbg=3Dclass-settings check module specific flag settings 2. modprobe submod, supermod is auto-loaded set supermod class-params check expected enablements in super & submod 3. modprobe super, with param=3Dsetting (like drm.debug=3D0x1ef) modprobe submod validate submod's class'd pr_debugs get properly enabled The test uses multi-queries, with both commas and percents (to avoid spaces and quoting). This is the main reason the test wasn't earlier in the patchset, closer to the classmap patches its validating. With some tedium, the tests could be refactored to split out early tests which avoid multi-cmds, and test only the class-params. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- .../dynamic_debug/dyndbg_selftest.sh | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 513f6cb1db1d..09937dca3056 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -279,10 +279,83 @@ function test_percent_splitting { ifrmmod test_dynamic_debug } =20 +function test_mod_submod { + echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + + # modprobe with class enablements + modprobe test_dynamic_debug \ + dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+pt%class,D2_ATOMIC,+pm + + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + modprobe test_dynamic_debug_submod + check_match_ct test_dynamic_debug_submod 23 -r + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct test_dynamic_debug 46 -r + + # no enablements propagate here + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + # change classes again, this time submod too + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml "# add so= me prefixes" + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + # submod changed too + check_match_ct =3Dmf 1 + check_match_ct =3Dlt 1 + check_match_ct =3Dml 1 + + # now work the classmap-params + # fresh start, to clear all above flags (test-fn limits) + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + modprobe test_dynamic_debug_submod # get supermod too + + echo 1 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 4 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( V1-3 + D2_CORE ) + check_match_ct =3Dp 8 + echo 3 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_CORE, D2_DRIVER ) + check_match_ct =3Dp 4 + echo 0x16 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_DRIVER, D2_KMS, D2_ATOMIC ) + check_match_ct =3Dp 6 + + # recap DRM_USE_DYNAMIC_DEBUG regression + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + # set super-mod params + modprobe test_dynamic_debug p_disjoint_bits=3D0x16 p_level_num=3D5 + check_match_ct =3Dp 7 + modprobe test_dynamic_debug_submod + # see them picked up by submod + check_match_ct =3Dp 14 + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests + # these require test_dynamic_debug*.ko comma_terminator_tests test_percent_splitting + test_mod_submod ) =20 # Run tests --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 DC05B392814 for ; Wed, 8 Apr 2026 20:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678572; cv=none; b=XeTywOscIg9mAADHtCWlFiZ6qtusvCIVBVVQjztx5XNuRZrXGCQMD27VDrT+EmHJKOra9wYmepTfw8oWT/TX5FwvFB2qn0iUyKgIiL8YEqGiwwaeAm1GJXErhU6dXMj2LiDf7pcmPlsXbCCREfqHg9neMBdbEn2zXGp+iU6aZ68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678572; c=relaxed/simple; bh=ffYea5QwG/vcMRALURtxHTtwAd5CEp54EzMGG1f4Al8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mt6iwQdzBKbdNlUzg/R0kmtpXRSIwuxQdBn89D/8h/jQQZIK7g9kpXHjkM73I+ORu55u3PA9T6Sev2DU5tlgEkEjEZfXOsIGkPeWQ0WXp53g6tOrwXTBmdS/V0WGrp9jLPaZut45z1unUeT0GUoNtt4IgWew3H9a/qygC+oN0y8= 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=nZGrCHCc; arc=none smtp.client-ip=209.85.161.48 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="nZGrCHCc" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-673ee2a98b1so86857eaf.0 for ; Wed, 08 Apr 2026 13:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678568; x=1776283368; 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=J42RjL3XW7iYvn8zHG5csoL/H2RaSYA/baR8+V+mULo=; b=nZGrCHCcVV5HqIIu3AxfJ1LWu5HrJWtEvEdi/SewYXcMR9ufc0uIkaDjwRAJ/lVe6g DhnOpvSdDqaZKtlglmgsEmRbCJKXuOpcTelh83pzujiW55QQda28AhfUjq/tq4sV6D8I ba8mB5LTeLK2Q8+Ws+l8PD7UaTPJWQu01iZ1IvtYVZWLEqM/7ad/KrKeHd6j8ci3byc0 6hrD2oQ2uzIpYNIBo/Lqfc4nqllH7mxZylRBPR+7aAdd8c9bqTwNpo18GjgH6Tu/Ml5A LouKOm2Kg+etLwaJU+UE9lwNi3TDQI+a2yNpe7TEgPiBK0YS5YH8vXKqaHWCR0aTIppY SBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678568; x=1776283368; 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=J42RjL3XW7iYvn8zHG5csoL/H2RaSYA/baR8+V+mULo=; b=dFQ6UGNI1LwXRrG92LIsOxXpEHHrUyhlLJA6zDDnNqEFM7hWerNN/qBKArRq76rbgp sAYduyfvZ8Kfa2OxcF2xhDHwgounOgFcc8WCjxrk68LkLdb3UVFfGiWiARW2BedEM2Zu wR5b9RvrXrTAMkz7RWk4cPlQ3gp7vhVxFvh53dszKp3q1PSPiXzp6KjD/23hAVNnd0LG ZYiBwe8iE2i6TxzHar38M+PiJb6uTECx0S302V7Dyi5TjOIXPlpuNT3fl4a2pa8YyiLw UZn4sQ9qgcmWFMIYBNbAeqvVW7Nz+F9U5OdNRYvzze4qSBwut4XzkXV9X2kdutw60Fcl kRXg== X-Gm-Message-State: AOJu0YwXNBQfhHljzpRi1cMhU5S80cRmY3ThJPW0sL54qJE1m7neWfLf Ch8imls/KU6HOOEJEd9XYQONXwCMpUWkc6R8bT4duE80lCBNbZpfFT5e9OpHbA== X-Gm-Gg: AeBDieuZP1e2e7HSZCOb2hI3rmb8xMb/O6ylDXz3e33E/1f8q66otrk56aBjmyK8NWu MaqLOxA5p96nxCDnlyEfe3SObRvubJA2AftT1wHiwPe2zTDo90zHHg3b6CS6471EHB0KYuP+qU6 xqf83JfLUQaycxgA3O8cX3j7fXxsScKCV2XQTZLAimY09G0H0kAlIzIcBeSdCeuJPLpKCKFX/5h DGEpVim+HUF/Jhmy1SfFn7hfaIbR0BEaU26n8LPXfGFH78/rfo6DhRFU3LUDwM5bEUPy+MRAM1E 6YgY1RS4bOWrEmy5r5P511SV4/YVI90ppKbkf7l7UgrDYDkicE0hsOv5lq4fXLJwp0YAFarWRd1 plUQSWczZLujkRibFRAz+1pba27sx+E5bcHDfY3QIAdUPiIzGILWqQJDxWu+hZvkNOMTx3ysl7N stJ3kbvcfPxm/GXvCRgb1tar/20EUqxHYj2tPOYLDmqTTEd+l+rYVYi+Xsk9HEjLzwbJUydp6Oc bk= X-Received: by 2002:a05:6820:4dfa:b0:682:4005:5f0e with SMTP id 006d021491bc7-68a63c89424mr524468eaf.59.1775678568288; Wed, 08 Apr 2026 13:02:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:47 -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 33/36] dyndbg: resolve "protection" of class'd pr_debug Date: Wed, 8 Apr 2026 14:02:08 -0600 Message-ID: <20260408200211.43821-34-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: quoted-printable Content-Type: text/plain; charset="utf-8" classmap-v1 code protected class'd pr_debugs from unintended changes by unclassed/_DFLT queries: # - to declutter examples: alias ddcmd=3D'echo $* > /proc/dynamic_debug/control' # IOW, this should NOT alter drm.debug settings ddcmd -p # Instead, you must name the class to change it. # Protective but tedious ddcmd class DRM_UT_CORE +p # Or do it the (old school) subsystem way # This is ABI !! echo 1 > /sys/module/drm/parameters/debug Since the debug sysfs-node is ABI, if dyndbg is going to implement it, it must also honor its settings; it must at least protect against accidental changes to its classes from legacy queries. The protection allows all previously conceived queries to work the way they always have; ie select the same set of pr_debugs, despite the inclusion of whole new classes of pr_debugs. But that choice has 2 downsides: 1. "name the class to change it" makes a tedious long-winded interface, needing many commands to set DRM_UT_* one at a time. 2. It makes the class keyword special in some sense; the other keywords skip only on query mismatch, otherwise the code falls thru to adjust the pr-debug site. Jason Baron didn't like v1 on point 2. Louis Chauvet didn't like recent rev on point 1 tedium. But that said: /sys/ is ABI, so this must be reliable: #> echo 0x1f > /sys/module/drm/parameters/debug It 'just works' without dyndbg underneath; we must deliver that same stability. Convenience is secondary. The new resolution: If ABI is the blocking issue, then no ABI means no blocking issue. IOW, if the classmap has no presence under /sys/*, ie no PARAM, there is no ABI to guard, and no reason to enforce a tedious interface. In the future, if DRM wants to alter this protection, that is practical, but I think default-on is the correct mode. So atm classes without a PARAM are unprotected at >control, allowing admins their shortcuts. I think this could satisfy all viewpoints. That said, theres also a possibility of wildcard classes: #> ddcmd class '*' +p Currently, the query-class is exact-matched against each module's classmaps.names. This gives precise behavior, a good basis. But class wildcards are possible, they just did'nt appear useful for DRM, whose classmap names are a flat DRM_UT_* namespace. IOW, theres no useful selectivity there: #> ddcmd class "DRM_*" +p # these enable every DRM_* class #> ddcmd class "DRM_UT_*" +p #> ddcmd class "DRM_UT_V*" +p # finally select just 1: DRM_UT_VBL #> ddcmd class "DRM_UT_D*" +p # but this gets 3 #> ddcmd class "D*V*" +p # here be dragons But there is debatable utility in the feature. #> ddcmd class __DEFAULT__ -p # what about this ? #> ddcmd -p # thats what this does. automatically Anyway, this patch does: 1. adds link field from _ddebug_class_map to the .controlling_param 2. sets it in ddebug_match_apply_kparam(), during modprobe/init, when options like drm.debug=3DVAL are handled. 3. ddebug_class_has_param() now checks .controlling_param 4. ddebug_class_wants_protection() macro renames 3. this frames it as a separable policy decision 5. ddebug_match_desc() gets the most attention: a. move classmap consideration to the bottom this insures all other constraints act 1st. allows simpler 'final' decisions. b. split class choices cleanly on query: class FOO vs none, and class'd vs _DPRINTK_CLASS_DFLT site. c. calls 4 when applying a class-less query to a class'd pr_debug here we need a new fn to find the classmap with this .class_id d. calls new ddebug_find_classmap_by_class_id(). when class-less query looks at a class'd pr_debug. finds classmap, which can then decide, currently by PARAM existence. NOTES: protection is only against class-less queries, explicit "class FOO" adjustments are allowed (that is the mechanism). The drm.debug sysfs-node heavily under-specifies the class'd pr_debugs it controls; none of the +mfls prefixing flags have any effect, and each callsite remains individually controllable. drm.debug just toggles the +p flag for all the modules' class'd pr_debugs. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- -v12 minor fixup after squashing subsequent commits to previous ones --- include/linux/dynamic_debug.h | 14 ++-- lib/dynamic_debug.c | 137 ++++++++++++++++++++++++++-------- 2 files changed, 115 insertions(+), 36 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 1cae9a2f32d7..1b401f398a3c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -76,6 +76,7 @@ enum ddebug_class_map_type { * map @class_names 0..N to consecutive constants starting at @base. */ struct _ddebug_class_map { + struct _ddebug_class_param *controlling_param; const struct module *mod; /* NULL for builtins */ const char *mod_name; /* needed for builtins */ const char **class_names; @@ -281,7 +282,12 @@ struct _ddebug_class_param { * * Creates a sysfs-param to control the classes defined by the * exported classmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in a private long int. + * + * Since sysfs-params are ABI, this also protects the classmap'd + * pr_debugs from un-class'd `echo -p > /proc/dynamic_debug/control` + * changes. + * + * This keeps class-state in a private long int. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ static unsigned long _name##_bvec; \ @@ -294,10 +300,8 @@ struct _ddebug_class_param { * @_var: name of the (exported) classmap var defining the classes/bits * @_flags: flags to be toggled, typically just 'p' * - * Creates a sysfs-param to control the classes defined by the - * exported clasmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in user @_bits. This lets drm check - * __drm_debug elsewhere too. + * Like DYNAMIC_DEBUG_CLASSMAP_PARAM, but maintains param-state in + * extern @_bits. This lets DRM check __drm_debug elsewhere too. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6430f77c7b9c..66879a40b822 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -206,6 +206,55 @@ ddebug_find_valid_class(struct _ddebug_info const *di,= const char *query_class, return NULL; } =20 +static bool ddebug_class_map_in_range(const int class_id, const struct _dd= ebug_class_map *map) +{ + return (class_id >=3D map->base && + class_id < map->base + map->length); +} + +static bool ddebug_class_user_in_range(const int class_id, const struct _d= debug_class_user *user) +{ + return ddebug_class_map_in_range(class_id - user->offset, user->map); +} + +static struct _ddebug_class_map * +ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) +{ + struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, map, di, maps) + if (ddebug_class_map_in_range(class_id, map)) + return map; + + for_subvec(i, cli, di, users) + if (ddebug_class_user_in_range(class_id, cli)) + return cli->map; + + return NULL; +} + +/* + * classmaps-V1 protected classes from changes by legacy commands + * (those selecting _DPRINTK_CLASS_DFLT by omission). This had the + * downside that saying "class FOO" for every change can get tedious. + * + * V2 is smarter, it protects class-maps if the defining module also + * calls DYNAMIC_DEBUG_CLASSMAP_PARAM to create a sysfs parameter. + * Since the author wants the knob, we should assume they intend to + * use it (in preference to "class FOO +p" >control), and want to + * trust its settings. This gives protection when its useful, and not + * when its just tedious. + */ +static inline bool ddebug_class_has_param(const struct _ddebug_class_map *= map) +{ + return !!(map->controlling_param); +} + +/* re-framed as a policy choice */ +#define ddebug_class_wants_protection(map) (ddebug_class_has_param(map)) + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -214,11 +263,10 @@ ddebug_find_valid_class(struct _ddebug_info const *di= , const char *query_class, */ static bool ddebug_match_desc(const struct ddebug_query *query, struct _ddebug *dp, - int valid_class) + struct _ddebug_info *di, + int selected_class) { - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - return false; + struct _ddebug_class_map *site_map; =20 /* match against the source filename */ if (query->filename && @@ -255,7 +303,28 @@ static bool ddebug_match_desc(const struct ddebug_quer= y *query, dp->lineno > query->last_lineno) return false; =20 - return true; + /* + * above are all satisfied, so we can make final decisions: + * 1- class FOO or implied class __DEFAULT__ + * 2- site.is_classed or not + */ + if (query->class_string) { + /* class FOO given, exact match required */ + return (dp->class_id =3D=3D selected_class); + } + /* query class __DEFAULT__ by omission. */ + if (dp->class_id =3D=3D _DPRINTK_CLASS_DFLT) { + /* un-classed site */ + return true; + } + /* site is class'd */ + site_map =3D ddebug_find_map_by_class_id(di, dp->class_id); + if (!site_map) { + WARN_ONCE(1, "unknown class_id %d, check %s's CLASSMAP definitions", dp-= >class_id, di->mod_name); + return false; + } + /* module(-param) decides protection */ + return !ddebug_class_wants_protection(site_map); } =20 static int ddebug_change(const struct ddebug_query *query, struct flag_set= tings *modifiers) @@ -265,33 +334,31 @@ static int ddebug_change(const struct ddebug_query *q= uery, struct flag_settings unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - struct _ddebug_class_map *map =3D NULL; - int valid_class; + int selected_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { struct _ddebug_info *di =3D &dt->info; + struct _ddebug_class_map *mods_map; =20 /* match against the module name */ if (query->module && !match_wildcard(query->module, di->mod_name)) continue; =20 + selected_class =3D _DPRINTK_CLASS_DFLT; if (query->class_string) { - map =3D ddebug_find_valid_class(&dt->info, query->class_string, - &valid_class); - if (!map) + mods_map =3D ddebug_find_valid_class(di, query->class_string, + &selected_class); + if (!mods_map) continue; - } else { - /* constrain query, do not touch class'd callsites */ - valid_class =3D _DPRINTK_CLASS_DFLT; } =20 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)) + if (!ddebug_match_desc(query, dp, di, selected_class)) continue; =20 nfound++; @@ -656,6 +723,7 @@ static int ddebug_exec_queries(char *query, const char = *modname) } =20 /* apply a new class-param setting */ + static int ddebug_apply_class_bitmap(const struct _ddebug_class_param *dcp, const unsigned long *new_bits, const unsigned long old_bits, @@ -1107,17 +1175,6 @@ static void *ddebug_proc_next(struct seq_file *m, vo= id *p, loff_t *pos) return dp; } =20 -static bool ddebug_class_map_in_range(const int class_id, const struct _dd= ebug_class_map *map) -{ - return (class_id >=3D map->base && - class_id < map->base + map->length); -} - -static bool ddebug_class_user_in_range(const int class_id, const struct _d= debug_class_user *user) -{ - return ddebug_class_map_in_range(class_id - user->offset, user->map); -} - static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; @@ -1242,25 +1299,36 @@ static void ddebug_sync_classbits(const struct kern= el_param *kp, const char *mod } } =20 -static void ddebug_match_apply_kparam(const struct kernel_param *kp, - const struct _ddebug_class_map *map, - const char *mod_name) +static struct _ddebug_class_param * +ddebug_get_classmap_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map) { struct _ddebug_class_param *dcp; =20 if (kp->ops !=3D ¶m_ops_dyndbg_classes) - return; + return NULL; =20 dcp =3D (struct _ddebug_class_param *)kp->arg; =20 - if (map =3D=3D dcp->map) { + return (map =3D=3D dcp->map) + ? dcp : (struct _ddebug_class_param *)NULL; +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp =3D ddebug_get_classmap_kparam(kp, map); + + if (dcp) { + map->controlling_param =3D dcp; v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); vpr_cm_info(map, " %s maps ", mod_name); ddebug_sync_classbits(kp, mod_name); } } =20 -static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +static void ddebug_apply_params(struct _ddebug_class_map *cm, const char *= mod_name) { const struct kernel_param *kp; #if IS_ENABLED(CONFIG_MODULES) @@ -1280,6 +1348,13 @@ static void ddebug_apply_params(const struct _ddebug= _class_map *cm, const char * } } =20 +/* + * called from add_module, ie early. it can find controlling kparams, + * which can/does? enable protection of this classmap from class-less + * queries, on the grounds that the user created the kparam, means to + * use it, and expects it to reflect reality. We should oblige him, + * and protect those classmaps from classless "-p" changes. + */ static void ddebug_apply_class_maps(const struct _ddebug_info *di) { struct _ddebug_class_map *cm; --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 5122D390CB1 for ; Wed, 8 Apr 2026 20:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678573; cv=none; b=be5Hk3ES4jA2Z6tdWG+AUu+cb0+NNZ1E0GTuLqyaiqpoKjHA5w3QMhLqlfSXwdLMz3spCPt5gjToGULFn1A5JMWL24YaTFyt7606iLjugI6W/vDdRLIXM/NFoiwnFi6Sg29erlW1Cq+VcSMtsKaCn2OPiBOoduPqmMEnrqIxA44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678573; c=relaxed/simple; bh=loQz+STp3wa7v9/r0rWlqL++qVZMQDCgMzGEqpUIZBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TS2YGH05QwmTstLdl2BiNjNwVrDSd4iNTWNLgXyo4WmR5lP38wlL8ADVB3omvuVQljUlHIW0hyrgFpzqEPPVtmGGk6NDRRk6bjp0d8xXdE77ZJhGLlG0ozKuC1kGHjFWS6wm53FWr6fOBkxIzuUXrZWSN5KzikU2yu0mcGMIF8E= 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=FvoWHdnZ; arc=none smtp.client-ip=209.85.161.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="FvoWHdnZ" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-66ee7b9af94so63198eaf.0 for ; Wed, 08 Apr 2026 13:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678569; x=1776283369; 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=+oVkFpq55n+kC0Q5w6v7ajVoPipPUrDkhvMf2L9Tp2c=; b=FvoWHdnZUWhTs5orBsedh5M912yad4FKeHgNFv/QVvjUO3Q7MxGnTx23iYXj4hvCNt zW/1WPnUjsmVec7vy2P7uF657XsOWT6HhTPxrkYRsrXZZnwAAytKUHQ80vHdvOba4XGk s4tS7TlKWrr+nPbbugnlflqzH+fKYR0k+230lc9NwKVO/6OHRRierVOpzQN/ZZx78KSN fYcYRcmU2jzsFo97etywZRwuMDE66E878W/mc3osI7JsNafcin/sxC6s567NKnf0bxi6 CDfVzCVRy6Ty8yulnf16ywEy87O6HLkctrwjQoy7wfWY3ciKn6FMTP8NXzF83W9v7lhg /zSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678569; x=1776283369; 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=+oVkFpq55n+kC0Q5w6v7ajVoPipPUrDkhvMf2L9Tp2c=; b=EeVDKx/CmxE61UMmGR2smVyV78Zzq3tFZzgxtfZc0QQn1XUCGLJ7yywDr0s1sSLF0O zmHKrAIDct2gFRdj6yQiF6YxiFCKpc36Iw2vH6UbzSfXe8xXJNPbfyxfBqRyVQRoVfGX /yROQkorU5+ANArNQMEW4Rm7UidfbyAp9HLlcv/yt4y6u7yXti3OV140XEmULSAbtwz6 kjRS0yqcnGa5q6z+mLXZz+9H60HuIFH8fqv45Jc7AX6AKSsqa6rALvRj8bB4likQpU0j QAGfThkPuM8u72wOH4LasGGsUrAJt38u/FCWXWWzh9tFGtPO9SklNqBMaGbOA6K5cDkB uYDQ== X-Gm-Message-State: AOJu0YzPVHTVhC66XN9bsVToZVzZFtOQni5Mlzu0jyPPc3ZBQCISFwUC bXaPcuXv7Kw06hggTPBNtiQ/x+ONP7mJvYdH54H/fO5me9AZomqxjyYwg/T0pQ== X-Gm-Gg: AeBDieuR+B7LtSxHWyavGl8u5KPPvX+aifqlDc68OUxu7XfN9+yzrWEPz65hif4ooFi JySdjuGChWyqpTtVbWIB7tmnEjRWGFmm/RRVVG8mibeD1i4AUmUtJKYhnNLVqiVtv+ekHVR6DjD H5BVIn+//W98a713MTyzTdXzLmuvFc5/LfbHmYkFb3e8SzFlNnomSFFgds3zpBY9Gqjl2lZ8eg5 OkAIx+u1Qo7yfIjx/XkEaAxMKtpvdiR6qkI2f2fe+YovXfPofymsJUp+IT1i0EcAF4Z0+vgsNGs 7pQYeHsK/K0a7eNuymlfvxNewExu+5HKP8UYanU8p6zNdGK3oAWVNcGSEP8KcllI+wmO1lmh+zD +W9Wy9PJ4dQtuyMQHdNMz/6rWUOWC0P0umEOju8/9AkS9YshB1AE1ZcAOCTCn3Ed7WNJgb/rj0S 4qfmLDrrArr0PaWchLkQZBiSos96kqyzlGRS5iuHmbII2fN5Do6GONF0YBTxqqnfV7CwNyW2Xw2 pE= X-Received: by 2002:a05:6820:2d4a:b0:67e:cf9:ea2a with SMTP id 006d021491bc7-6821ef801cfmr14200699eaf.17.1775678569059; Wed, 08 Apr 2026 13:02:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:48 -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 34/36] dyndbg: harden classmap and descriptor validation Date: Wed, 8 Apr 2026 14:02:09 -0600 Message-ID: <20260408200211.43821-35-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: quoted-printable Content-Type: text/plain; charset="utf-8" Dynamic debug classmaps allow modules to _DEFINE and/or _USE multiple classmaps, but this requires coordination amongst the classmaps. Previously, class validation done by DYNAMIC_DEBUG_CLASSMAP_DEFINE at compile-time, and ddebug_class_range_overlap() at modprobe-time, was incomplete, and DYNAMIC_DEBUG_CLASSMAP_USE_ had no validation. This could allow broken classmaps, making them harder to use well. This commit improves classmap and descriptor validation: - Mirror the compile-time limits of _DEFINE by adding a static_assert to validate the _offset value passed to DYNAMIC_DEBUG_CLASSMAP_USE_. - Add run-time overlap checks for _USEd classmaps in ddebug_add_module() to prevent collisions between private maps and imported APIs. - Scan module descriptors at load time to print a single warning per missing class_id, rather than waiting for a user query to trip over it. - Downgrade the global WARN_ONCE in ddebug_match_desc() to a pr_warn_ratelimited, since orphaned class IDs are now tracked and warned about early at module load. Signed-off-by: Jim Cromie --- -v12 - squash several enhancments together drop run-time USE check, now done at compile-time s/WARN_ONCE/pr_err/, dont need stack trace for this, and do want multiple error reports, so dont quit on 1st err. Now that DYNAMIC_DEBUG_CLASSMAP_USE_() has an offset parameter, it is possible for a user to specify an illegal value - one that shifts the bit-range past the 64 bit max. The macro detects an offset > 63, but this isn't enough; the legal max is: map.length - 1 + map.base + user.offset < 64 Testing class-map vs class-user overlap is nonsense if the class-user range extends past the implemented limit. So check that 1st, before looking for map/user overlap. To validate this, add ifdef DD_RUNTIME_CLASS_CHECK code to test_dynamic_debug_submod.ko. When its enabled, it creates a bad class-user record via: DYNAMIC_DEBUG_CLASSMAP_USE_(map_level_num, 55); bash-5.3# modprobe test_dynamic_debug_submod [ 19.359818] dyndbg: 23 debug prints in module test_dynamic_debug [ 19.366239] dyndbg: module test_dynamic_debug_submod: base:16 + classes.= len:8 + cli.offset:55 must be < 63 [ 19.366612] dyndbg: dyndbg multi-classmap conflict in test_dynamic_debug= _submod [ 19.366945] dyndbg: dyndbg: failed to add module test_dynamic_debug_subm= od: -22 Finally, replace the misleading "Failed to allocate memory" WARN in the module notifier with a pr_err that reports the specific failure code without the stack-trace. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 67 ++++++++++++++++++++++++++++++++++++---- lib/test_dynamic_debug.c | 9 +++++- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 66879a40b822..3cd9b67bd995 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -320,7 +320,8 @@ static bool ddebug_match_desc(const struct ddebug_query= *query, /* site is class'd */ site_map =3D ddebug_find_map_by_class_id(di, dp->class_id); if (!site_map) { - WARN_ONCE(1, "unknown class_id %d, check %s's CLASSMAP definitions", dp-= >class_id, di->mod_name); + pr_warn_ratelimited("unknown class_id %d, check %s's CLASSMAP definition= s\n", + dp->class_id, di->mod_name); return false; } /* module(-param) decides protection */ @@ -1420,6 +1421,23 @@ static int ddebug_class_range_overlap(struct _ddebug= _class_map *cm, u64 *reserve return 0; } =20 +static int ddebug_class_user_overlap(struct _ddebug_class_user *cli, + u64 *reserved_ids) +{ + struct _ddebug_class_map *cm =3D cli->map; + int base =3D cm->base + cli->offset; + u64 range =3D (((1ULL << cm->length) - 1) << base); + + if (range & *reserved_ids) { + pr_err("module %s: [%d..%d] (from %s) conflicts with %llx\n", + cli->mod_name, base, base + cm->length - 1, + cm->class_names[0], *reserved_ids); + return -EINVAL; + } + *reserved_ids |=3D range; + return 0; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1430,7 +1448,8 @@ static int ddebug_add_module(struct _ddebug_info *di) struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; u64 reserved_ids =3D 0; - int i; + u64 bad_ids =3D 0; + int i, err =3D 0; =20 if (!di->descs.len) return 0; @@ -1454,10 +1473,46 @@ static int ddebug_add_module(struct _ddebug_info *d= i) dd_set_module_subrange(i, cli, &dt->info, users); /* now di is stale */ =20 - /* insure 2+ classmaps share the per-module 0..62 class_id space */ + /* validate the per-module shared 0..62 class_id space */ for_subvec(i, cm, &dt->info, maps) if (ddebug_class_range_overlap(cm, &reserved_ids)) - goto cleanup; + err =3D -EINVAL; + + for_subvec(i, cli, &dt->info, users) { + cm =3D cli->map; + if (!cm) { + pr_err("module %s: classmap not found for user\n", di->mod_name); + err =3D -EINVAL; + continue; + } + + if (cm->base + cm->length + cli->offset >=3D _DPRINTK_CLASS_DFLT) { + pr_err("module %s: base:%d + classes.len:%d + cli.offset:%d must be < %= d\n", + di->mod_name, cm->base, cm->length, cli->offset, _DPRINTK_CLASS_= DFLT); + err =3D -EINVAL; + continue; + } + + if (ddebug_class_user_overlap(cli, &reserved_ids)) + err =3D -EINVAL; + } + if (err) + goto cleanup; + + /* validate all class_ids against module's classmaps/users */ + for (i =3D 0; i < dt->info.descs.len; i++) { + struct _ddebug *dp =3D &dt->info.descs.start[i]; + + if (dp->class_id =3D=3D _DPRINTK_CLASS_DFLT) + continue; + if (bad_ids & (1ULL << dp->class_id)) + continue; + if (!ddebug_find_map_by_class_id(&dt->info, dp->class_id)) { + pr_warn("module %s uses unknown class_id %d\n", + dt->info.mod_name, dp->class_id); + bad_ids |=3D (1ULL << dp->class_id); + } + } =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1472,7 +1527,7 @@ static int ddebug_add_module(struct _ddebug_info *di) dt->info.descs.len, dt->info.mod_name); return 0; cleanup: - WARN_ONCE(1, "dyndbg multi-classmap conflict in %s\n", di->mod_name); + pr_err("dyndbg multi-classmap conflict in %s\n", di->mod_name); kfree(dt); return -EINVAL; } @@ -1559,7 +1614,7 @@ static int ddebug_module_notify(struct notifier_block= *self, unsigned long val, 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"); + pr_err("dyndbg: failed to add module %s: %d\n", mod->name, ret); break; case MODULE_STATE_GOING: ddebug_remove_module(mod->name); diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index d65fa3f3ef9e..3cb41a3a18e2 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -137,7 +137,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict, = 0, D2_CORE + 1, "D3_CORE") * DEFINEd (and exported) above. */ DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); -DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); +#if !defined(DD_RUNTIME_CLASS_CHECK) + DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); +#else +/* + * force failure of runtime sanity test of classmap.length + offset < 63 + */ +DYNAMIC_DEBUG_CLASSMAP_USE_(map_level_num, 55); +#endif =20 #if defined(DD_MACRO_ARGCHECK) /* --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 6D6393AE19B for ; Wed, 8 Apr 2026 20:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678573; cv=none; b=qQ0VsY73gcdSAOWHjlONbgBvcWWDXqJqOafwtswUS0g9zblIb48f0V4DRpa3pfus03btwwc7sblXBPhfT+IH4X8Bqhiw96Q2Sek8u0Q5riENXB0g6OKqutgyDLMNmhcutUMc9A7daqRAsw+PfIjk5rBm3RbHD5Dm/j9hpt0olZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678573; c=relaxed/simple; bh=ftTpVckDB1Ntqu89+1elJ8nn6xn5PfMnDJrkqsIjPtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hjMpKTgcG472TBGVfX51c/48p3+Pef3Tk9LA7ZHEDWtYOSmTlGMGAjqzyb8yGnFuMt8C1ocbyVRYNxU86c1jPcMfCz1vc7wmzH/8ws5YTLAlocJ7hpi7YWZVV+dVR3IFKLmqeIGXXmuDClClo2fUGTcDkB399WsksFcEiiBbDW4= 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=RY/J5xAZ; arc=none smtp.client-ip=209.85.161.50 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="RY/J5xAZ" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-682d981b025so89125eaf.3 for ; Wed, 08 Apr 2026 13:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678570; x=1776283370; 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=8Fn+1VGRF0lzR7vhJfSVcQCaTLdIbHbYdKyEKI0VCCs=; b=RY/J5xAZotuQwD25pFXBuzmUdc6aGA3qkVT9z+E3ke+xhkSUBPcQFgw8mfIAwrjyDv W7zSYAcq5JDkJ0omlWqcKLiOg8kJq9n+ga/xVuXAsSSpuOi42BF7OYXWMtFtBtRI/O9P LxScPIxCT/Nh+eAqTZGU+r+afABAVAZ6BZH0mx2o1MbaVqvpINEMg9L9gOrGAY6q7qj9 PADYGejSvikD24PICU61Cr1ewpK8LVFY0goOSk/l82czxIBmT7x0d9IzsIdHPjTHW/t4 70bOTVG7MShyBKBnRMMC3BwxHUCmjljNL+J59/D7AQMvS8BUuLhnCGoIAi6M/rlccf/w Wlvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678570; x=1776283370; 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=8Fn+1VGRF0lzR7vhJfSVcQCaTLdIbHbYdKyEKI0VCCs=; b=OxxIByU0L8vwjeAy81oV37sK1i8ZRrMhiofXaf78wXzmkZDda0EISnGAz4Yg6INMW7 7wO4GfuLdJoLEThstOiEfBE8XGXiGZSQiMdNwi5BiIPJhzcg6jMpaMkNXwmiXODshRN2 zX9SOyj2ijDgSRRYRph7Jp+DMMn9duVuLVKb1PRY5ag9fK4Gqzy1QLDud7VelFi1SJGM Sn1FJ0rFPKAMDkujTELY6RYg7Pn19fNo/0Wg76HEVvVqrhgdzyWoItOhlAPr8sJK+v9h EPan24kaygTYr9/F/4M2Ka6OyGHNoICthg7j1jHuDXNaZAppx0Frg2hfrEmfy9whYlH9 EPVA== X-Gm-Message-State: AOJu0YyjR+9TWBucbB/1+k9v7/fiIAVe/FdgZ7SnCEMx193UYPhNnJZd z67oVgtLn7b8H3bB3qSsGs3f8GgrRGy88E2OeibVzSL6u8JorcV7va5Sz9EZvA== X-Gm-Gg: AeBDievqDrAKildbXYFYBNAp009dRkl9yXv7F/JpYx9EtKCL2mzyp4RFdnOdLFXu8kJ IIJY7KaNE7SuBRp5FFyDdm6RPKzKK7GGzjK7MujB+c5p5l8HTwjEaQxnZ+7cmg678kaFRc8P/dd /TzcmlqptCwLj3r9bCEWdJ1QwByBnFXqjFGl7Muqmhnvcj9zJUZSeAVhi7YLroCRP9aYSw5x5JI rVCEEXY8QjNlrfQtb5nDUzoJ+GF6sPxZw8WqlYh41PJ7RFHjbDGf/MTlHc2JracYaFqioawvj9j vPAhXz1WheQLJycK1l+VuPm4I2AS9vTdPC72eSLlVAhHX80wYNSS9eWEFt0LQCcroChN1s0j9z0 v49aPYOUcGLCkVdTipJznKCpDE2tBCuEBL81NYyS9cZHV/w1xpRnjv3ya1x+BqjtkyIlBVfDJA5 a5gcRTFOciMkjloknwtR3xgK2pcWJJ2jjPGTSe2wHraDAQUyW154Sanl0Z7Rd7OkE0ED0T50tyC oM= X-Received: by 2002:a05:6820:604:b0:68a:1ed1:206d with SMTP id 006d021491bc7-68a1ee07119mr945464eaf.6.1775678570033; Wed, 08 Apr 2026 13:02:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:49 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v13 35/36] docs/dyndbg: add classmap info to howto Date: Wed, 8 Apr 2026 14:02:10 -0600 Message-ID: <20260408200211.43821-36-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: quoted-printable Content-Type: text/plain; charset="utf-8" Describe the 3 API macros providing dynamic_debug's classmaps DYNAMIC_DEBUG_CLASSMAP_DEFINE - create & export a classmap DYNAMIC_DEBUG_CLASSMAP_USE - refer to exported map DYNAMIC_DEBUG_CLASSMAP_PARAM - bind control param to the classmap DYNAMIC_DEBUG_CLASSMAP_PARAM_REF + use module's storage - __drm_debug NB: The _DEFINE & _USE model makes the user dependent on the definer, just like EXPORT_SYMBOL(__drm_debug) already does. cc: linux-doc@vger.kernel.org Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 132 ++++++++++++++++-- 1 file changed, 122 insertions(+), 10 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 0a42b9de55ac..734be0b5fe9a 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -146,6 +146,9 @@ keywords are:: "1-30" is valid range but "1 - 30" is not. =20 =20 +Keywords +-------- + The meanings of each keyword are: =20 func @@ -194,16 +197,6 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitesp= ace =20 -class - The given class_name is validated against each module, which may - have declared a list of known class_names. If the class_name is - found for a module, callsite & class matching and adjustment - proceeds. Examples:: - - class DRM_UT_KMS # a DRM.debug category - class JUNK # silent non-match - // class TLD_* # NOTICE: no wildcard in class names - line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single @@ -218,6 +211,25 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file =20 +class + + The given class_name is validated against each module, which may + have declared a list of class_names it accepts. If the class_name + accepted by a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a drm.debug category + class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names + +.. note:: + + Unlike other keywords, classes are "name-to-change", not + "omitting-constraint-allows-change". See Dynamic Debug Classmaps + +Flags +----- + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: @@ -239,6 +251,11 @@ The flags are:: l Include line number d Include call trace =20 +.. note:: + + * To query without changing ``+_`` or ``-_``. + * To clear all flags ``=3D_`` or ``-fslmpt``. + For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only the ``p`` flag has meaning, other flags are ignored. =20 @@ -395,3 +412,98 @@ just a shortcut for ``print_hex_dump(KERN_DEBUG)``. For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is its ``prefix_str`` argument, if it is constant string; or ``hexdump`` in case ``prefix_str`` is built dynamically. + +.. _dyndbg-classmaps: + +Dynamic Debug Classmaps +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The "class" keyword selects prdbgs based on author supplied, +domain-oriented names. This complements the nested-scope keywords: +module, file, function, line. + +The main difference from the others: classes must be named to be +changed. This protects them from unintended overwrite:: + + # IOW this cannot undo any drm.debug settings + :#> ddcmd -p + +This protection is needed; /sys/module/drm/parameters/debug is ABI. +drm.debug is authoritative when dyndbg is not used, dyndbg-under-DRM +is an implementation detail, and must not behave erratically, just +because another admin fed >control something unrelated. + +So each class must be enabled individually (no wildcards):: + + :#> ddcmd class DRM_UT_CORE +p + :#> ddcmd class DRM_UT_KMS +p + # or more selectively + :#> ddcmd class DRM_UT_CORE module drm +p + +That makes direct >control wordy and annoying, but it is a secondary +interface; it is not intended to replace the ABI, just slide in +underneath and reimplement the guaranteed behavior. So DRM would keep +using the convenient way, and be able to trust it:: + + :#> echo 0x1ff > /sys/module/drm/parameters/debug + +That said, since the sysfs/kparam is the ABI, if the author omits the +CLASSMAP_PARAM, theres no ABI to guard, and he probably wants a less +pedantic >control interface. In this case, protection is dropped. + +Dynamic Debug Classmap API +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(clname,type,_base,classnames) - this maps +classnames (a list of strings) onto class-ids consecutively, starting +at _base. + +DYNAMIC_DEBUG_CLASSMAP_USE(clname) & _USE_(clname,_base) - modules +call this to refer to the var _DEFINEd elsewhere (and exported). + +DYNAMIC_DEBUG_CLASSMAP_PARAM(clname) - creates the sysfs/kparam, +maps/exposes bits 0..N as class-names. + +Classmaps are opt-in: modules invoke _DEFINE or _USE to authorize +dyndbg to update those named classes. "class FOO" queries are +validated against the classes defined or used by the module, this +finds the classid to alter; classes are not directly selectable by +their classid. + +Classnames are global in scope, so subsystems (module-groups) should +prepend a subsystem name; unqualified names like "CORE" are discouraged. + +NB: It is an inherent API limitation (due to class_id's int type) that +the following are possible: + + // these errors should be caught in review + __pr_debug_cls(0, "fake DRM_UT_CORE msg"); // this works + __pr_debug_cls(62, "un-known classid msg"); // this compiles, does nothi= ng + +There are 2 types of classmaps: + +* DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, like drm.debug +* DD_CLASS_TYPE_LEVEL_NUM: classes are relative, ordered (V3 > V2) + +DYNAMIC_DEBUG_CLASSMAP_PARAM - modelled after module_param_cb, it +refers to a DEFINEd classmap, and associates it to the param's +data-store. This state is then applied to DEFINEr and USEr modules +when they're modprobed. + +The PARAM interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation +amongst the contained classnames; all classes are independent in the +control parser itself. There is no implied meaning in names like "V4" +or "PL_ERROR" vs "PL_WARNING". + +Modules or subsystems (drm & drivers) can define multiple classmaps, +as long as they (all the classmaps) share the limited 0..62 +per-module-group _class_id range, without overlap. + +If a module encounters a conflict between 2 classmaps it is _USEing or +_DEFINEing, it can invoke the extended _USE_(name,_base) macro to +de-conflict the respective ranges. + +``#define DEBUG`` will enable all pr_debugs in scope, including any +class'd ones. This won't be reflected in the PARAM readback value, +but the class'd pr_debug callsites can be forced off by toggling the +classmap-kparam all-on then all-off. --=20 2.53.0 From nobody Mon Jun 15 07:32:47 2026 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 640813CF68C for ; Wed, 8 Apr 2026 20:02:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678574; cv=none; b=lkYscN6g0wF06VK//n66IWRdwaiG7MsNYBKPo3F1z6zSiaE860fb1hEvPQF4Tet0ZfjN+Uk5rhFT3SOTNGVoycmjNQaKBLJRizjbm+PYud1bLwAHrQ7T9R8vIAuzsCwamdX19H+9TVnSMQHjzmG41b5NrBEfsDV4dQSTimTVANY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678574; c=relaxed/simple; bh=Lz3HqFI7sjTcCXUhEwpag2fwG3Cj2gkwqi1rf6C3f+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VqobYjxHm8SBBpNyLModgPa0FpEZU2OuXIm7TrJmHePgjrof6jhh5Xf86VbGLeEYAFXSwh/D1BFRFTHu1S/+JMzV0euN1BMZOMq8cR+BNNjP10g5D0lqBA2Jr7AiHNFW3ILEtJKWv17ke6z6tD4PqEFN0GZ9ZoRv/xhXO2WHVq8= 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=ouhfiem2; arc=none smtp.client-ip=209.85.161.47 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="ouhfiem2" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-688a8e5fc2eso102683eaf.0 for ; Wed, 08 Apr 2026 13:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678571; x=1776283371; 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=zN4o2slkpMLzBRxTPQWkZ3+07q4Tlozj8gzJnHB42uk=; b=ouhfiem2Z0PMi83AaQg/DTqK3rSiYh5yWA1yBIxh4Iw3xzlWl4dnIvVLm3va+T3jI7 2PGjRjxpCbC7pp9oD5nLbkbZr41+hA+PAWImQpyS3fy8LTohpZiVHiirzRkqQRAUiPk8 KPooFkMxHbXgOPZp2q1rb7XObZQJhl+BipVPbs0ChtMDbzXYjYW5l4kBiQmKeXqDN8/J In+9hIRGwaeDVTl6deXoF8mv5sj8oOmEFgoHp14p5/mh46BH9XtowZax5/plBdC0UHW1 2HQpf3/FPn5zaE3YFlR9aMbTuMoITLNU8T/JJ/n6zHaSj5m/EIWpnVAKW2DH2FZ8jUbl o7TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678571; x=1776283371; 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=zN4o2slkpMLzBRxTPQWkZ3+07q4Tlozj8gzJnHB42uk=; b=HWtVpOykFUt9O8iDjtDtXzypZiFrTqY1Y4hfQNWgaxADhzeNyCSjeWZvnDkSSO/4AI vo5gmJzFF4esOP6fmiEt05GmEKIWqBPgs93su02FFbRRj9eBQ9fTvrnp009UskpSmxCq YIgj2dYYAnUF1FaH2nB/Xuw3G+ioUDebsORqG7Tg4KYVxsH2J+JjO9dyaXrFToW/uk8s 4z2kpmTEH4nSdh8qMzrac+sla77b67DrVoyvMDh3L9WxslQbNNvHZK/UdmyRhIUGUfT8 B7efmCucyQBwAFN//KQWYGxrY4rJ8Wh4ikYZ+d/bZKmqGMAAzp22qWv/j839VmEYe18C YnSA== X-Gm-Message-State: AOJu0Ywkf9bNctvbXMiNlaEc72npM0fvxVJ5+nbZEV1CksNxasfQoS1V eKd7NyXD95b0+c5oaBMa43nPJaRD1QbjqhttcxyasPBDtwGXd3G5zEbNoDJDKQ== X-Gm-Gg: AeBDietY4FGgotCA1r3KWpOQzVZtqY9lj29unmRdeeUreERqfY+SmXvJIxNvLMfZzC/ 0CQZovE5nMe/gptv2zVBbsSikZPcjjf+QfXg4BLIChlBtLweR67C8QkzmKladE6lx6zn9JOcCFx /ZylfTT01KSYSPL23eqba9gcF9PEhm5O08S4eDOGxSUIbGMSAyTPRnqSuG4Z0JjHdEjZfoDzuXN FZNgdixkUGDupzdu1IDnml007V046WzaHotC7vJE6P++GR+4bukq1bCq8lunce2ALTLugeqoOop eQgd6KCZRsnPvJ/vPVB+FnbK2v1m50VSJxC0vDZlmA8DilAXfGZS0tG1iN3vhzjb41U1XJtSCoc 1zA/5VsHBvbXjzpMBPrrSrT1mq2wLYeF+Vsepgc0JbCafugX5AraReIujABPPQhYq3gSzhGzK4E XaGRM6uLwlFiAM79LjNrGBBUr3RMUt0wEFA86d7XaZbn2IltVSudThS2SLdYJ9vwqRZ1ll7IYHt Og= X-Received: by 2002:a05:6820:1842:b0:67b:f12a:dfcb with SMTP id 006d021491bc7-6822103c55fmr11556047eaf.60.1775678571117; Wed, 08 Apr 2026 13:02:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:50 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Philipp Hahn , Jim Cromie Subject: [PATCH v13 36/36] dyndbg: Ignore additional arguments from pr_fmt Date: Wed, 8 Apr 2026 14:02:11 -0600 Message-ID: <20260408200211.43821-37-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Philipp Hahn pr_fmt can be used to add a common prefix to any output from a module: #define pr_fmt(fmt) KBUILD_MODNAME ".%s " fmt, __func__ But adding additional arguments breaks dynamic debug: > error: macro "DEFINE_DYNAMIC_DEBUG_METADATA_CLS" passed 4 arguments, but = takes just 3 > | pr_debug_ratelimited("%s", "Hello world!"); > | ^ > note: macro "DEFINE_DYNAMIC_DEBUG_METADATA_CLS" defined here > | #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ > | > error: =E2=80=98DEFINE_DYNAMIC_DEBUG_METADATA_CLS=E2=80=99 undeclared (fi= rst use in this function) > | DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fm= t) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > note: in expansion of macro =E2=80=98DEFINE_DYNAMIC_DEBUG_METADATA=E2=80= =99 > | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt)); = \ > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > note: in expansion of macro =E2=80=98pr_debug_ratelimited=E2=80=99 > | pr_debug_ratelimited("%s", "Hello world!"); > | ^~~~~~~~~~~~~~~~~~~~ Add an additional ', ...' to DEFINE_DYNAMIC_DEBUG_METADATA_CLS to slurp any additional argument, which `pr_fmt` might add. Signed-off-by: Philipp Hahn [pr_fmt change on test_dynamic_debug_submod instead of parent] Reviewed-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- lib/test_dynamic_debug.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 1b401f398a3c..49f37d6a4eab 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -344,7 +344,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dump_stack(); \ } =20 -#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt, ...) \ static struct _ddebug __aligned(8) \ __section("__dyndbg_descriptors") name =3D { \ .modname =3D KBUILD_MODNAME, \ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 3cb41a3a18e2..72a1a1c89cb2 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -23,7 +23,7 @@ * the usage clearer. */ #if defined(TEST_DYNAMIC_DEBUG_SUBMOD) - #define pr_fmt(fmt) "test_dd_submod: " fmt + #define pr_fmt(fmt) "test_dd_submod: %s " fmt, __func__ #else #define pr_fmt(fmt) "test_dd: " fmt #endif @@ -215,7 +215,7 @@ static int __init test_dynamic_debug_init(void) =20 static void __exit test_dynamic_debug_exit(void) { - pr_debug("exited\n"); + pr_debug_ratelimited("exited\n"); } =20 module_init(test_dynamic_debug_init); --=20 2.53.0