From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 7026B3C8719 for ; Tue, 2 Jun 2026 22:48:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440497; cv=none; b=V9t1O7jHp/cTSq1g6yqV5bvL6lYeuVFyu+vto50ufFXWiUo7A2T59PJtMs1v1f+EiIiheHErnEwmBPQmag5ArKdQ3o2xCyUjG6qB4pXiiPBlpmvmBQuwYP8MlXzQARJZDMhSKolPUEqnJsAkKoCNtV7zOHrai/j4NnycV0vdB8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440497; c=relaxed/simple; bh=/BEze5uZvE97vkdxdEKscGQmmLTlvHt75B8/b2suPbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R+rjC+2CqnQySQ6id57cnkN2e4fb7moxFX6g5AZVvqwl+VOxbZTUXnz7I3mf5frzjXQ/EO2SOUIIft+TpH1xlKDdFWI5fBnKk9lKllLx7yLM7UYa19kivv/qf1BKux2gcQzCY89K6qaFjU2uQ9Mobf5VaH8m/cyMLV7ml0WhMtQ= 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=qlEI31kN; arc=none smtp.client-ip=209.85.221.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="qlEI31kN" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-45ef56d9b67so3576802f8f.2 for ; Tue, 02 Jun 2026 15:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440495; x=1781045295; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CwPLhLRZkxVDbJ+XZfxPTCPSMzzunTFiSNGj95FvoLA=; b=qlEI31kNxjbwB74F76h/iMA8Rt70PBfAVAwkfvOQ1OUWFaHg+UbcdRJZrCzi6K5HkO Hd8lnyadsYYTlSZz3jK1pWycosr71xS2M4gkHt5HIqBgWMW0INpWQbOTimKbIlKy2zso Oq1p7pXaJ8LAhZjSF1O2xlSlii4UyK5tnnIc3snbTN7GCBWwWva4f+qMsU2FmgeXgkrF OA/qHwFju4QSoJP6OgJ54C6ll2mhiQx4AGI3wHifogZfzGUa+spyNxhMVT1upnK12gfs Be/czoIFK+YVAZxE67rJbaOwKOKpqq++0nr59IloW0MBIUCheKY7/V+7LVsW3vAZepEJ Oz5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440495; x=1781045295; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CwPLhLRZkxVDbJ+XZfxPTCPSMzzunTFiSNGj95FvoLA=; b=Xq3VSklusch4Mb0tWLv3YZr718TS1Co9Cc+YN5/YQ6PbFSKVteabOYPaSxVnVTTpQo 4OqDloReTht0yAmPfeGpllGwNeRX9MGSthMnRZzNJMrx+OTNm5vAg0wg2DVpzLhOkIjq zNJAmEU2tBPdXjhXerV5+eQVXbHVmU/DdR8yRyJm+gGVB8caZHuq+HjR9tPS6JAMdEyP FPuqMt59LdvO/xfCrEjyp4dhczvtMT+Wn/RNh9rJjY7bW8qyNR49aCf/0P4xmr4Jv/Pb iBWjFb7iD/1E5TkcBJtskvCpeVjdg6wlI8JpFJskRN6Bckf7mpfXIf0jKtXGqQOEHzMc QyJA== X-Forwarded-Encrypted: i=1; AFNElJ/Z8lVDaTXWLwlSkDvS6PKrO1FPnZMzRjLjNxxusxDtJnq+E5dLX2EsC8Iz2SWjbzLw5eIxtP8+e5AYAUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxPStVSZNMpMv1lmzTcB5/AxTJRSu2RtGbLAvWxk/1enw00eyFg KL7LylGRCj8wnoLWNsyhhIzGsVQVK0jrCIX3pkiyYiN7gC7zCbwQly97 X-Gm-Gg: Acq92OEw7EMrefrMqVcegR/ZkiXCMVCcNPlATq9GpXh70uE74dxeXF/EZhxeep0Vk3f 0ZAkGb/DdXmNGZdMVoc4KNoIal6I1Js8WySt/puTnL8uBkPoi147q/QD+WY2G7bDlJj5BJkArTn XSOmTFS2sVCri+i/ncPvMwxzXZJ53ijP1CNq+P7RYAEMPvjsUj+U5cDuYXbEv0bRGUB8/U/UhOP Qon4C7Ee5LOxi5kSdDRzOENK3ve067jNmeo5JL0EAK7XNQ/SP7uSFqWL99dKkXa945ZWal5Y/m3 I3KeYFPzsjJ8hAXVPF/sqkWRoPM8ial4rI1o3/s4K0Vo/iDd1gOPniRAsO3QMMNum99gZU6uqau XeTK+DCLsfQ4CdAapqvEJgKQhZjeHH8/7nrYQeF1ODqwx+WLQUAmhaIYCxy4dELMQFE+6KbJ3li tgA5o+thbl3I7/s7negy+i7mMRmQRMFCW5ywJM0DpBHQ== X-Received: by 2002:adf:e8ca:0:b0:45e:dabf:a00e with SMTP id ffacd0b85a97d-4602195abf8mr384315f8f.31.1780440494697; Tue, 02 Jun 2026 15:48:14 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:14 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:47:58 +0000 Subject: [PATCH v4 01/25] docs/dyndbg: update examples \012 to \n 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 Message-Id: <20260602-dd-maint-2-v4-1-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=2677; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=/BEze5uZvE97vkdxdEKscGQmmLTlvHt75B8/b2suPbI=; b=eGa6JOHZRbOrzq3N8stPRNIhRHhJDTd+EXMPhxsQVEHGQJoLEX5/8ExqTRqXIhbGFTDS7i/jW my6ir9qw9H/DG3fyTSa1Qx5Qli7GCViICT1Ms058vTbgPI0z3h/lvaZ X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 --- Documentation/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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 AECD23C7DF5 for ; Tue, 2 Jun 2026 22:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440500; cv=none; b=nE3d/mHpXIiQQdk6OZPrH/aDkl1U/jAhDTgKQekKKfTxsPcGCts3E2KjGdPDY+LaXEitCtsXjtWPpBtUa6AcpTDYZir9GxktEj9HHTjLZpITPHU4QJJKA3/hhShe8CoLq3xS5xuJ0r19zRZ8XgAGpam3nvqKY6gOJAXGsnRFmxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440500; c=relaxed/simple; bh=Ybb0kJKNd2BJDDcZYbhZbCACFsLVAC7m/M+jXCdbe+s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QmiG6oFxmHkt82g5PDImHx9f5el6kCAd0oFv4dt85SJjoGwq+vHCZyz/cKD9ta2Ew/rzf1EeZLQRlOGoa8L4R3aybo8ine263jYwpDx2/gyBwD67T/ec788ltdG4J+7KLPPb+LhQtyhKJ6yiO62ky9ayu5qiVcRiSW6r04t8vss= 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=pBoE7Ur7; arc=none smtp.client-ip=209.85.221.49 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="pBoE7Ur7" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-45e9f4a3510so6955392f8f.1 for ; Tue, 02 Jun 2026 15:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440497; x=1781045297; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T5zD1QygmB8fWogN5M5u4F28IFz6bLgLGYRTXYqao/U=; b=pBoE7Ur73OododeuuifWDn5wMtoQL7yOw348/abCpfK/wllh0lM91/84CEnCPPeUT4 fJH9skgUnlmmjnBdYyeP+IAJ4pzy6HFFtdaT+eP/+Gmz5BOkpVTt/kGFp9DyAx45cmz6 kT/+ShtNSehFz/kg22vKaPjpJvBx5dcpppX6HUpL8tzb2IE7BledM1NliSG2aTr4Z+Ke 6tMztv/L+f2lw8qnP1RgHkqnKztJdZNv10rFEUnCbCjhRUBxY/FoRGSCfYNRvtbsVqgX VGph0jT3Db3uuOwQw59gwpsDC3ZOj5XW7KaqaUmXLkDRPnwdRPYxlfUKZtyW4cVXCCYv OMDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440497; x=1781045297; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=T5zD1QygmB8fWogN5M5u4F28IFz6bLgLGYRTXYqao/U=; b=Ls3k+51N9gt8Hv9s/98I1LmeVAqzWFh0hsMGIqVrch67fzDjo6BUI4IoIVuOsV4MEe ln8mA7MN/r6TxSnuP3RxlkdzlrLVwoyMxU65UrSdBCk8EBAqlPKwLi/jjefPzUnWq+1n 1UG5brLyOqnkv3eJofhB9KIVH9Uj2fsoJCiffZEWG67FQQOIAHFkZxcdb3EhE59MOEed 3N3Qm4iozJOAIS9Hot7+5JSZXZ3yxRq4zIIDHSbxHb+SmmYmrH9nenukDlasB9JaIcJG eh7nFw4mQgLDjFaVDy8I3oQbfO1sm/zNFuI6VfLYF1dhIWktmKxj4jhA9v0gNJrJGP3J H+LQ== X-Forwarded-Encrypted: i=1; AFNElJ/r76xQykZYMju8VPbGT45tE67xv4ql8vJ/lwXRbT2Hg4P1YUAyprmAg8Wh1l3DrYGVUpz+5aZgI1AUlw4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1RZtwhzHffLzH2i2UILww+o+JfodlIDppDJ/+VFsx9EMPIXRX n3DoQXv0djc9Nwkhlu2OoJf6ngabUsU707XEQgrSreLpFYY7GM8SEWa2 X-Gm-Gg: Acq92OESHr+5bHO4bZFnxTS6oNySsvptYcRPyOhqtiNmxS3F1l8t19fYFGh2PlsDVv/ 3CUTm1TNVoVdEXU89lYkHmnRyjcsDNpO0jZisbAY8/pjQKCBRH6fMdIoGi8o27lOyxdtGEyfSui LLcvat5CbeWVTRqfy3vtSd91Pdogax5zrs7QFPVjstqj+GpOaqOXR/ScsUuhf/473CPomaCV09d RPaSKZPekIeaBY1nj0Mj4v582jZIk3i9KZG3zlCX/aHxeGFqk3MtnDF7S4tJqdhzpo1XthncbnW E/Vqev8lTz1QAn6/SIwvNeXM537x9IentCg29OAzZprKawIDxNXvmsONDnWzsCsoHaL1tvGNMUH tH1Poc11hAFkKOnjyXofI7Va8gVTg1TGfyI0Bnj18I+YvdvD08W/ZeFddhUnSC05rqBFWX6t1KA W2o8Imto3kJOrJgtWN8p/SISAKvv0O8d1WeS+iF7iMAw== X-Received: by 2002:a05:600c:c84:b0:490:389:7644 with SMTP id 5b1f17b1804b1-490b5fe0e36mr10870455e9.17.1780440497119; Tue, 02 Jun 2026 15:48:17 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:16 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:47:59 +0000 Subject: [PATCH v4 02/25] docs/dyndbg: explain flags parse 1st 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 Message-Id: <20260602-dd-maint-2-v4-2-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=1814; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=Ybb0kJKNd2BJDDcZYbhZbCACFsLVAC7m/M+jXCdbe+s=; b=iGpCIeDHPVfQ770YcsgKYXv3tJwW3O+XIWlcq5CIrp9h5VC/6DBVR3xkR4b7Qcc8Pnj13ieeI Y4QZse5sLQqBLq9EL6k0vDUfzHjGV6rne+yovUgeHPiSQqfDC5aN483 X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 --- Documentation/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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.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 0CC983BD64E for ; Tue, 2 Jun 2026 22:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440504; cv=none; b=TTGKBeJQmHexsSCvsvJTr1UlYSwreuB/W6zN5wieZbwVGFL82lK7xewlBMzG958notTc9CQdwCOJ2iVZ6Pu6V7q/v1fSggk6duOaRVSpzUYfKn3HDieySJrkBzcHT0Ce8uRaDFEpsMInqMAzBSG0u8Ni/RZCoR9r+PHW5ryMNqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440504; c=relaxed/simple; bh=pg9cpl0bo1AtFElQETrwEKQ1mUnu0drU6Mzj79jx4XY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JWJ8o3SR/vuly8uk7Lgm7HQFX8giAYDD9juNCGAxsQwU7cQgIf6kj4FU40/b8NHoR5eTMKtCERtn3LWurEm1kCzE6E8xmwzAgd8QMK+1pkqXXYwk7V+nr2R4toogWRzLbC7dHo54acNn29f3mZSAyPvprhIlN6ILU8BPyxfRKKs= 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=JBFMYl0c; arc=none smtp.client-ip=209.85.128.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="JBFMYl0c" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-490b3e03939so416775e9.1 for ; Tue, 02 Jun 2026 15:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440499; x=1781045299; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AgjU2Qt2uFal6066puOiKcG/bH5c3F/sQ7Yrgz0f2yo=; b=JBFMYl0csfWsyVAWBMvOQ+IbPkuhDsGXQrfztSt9iJF2REyqZr4T1EiPEL34fqbH51 ONthIVFW5w44iED8xABZaOBMvANhB++pZFqX4/jsLGIu9FNJ9TdqsEKNWJ7uTng35aBY w9ZhbpOe3bS6VAbDFgJELS4aCexEHd+oKHEkHDf6hxIQo0PAsmb/qWUd4q7IBT98E/PD 5ujv4TAnZa8U9RQosp40dseGaN3Wwgz3z1IXRXIcD3sF7Z+qgOk7TXXCD4hkAK4vV5TN qNvN4fdPaDbbcVbPVC40oaIVK8iBkpA87JYiN5rIgShFtgtTVLT8f4fyCu+ofll8QHiI Ad7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440499; x=1781045299; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=AgjU2Qt2uFal6066puOiKcG/bH5c3F/sQ7Yrgz0f2yo=; b=J+zutNV/LaMhIwTVNiduu5E0Dm+2SClDzXgsunGurUITM0ega411NT4/8IoKVr3lhC yqgeRsvSvP9KqIZYBnhfmSjHh3trzSG3lZW5OrIOM3pqkollQjGH+K7npHPvSQO9Ckxj FfFJkceIgb720g7qOkAIwu1aF5BIJFi5mnHpl4VsuJbCCUSsHpqvkfFA4uJPDk0IgGpg SmchpXVM5wOU0LeYVSYCGc/a+TwE5k41nHhyMmBJqgzz2iTl5IEMiRNZk+sCASZlKOHo uSUD4HF+PafSiF+TfaMKePEdiW6i1rNUPUglEPvgS28YV/JgS4ArFaUL9j89ixhKeQfg i0YA== X-Forwarded-Encrypted: i=1; AFNElJ9YEO9JYEVlxHII+rR9icD4wdULW6GqRzlDOX41bWRNBP0H0qys90Ijv8Ans/rse6efGMJNbiMkSVEgdWw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/8LWEpSCFOLz4nzSBpIyTrQdKP/LATFHwsIf+pQcAp0hrIj8G Vij61qLIOashbejyCcwTpcD9K/jNVK9u+vWE2T8qlTGq6Yx2sO8Apxqe X-Gm-Gg: Acq92OERCZ6N2883HCqSuvpEnYggCvJIAY6czY4J0LM3j4/mZUZmo5hKa5KnlHVuXU3 HSzfZhVDAqRhKbMnu1swqai0bSOb4YUlaFoMqNlIAMj9x+K2QpiJPA3QyPX6FDXcvpB9CB9Gmsa bRLkrFTLIxHXYlaRmGKcFhuWmNTEeW8Slr633CToDMCIyJsRM8rs58bWxeTl7Birikaw8AaMqnZ HzInnpPjvfAc+xkgppdQAWPUgLL6wPIXoB5TFtXqFN52acN/GgxkbgDMWtyUG6QL6M8m7dgsTzt wSfanw5Osk6aAyhzE/a1Rgi7ON1YvNU751UpFzB+CVgC/nhENHxmN9XFIDN5OzuctLn/J6BcHad CzVGhfC3hOaWuCDYJ5KVav/wEERF5DfVSpxJnzbgf2D0dyA7NUuQjaTv7jlsx0L5iSSqGKyz1eM RRbyxRhXrdFDAD9GESBAAEGLcAG+w0Qio8Pb49Cl1tXA== X-Received: by 2002:a05:600c:3586:b0:490:b080:4835 with SMTP id 5b1f17b1804b1-490b5ed385fmr9521615e9.0.1780440499499; Tue, 02 Jun 2026 15:48:19 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:19 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:00 +0000 Subject: [PATCH v4 03/25] vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h 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 Message-Id: <20260602-dd-maint-2-v4-3-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=4249; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=pg9cpl0bo1AtFElQETrwEKQ1mUnu0drU6Mzj79jx4XY=; b=PCbuEwQZdW6szL958qPtN2q+zMt4zTLcoGfE6vSsy9ddJg9N8GB0rMqs9omnhc5qIM1axWwgb JWqDFwcoyPoBGXBOz9hnvLRwlK/S2RSIVu0TO650z7JAaGNP0niqcfU X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 failure to keep dyndbg sections in some circumstances. NOTES: These macros are only for use in vmlinux.lds.h, where the _start & _end symbols are needed. Modules keep sections separate in ELF sections, with their boundaries known, so the _start and _end are not useful, and may confuse tools not expecting them. This patch ignores a checkpatch warning, because new file is covered by "GENERIC INCLUDE/ASM HEADER FILES" in MAINTAINERS CC: Arnd Bergmann CC: linux-arch@vger.kernel.org Signed-off-by: Jim Cromie --- v3: move include to top --- include/asm-generic/bounded_sections.lds.h | 36 ++++++++++++++++++++++++++= ++++ include/asm-generic/vmlinux.lds.h | 31 +------------------------ 2 files changed, 37 insertions(+), 30 deletions(-) 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..8c29293ca7fb --- /dev/null +++ b/include/asm-generic/bounded_sections.lds.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H +#define _ASM_GENERIC_BOUNDED_SECTIONS_H + +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + _BEGIN_##_label_ =3D .; \ + KEEP(*(_sec_)) \ + _END_##_label_ =3D .; + +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + _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 60c8c22fd3e4..9c61dd083f26 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -50,6 +50,7 @@ * [__nosave_begin, __nosave_end] for the nosave data */ =20 +#include #include =20 #ifndef LOAD_OFFSET @@ -211,36 +212,6 @@ # endif #endif =20 -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ - _BEGIN_##_label_ =3D .; \ - KEEP(*(_sec_)) \ - _END_##_label_ =3D .; - -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ - _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) - #ifdef CONFIG_TRACE_BRANCH_PROFILING #define LIKELY_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile) --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 6F11F3C81BF for ; Tue, 2 Jun 2026 22:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440505; cv=none; b=u4JKE4nwL6+zAMi62mM+I4dsduvVRPWjzL6IscZF6o5UAJCW8dmDtnhtPREKPR/8AazGwQvnH7Ex1f+ewhLLaM1IHCQhz/P/Ectj0pzm2JcVrCIiwfCTjqkFxmR4Rk030xTNFndvJ99JVG4x8qcCuDAgIFHy5hikq3Y7fYrZn9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440505; c=relaxed/simple; bh=gyhl2dDHOhDRfo2EoLm//e3PBy86xHd/L/qSVe14+FQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=No1eS05ema1Gj2ob4VJU9Xj2CwOuwh/NbftSmvl09rTBnQvRC/8SaURDF5yD83qv0MjPwdMWHnDrPgJUuNDeN6ruihje8u1tQ0THLyjS1TBkh4MUbA1rWFnIon59+dYc3C6mRaqoMnvDp3AxV/LtOBrCT/yAb6HoQK21S+dahNM= 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=AhpFbID4; arc=none smtp.client-ip=209.85.221.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="AhpFbID4" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-45eecb8bf67so4335611f8f.2 for ; Tue, 02 Jun 2026 15:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440502; x=1781045302; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GsoCp+QEhPQqcC7YciJ1pPB6BZ3pQYi3CKXlL70tQeM=; b=AhpFbID4JCIUXOJSzh/dJxAv0z16VlrytM49g+48C2VKBz/4pL55rX2dgMdicIM6Xc i4c6K7ehBhnVPYB0MqlPvpqEmDZVXlCHRze4fUyzXeHUOT/maImXRE1FCVIG0iKF3B0U J4XQCUeCFpzPJcZ8o6uh7jnpTCG1zRmkEHggRviL/qQdwzx6AT8TIcZgsoZOzcgT41Gj 9WWX09T8frTb9pXONy4hRAYR8Jd9yeZcv1U6eb3KAdbQBmBNcgCIma75xUgt0rGaByhu A3qdVmyrtNnS90D1UMln/kcTxNH36oOmJP0NbQ5VnAu33eOmoPW6yPBRb9J29+HwTtjG G/GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440502; x=1781045302; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=GsoCp+QEhPQqcC7YciJ1pPB6BZ3pQYi3CKXlL70tQeM=; b=ExuDNalOfyOpw9dKFvIZT+YppsaD1GA1YGjwYLts1J+E2m/Uo6iZj/LV94wJ9oTUVo SnBwbUYQzVaP5Pt4gPbaH4cZH/aBz3gySEqyTy0mM5JtbXYvG+TJ5VefCJuwbJa4tS3h JiQwd3h9qxkKBq8i2640cIPxEb6SeKPwfHqzcKKfRxPZbuXzm2OOqpOL/+LL4FmoQCor pnEmV1sAmvHnFGM6SGucBw3sNjj8IzgSg+cIfNMF5bMmc3STpSCYhXU8d4m84AmDwAue Z+bJdW59Uw6M5ZY97cN3gXwWJ7EO3qkh5aJ27pJa9OUweTQBSryH0Nqu9mhCbptU97m5 qt6A== X-Forwarded-Encrypted: i=1; AFNElJ//DlDstL3ZyOlHfT+1nPSFMWTxHtT9jKHs4EZO+mvCp/XG0TugGTZjx27uoG+AtXEGCCpXS11IcvLs0Eo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyohc8RSTXo/YzI7iA4YcIii408JY1HTef3A5n1Te2WJM/s0Xvu 1u1NrfpTxW2/hEjFZrOmlT+mIU42JoUsUheOuyiiLOsd6CwlcrDwyoKE X-Gm-Gg: Acq92OH4Jr77i0m5UqDjgaTmobAb23s7j8DDxbKf7GlcSYi6PVyu0JYoY3/zvCZq561 OSCl4Tt9QlalGKrUBVUaCBKmjMjB9WzVNdhljY0E0rhD/U2JcuFMKW/FTM7e6bA6XkCssA5tk8a oBKqJBrwwyRZIgqTgLOOrJkjybCgMxvhIeruCYIaQAp+UCVqyLt4+1FNPOEuizIQuEG3CVgqHPF apSW2nM0luD0hiwovnaG+pIABA5rl3PaXYXQ9beJqgKMbn+r5gGP/q3YH3TdiUf/2SMB9SgMx5z 4dfJthl5b4YD5X0a5rCxjVad/z/MkwOC8GksQC7XSEOZDARcq/3t4gHTfvcmwzVk8SVB+o5MZB4 WFr+x1IigsjncI0XzM7IfuW5KIe1Ovac10rLqYXZyxC9ZLTNsO5wiR8/c3km4apkdS+d2RI8Qvn 5lQ18iss3lLnJ2ShMBEVvH/7D7n065E7xd95WfG8q/uLHHFZxfAG4U X-Received: by 2002:a5d:4987:0:b0:45e:f780:6181 with SMTP id ffacd0b85a97d-4602182cd9emr456749f8f.23.1780440501948; Tue, 02 Jun 2026 15:48:21 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:21 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:01 +0000 Subject: [PATCH v4 04/25] vmlinux.lds.h: drop unused HEADERED_SECTION* macros 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 Message-Id: <20260602-dd-maint-2-v4-4-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=1428; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=gyhl2dDHOhDRfo2EoLm//e3PBy86xHd/L/qSVe14+FQ=; b=MvsNf/S/xSTGRA+QFVkd0l5ykeS++JYaB1FrXileFx3gCJmyjVcFCFJQIWqeiUZo7GqEj3BlU 9d1r+RLMW7bDHjfviGujkjn0nEiFeEV5seia07THPaU+H02yfAvWuLZ X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 8c29293ca7fb..268cdc34389b 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 2529E3CAA3E for ; Tue, 2 Jun 2026 22:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440514; cv=none; b=QnOVBLd5+J5KUooUJ3eLJRP1lt6QmBmWytZq263P806b2jYv+9dehKJV8hMrMvoGmDxBAd8dbaog6R7Lfiw/A45zP0PjcUQ1N0m6s1S2IkIAwHSVJ7tXFwq4YPsxWi200PY/Pin2mvDcUzLj86Y14PZXKTtooyC2XDlI9mTx7aA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440514; c=relaxed/simple; bh=hdVbw4QKJX2tLtQU19EGleFHqr3Zp3coBIFOgLu7iTA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hab0unYedWEZV7lbfgUdRS11tkHVgAq9Ylx2dTNI8RKtkNz4I9rNJicdXAFjkImpoq0Nl8vBjDz3I6xXeoVKU0Y+ie2+GhLDyS+21ONsRclv9iOodmu+k9OUXrL5e4dc7WggmV8kXA3lYFQ3p7EruUeN4qJ2LgJf8YLsKTSYo3Y= 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=mFuhjrkU; arc=none smtp.client-ip=209.85.128.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="mFuhjrkU" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-490afc47455so10248625e9.2 for ; Tue, 02 Jun 2026 15:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440504; x=1781045304; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ORGg5NVhIfXoxcjPdL/EfpbtAVKkW13ZtTAMFNgq2uU=; b=mFuhjrkU54pRlISYkDMX3v27xkb4N2J3SMsottSc3zo1KbgWIpoUdAwuZG++GVyWda R/1L/pDDo1pEISYoTVyUWI0Gy1CBH4J2hLY1Anmj671DxlJn9SZU/RPCx97wE/AySvdk TT/SZIHayowlAEYuprGB1qFyxErFrs56SzFzyiwvxeHH4n5ITAczpe2n2xC/PaDK6cXZ pD3VY38fwkXiaGSEWOlaH7ONatPppdD2vpc93DQmSqatmkDpW2s+dcfksTkN5Dux5I2Q C0P/mQyI/aA3TC6edqgV1nVMMlOVcdag9M8kjXD/C0MWRIxdiwZs0TTs4REeGhatrgvm wjpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440504; x=1781045304; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ORGg5NVhIfXoxcjPdL/EfpbtAVKkW13ZtTAMFNgq2uU=; b=tF2MPpCTQfdu1YimvUObF3vNMWeHchz9eUG2rQi6Qwu6d2WqeverAOvqBuLsYHdykW 7VJ68X6lkqMarNMjMkZlP8MUjOj4uckwvvBphf2j8H3XdyQsw5lf+/17zNCmKSLKgAOT F5QpVnnQ+nl97rZB0l9I7zM7SRAbWMYFat7qwMN4VdAl5bXEdb7cS5wr8N54AUmC1YVR 1WVM4bLTHEQzu3vAWGFx69L9KRwZJjlPvSC1fRzhoIw0lCym6GZ90L7A8AZraibkBZiH 9Yuy0SiGlX3crtmdsBUBQRWSRSadvD3vCsxhr7/Zk2N1zKGiEYxwalzmNOlItozvNFu/ dTgQ== X-Forwarded-Encrypted: i=1; AFNElJ+9PVzrZM8e86JDfduqualVV16iSy7VtmR80QWSKXGQ/oTmztCM1PLhAPXFX1n4BMq8kHTk6qq0Wc0Cs6w=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1q3EanlD1xc1HciEv3vx+m53vVRQkJtW7zYQq8jv+2LT5vhrL s3ybheaZ2XoEwT603tcUwaRtv0w4HVZVwCGSnhorjSPsuPUbEGuKIIsO X-Gm-Gg: Acq92OHtzLnb9bk8tjqt7QvjpvjlIVBfpXTZwVNXyDr6bL9mE9iI63URqVgdCuMZSX4 WaOIOTR+GOaKL+HYWx4IeE9FzUh+06rGvFnpzg8RMdreC1dJpCVM31smMvUjySQhcPkHXE7itX1 /tiDPWtUiEjzjf1PJJJ8tW1Ljn3/ZCJLo1m/YDErH/gwR24ogByMSXnAI9CTAnoVaa5ACg5OZpL PFEKXcf5+Z1q5qTizVNbcpPcB4+d4k8yEIL8Hsmj0/pkbdr7uHfXF8G9WLkKCnXX1yftkwCwgxh 1oDEB7vTzymlu264yQjzDK9K/Z1TChaCdhLSysovv6cT0TuZEASBRcd57xqvFf9FxZypvMWJFxB bgN6vjO1Rky6M6u4q4A++frvOcj+otaFYDIHZJzuNAuAaYJ4uFjTFcK80i9SdKG5hwws2MU2bSx TV0oFASYv9FzpMDM+oqqy/AR4eVi+cnmQQXcFyKjeVXA== X-Received: by 2002:a05:600c:4588:b0:490:58f4:ba2f with SMTP id 5b1f17b1804b1-490b5edd750mr10674115e9.23.1780440504473; Tue, 02 Jun 2026 15:48:24 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:24 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:02 +0000 Subject: [PATCH v4 05/25] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 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 Message-Id: <20260602-dd-maint-2-v4-5-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=6221; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=hdVbw4QKJX2tLtQU19EGleFHqr3Zp3coBIFOgLu7iTA=; b=wJJRoYbkwwyJpKMHSOizH3ArydPecayEYSOrNmc802WEsYnx4IVV34cFJFb7teNXttZOhM69i b/frrmLSEa7BI8j46+1Dz10VCpwCtXCxvvmYN0nCvCz0xnY4mKcAEtb X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= Almost all uses of the BOUNDED_SECTION macros are ALIGN(8), either explicitly, or by being below an aligned section containing x*8 byte objects. The noteworthy exception is BOUNDED_SECTION(__dyndbg), which immediately follows BOUNDED_SECTION(__dyndbg_classes). On i386, struct _ddebug_classmap is 28 bytes, so without an explicit ALIGN(8) in the macro, the following __dyndbg section gets misaligned, causing a NULL ptr deref in dynamic_debug_init(). So fix this with an explicit ALIGN(8) in the existing BOUNDED_SECTION macros, and introduce _ALIGNED variants to handle the cases with an explicit . =3D ALIGN(x) Also add explicit alignments for: EXCEPTION_TABLE, ORC_UNWIND_TABLE, TRACEDATA, INIT_SETUP, and NOTES. update BOUNDED_SECTION uses inside . =3D ALIGN(x) stanzas to use _ALIGNED variants, but keep the outer ALIGNs so the symbols between them are not "re-aligned". In particular, scripts/sorttable.c does not tolerate sloppy padding. At the top of ORC_UNWIND_TABLE, add . =3D ALIGN(4) to match the struct orc_header __align() call in the code: commit b9f174c811e3 ("x86/unwind/orc: Add ELF section with ORC version iden= tifier") Suggested-by: Louis Chauvet # _ALIGNED variant= s. Link: https://lore.kernel.org/lkml/177402491426.6181.12855763650074831089.b= 4-review@b4/ Signed-off-by: Jim Cromie --- v3: sashiko complained about NOTES and .BTF_ids. gemini asserts that NOTES are natively 4-byte aligned, add comment repeatin= g it. .BTF_ids doesnt use BOUNDED_BY, since start/end isnt needed; sashiko evidently got confused by immediately preceding usage. v2: sashiko picked up 2 cases, added to the explicit list above https://sashiko.dev/#/patchset/20260515-asm-generic-1-v3-0-680b273666d4%40g= mail.com --- include/asm-generic/bounded_sections.lds.h | 17 ++++++++++++++--- include/asm-generic/vmlinux.lds.h | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/bounded_sections.lds.h b/include/asm-gener= ic/bounded_sections.lds.h index 268cdc34389b..8ff3e3420f60 100644 --- a/include/asm-generic/bounded_sections.lds.h +++ b/include/asm-generic/bounded_sections.lds.h @@ -3,19 +3,30 @@ #ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H #define _ASM_GENERIC_BOUNDED_SECTIONS_H =20 -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, = _ALIGNED_) \ + . =3D ALIGN(_ALIGNED_); \ _BEGIN_##_label_ =3D .; \ KEEP(*(_sec_)) \ _END_##_label_ =3D .; =20 -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8) + +#define BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_,= _ALIGNED_) \ + . =3D ALIGN(_ALIGNED_); \ _label_##_BEGIN_ =3D .; \ KEEP(*(_sec_)) \ _label_##_END_ =3D .; =20 +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8) + #define BOUNDED_SECTION_BY(_sec_, _label_) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) =20 -#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) +#define BOUNDED_SECTION_BY_ALIGNED(_sec_, _label_, _ALIGNED_) \ + BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, __start, __stop, _ALIGN= ED_) + +#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) =20 #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 9c61dd083f26..145beb14b94b 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -640,7 +640,7 @@ #define EXCEPTION_TABLE(align) \ . =3D ALIGN(align); \ __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(__ex_table, ___ex_table) \ + BOUNDED_SECTION_BY_ALIGNED(__ex_table, ___ex_table, align) \ } =20 /* @@ -650,7 +650,7 @@ #define BTF \ . =3D ALIGN(PAGE_SIZE); \ .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.BTF, _BTF) \ + BOUNDED_SECTION_BY_ALIGNED(.BTF, _BTF, PAGE_SIZE) \ } \ . =3D ALIGN(PAGE_SIZE); \ .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \ @@ -832,16 +832,17 @@ =20 #ifdef CONFIG_UNWINDER_ORC #define ORC_UNWIND_TABLE \ + . =3D ALIGN(4); \ .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_header, _orc_header) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_header, _orc_header, 4) \ } \ . =3D ALIGN(4); \ .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_unwind_ip, _orc_unwind_ip, 4)\ } \ . =3D ALIGN(2); \ .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_unwind, _orc_unwind, 2) \ } \ text_size =3D _etext - _stext; \ . =3D ALIGN(4); \ @@ -869,7 +870,7 @@ #define TRACEDATA \ . =3D ALIGN(4); \ .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \ - BOUNDED_SECTION_POST_LABEL(.tracedata, __tracedata, _start, _end) \ + BOUNDED_SECTION_POST_LABEL_ALIGNED(.tracedata, __tracedata, _start, _end= , 4) \ } #else #define TRACEDATA @@ -898,13 +899,14 @@ *(.note.gnu.property) \ } \ .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.note.*, _notes) \ + /* *(.note.*) are natively 4-byte aligned */ \ + BOUNDED_SECTION_BY_ALIGNED(.note.*, _notes, 4) \ } NOTES_HEADERS \ NOTES_HEADERS_RESTORE =20 #define INIT_SETUP(initsetup_align) \ . =3D ALIGN(initsetup_align); \ - BOUNDED_SECTION_POST_LABEL(.init.setup, __setup, _start, _end) + BOUNDED_SECTION_POST_LABEL_ALIGNED(.init.setup, __setup, _start, _end, i= nitsetup_align) =20 #define INIT_CALLS_LEVEL(level) \ __initcall##level##_start =3D .; \ --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 AA4EA338936 for ; Tue, 2 Jun 2026 22:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440511; cv=none; b=ick00muND5VycreHPSrlctpHUrrt1X8HETwcnLtUzR+BIWPkpzjE8NE3LvTl3hVlFBh6sT38a6/psveBopImYqASLXDPCW2DliEdv5r30N0/upiJ+wuPKu6Gi6hSCuBSf1Sg4aB1aaFhd0hhlc8amPtBHtkbgS1c4GnCY+0WySs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440511; c=relaxed/simple; bh=+UeoPcUgk4vgSL6bIOBGSbmEMWJGj+kcMG3jKhNS13E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LP/rj8dMaTiTHmfxxcLlCXKjMlMaL162ygGmXjoU7fYeDm5RkrtTiBNssHtRCxP0eIdsoqgg3vRcUFhXBZgI6hY16Nv0PlkuvfBCWMCISsq027/PCdCAmJ61R2ncgAGaKazr7XFGkP3d362O7ojzaILIiRrEPokhWy60xO0d7dw= 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=hytj/eK2; arc=none smtp.client-ip=209.85.221.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="hytj/eK2" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-45ef189aa1cso4078718f8f.0 for ; Tue, 02 Jun 2026 15:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440508; x=1781045308; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=n9btmEwYy4mA0lJ0Eq1DfE2LNHPtUWEmA56rbSRa3u8=; b=hytj/eK2esyu8IhuoWC8R10aNxnYG6uDsOhjwECdEynMeCWdBKb8MvD7Ng+B5VfRS4 Zy0IGJlzWG2U8Re6CWbDvkBrdI6hL834RWcWlhQruujjcTNm/hwEummTdE6jyUM11Gqi EVcH5qdfkmDSzjdjW09DpCynsfaaE1UcawCQeQKoTJvPBVPFXMjYc2Drr9IR1pPu7mW1 8KM9fkmycrt86aMjqV4X59jhJx1C5lNb1eOiYs8P5YYnNXIQx+Rz0KRX1ay0S5tECUnK b7gYREbYKq0lXcLCDk3EFGdnuk9nQvTaKqopBLb7RErK1YyCRzqRmdm2QA88inZB2MFf ZC6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440508; x=1781045308; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=n9btmEwYy4mA0lJ0Eq1DfE2LNHPtUWEmA56rbSRa3u8=; b=C8CFsDIUt2MsDWOdBBDQbBpxU0n3m051nd+T44AWZslZHwRYwm4VznFmvcN94fpd72 lcEtzHWaaOz+CYYTRJU1O6eRtjmE4AUTwY7krHVLUacmj2Sd+JdG+A+6douq8WBcOeYt 1JqikYBh4rNQPtbeYya2UTfrnFXyRqC+aQMJqWYmPF1tIV9+0Db7NkmIuAv02dKQZQLR CZS/vIIcJSGTbTlzTjAHj9Bmkp2DyCN7OkMqIct7dA8ZA4VZjY/93RjWgAG6de/sx3T5 a3ABSXPbok/QNvrfVKLrssnRq+SKqkD005r5357vGtYiNl9NgjgB/0Lel298eL4H8aiW E+JQ== X-Forwarded-Encrypted: i=1; AFNElJ/T6dmJHbthxghOlNr8WMX4G3vvxGwYeLz4btvWCrZBBsCRVlO8WkAxO17BivkkWEZKCRCwrVqfqqL+wEc=@vger.kernel.org X-Gm-Message-State: AOJu0YxWIkPSxumWEslKuovfTVcTkwQWoqHiNizu9AKRD0jJQGv5h1uX k0Jt2XeZ0IAVGql0veqQH0GHMGf963hrk2sAKg/uE06NvYP+GzL3LOnO X-Gm-Gg: Acq92OEQ2jnQE6LKQ59p+l3SDg6/spXl+FYEj6v7V+Kafsq5OUV09aR2HfPVi1RSnrG 8YpqHctZEU+HjAy9d0TurY0ipdBx0+TlpR4LfWn/ocgQfbNXjYSvnDKCn6GBosUUmwkVxMqT9qI hNhiqc4Y0TnMJeRWGeXMMq5ZbmmdnIFuJ9uk/29h1c2ld4kOsxTQH4p0eGs8ToflfCteJbXJrrV IrKDFk3ov+5kauG+JZbcvWuYXnuTm+vM/PgEMaL2kMqbzHAZ1Q2+xjstzfHT94jqlOcWsDWesea Es7sls74Od6qcvkcEIKVj5pJ15DIZ1Od9DI6oqopwRCmmwg9TzkjB5Qtidop9KXqd5Oe6ha0MkK 6KWSg441U0tYFbgs6a+fLCbQhFolIqyfHJ3JdLlFFmlIEraVFHP1BIDu7hVNdOBZKrjJbAPb+dq DUhxbzAyZtCeYRzoJ+seuHSwNH+SODu3EImFvhw9Tyqg== X-Received: by 2002:a05:6000:2081:b0:45e:ed7e:f900 with SMTP id ffacd0b85a97d-4602178ae06mr723209f8f.6.1780440508010; Tue, 02 Jun 2026 15:48:28 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:27 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:03 +0000 Subject: [PATCH v4 06/25] vmlinux.lds.h: remove redundant ALIGN(8) directives 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 Message-Id: <20260602-dd-maint-2-v4-6-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=3579; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=+UeoPcUgk4vgSL6bIOBGSbmEMWJGj+kcMG3jKhNS13E=; b=8YvEAPoW9Zb0SdA8n29Rq4/x+ymnjVU2aF9GW/hlp7J8X4pImXdIV61FGkChWr4t0qJXiM8yF 7JUjhv70j7kA8WQegySLYFgP/s98yMXecJXL4zXvv+/zRUqWaGh7XSD X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= The BOUNDED_SECTION_PRE_LABEL and BOUNDED_SECTION_POST_LABEL macros were recently updated to inherently enforce an 8-byte alignment. This makes the explicit '. =3D ALIGN(8);' statements preceding 'naked' macro calls in vmlinux.lds.h redundant. Remove these redundant alignment directives to clean up the file and clarify that the macros handle their own alignment padding. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 145beb14b94b..2b1becd809be 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -228,7 +228,6 @@ =20 #ifdef CONFIG_KPROBES #define KPROBE_BLACKLIST() \ - . =3D ALIGN(8); \ BOUNDED_SECTION(_kprobe_blacklist) #else #define KPROBE_BLACKLIST() @@ -244,7 +243,6 @@ =20 #ifdef CONFIG_EVENT_TRACING #define FTRACE_EVENTS() \ - . =3D ALIGN(8); \ BOUNDED_SECTION(_ftrace_events) \ BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps) #else @@ -261,7 +259,6 @@ =20 #ifdef CONFIG_FTRACE_SYSCALLS #define TRACE_SYSCALLS() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__syscalls_metadata, _syscalls_metadata) #else #define TRACE_SYSCALLS() @@ -276,7 +273,6 @@ =20 #ifdef CONFIG_SERIAL_EARLYCON #define EARLYCON_TABLE() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__earlycon_table, __earlycon_table, , _end) #else #define EARLYCON_TABLE() @@ -284,11 +280,9 @@ =20 #ifdef CONFIG_SECURITY #define LSM_TABLE() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.lsm_info.init, _lsm_info, __start, __end) =20 #define EARLY_LSM_TABLE() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_PRE_LABEL(.early_lsm_info.init, _early_lsm_info, __start,= __end) #else #define LSM_TABLE() @@ -314,7 +308,6 @@ =20 #ifdef CONFIG_ACPI #define ACPI_PROBE_TABLE(name) \ - . =3D ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_acpi_probe_table, \ __##name##_acpi_probe_table,, _end) #else @@ -323,7 +316,6 @@ =20 #ifdef CONFIG_THERMAL #define THERMAL_TABLE(name) \ - . =3D ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(__##name##_thermal_table, \ __##name##_thermal_table,, _end) #else @@ -403,12 +395,10 @@ __end_init_stack =3D .; =20 #define JUMP_TABLE_DATA \ - . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__jump_table, ___jump_table) =20 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE #define STATIC_CALL_DATA \ - . =3D ALIGN(8); \ BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites) \ BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key) #else @@ -453,7 +443,6 @@ *(.rodata) *(.rodata.*) *(.data.rel.ro*) \ SCHED_DATA \ RO_AFTER_INIT_DATA /* Read only after init */ \ - . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \ *(__tracepoints_strings)/* Tracepoints: strings */ \ } \ @@ -947,12 +936,10 @@ =20 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test= .h */ #define KUNIT_TABLE() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(.kunit_test_suites, __kunit_suites, _start, _= end) =20 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test= .h */ #define KUNIT_INIT_TABLE() \ - . =3D ALIGN(8); \ BOUNDED_SECTION_POST_LABEL(.kunit_init_test_suites, \ __kunit_init_suites, _start, _end) =20 --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.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 C728A3CAA52 for ; Tue, 2 Jun 2026 22:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440517; cv=none; b=ZSgu/VvEjEVZhQCxZqEji7bgl9vaZ4SlOxrx/gubIpzfS9pBaDuf3GjpaRwBXMzbXjvHifyUNBKZvNTcYFR7YprgeLgDrpeY7Dz7QqxvjBoeU30cpUwISbdltIZFHH1QRW/Pe6jMwQCVfrPsS1d6682T+lLx6FzoAeqh2yhF8hM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440517; c=relaxed/simple; bh=dHDLAmmZkSEwCrVjFAbC9GSDOGfjrhwtK5sTHYbJuoQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K5k/7R62YKq00MVVxUINkK5KXufaVqHCDjwuZucNFjsSa/ooDY9ZYvD6xUjr0jv0t6RUpovif3MLGPOUhNDWpOQ/R3M70TExGrukB2hs8xFw7CZf/BVkJWeEwV7/alCWY+jOuu36GY+UciTN5D2rsoym//8rO7hv9jUPz5bAVW8= 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=JJtK/d5E; arc=none smtp.client-ip=209.85.128.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="JJtK/d5E" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-490b211ee6aso11137035e9.3 for ; Tue, 02 Jun 2026 15:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440511; x=1781045311; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ks10Mou4dS+uM/gF5zD1xC7hoNz/3aUwUMnLMPkjLt0=; b=JJtK/d5EfKNWAwcRClNaXWtnneknh6as8UV7UfZ1nlOt9R4ByRtwrZZbnleZ8OzdvH 7RSqDpnwe/AnKVzTg6AczAhrHIzIuZ/sag8gLLXzKVTj6Qf+Vaw1py0CWeS9rZpRsFY3 VSIMWOQeOFynsoW3YupToJCPhnzJbnHheHV47DkIEhdARkZLANRaPy13bqiNQt1Acx59 yPfhAC+WgYGThLwY8nRa4ixOgiERdy/B6ENABJ61/0uOabs1WqAEvTLIUggFowtW1QsG B5b0fPJ1l/HM6Mp8h+MYQwaeSgGubndc0XwawyUWUm+nnxXpQ7xcoi/n0R54htqcskL5 mf3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440511; x=1781045311; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Ks10Mou4dS+uM/gF5zD1xC7hoNz/3aUwUMnLMPkjLt0=; b=PqjLLEjrj2OyLkEyh+QhqfDGoH2MqFNxjkQ5V3brg+wSKkShM03b4BnFh4aTgH03nO k8fOVFLZ/lqwr/RonASETCLW90hcnQ5ZR7jrME0eXh5y8jo0NZA/MVTNagc73fYs1vvP X3LvoKepyeIDLafGB6Ikf9JaXwBSggcmhMdT0ygtOGewnCHs+qgyjF7CMkMgt4Mgrpyx rJU1g4L0DJXmrQ6iUtvpbrtTIc0EpLUtw7LGpY46S5MCn9fQ83/DJr05xwjVqIvRDEC7 qWeCdZAKHmYi8BuIMenf2C6On/89wJm+JBDn6H2Kv8TXeERQnpXvliAvgY++KOulzgl1 jO7A== X-Forwarded-Encrypted: i=1; AFNElJ9As2sHjQedgvgU3Bb6JMpHcIIm6q5MNWQt27ne9azfMtcDKwUgkzpgTEStss4TaJifvC2uQTNTVU4dMkY=@vger.kernel.org X-Gm-Message-State: AOJu0YwZtRZkRfWktVAF9hv2teR/paFU2xo08Im3FzHOH+kiDoTViI4m N0lk8drPUqNSVhphRjJWdbeeYjMXnmIr7KfGhcZ+We+5xAbyxu+jXuV2 X-Gm-Gg: Acq92OH3SZ/2Kj0Cn7X8Fu6DRKzGTJr2+9Z3OAocsulDRvBc7ZWO/DGA0o+AiEVSWQ6 R2z58x98MvU/WGNyiS78WGUjVaNVU3cYdn0iynYbma5fkUf22OWe82gL6RgSChB96y+BCNnnKd7 2stC81l/FKFHl4oY1u00Me4lqTPsvQqjUaUpVxZmev/XJRTC/8L8yRdAYPRi2hAIYylagXTOJfI eBAgkgi08CXnbWU4hgaNjCp1+tv12zGO/pmIQRAT/+x04CNEW4HmIuNcrtI9O9RMjEUaDQa79/E 5twoK2zFmowyp1jqVliZv7j3bHgc48j0iAOdyjIk4i2gOTGnSYqNe4l1QduLNtyXd2OiHx1G1Oy nG1nJaLw/idqAj/MSc3ORg8Ubgq6GFDdnSNS+QqmsFwQAkX1atKlB1Heo+TBenZrOb+un74Rkqb rU4aaIZCTHVqI6WdWvSbDNz/WkSSSzM3MfQprshvzMjg== X-Received: by 2002:a05:600c:1c1e:b0:490:3d62:f5df with SMTP id 5b1f17b1804b1-490b5ed10b4mr12433385e9.30.1780440511256; Tue, 02 Jun 2026 15:48:31 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:30 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:04 +0000 Subject: [PATCH v4 07/25] dyndbg.lds.S: fix lost dyndbg sections in modules 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 Message-Id: <20260602-dd-maint-2-v4-7-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=5103; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=dHDLAmmZkSEwCrVjFAbC9GSDOGfjrhwtK5sTHYbJuoQ=; b=LgE/Ax74P2Yjlnhsm6MH1wa6Hvkqc9ItHp5m4Y2LZojY/pi9asSAVhoGDgkZOORwDx8iHvhdp AwQ4fgRjXD0CyFUu4vc9iMWWwynZddzKwVQI/zAzdr55WpWVsA3sA3a X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= With CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, several build configs had problems with __dyndbg* sections getting lost in drm drivers. Fix this by following the model demonstrated in codetag.lds.h. Introduce include/asm-generic/dyndbg.lds.h, to bundle dynamic-debug's multiple sections together, into 2 macros: vmlinux.lds.h DATA_DATA: move the 2 BOUNDED_SECTION_BY(__dyndbg*) calls into dyndbg.lds.h DYNDBG_SECTIONS(). vmlinux.lds.h now includes the new file and calls the new macro. MOD_DYNDBG_SECTIONS keeps the 2 sections by name, aligns them and sets the output address to 0 when the sections are empty. 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. CC: Arnd Bergmann Signed-off-by: Jim Cromie Reviewed-by: Petr Pavlu --- v3: move #includes to top, drop extra ALIGN(8) in DYNDBG_SECTIONS, add RvBy v2: Address linker script review feedback for relocatable modules. MOD_DYNDBG_SECTIONS() used the BOUNDED_SECTION_BY() macro, which proved problematic for kernel modules for two reasons: 1. Unwanted Empty Sections: BOUNDED_SECTION_BY() automatically generates `__start` and `__stop` symbols. When applied to `MOD_DYNDBG_SECTIONS()`, the linker assumes the sections are populated due to the symbol definitions, forcing an empty `__dyndbg` and `__dyndbg_classes` output section in every compiled module, even those without dynamic debug configuration. Since the module loader uses `section_objs()` to locate data via ELF headers instead of relying on `__start`/`__stop` symbols, these assignments are completely unnecessary. 2. Non-zero Output Addresses: During relocatable linking (e.g., `ld.bfd -r`), omitting an explicit base address causes the section to inherit the current location counter. This results in non-zero sh_addr values in `.ko` files, which is confusing, degrades compressibility, and can cause issues with external tools parsing the ELF. Fix both issues by dropping `BOUNDED_SECTION_BY()` in favor of a simple `KEEP(*(...))` constraint and explicitly defining the sections with a `0` base address: `__dyndbg 0 : ALIGN(8) { ... }`. fixup-inc-vml --- MAINTAINERS | 1 + include/asm-generic/dyndbg.lds.h | 18 ++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 6 ++---- scripts/module.lds.S | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 9ec290e38b44..6cf80e7ac039 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9083,6 +9083,7 @@ DYNAMIC DEBUG M: Jason Baron M: Jim Cromie S: Maintained +F: include/asm-generic/dyndbg.lds.h F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.= lds.h new file mode 100644 index 000000000000..9d8951bef688 --- /dev/null +++ b/include/asm-generic/dyndbg.lds.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DYNDBG_LDS_H +#define __ASM_GENERIC_DYNDBG_LDS_H + +#include +#define DYNDBG_SECTIONS() \ + BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) + +#define MOD_DYNDBG_SECTIONS() \ + __dyndbg 0 : ALIGN(8) { \ + KEEP(*(__dyndbg)) \ + } \ + __dyndbg_classes 0 : ALIGN(8) { \ + KEEP(*(__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 2b1becd809be..0a1994bb8793 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -52,6 +52,7 @@ =20 #include #include +#include =20 #ifndef LOAD_OFFSET #define LOAD_OFFSET 0 @@ -344,10 +345,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 b62683061d79..2e62dc5bd5d4 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -10,6 +10,7 @@ #endif =20 #include +#include =20 SECTIONS { /DISCARD/ : { @@ -61,6 +62,7 @@ SECTIONS { *(.rodata..L*) } =20 + MOD_DYNDBG_SECTIONS() MOD_SEPARATE_CODETAG_SECTIONS() } =20 --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.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 4F4D33CA487 for ; Tue, 2 Jun 2026 22:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440517; cv=none; b=HX0vNl0IH7B7DJSWFZy0uwKbOJ1CuAfJD/6Lw56pNie+hnTcD0fTdCJllhCMoSKCeBCNsENxIJFowuhqY3Q8T4WSJaVa+8QWjaEnADUDkz1f//LFB+4syllCwisF+ffbwJ3I78hR1zozuw+3gh9elVwwImicvdWWd0HsjO0orR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440517; c=relaxed/simple; bh=ytc0P/UZw6i8hpySK2Au28vrT+KoK4/4tvvmOq28NjE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A2Ng5zbh5OXW4UG2aruxhUYXmFomIpezshfUFvMdtkfAqTvkpy0NRSNTSiojiK+ezjbbAmC3J+RUHMbmA187KBRTk0kddzLin2NzfgWvF+XTCDdVeX/HtV2QcfwHRNcfa3PZZ8JHgLJlJrTKIm+eVLaVBecyvcUIsWS28im3Pk8= 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=qdm71sAh; arc=none smtp.client-ip=209.85.221.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="qdm71sAh" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-45eecb8bf67so4335694f8f.2 for ; Tue, 02 Jun 2026 15:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440514; x=1781045314; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BdDKIkZQT8kN6q6EUNEFoTcvXlPCpXkuxCaw1ETC1j0=; b=qdm71sAhQ3ko26Cw5K+WoH0aqzULaWlhIY52ZHndwnQkyWudXIXAm/7/0ZXkZzgABW a7hFn1agXWAt/CQZ6wzA4+pbX+iSrU2hCBd0a/LGJK84OpvrTak3KlpjMFkzO/PeBZJS mgAXNvxbx0Q0p9B8N5gngzrUXmse2Ih3uPOAY2AkQxIyW6qUc3Wwq9Cb/vFawO5+PHX1 Lnu37mka0eYKXNUUM4MxLzAuPnMvcolpyL8X4yCjkB8FcsAgAlzF3YjjO5ALpnWF+e0J WLxNNSB5Jd9z2Y24+7qXm8TD6kAoy9MkPINGp0htPLW6DW6S31X2yI3Lz4dsz6jen/IQ 57Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440514; x=1781045314; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=BdDKIkZQT8kN6q6EUNEFoTcvXlPCpXkuxCaw1ETC1j0=; b=dBSDLrtTapl5K7HL2WSm9pmsEqDJ59HLD4AiJA1mPdEaLa1BjsBVtPkVq0hSWJDKjq oxB2ejCG3QwyUyyEgBAdnHMS0NJ7yn3T1g47ZgMQHyk17OiMaAEvRtLf5zt8OjCfxdj1 yf1BVg+iom/b92LwaVFCIdtNyNoKVTgk4MzG24iOGhTVK414pd3wyQas4MjCw2ZRarKJ RKql4LIukcp9n95nCfFWu4GlVfcT4BPQ+PehU/zVHRF9v97IT4l9jmiVSntSsk8dJCWt Ql4pi3u9AgbzANUkc0RnxgT798A7P4TB6eyGahGHPsYhqmwqcSG43iVL7bY2P3qKtuf7 7z6Q== X-Forwarded-Encrypted: i=1; AFNElJ+OzhmpkwyMtAN2nBJPNmHbljWAycjH6Lg1RIP2iPC2MJGKyAN959GCmyMiLcs86Ip+5jWewqfqcKV51J4=@vger.kernel.org X-Gm-Message-State: AOJu0YxXIG5t5pyuUjXDAMWRPyYOzclcl8OsWBd5+KUNtMJ5GJOG1viS Ve9rfHUiboHfmDmqc0GteKXhPAZHXv7+J0TX5VmGb2cL0YzExz8w2/rf X-Gm-Gg: Acq92OGsEdl5xqE3+Qnz2uok1oKBp8LJ+eFa4mmHbLlkBZWIv0+NsmhbwXt4gmjGxmJ cmbx/vBM4rR38HtZNL5WzgzLQrhCjB5mSPoEeryzbOV1yEAJtwyhuIwiy1D1YZqeuMl5hDPmBLJ tj4DuhpcOnhRZupbkc28Cmcgko/pQoP/sHoznb8KSm/Tyj8+eK4nIFGPoIUjwKpUxLEYJBIWxjA iTioeSFfZhM1Tuq//8nd39MYWJIDsI4BARmNsBQNkGFAXPCWwn1QHecu4RS8QRYhjkpfAu/TC0h L/Mv49xY1KI8AXJaxAZuprsKbA1AEJrSnQvoS/3p5KBrSJFbRkwKYpGZb15EZwbYyYhy6AauCQ0 B5jwiO4dZIIRGiYoYkdFvTNbR4ezyxPRkdMUdl9PIMp+D0TLElnwf2HhW6PKt2p4fc8NKI9YFi4 4xVk8L/ZDbEFhMRhY+dydaa/VIA5fK/itOjL0bbq0r/A== X-Received: by 2002:a5d:624a:0:b0:45e:ce28:666a with SMTP id ffacd0b85a97d-46021781a64mr481587f8f.1.1780440513739; Tue, 02 Jun 2026 15:48:33 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:33 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:05 +0000 Subject: [PATCH v4 08/25] dyndbg: factor ddebug_match_desc out from ddebug_change 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 Message-Id: <20260602-dd-maint-2-v4-8-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=4346; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=ytc0P/UZw6i8hpySK2Au28vrT+KoK4/4tvvmOq28NjE=; b=5Nnx0wurAISA7XPWvLxIHjr9MiqVPJsdjQtzB3crXplmEx4Fh70GzBvOTm8YTKred1nIS6x5n Js4PINvk2WlBIWopr7o4sC+XOKirBZgfd5GHiAFVWak9zlb/tYYXGsy X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 69F1B3CA49C for ; Tue, 2 Jun 2026 22:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440523; cv=none; b=ifNpiAZdcRA49t3T/WvYcYLbTE9bEnzNH2q89YczsjrZTMj3qKkGWB6uYNuhzIszDEunxfuDOrBGS1kGRh2HWAAlBwLYi09YHGxVrl09jZYsJJyyMdBTlaLntGHnU1Wn7f2d9Ol9nmSjDQxvC88IMe+yBtHqQGPb+DjmO1RAwJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440523; c=relaxed/simple; bh=ifMjdOv9s5iBVhpB9m4hzA/NaIvmwyfWNqe78zgQbz8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rOv4F+ATrdE3TeF/+l6+RYPyYtis3VY9X+jyuEWQLWQO6cu2xku1APwXVP3sqSOjezX3NF+ahqlUa1Zn2F/OjAmW1MP1ff5j2/ksgbfW3foGh/cqtOtEAwiXEgdr2tyxzYITOC22jhv57cO0ttuyJk/rUO5/6s5NtNLajP9M3LU= 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=ndhxaXwZ; arc=none smtp.client-ip=209.85.221.54 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="ndhxaXwZ" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-4600cbb06deso31282f8f.1 for ; Tue, 02 Jun 2026 15:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440517; x=1781045317; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=x+DQN3gI8cDIPCl5342KuGjmmS7ZUCk1xMik8PQu+to=; b=ndhxaXwZxROMUTkTTheLiHKJunBF1NoP3N2sjOKjkiBlAe2lhUhyVcejVtcSKbYsKb q8jQ/T+g6KHvPi7VsbnzV2o2MuyXPaE0Fltymle6dnf7x0uC89U40eMu91i0xEav4Qqj qWqDL/7CfGqzQVhyHsFi/uqRcDkfLjYBR30HrGZxp4CMqbo7CZsh5Th9NSz98INLohR8 KT6GzLHlwbxVj00+Npq9/fSWrMXy0HhjiQfgRcomqKy0Q18rEo+3iGnjIlxbu+mkrnUD yAjwbtfwuydgNbuPSWYFDvxRS/bBBlWHv4hnqEDrcFjR0nMaHkGfA3xgE3gq9exXak5g berg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440517; x=1781045317; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=x+DQN3gI8cDIPCl5342KuGjmmS7ZUCk1xMik8PQu+to=; b=HWTx3Ou69xSH9WxX0ilBH9ANvS39QlarkP64d4q0HpqanqrV953HNisd9DI9bvAcXz Y1h529fM7jYW7+dOSE4IkYo8Rc3ZHNWYxJ2wztiwqaXm614me2WzWFEjC9tRoEJXhpU6 sEDcyiNEyYOspblBgdkn7cloU72ub/gB9mFyep+s6Nv6Fsr6mOIy352hziwhYVDDBXxO jLX7EgaFA/va+WHcwhUALwyVR/1QYMsgcod2tD8ljz6PoenD+CjoMZ6pyisYJh8eKmAa bpOEKg7Gv0J2LbYFBKo51/DaSuhmwKdsXpSDK1dyI1vaJQf2PPYWviSSsDSW7vlwCk5J K1kQ== X-Forwarded-Encrypted: i=1; AFNElJ8ti2Z8zSo8bTLpU/dFVIEqDy2mnR8+B2Fdst5v0giaJuBULJIyAi/c2sCTcS11tdtzoUhRBo2Us747XAs=@vger.kernel.org X-Gm-Message-State: AOJu0YyxlJvp+AgY8H9khPeMmvDVtX5mSBY0VKh756KR6a968MvP5Eml IaNaq/adsCf5q9qAfQ0SIFRf1bRU9BjTWbvi5Zvb/Dam+nZL7F029kpwkjI53Q== X-Gm-Gg: Acq92OEvYpH3PJifUiRkwxcvjBbWie+YkFoK8ZGgWo8oiweuiL3KUOxe9Yc7Dylvmqe gaICFQYjeysuCi40qWGQTzdGu06XaA1U+PU8mrkLn1w9elno8Ed8st8OvxRNAEpb97Ngm46iIIM 5Uhw+3cRnD/8qJOxvW0obBP3Io4ygVztuQ/9j8mio7sR2TRu6PtAyPSuNkpBO5v0cg8NU96Fr/a 1BPLoJcSt9fot87aDmrmDGOZQBX9Gz2DmDVe1qYNvt8kLe0NtlQynp0HcQY3piH1Rxr2j72JNeT mzomlXKmR2Swv8lbemWh1oTSXLgTTHDXaZ4uYKadYkVRUcQNJ3ANHqI5dT9Kh+nhQF3ohjGn2Wa +9FgiSCrRxnwV44DTeuvjrjieg0XIWXz6xFOurLm6a345ThHnM3fAq7er7Bu7SBldUAeKIO1lIP Fx6+7cG0TbFvTWhcwEyrhUZAc+qloVZBSfhtX2OV1fuQ== X-Received: by 2002:a05:6000:41cc:b0:457:ff13:b2a4 with SMTP id ffacd0b85a97d-460212d45famr957487f8f.3.1780440516932; Tue, 02 Jun 2026 15:48:36 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:36 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:06 +0000 Subject: [PATCH v4 09/25] dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP 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 Message-Id: <20260602-dd-maint-2-v4-9-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=3163; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=ifMjdOv9s5iBVhpB9m4hzA/NaIvmwyfWNqe78zgQbz8=; b=yKRcSUGKJPF1N81xOkwGdUsrGS5e7k+0oxRa79SHVcqZnYwsk+bAI6TglGb/cerMPabg8MXRZ vNNsAP0WXz6D3Gpiqi344zOSBq0aoaRivT8jjMznCdZuOtdT7emOwdg X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.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 0BE063CAA47 for ; Tue, 2 Jun 2026 22:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440525; cv=none; b=r9KdL0oa/MYeDi/QP0VdPTnOjypVWhytO0emzqd1y4g0zjg44XQuz6lFxVxR2IHqfcJ7H5wXY1A8V5j0khPr3I6Oag8HDRHfFH7hGcEj/nGsD8UbNRGUY++lAnSozOe+mg/hfu0XCWTZEOb1qMXAFvD54ieYNwDmZlhqcyQ3GGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440525; c=relaxed/simple; bh=Ah9OubhC/0J+O5fnf6mytQN8u50S2Bl4xoeKfk7IEd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QWcq/pQPq7YFeuTJopbQvAYSiOXrp4c1j3mpsniT7rCCAiMkviNIqFl0BpejpuZZqUNLn1H9vnh+GV6MFujoHQmnXze6IQ55bOHPbfw8GT7nqipmXXKv4DQ1AQCcz80v7tH2u6GOxhTUNsRlT+m3hOQZGhFHM75lfjxv6GfOSL8= 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=hFuxi0H2; arc=none smtp.client-ip=209.85.128.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="hFuxi0H2" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490af320e2aso20584015e9.2 for ; Tue, 02 Jun 2026 15:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440519; x=1781045319; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1/UoMyrbDRBJtnX/0jQKUAOsd+dEJyLvzD20lPdR4ww=; b=hFuxi0H2UuJnZ64MYnC7sk1J7y3+R9yeqezMzy6OPMv3yOV9tOrx0vSkjnvoCP1MNg Z/sctMu6JTcTxu1ng+32FHKBbFWFUOHLT1k8cRTf6CB3MQoVyHJYMzhTJl9MNhas3JcB V4MK4N7d+0njhO7U9zJZmIF1t7HUEF2+8ZB9L/6ZPM+iC/mr8SeCg9TgPsWtxDADNJfP P3loPLaXlwuy6HgaGkizpXNQs9k3iIbojMWpWA9MLasUmVUomupYoYqFUCm6Jj2QsqW1 RaN/FnjxN1G0Sx6sk/G+9685NCbRdv1EhOzDMiFqcv2nPPcvFKIlET7p+nspkMfjFBEv oZpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440519; x=1781045319; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1/UoMyrbDRBJtnX/0jQKUAOsd+dEJyLvzD20lPdR4ww=; b=B6VkFUCSfyMjjG4qMqHkAA8W/SL74chE5lYv2spwFKsc4ZGph+CphWBMMCDsSEutfi P6/zwtawDhQPeU9YRBXytntwSKPPXNaE6vQW1yBt5O7+iw90yEYsKvtF7B0pYiSKbXzU LhVFkGPMNT9jNOT9MEWjFCzYn9PJiAO3v6v748a9HyVZzB2fwgxVwvEEpw6lXVUBYq3I mkvF5YqfRe0Tb2aZ8Zl+y7ryNqHiq51LEeN+oYpwcBlFeQH+Intj1JQMephGj13cFkcF Z12sZm8sUCV0SYoyIwtxPzt0+9AyuC3NK2VgmfBbwGXJq3EkdlsdjJcsop3HKzhFrdAI M6DA== X-Forwarded-Encrypted: i=1; AFNElJ9AS8ySbOnSpIslaMeceM3/nM/2FgaaEzrdjH5rt64N3ho/ob54MNKLKPCt4furW+dTdyrc77KlFg+MZMI=@vger.kernel.org X-Gm-Message-State: AOJu0YzDy/n7yHLSStnGTh9mnLJzHY2W0DmoHezrgOAprRvxjTs9frLW 8rXpgJbRI7peqRBlqTCJ5WlcCg6NS3Eo4bdiLC1OOpSXT/8AKOldSUDl X-Gm-Gg: Acq92OGvziLbEiA99YCeeYZWVB0FRWVf6Bmae6rli/19t6tAUARamwHhQMu2wDIIsxE 8/B7avXS5ui3twa9Me8mBeOo6M+xjEssekVK5LqOfr8PO4JOedia0XYbTacTXDU2MbbmY4+7W6Y MPtosv6AiTtvwhT8uHVH3A//NJZBDGvGLfJYnOaT1+Ns0UTtL5lxcnhDUymg77MABy7CSjTx7fy Xe7WHBpSjmHTrExDKJA4P5FPMMFef3AGd8R0Ian5RRcoJW6JMuYk+QjITpbndE2lgYeMqK2VFXf pmFDbqfglmNl2cs+1PXTQsc5l2QIkEZzyntQ6/c+OxXCQrecbATlrBg8cZA2uztLX6mZiTuE+pX gC5J93nEA1kZCaY39tMLGrM5lncL8b2l/4sRAEEtW6kAKQIMMTqGAJF8R3FIj50evLSFCvcjwT2 qn4VllSBFqroRvXkPI+X+haA7aG/bHfOjhiHNwmyZUdw== X-Received: by 2002:a05:600c:458b:b0:490:b409:94f4 with SMTP id 5b1f17b1804b1-490b5fdcda1mr13028365e9.28.1780440519473; Tue, 02 Jun 2026 15:48:39 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:39 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:07 +0000 Subject: [PATCH v4 10/25] dyndbg: reword "class unknown," to "class:_UNKNOWN_" 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 Message-Id: <20260602-dd-maint-2-v4-10-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=1309; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=Ah9OubhC/0J+O5fnf6mytQN8u50S2Bl4xoeKfk7IEd0=; b=mY6va1q+pplf3oiRh9kAqV2/4rkm8Jt+FXjkD2G7wa/YV3UYCu8KlP74E8zHuHM0fBwUW7QfI 85+dFL9KEusADx7bjdzgWA9Z4a2ALDbaZGX4b6jMBC5KuU25CaW5OCx X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= When a dyndbg classname is unknown to a kernel module, 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. NB: while this might be seen as a user-visible change, this shouldn't disqualify the change: a- it reports classmap coding error condition, which should be detected before review. b- SHOUTING the error makes it uniquely greppable. c- the classmap feature is marked BROKEN for its only current user. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 9EC683CAE9E for ; Tue, 2 Jun 2026 22:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440526; cv=none; b=KGQpZROolSVmvwM/oD4OYgd5eeuYEfrFHfNQUAcbhjJJvIC1/K+0wzYX8XNXVliXpbKjL0JeKvkM58qK4Oov3v+Lue6fNUSjuNbhgKuo92YdnzjZdgiUq1QdlLb00Vd3Elcha1o8uZXDXKPf+cLdUSKhcB3qo4jJkCKOELo3Q8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440526; c=relaxed/simple; bh=3/WKOcRSB+nt/VjxfVuHRY5i0B3sWWTVXpV+X5m2Kcw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CThArEWEjGt61HTJEWFW7A4k+ZWp6co4P5DDx53qk2jX4sS1XLU43ZgBb9AEzpb9oLLuqkc1MjE/1HX18UDOy0ttoCCMCW9OgTlE9Dtqcxe/zIlTf8rd+FoJQhW+SucCaUA7ta8bGWNbCdNDV8s9INaheIMRO9upbV3Z6JTbmbc= 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=cViidzV3; arc=none smtp.client-ip=209.85.221.54 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="cViidzV3" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-45ebafde87cso8109546f8f.3 for ; Tue, 02 Jun 2026 15:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440522; x=1781045322; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ouT17iaKBzrIR7K8VitMxlklOudvhENGiC0/9mkENrM=; b=cViidzV3XPTzjGNuq4pXlzpDtguJUwYlFe4NtGUGPJao3oLSbbbDnkzAG5LhrDgqqe z3/0oPFzWgouoaQPnsy6MfT4K0lAGw70VMLU6KXjAW6SuhX5+PR0J3TxXAA3AA2OtUfV m1WA93sWWK4LZE0dQSsnQp+8ogh3BQ7v0qCY2SGXJDJ1Zcm1jLLEmJPTEEBpO2OncOBp 1eB+ZGQ6EVVFcrPWHkWqKBpKKMc50m0ZomHJYSc3ySJl1Zm2zjMpa5ojF5hr+vBAyg/b XgwjwjglRHRhE9fYrbRbLeCBZrYQrE6aCP+HCD6IlIU6xyaMceXUUpyRRj6zp/XDlzhh pqmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440522; x=1781045322; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ouT17iaKBzrIR7K8VitMxlklOudvhENGiC0/9mkENrM=; b=clx/RoEtpr74u/25TRVLjPrNRdfYa3VFCGS+ZiAs4S/epNsKz2go3L/VFsooBGlNqe IXSUhGr8utakTGGgdmNyyFQMXbwAEH5jWKOXWFRTl5aaEf0RhGP/eN5EeLhc8sd+KJpS tB7XIQBBRODFXytH8hb+6fh5PG1SAhOX5z9gN2ZH2AOh7ViNl9aoNHoK0ylY1lZeHaPw jM5ynicJ/i9OZ8jNxl0JaxfWClsCKNNI9W3KR+1yfsAMhIRhVfmzxSy790on2f4mSy1W EOI+4MzgNze2+C+2rN6Qm5xk0Y4/3XcjP7OIGeUeNCXAwQnGjencj+TC+ieYJTdOTG01 yJtg== X-Forwarded-Encrypted: i=1; AFNElJ+xEsYnb7jIStlh5i1JkF3kDU+Me9H8aHp3gBgodUSMrYNj4qV/T/1+1ZRVT+lzTgS5zQdBExMk3hgmCS8=@vger.kernel.org X-Gm-Message-State: AOJu0YxUGD/UNrBVS1nsBY88hPAQfGVbXDe02dT014H+3Ev4+jYU4wgJ rdkbm0sT7U4H+1NvVIyp9kmKOdDZZTfrHsGvPDJm7Gn9ufaZWOnIaXA5 X-Gm-Gg: Acq92OEtBaZUDKxT+iSlrnS8wWcO8CPBO+3+UPvZRdldeahdXdZaxZFKDoufKbmq5ob +CMFsKrt22J93rltmxg6nvRO/v+6rs0NG/g10J3CBymaCNA1jd8Fp3OPwr/VXusgu3J2Umkt6Jn QWTdVYJRClq2WfMKJdjNqx4r8ECe5VcjWHF30OqO01LIsZNw9XSjPASauJVYKCmFhrFNLwM2UzU 7IzcJVSZSabX91oaUyXx4U7NdoCXiQk4pZh3Dm7prqJhMPuSrXBBGVvVspjlVJUiYHVWZatucQJ WiK7QaRhZOkHQICvWOGP967WjJOU8SN2hAwf6NqsIANtLHV/iuKDp6oCYk0h3ueJJM+/uXLQEBV k1/NIK8Lo9YIGZZ6+g0ueR8Nl/Jn2dQHQTzEuT6a28zEKQu+7xOWJgrANZs6YpCKiNRBWrwYUXn zJqXaZglP+78JohA6Avwvp/efw2SHo4F5NClxDaRHnmw== X-Received: by 2002:a05:6000:2401:b0:43b:5097:6f62 with SMTP id ffacd0b85a97d-46021760f85mr726977f8f.36.1780440522072; Tue, 02 Jun 2026 15:48:42 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:41 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:08 +0000 Subject: [PATCH v4 11/25] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code 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 Message-Id: <20260602-dd-maint-2-v4-11-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=9437; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=3/WKOcRSB+nt/VjxfVuHRY5i0B3sWWTVXpV+X5m2Kcw=; b=0Oro+fvs96gHBULnbgqI8LvicLUd9KRubfWOKkcC+3im25aR56j8yFM54WrNioaUJX2NhahT3 g92pijhfZ9+BxZYVa1GA+7gp/D5ui60gQw3JyQREtZAWwxIMkqut0il X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3: fix name of enum in kdoc also change name of struct (to future name) v2: move RvB after SoB respect const instr in param_set_dyndbg_module_classes, return -EINVAL on c= lasstype err. --- include/linux/dynamic_debug.h | 27 ++++-------- lib/dynamic_debug.c | 99 +++------------------------------------= ---- lib/test_dynamic_debug.c | 26 ------------ 3 files changed, 14 insertions(+), 138 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a10adac8e8f0..78c22c6d2312 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 @@ -90,7 +79,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 /* encapsulate linker provided built-in (or module) dyndbg data */ @@ -119,8 +108,8 @@ struct ddebug_class_param { =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 + * @_var: a struct _ddebug_class_map, passed to module_param_cb + * @_maptype: enum ddebug_class_map_type, chooses bits/verbose * @_base: offset of 1st class-name. splits .class_id space * @classes: class-names used to control class'd prdbgs */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a9caf84ddb22..0377d9f8dcd1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -646,76 +646,6 @@ static int ddebug_apply_class_bitmap(const struct ddeb= ug_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); - *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); - *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; -} - /** * param_set_dyndbg_classes - class FOO >control * @instr: string echo>d to sysfs, input depends on map_type @@ -734,28 +664,14 @@ int param_set_dyndbg_classes(const char *instr, const= struct kernel_param *kp) unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; =20 - 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); + rc =3D kstrtoul(instr, 0, &inrep); + if (rc) { + int len =3D strcspn(instr, "\n"); + pr_err("expecting numeric input, not: %.*s > %s\n", + len, 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 */ @@ -783,6 +699,7 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) break; default: pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + return -EINVAL; } vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); return 0; @@ -804,12 +721,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, "%d\n", *dcp->lvl); default: diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 77c2a669b6af..74d183ebf3e0 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 11, 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 3D2CF3CBE84 for ; Tue, 2 Jun 2026 22:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440528; cv=none; b=uJqaH4F7xhZCPjX9q8Wv+PaGE6KiE6rWB+juhJAup5+ZDZZ+GJglJaQCy8abb/kXb+Vyy8pHhQXfLqQ6uIEd89PSmPduDjrMblh9QAlp68du9B1dUQHxGrn1ZsXbWgJMs+gNOnraBodtxnt5m8ed834hMN6+JOuZUBlp7Q9dmxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440528; c=relaxed/simple; bh=UEhkyuT+BoyqFKDfW8oKnsP6vZUUYVyVd65DI+YPTOw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nKgBOUP4mHqeiRvFnT4tcPJpB5Ltvv1BLvSZDGNkvXH0AKkV/bqTREkm5OyLI3LRqrPEaQODHbsykQdfU2AgVYfQDynAc3FshX68bt2uFTPqD51Oot7AY01Hxz/TEk+yMQO3rk+spXrUpHOhyMhRsHcrT7QSWm7S3rsFKiHFnxc= 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=dQbipdQU; arc=none smtp.client-ip=209.85.128.49 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="dQbipdQU" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso11739455e9.1 for ; Tue, 02 Jun 2026 15:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440525; x=1781045325; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TGR65ICT1aK9aLz3a5pYWL7xsIsBQYnd5g2GK/yOwYw=; b=dQbipdQUF7C0ZAS7AX1csTfSROtCgiDIMKgzdaQxWAVa5+enX93B4lu2XRh0l9flEE 0Hxq2TQBtk9CRW/z7ePTyk7YZLqCxeuBjHwL24/OF5paH4Ui0dwRx79B3yUAtjuCFdw6 JLxnTXt0KSFUTABL7vCCLeY6aLtyekXvI/3Gco7wfcNeOxEYiwBHjCiwfG35HZr2la0m h1EOe+ZE4hUTUInZcDgN2a6w5cJ2kj5ivClLzr3LygVpTcuuiLG2EjpPBUrAW4N56pST uh5AVYDq/QP+59SNwG8Bv1fwKjNgQZsC+cjagVO7v9ylz0JbTDduA41rFhBuehgMOH9T aA3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440525; x=1781045325; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=TGR65ICT1aK9aLz3a5pYWL7xsIsBQYnd5g2GK/yOwYw=; b=baLRIJ8da9rVVGrO2AkSK0AJkHcO4VqNa56rfnQWDnCm5wuzvcqBlgm8ije8H8dFIb 1wdY6B3nCLEAjS+onBRJJGPRGr6lskv26HbsZqpaXaxOTEHTbZyx23j1wpFt6FHpVEwc 1mzcGR5SQNm1vsHk8a2XwzUt2PGlV/Qfqb4K5QmBK0rnP+B/UjNcKoCuNOV4yn44KMoM Q6E+VtyqQ29Nq4rC9OqWVR0PdkiOkEA8c8TSIzQ2fgliu5gtc+K7g6fxxfxhPS2xroSf pr0pTHWAyqAOgFXGmxrqR+TI9mKjV8K+A6X/uJF7rDSsHKrT26Nl3yN2VKNWYG46to8S iOXA== X-Forwarded-Encrypted: i=1; AFNElJ/LbUniD5r/f0ODg5dV6iLUWfSK+iPRNLp4ms0hwosNpSeqC/zAtoEh6J49ZBvtaXjHFv1nU/0PviD0RtU=@vger.kernel.org X-Gm-Message-State: AOJu0YwwtZRnaYm+Qe7YX5tFUSQlhMrxM9eLr4gDrdJ7DQrYOoRdGji6 l54b/X/EGakIQnzpPoEvZ5MHyeE2MmtmK3AOQL9RdzD17AxGCQwkgTsw X-Gm-Gg: Acq92OEt5Uwbor5uj0Egqc2bPeZUcOa/7utugKT2QrZonN78zECrm8gbRzW8uf/9X+9 U95XhR9Wsl5x046mo1XcFEMI0FvYW1A7D+tAMDmbmnPXws3JGbDoP0105yd9A0wJ+HOPvtJghAn /F0ZqOm3ZRXGHV9DU9zG9Lw59IYoQ+Gq7X3L1JszXbsZOzuJqbZJA6Xm+3Ocpwu7bPlxuBeAdao hVpYgx8ECFokProe4QANJ2Cwc2WExon87RI1ivYdOERp+3h2RBUIZwAl/2is41lsYV+tjCHij3g iTqfVl1HAlpufqoGjsU3YeQXYZgylMl5j7k/nhjGE94WCE/97h/kJik6hCbmsPlHuFaetUIO7DY J0KtoDdQOWejnCBb5Gg0TYlg8AVPudQWoS613iuZtCEqtykJXfz5/eKPfUHCkLx1KVXgWlwTkcD IO0/nVwMTkxxS+8JFmA6sKhYiNx8+bD1htPdi2rtPoFw== X-Received: by 2002:a05:600c:444c:b0:490:b58b:a4a5 with SMTP id 5b1f17b1804b1-490b60e0a19mr10858865e9.31.1780440524578; Tue, 02 Jun 2026 15:48:44 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:44 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:09 +0000 Subject: [PATCH v4 12/25] dyndbg: drop NUM_TYPE_ARGS 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 Message-Id: <20260602-dd-maint-2-v4-12-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=1065; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=UEhkyuT+BoyqFKDfW8oKnsP6vZUUYVyVd65DI+YPTOw=; b=oyNMvL7qSBs9lqVN4LVgnejy7txyYF8Shv9mWgJ+0KrkNEc3NqHoPNa6IT5raJlG3MwcHq7XR qlFV9dpli+hD8ELBygRyFABvmf4T8xIJ2ymzMxgsM8PRk4Z5FJyAeGg X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= ARRAY_SIZE works here, since array decl is complete. no functional change Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: include linux/array_size.h, correct commit subject review after sob --- 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 78c22c6d2312..867e3978675f 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -121,11 +121,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 D3C5C3CDBCF for ; Tue, 2 Jun 2026 22:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440532; cv=none; b=ee69ZjE2Y1q7yeVpQ74/gANvWkWZ7RuX6zA2eR3wT4Gu5ME58E07jVjwj5umyz8U23GDwBiC8Lx5zhvTtBEo9z4gBDT29THobY4qjN0laIm10P2Fzhc+jviINPkQpFQJJqm2L9NHw4D2H5x1A7IF5PfdnmqXK41p0ZjG2b6efec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440532; c=relaxed/simple; bh=weM4kXK4ZroqgxDMQCEUnSrZj0zxepbFA1mJkvW7x2I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sUwpGcVxb50Ra9lU58omLNvb8iNWdeWT6Y+szh8yUpWGLr6QzQEyBwYpIAMQU4CeNeBerGFgsTRmm8RSf/E7QRc/Dudj4kkAouqAnQ5BXE3Kdq+5uAFDlg1Tw6wyiIJmFSUjwNpGB0p7iQEl7vKSPBAZZc4xVdwNuUHg4yg5Oik= 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=IMsE4eFA; arc=none smtp.client-ip=209.85.221.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="IMsE4eFA" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-45efa80e0afso2901729f8f.2 for ; Tue, 02 Jun 2026 15:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440527; x=1781045327; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Yhq+U5OSRDicP85+S9FaWBdLNaFdwOPlYIYghUJlarA=; b=IMsE4eFAOxL6QZOhdCvv3jdIV8PFafbKUfhDS+tPnA9vhxvzpWdfQTsIgHzphStKo5 XAMahzsCzze3v2dUkiVXy5YTwibAi8aOE0L4GJFdRTHDZKpeaHc/snHMYhHz/91xIYjo NC7gEa4+nvSog1qufmOZsiKOno0F5ippviwBMisae1Rx4ZQG51SmAeGiYcAXjCepBS83 IgUlohOBtgzO6IQJ0l1tbXMS6rD2Xia+9BsKuYN1t4xdwW5eVzeU7sIcZya+PEJjjLtj WLIYQ7WpOUWTxVI2mSeZR8xg61lR+hPXm5mP6gkEIkAbmKYTu4Weep19dllaFEQ9NzmX V8Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440527; x=1781045327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Yhq+U5OSRDicP85+S9FaWBdLNaFdwOPlYIYghUJlarA=; b=VlTaoVMsDOB8ZGW7JxvrosTlcO/dwSBS13+ni44+lFgyGu/diWQ6ufXDbrVrhHT7qt WsIX4z0uMtDxC0dTp9829AtYFK27p0gdrEKUCk+faeSauYbQyiH7bfKFa6oymqp8NWJP f9ue1BYIJuO7+lywJmuBg3G52rDZdLmJWsrTB58ymzY1r12fooGYpt8yu8A4s5u2+ujd Wm3rKSVoD6e6uNXxU5VYOTgsjf0+aXFPaa21dCNHhwQuq8U46RZ4PNdy3Dod57zuicys nhJbLHEh534ZYxyetisg5+1M+CgWQTeI9QKYgRXPlZ4Vg8CF0KhDdr3dxoURBfJmdeQs f+lw== X-Forwarded-Encrypted: i=1; AFNElJ9IRcp1YuBcvlZ1TDWW0cZrTwRZpxV3AgnIQ7OZ2cY1JNSUXMRpZxxZJRFk/5IxLhZrntAYDbnBhRzhX3Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwVJlntTJ2KVBqqtMS8O7AzWWjYPyIg3GRRQkwjHuQGeEhIyOfa HKPkTO73apCixO9rMoUqaTP/JnTQT84p3DEKBUwZH7uhNEdh14zu2p4d X-Gm-Gg: Acq92OFk3mgRDWqVML2GcTZA53HEidYoej+3NG4EO87wndRMrlF7PCGxZZDPWvGXk+8 6fjDExToWFYDOhI2/b6afkxQwzfItnN0T1hBsNbXNA7UfXfy/O6l9+HaRsfWCeSaN8dtobkNu3r ANThSatASlB7T3FKGiDO4Y2kH8M+eO8UzOm/KwDk5NrjujNMnu8xg1s1ibVYMd0d51mhMyrvSQi K/a2oT5t4juxHbV1rW1q/fG+JW/jiMglLU3DDNoPGuJARAlVZQTFP5LPf4rDnekAWPU2vuxYjgV ITHfmOMVidZdcG2LDDGqGngOSlO8JP9X3t23HOghc81gH7FmBOBl7QSsaEN0HQinOb8rujBa6qv hzrCdDB6bi9FNN/t4w6TECi+OfqWxP6BowQ37IrleL4xqwIzI+/pbpuXO1n0Pf80UCyEW3TQa2E QpRJ/zd2BcP0zovGUa6+/SwU4OXWhJibNaFfDmLtryU4TfQeWhmo2D X-Received: by 2002:a05:6000:1cc8:b0:45e:ed7f:1d9 with SMTP id ffacd0b85a97d-460216e6c10mr535924f8f.17.1780440527095; Tue, 02 Jun 2026 15:48:47 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:46 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:10 +0000 Subject: [PATCH v4 13/25] dyndbg: reduce verbose/debug clutter 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 Message-Id: <20260602-dd-maint-2-v4-13-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=5056; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=weM4kXK4ZroqgxDMQCEUnSrZj0zxepbFA1mJkvW7x2I=; b=60JsmO3vGkvHB8Wbkptgdh59idXBHU6megWsjkTqaulbU6qXBQ5J81a4YTYlMRoJy6Y/7nNeR EmZCu3IAwOSDqEqibblfA4hs2wXiRSlGkqwoD/KbxNqiLScteYh5W8g X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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" dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' flags=3D0x1 maskp=3D0xffffffff dyndbg: processed 1 queries, with 0 matches, 0 errs Also drop several 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 Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v4: rename vpr_dq_info to v3pr_dq_info to tell its active logging level adjust some vX levels per doc'd intentions v2: RvB after SoB trivial change to verbose-debug output line to output the actual "module" keyword rather than "mod:", and do so only when the module is constrained by the callchain (ie as part of a modprobe). was: query X: "(keyword value)* [+-=3D]flags" mod:* now: query X: "(keyword value)* [+-=3D]flags" or query X: module FOO "keyword value)* [+-=3D]flags" IOW, adjust output to reflect the input grammar more closely. drop-info-parsed vinfo-applied-nomatch dyndbg: tweak verbose-levels per doc --- lib/dynamic_debug.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0377d9f8dcd1..a967e3ef1dbc 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -128,7 +128,7 @@ do { \ #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) #define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) =20 -static void vpr_info_dq(const struct ddebug_query *query, const char *msg) +static void v3pr_info_dq(const struct ddebug_query *query, const char *msg) { /* trim any trailing newlines */ int fmtlen =3D 0; @@ -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 @@ -487,7 +484,6 @@ static int ddebug_parse_query(char *words[], int nwords, */ query->module =3D modname; =20 - vpr_info_dq(query, "parsed"); return 0; } =20 @@ -511,7 +507,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 +520,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 +535,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; } @@ -570,7 +564,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) } /* actually go and implement the change */ nfound =3D ddebug_change(&query, &modifiers); - vpr_info_dq(&query, nfound ? "applied" : "no-match"); + v3pr_info_dq(&query, nfound ? "applied" : "no-match"); =20 return nfound; } @@ -593,7 +587,10 @@ static int ddebug_exec_queries(char *query, const char= *modname) if (!query || !*query || *query =3D=3D '#') continue; =20 - vpr_info("query %d: \"%s\" mod:%s\n", i, query, modname ?: "*"); + if (modname) + v2pr_info("query %d: module %s \"%s\"\n", i, modname, query); + else + v2pr_info("query %d: \"%s\"\n", i, query); =20 rc =3D ddebug_exec_query(query, modname); if (rc < 0) { @@ -1159,11 +1156,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.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 67D5D3CAA3E for ; Tue, 2 Jun 2026 22:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440533; cv=none; b=LSivhOMgZwwWZNySTPnfPsDC2rw6k05E3/c5xi1GCcm6dMQ3QgMtbxXd+LGDdpNQIS7sFG5QrxWSdvumcFsq1zmfrS2UrRtSxLPTGk52IlJPXp5LG16oaKMh1YlRLnq9dzSLg1PBrZzztM6jf09IkC0oXLCihWLxvJWhGHqy8v4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440533; c=relaxed/simple; bh=h314q4SgzcLZs5zSIhdTXKF8/miA8xW5BwEyLKquswY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o7OR9DVk4Ca612+5DrgaDk0TXf7akOxhila4rNVKmv8rFjXl+hYsYX5kVrJcezu5AT0g8wjMeuuGRFTkstAhv1hzFckiA7Suu5AULqu96MpCdOthPgmmiccrNdkoz1tyuemxv9/EpbAqPDZ/2kMDySFcxtmwh/mU007oE+YqHqE= 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=faXw0NPs; arc=none smtp.client-ip=209.85.221.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="faXw0NPs" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-45fe59255beso1825861f8f.1 for ; Tue, 02 Jun 2026 15:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440530; x=1781045330; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cHUkaftriuBz1I51Pi91MxDc690icL3AXvv3wepV7zM=; b=faXw0NPsOcgydXQXg60zNSAzYU7fQSFqeGbztIyuECs2vI7PnSwuWEnm6imDnKpQoN y2E1U6A1W21tWWe8rWSWl1xaee0sIuB40Y2gi0Jssis6gGD0vSYfaiFwf82JBICog4bk 4eMQa9j+oBKNys6CM9YyaQU5LRM8BopajrI0YW4jdY/BKxERlh9E+srvI2IplnE+dSED qLcVAYiju1k9KNs1pdqI2lGHgLsHOim3T2s+oeSGsLnzX6rMv8REcYLKs3wgfWfrcc1b 5fXZL7j3mcLSb9p+QBJTxGip2iLq0KLmjLlPym9zt6BzEWEZH0EyA908b4np+xFUIBR7 2+rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440530; x=1781045330; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=cHUkaftriuBz1I51Pi91MxDc690icL3AXvv3wepV7zM=; b=Jr0arBbqs/D6nIjmsLaKfjXPys/4oG11VWQy+66wARawLXLqo7NiqhVSFvaB1QyKg2 R0+l7MeAaqiF96qQ+5ALQKsS7rdMr2GpriYIE4s0kGuU94kaRiljI3sk58N18siL8tMh W+r+ScYOOnlDPeHo/g36VKKFeU8Eoz5yM8Ez2zIOonwgm4PA7LCwycRXEexcnarAekuG 2hcLaHo4ANOeyB+T9TWnMhvjsFc1Cvk1vJTm9DlylrtB4DRBwBs7Z2sNbQTGwPW9EyOX CU0zRWL9OLvSfwmDNGJm4v5jZ6Bdxj/oP7nGLbCLGXHwKofSEbY97Li/Qjr8W4HXAk5Q eC9g== X-Forwarded-Encrypted: i=1; AFNElJ+0aWC/SCq73eqeZQPz6P+e4X8ga8/IHZ6nuR0EztN0TWnHO6eBj4MEMkFk1qRfQ2Vffova639/y7PstFI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzjo4FY8qWLYP6HzkTi0WU0pQgey0uNiymSAr5okT6RkgZcb/QO DCVxQl6osIeHcz92Fmzrh7U5GKam6qwaPfIB0fqwQC4exc4lTHO0lHaM X-Gm-Gg: Acq92OHCHzv32BrvvQonvmLCIOrFQQjq36oBG2dVUuXpZtv3r0fJBAScmrZtShvBpJL p11ElEBJgm72GXq+w/Aqe+SFCEsfwox5WfrVktEei5nV3TImO/hh0hYjH3rgt49CjZDL1JaHBOp w9koZbBCkwui1n5S/cKDXvzeamqajCh6FLi34KQ8w/W46X2sScdPaGfiVq4HT9B7EDCJA+W07SM 7v59kZkx+yANo7Bee6qkEzYWvN+3PRkEo3uXJ6E4sUQfTw/9Rfz0/va91r3JShxjW8O50jBGs4Y V/1egFWUgHjwz0ZGmkH6EOiz0l7yjvJ6E/HT+OeMiPhTgh1HdcIf0wroABDMZwcilNqNIUAXN0U skgeQmMfezvehtt32a3umY1L3qwZTKWJgXO5pTy8wJUht6+9CaOywNDNbZLwRNh4JYVw1qWQzv/ dqcEuR75auI0hR3dcj2Es7HQC/pABERKyEAW8XjP5p5A== X-Received: by 2002:a05:6000:2c12:b0:45e:e3ea:1101 with SMTP id ffacd0b85a97d-460217e3eabmr717005f8f.17.1780440529770; Tue, 02 Jun 2026 15:48:49 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:49 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:11 +0000 Subject: [PATCH v4 14/25] dyndbg: refactor param_set_dyndbg_classes and below 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 Message-Id: <20260602-dd-maint-2-v4-14-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=6146; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=h314q4SgzcLZs5zSIhdTXKF8/miA8xW5BwEyLKquswY=; b=+vaQbkvBmItkENuH0Sby16WrI923FPRJx+YTL6H2fFFwgm2l3DAqqE03QJWrfGp4jOg4K/Nev iMnKtry41eJBvqKyCRWLHeD1tXZ4FqKTCS72cYFQplzfW0jo4/eFygW X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB --- lib/dynamic_debug.c | 51 +++++++++++++++++++++++++++++++++++++++----------= -- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a967e3ef1dbc..f59fe7b25ea9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -610,9 +610,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]; @@ -620,7 +621,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)) @@ -629,12 +632,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 @@ -647,6 +654,7 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, * 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 + * @mod_name: module name or null for all modules with the classes * * Enable/disable prdbgs by their class, as given in the arguments to * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative @@ -654,7 +662,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, * * 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; @@ -677,8 +687,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: @@ -691,7 +701,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: @@ -701,16 +711,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.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 DFAA73D16EC for ; Tue, 2 Jun 2026 22:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440537; cv=none; b=Pydk0ySE1/Mh22PY+oDSOlAZZsXiz4YwM4v0kIUoEqAM2Ua8j2bPbE2ZWo/SFAIDZREbGuqVsMxuq7LxNY2wlb469pVsM5HUTZBmIC8qiR9dyaKALllZ46vrxW8tiLoW37g3n2pRdgQrK2Fh+EcSpeBFk7KAPLBDM+u2STGIJt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440537; c=relaxed/simple; bh=yYzaloSWpMCcf2mBssnDdUdry2Mk3lsvbkKFQrUnGj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q/LF8bb9XF8bEI3RW4vgygXUxOHpCYFvT43hHD/6pxGmNQXVZ3H1KojaV0blFE1rMezFmghaKCMoOR+tLBJjISqBEmYjVZplgBwpCl4iW1KALUei289VYdd7UlSF/3ifp9tSddC+lMdDsrou0hY6fyBjMErBK7nOghkqRVoAwcc= 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=PeNw9xGU; arc=none smtp.client-ip=209.85.128.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="PeNw9xGU" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4903d730b1fso108423225e9.2 for ; Tue, 02 Jun 2026 15:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440533; x=1781045333; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kG9RuYZKN9VVlKwBSxHqXl1ePoc3WUv6h82ZqRPI728=; b=PeNw9xGUL2XyNCjvqegIbAhZqrlthhSS6z4FVxzhvOYvaj5VpZJDySA65FEcDnEZSS dWLQ2bg2mF9FaBi74z5st0uYEUQMp5c/kR7rxCZrrPbb0Ugz/0vRhJpQ/7fu8pDWZM5k GZndyK6k4eDcQlA2uhEXxnnzvLDvVBBQdhHNgQtiwLGWaSPxysxyhLDD70CFPHlGBBr3 tBqJFlBBGzVFUWaGn22fIu3Hpt1tNlxrBmAVDfpRLdvH8csfa37in1R45K6aUwHfBX1N jB7AcKDCXX6RsW1VIgUR/vXAnVzEyZHDhqrxos0aXY8sI7muWX/3i04otTgdac1HvHjh tU8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440533; x=1781045333; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=kG9RuYZKN9VVlKwBSxHqXl1ePoc3WUv6h82ZqRPI728=; b=DTdKppqE74LRYmajcpMNl8IgQVFLYxRZnzPNjdzefmosqqpAwIXtGdqUUvqJSbhpuf PkSp12ZMH+PoQES2/ukBs/DyJkIJEZSs3muH7gLf1FFqsf5j+R6iymky7zWGHEaSdQpC KddIGd45MYEnFyni094UmC69eRSeYWz4LLle2TVUeQ0pp/5+Z2vkodFGrS3e61X4xTwm gyf/XElxnnaKGQa9IckZSIxIDPROi7fZz5uGUj/rtch7El2BWpPyf3mib6Ks1yopCF42 itMQjGh23XNqJ5vPLWDZaEt+C0WcE+T5I13pkG1T5clLdK5gUOnmNluKNv7uCIFpDC8G waAA== X-Forwarded-Encrypted: i=1; AFNElJ/TbqxEA0BliIWtaxcojQabbrgmS7ictJd06EpD1J/DnDnp+rFNb8Z+ydfO4y5yK+to3td8fYr8tzHoLrg=@vger.kernel.org X-Gm-Message-State: AOJu0YwuXO3N4iC1J1ejQSrXjYUAavdeVdjWTGAf4ITKVmWC/TEbgltg NOEPKY76JawzXJgSoEQYTdd9kVhfaLDTE6pcsjJieiy3D4qE2u76K8+o X-Gm-Gg: Acq92OEEmqSo/ibpRuCtLa9W8BZ/xF+IxTXCQGG4nRJPCtBvrBI2A9WDgUasUmvQUZ8 KdjuYH0LKYZz+TZfop0ilVpnpm/KCYdl7pHgDbvekpoMwPp4l5R/aP4HUV/ZRjjEcvBIu8ufDoO eNX4yA/Hv9/emwAzMPlQHuw8BoVM6BDYsTR+2jfztIyMejhZX5KmKDyeLCIHaXNfGXhR6gJJKvx MPLtmVVmJ8CfBu1vIyW5BFcQWDMvM7ub1USQeN2CuTHuVUoJ2Al2ewlcJ6ZATMMrTH6asWKJ6I4 RX1AY8do1FkEU0xdkhCbJGajMOdDUFJtKMIzUTMIqrsO8saKE6DioaoIR6d3SvhsuezLxgIUWTc HT1+sp8hr7xvPabmenAk97IUNU2Q5KrHYcyl4fTZ+lsycVKY8aFmrniIip0sVPCwFO0CXvbsHtK +L5FtWLydwphDsx7dB88wuRzy+XjrWziMvCUxNHl+dXQ== X-Received: by 2002:a05:600c:1c1e:b0:490:b00c:8e6a with SMTP id 5b1f17b1804b1-490b5fe65a6mr12193215e9.28.1780440533361; Tue, 02 Jun 2026 15:48:53 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:51 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:12 +0000 Subject: [PATCH v4 15/25] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap 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 Message-Id: <20260602-dd-maint-2-v4-15-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=2913; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=yYzaloSWpMCcf2mBssnDdUdry2Mk3lsvbkKFQrUnGj8=; b=jjLEoXkJF9i9OhldBjaZjELUHRX0zlhmfVnIaKMKki+R8Pk2d8dPgzTVoDEdjIo3+QfsdvfLR ByeKIgUGjr4CkUVmBBRNr6e+BZVeYA+GMu2Kfz6YrJtQGL+T8veBJhe X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB --- lib/dynamic_debug.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f59fe7b25ea9..9bd521651c48 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -612,7 +612,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 @@ -621,12 +622,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], @@ -638,9 +639,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; } @@ -688,7 +689,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: @@ -701,7 +702,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 917593D25CE for ; Tue, 2 Jun 2026 22:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440539; cv=none; b=mFGh301EYPzHlCYnMo3crA8GQ4FljsJzUDCJkDxib5ERDHIfS8/IJYayskKR3vJSNbQmbwuOilSifpyMC372ubMC7B4Myag/wWT6qr/Gzx5LnnQ2vtWWu4kthmmjFbtLPxz3yv4ny3lA6vS4JwTQQDl21098h1d6Dp6RDK1Zls8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440539; c=relaxed/simple; bh=vk7X0gvsN/pluaAvdCwu1r3tDscy4XY8tNtE6cf5F9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NmfLxlbg1MjqiAXObpPpQH9H0mIiA65OkX/vuZpARkb4M8PgMwHefX8pov68P9SV92O9/aS8H1FL8pEbt2OW0S4DRUa8OUBVe92SpzNcT0Xzna/RLGRfSj11ypZyc2e4WVwz2kqcZHy7keCb348wu2tQHCSXUitfDLzBiH/SQmc= 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=WSLu4DFt; arc=none smtp.client-ip=209.85.221.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="WSLu4DFt" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-46019b190b6so1193493f8f.3 for ; Tue, 02 Jun 2026 15:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440536; x=1781045336; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6ZtU4wUM8LRFqe/NmO1eUuVYvzU4T+qbhigAfCAPlSs=; b=WSLu4DFtNmlcZs7beTHCjwYRN/H1PXqhGs6Rwh/oE8I72h2t4EeazqC2jHmrOqX4YX mMljSE/dt9IKafEiYfD5jtgbp9BajGnQyegAaCnQ3QrFsQ0yK7Mpppg5ARWwXckCr8gR Tpeo6KZw5/HFfh3f4UsSJluutnYr9EEnRtWf1c94Z+Z8HNQmn/At4aeKrFlNUeqdnVI+ DtYCy51j65NsoFL33DbjZVouuDRrsGVW701KVCCB8S0CQp9k/29vqXxmTLlAnTjJD60w 6I97H8nTKMHSrwVqmbO+fQEI/0ZBhbZCBsXenD+04uIneoOPESOnghrgmy+0hv/zNh6N Y5YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440536; x=1781045336; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=6ZtU4wUM8LRFqe/NmO1eUuVYvzU4T+qbhigAfCAPlSs=; b=OvhGwHRMgYpGaY415vb2Gvv+Sxffr+H465mZLfy3VP7W96/tHc/hK+3y7Z3nh1f7Si eaGtWnrQsly9MDT+Dg+bcuvknpuElxdLv9cSzXOMmtNlnev82uysH3A+nKMcMey/BL2p icibJnMfkHJphAZD7OEJXmVf1HZcgX6w3IiBgUNOvSTIUu2WyqQylDBTPdUgrRPcQL3B BX4EvghXM/VyvzJr+8L6EzhXtDmOxx36MWwNQYqGTf/qPnqWmoyWqXKJvdH/TWYmLaMb c/bqSg7EUGVJT3UOpm+CbliMZ32OGn0zPA3cPQB8Pkvh7S7UpTrtOlSrZ89Xbq+cZbv+ X+jA== X-Forwarded-Encrypted: i=1; AFNElJ9+o7IHI+WelpJGpiafceWFaoT+a20/rQvmU0WKBxGmU9oiCTvqR74k9R4ubU6/ufWlgFCCIEoGTb4FzWU=@vger.kernel.org X-Gm-Message-State: AOJu0YzuqA4rZ/1hkL2EUertXWb2dLQRkKXI315nQtcrm9e1vsqZL2iO lqNUVSu8sQOYnK/shXnD7k5DmcuhyT5h7woqOslrvBJPz+GCS/zTVTri X-Gm-Gg: Acq92OE+z5HmYlO9j8MejU81il1DBktSAV4HNZZxC1+JD2DIag94+RJyWTYOgF2Hlme SqzcsHJJupnm+Xq3Mn6Pd6B08inXhSWSeg0LRG9Ln3b5mqhBvCD372+0gENlWyHt8bR+hUXyJZ2 JZn1YZ97fH/cZNZxliotqVDIvi1jpZ3IFTcy5sdARE4o2bfRJTw/RvNRn1UbVAXZ1fgNILCIBO9 67c2T7XiO4ZPxggX6Io69RzQhBpMONrs3/wdJwAi++BFtqlxM8QynkO/0dpZxKn5KhAkNhzKXRV uV2ji8pexxP+czIM4P9Na0pz+HxqH8tM3L4EtUer58Ghh03v50eV7Xt78+R4uRYRlkyctn8LpNW FIfGzmGpHsCb29DEcjF6rvOokVqGaAKI9ZZxdT1huRFuq3Nb6NY/YTm8uAfGawWtpWNVs+0OtRl FzdHYKq829k2DGivmunYgBvF5Mv8eZkHe3oBelK+K89Q== X-Received: by 2002:a5d:64c9:0:b0:45e:ea2a:dd79 with SMTP id ffacd0b85a97d-460218aaec9mr634198f8f.4.1780440535963; Tue, 02 Jun 2026 15:48:55 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:55 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:13 +0000 Subject: [PATCH v4 16/25] dyndbg: replace classmap list with an array-slice 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 Message-Id: <20260602-dd-maint-2-v4-16-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=6628; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=vk7X0gvsN/pluaAvdCwu1r3tDscy4XY8tNtE6cf5F9I=; b=bCI/agdbnZfA3Wzw5qVqSADM6r8GwdbtcnFMRi0CNQPZ/gF8oSeOh7PBSsTT4gYkukj4ZciSn PzY23Imk9K6BUlTS/Vbn0KVKWXv5pDePzLiGIjF68olaw0ESDwOuime X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 of the classmap structs. The "select-by-modname" condition is reused to find the start,end of the subrange of classmaps belonging to the module. NOTES: There are multiple modules named "main" but thats an artifact of how KBUILD_MODNAME gets its value, and none of those repeats are contiguous. The legacy code segmenting the builtin descriptors depends upon this, we are "reusing" that dependency. The "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie closer to dynamic_debug_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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: RvB after SoB --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 65 +++++++++++++++++++++++----------------= ---- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 867e3978675f..0443781ed95b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -73,7 +73,6 @@ enum ddebug_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 9bd521651c48..b8a494835ef5 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 v3pr_info_dq(const struct ddebug_query *q= uery, 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); @@ -1064,9 +1065,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 @@ -1150,30 +1152,34 @@ 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++; + } else if (nc) { + /* end of matching classmaps */ + break; } } - 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 /* @@ -1205,10 +1211,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); @@ -1321,8 +1326,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 E99163D333F for ; Tue, 2 Jun 2026 22:49:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440542; cv=none; b=QOlBhM5JGjLwwc2wlI3rA/estSZ3GiudjIElu5jV+hvsocrdDAj/ckIyQG0xaUn7rqJrXYOcQl5JRcVjOCmJcIfVqoAvNqOK5HIjW5xZxY1yyEBxA9kJ91eITo9bEICtXjMMUzza6UHYctXMWV6KRQWwXDu9ZN+U6+OkcFMRjP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440542; c=relaxed/simple; bh=4lg9KesBI/N2Rj/6xaevlfNeh5wYawcWkW4JaA+kRgg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=unR1tVfbPgF0L0OJYXsGK0ovEVJqqfufmI8lvTaStAGyJFXZOQBl3ouXuLiIz+vq+xiG4WvPlHyZNv85WdkccQrphsZBh9AwfN8ToTaeqGzfm2hQGZSXfOATT7ZDXvN4fMd1ezoP7UwcB9iiDuB3objM9+HzyUxyBwrPxcbZ7gQ= 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=PvuI13Yi; arc=none smtp.client-ip=209.85.128.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="PvuI13Yi" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-490aebf33e9so13647985e9.3 for ; Tue, 02 Jun 2026 15:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440539; x=1781045339; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=a5wuRkJDj9pHl8KpoGRxyvf+Yl8bVjDmoJ2Kfc5m7ZI=; b=PvuI13Yi+CpUe+TYj+CdvAynnYvoQyFeAdrmZ3M+Hkw+aEYuXq0QvJYLK+GHOKrKiA HKvIX17kpYzwovZ5qFIcYLFN7gqs0r/jgpq6RYuNSvxs3I9a3ue6/C/H+/CbJAXBDFDD 3C0wwrbXOG1kB0xQPUsceM9xB0MFig4MXYr4o/K/oD1sbtO5EcrD3OAvjNF6PEW5K9oI nvepBQSLyuPJSUZpEe7P5U+iJwwO5q/crAPlJrzhAUa5VUIIusNoGnvuPtzoA1tm367M mgCEUAwrhLXaE2D+tLnJj+C/XUOPlIDKQj9OIzkT8cfGDb1zxqzs2rfRXMzoJMgG8KVe G2bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440539; x=1781045339; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=a5wuRkJDj9pHl8KpoGRxyvf+Yl8bVjDmoJ2Kfc5m7ZI=; b=olaR83oXGmYxStDKraa7GxeV7QXDUcqNXWVUr5kCHWghKeEmL/IM+eBo2sLDOXsrzo l2dYFzZrJEAsAgR7XC0ay7ZXNRqTJK9QnwiBqOgvCNN1EXBoBLIIRwFceOqOVjCIt4q5 6AtpP29SbOZI/a8c3ZqLnOCVplAflOODq839Hp9NrQJjKlmzCDgQgKK1LUex7RLhpdhH C1fGP037t6auglRyU/ScaU4BR0E3248D7Spdx6sugrqnnBCeSquaEnIlGT4HKhYwhLns wzsE1xoC6H8+F5V11uNUhS1S4fOYdu5kz+0C0Ecp9UiaIa7uGzhvcTKxDFquNYliGbr2 Bl0A== X-Forwarded-Encrypted: i=1; AFNElJ8+YEgquvbO6UQP5QijvU7R6XI9YcDx6fC6lFJs2Y5wI178r/dI948iAbf2DIZ6vBKj71U0AtlQzVSRf6s=@vger.kernel.org X-Gm-Message-State: AOJu0YzdP6I4qtdWc9DoNosXG1tuF12DOQbBwxFBaeiup3r6qgebNYrO HmFDxb/BqflpYK7M4JOG/mq1Tyf3bllZeE75fsX3zKSNnyHjCJp207K+ X-Gm-Gg: Acq92OGDLjq7nLvYWhAt+Vvn/1n0qwNGCE2dM/b8TkWtAuwHD7HpTjowGdekss3ZEeX 2Hpl8D9j5FVeh8NWLQwWR+jrLQ0kKP73WsgrrRozb4xlmPf/510UDmA+RMRv9DmBGKJnPiAbVu/ uViU1Zwpj1CekfamUp85j9d56klSYFfEEAgN3F5EjR98i58xuzbWE5Ham4DhfjBS7C5/oyb3tYK guf7RIHjjPqXp+6VE3po6O/zHr97k0Ek+u6QzgA3hMlwCyoMU35fBmGBykqFomSc1GR0URoNMTs 800PbCnYB6YkqD8/ocVh5wNg4kV6QVD8+4S2Ozjoh43RftB2NO6dpJykxm+iIXK9HVDSG4S3y5y gbpA/YDXaUqSsBdH3mVDC/kCuZ2jGXpp0HJZryUbA2I8NFgHcBoENpHUUxSt0EsBKROAwNL3Qkn /oS9It5wd9BfxIKdoQ/WF5gxYqXndhHRR4uFwQkB+5MQ== X-Received: by 2002:a05:600c:1d09:b0:490:3f7a:108b with SMTP id 5b1f17b1804b1-490b5e51a49mr12032925e9.16.1780440539379; Tue, 02 Jun 2026 15:48:59 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:58 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:14 +0000 Subject: [PATCH v4 17/25] dyndbg: macrofy a 2-index for-loop pattern 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 Message-Id: <20260602-dd-maint-2-v4-17-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=2812; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=4lg9KesBI/N2Rj/6xaevlfNeh5wYawcWkW4JaA+kRgg=; b=3P7+mdCXoJxjAUzdstBNcQwkEcs02tscKMoOPE9iAw0vT6di3+pyxw9lbgtyKlr9wFEn3rgo6 J9clxTxMwNZDcYTI18IdMjs4v5w40CS0kYdfPFI8qc5yiKQpwOZjsfF X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB --- lib/dynamic_debug.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b8a494835ef5..a593e040d1ae 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -149,6 +149,20 @@ static void v3pr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =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 for_subvec(_i, _sp, _box, _vec) \ + for ((_i) =3D 0, (_sp) =3D (_box)->_vec; \ + (_i) < (_box)->num_##_vec; \ + (_i)++, (_sp)++) /* { block } */ + static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, const char *class_string, int *class_id) @@ -156,7 +170,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; @@ -1162,8 +1176,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 35DC63D3CEE for ; Tue, 2 Jun 2026 22:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440546; cv=none; b=jDqQOqGnVEhXzXHwVQbPx3pqWEFIxRMnDuUDnM76JdJq+//QofTDxwu31NqDvt+OnOiPmZ9pExr1rd+s8Q97L9x27bOgW5xF4xuImL9+QieCZwulAYbWfckooGAJuAl7Oo60xoLvqYPbWZZIYTcrOdJfM/RbFIK916qD7bBjvFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440546; c=relaxed/simple; bh=7QkcTyZCWN6yMIODzwkt5kyZDMXqN9r1gKsRuM6vY0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=btAx1sdUm1IsWCseiDzRAc4p9N3p63zNL1fjH7ynQej9iJB9IhPdTql5V2qSPbVatv7IGNUNj848K6WfGBgNwJ4M0tlfkgEtXNA7P72c+RbDNXzc61SfDkoPovS6zt/c7uFPS3t9r69CLqiLE8fsTt+/D+X5LtkCQfmahHcxEDk= 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=sxa1dIPx; arc=none smtp.client-ip=209.85.221.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="sxa1dIPx" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-45fd45e596cso1824605f8f.1 for ; Tue, 02 Jun 2026 15:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440543; x=1781045343; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=n6yMzakS1WVzaIBy+f9smd1nqOBpafHkibEk4ZXvtyg=; b=sxa1dIPxe3qqOPfK243s6qYB5pdp+z+Zzp+UyeTuzeveZwimQUaEJTPltvfwS3PqxE Xws6SFjkt2yIu67Z8/6Am7jB3HQu9+U09CsOShbZVi/VUfy+mSUUJeLv5OW/2g8Q4icJ oDkLoUQ8SyBpzlNJkwgyA7VHuIY7KNVHYiEBIUu1iqgjMSmp3JmM4/MoaCU3NrrxLgAe /CrsztXSeQUk9DfA8I2x8rnxQfP1VdxpK4r/113kzrxrVh+osHLyNfi+XWFIw36H5t8x pC4OQX0OCxol+0OFabCiLnXteCDI5bWOJa1SuP/Nm8Pnv3vK4YeNxyLHSKHQ/FRCSY7U 3MVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440543; x=1781045343; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=n6yMzakS1WVzaIBy+f9smd1nqOBpafHkibEk4ZXvtyg=; b=jmBwQdmqyuJI4qUqrh0AxUVzLxMO3ympdn8KMlMyK6t7In6VFBJtHcdAzH2xVe+cz2 smpLevE5v3TZIktagDk793FYy/LhlykURZ48xvvsqvvzToeNXlbZbTYR1gLfGab/r9mR QXhXSQ2sU1FVUNCtwehQGIBwJU0MXhFSj44TqWSBNRxMrvhq/7FESHHvnuLLF9n4V7qw NOPpR0R629t31U4SpIH1U07y/6ReV6WCPlNXHHjarRtkhHW6dz07N2sGNhSCE/GSbdod quBF/r4XRWQjotAQaeGEzygRWW47w0jCTlS9+3xbrpY7P4lYn49oPOzqWNEQd8EyXYdC BNbw== X-Forwarded-Encrypted: i=1; AFNElJ9jdeZk+3hZMPQK0DwNyCMdN/v/nltlFinRNIgB7TKpXV6GLg86z05h01wvKFCKarkimjQRUw5CnGgOBtw=@vger.kernel.org X-Gm-Message-State: AOJu0YxosKYUnU/4NnCDu+3HJyAenSTuqw5zPARh/0Zm+LIeDJgU2EiR R5We9JQtkQV2F773Pr0Pw5CzkSX74RS7SQuAUK1J2eyWBWoJtvaHaYKUa2bzbw== X-Gm-Gg: Acq92OHUaRtBmkpFYyj+VmXellKqb5W/AWAV00K0cU+X6hV3R+i+YuRK0OC24yyDRVD v9OharlSiglEwyj/MYbT048Ym8I+hvQtcQeTudG2MEAi0eAgr3R8jR0buxne9+cRMlyDePsq3Tf atZzjmw58EY3QW1a6Ys5MYCo6XVa+k7cBAuSpPXXSQ0BVwm5YDft0nLmJ+Z6maZsTmW4RlF/Ce7 xOgkW+3/h7uZN/Ooz7hRZfEjmwc+4I0SJ6G891Rc31/AtYJWRodaNMnO2bPR9YF2dt9rCwnlePF ksY2wjq2ubPy/6/z6XeqzpbvadhvVQ6T1KWrVK3eW2NBZs0HDE33/v0oa1EN2fpScxQAvQnAkLM vTHYPbytasK/L6RhKipPIdqOJ/9aQ+jQ1L0PsvN5x8uQiwf2elpmUaoczLh9BthQk0j76Oy6A7A Ji6dS+RDY3/XYVlCF9nxRe2OaxjK3PN0ze3uv3nKjKHQ== X-Received: by 2002:a05:6000:299c:20b0:45e:f52b:f4b7 with SMTP id ffacd0b85a97d-460217f1fddmr454368f8f.17.1780440542599; Tue, 02 Jun 2026 15:49:02 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:02 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:15 +0000 Subject: [PATCH v4 18/25] dyndbg: Upgrade class param storage to u64 for 64-bit classmaps 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 Message-Id: <20260602-dd-maint-2-v4-18-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=8637; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=7QkcTyZCWN6yMIODzwkt5kyZDMXqN9r1gKsRuM6vY0A=; b=0tpHpFzLjk8I4uwZ21aYU4mH5QtyS0EHyjlodH96NB2V6T/cqfRSNVZpN0KHfArMXx6At1891 X3DtNc8ymnsDLLJPKFCU+WzVHsGCA8A5P82H74gtj+knahAPOgRnlYf X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= Currently, `struct ddebug_class_param` uses `unsigned long` pointers to store the state of `bits` and `lvl`. On 32-bit architectures, this limits the bit-vector to 32 bits, which truncates 64-bit classmaps (such as the one needed by `__drm_debug`). To guarantee support for 64-bit debug categories across all architectures, upgrade the internal storage types in `struct _ddebug_class_param` to `u64`. This inherently makes both union members the same size while safely avoiding truncation. This includes: - Changing union members `bits` and `lvl` to `u64 *`. - Using `kstrtou64()` for sysfs input parsing. - Replacing array-based `test_bit()` operations with safe `u64` scalar bitwise logic (`!!(val & (1ULL << bi))`). - adjusting lib/test_dynamic_debug.c too - Updating `drm_print`'s `__drm_debug` refs to `u64` further changes to drm later, when BROKEN is fixed. Signed-off-by: Jim Cromie --- v4: undo change struct ddebug_class_param to _ddebug_class_param this is better done in next patch, with other normalization on _ddebug v3: fix undefd behavior when classmaps is all 64 bits. change module_param_named( type-arg from ulong to ullong) change struct ddebug_class_param to _ddebug_class_param in drivers/gpu/drm/drm_print.{c,h} api change later v2: patch was "make bits & lvl same size" but that size was unsigned long, only 32 bits on i386 etc use u64 for all bits, and %llu %llx u64-fix u64-drm-dbg _ddebug-cl-parm-drm --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 2 +- include/linux/dynamic_debug.h | 4 ++-- lib/dynamic_debug.c | 34 ++++++++++++++++++---------------- lib/test_dynamic_debug.c | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ded9461df5f2..3a470e808e39 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -40,7 +40,7 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned long __drm_debug; +u64 __drm_debug; EXPORT_SYMBOL(__drm_debug); =20 MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a deb= ug category.\n" @@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each = bit enables a debug cat "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); =20 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -module_param_named(debug, __drm_debug, ulong, 0600); +module_param_named(debug, __drm_debug, ullong, 0600); #else /* classnames must match vals of enum drm_debug_category */ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index ab017b05e175..21a0ced0b2f2 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -39,7 +39,7 @@ struct drm_device; struct seq_file; =20 /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned long __drm_debug; +extern u64 __drm_debug; =20 /** * DOC: print diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 0443781ed95b..91546a99014b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -91,8 +91,8 @@ struct _ddebug_info { =20 struct ddebug_class_param { union { - unsigned long *bits; - unsigned int *lvl; + u64 *bits; + u64 *lvl; }; char flags[8]; const struct ddebug_class_map *map; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a593e040d1ae..f164e11c1853 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -627,8 +627,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, + const u64 *new_bits, const u64 old_bits, const char *query_modname) { #define QUERY_SIZE 128 @@ -638,24 +637,27 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, int bi, ct; =20 if (*new_bits !=3D old_bits) - v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + v2pr_info("apply bitmap: 0x%llx to: 0x%llx 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)) + bool new_b =3D !!(*new_bits & (1ULL << bi)); + bool old_b =3D !!(old_bits & (1ULL << bi)); + + if (new_b =3D=3D old_b) continue; =20 snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], - test_bit(bi, new_bits) ? '+' : '-', dcp->flags); + new_b ? '+' : '-', dcp->flags); =20 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, + v2pr_info("bit_%d: %d matches on class: %s -> 0x%llx\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, + v2pr_info("applied bitmap: 0x%llx to: 0x%llx for %s\n", *new_bits, old_bits, query_modname ?: "'*'"); =20 return matches; @@ -664,7 +666,7 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, /* stub to later conditionally add "$module." prefix where not already don= e */ #define KP_NAME(kp) kp->name =20 -#define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) +#define CLASSMAP_BITMASK(width) ((width) =3D=3D 64 ? ~0ULL : (1ULL << (wid= th)) - 1) =20 /** * param_set_dyndbg_classes - class FOO >control @@ -684,10 +686,10 @@ static int param_set_dyndbg_module_classes(const char= *instr, { 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; + u64 inrep, new_bits, old_bits; int rc, totct =3D 0; =20 - rc =3D kstrtoul(instr, 0, &inrep); + rc =3D kstrtou64(instr, 0, &inrep); if (rc) { int len =3D strcspn(instr, "\n"); pr_err("expecting numeric input, not: %.*s > %s\n", @@ -699,24 +701,24 @@ static int param_set_dyndbg_module_classes(const char= *instr, 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", + pr_warn("%s: input: 0x%llx exceeds mask: 0x%llx, 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)); + v2pr_info("bits:0x%llx > %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", + pr_warn("%s: level:%llu 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)); + v2pr_info("lvl:%llu bits:0x%llx > %s\n", inrep, new_bits, KP_NAME(kp)); totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, mod_name); *dcp->lvl =3D inrep; break; @@ -762,9 +764,9 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) =20 switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: - return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); + return scnprintf(buffer, PAGE_SIZE, "0x%llx\n", *dcp->bits); case DD_CLASS_TYPE_LEVEL_NUM: - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + return scnprintf(buffer, PAGE_SIZE, "%llu\n", *dcp->lvl); default: return -1; } diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 74d183ebf3e0..c049580d2152 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -40,7 +40,7 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 06= 00); * - tie together sysname, mapname, bitsname, flagsname */ #define DD_SYS_WRAP(_model, _flags) \ - static unsigned long bits_##_model; \ + static u64 bits_##_model; \ static struct ddebug_class_param _flags##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.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 E29CE3CF670 for ; Tue, 2 Jun 2026 22:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440549; cv=none; b=IDWnN32MsFKobYv4X+O47LJunfWip/clNVgAp2p+SMYwo/v/i41VGEHs59rcquW4ZFhvyW3kR6HTGfW/mA6AZ3Gx/yAhBKA5BSKmqRb03DHwZXSXnL6xVHcpV0jCEo5BxTfm7Y5rvNhbZqJlJlFfQaS13Yic9r7NUzVMVDTXZvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440549; c=relaxed/simple; bh=a1YwseQaE7rwdsmfJ7bSKBT6pGE1MSI+QaPHqlpLaow=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=izH39em2Mq85YgQAxQyIoBEToQpgdvgMwmrrjJhRFY1NQmU1Oolrs3m1xOZubxoAjPZhjMdyzfyiwOgF3FD7DYknI3x/NtMZWQGJ1QLnVAnP2CaIfiq1E8hlQ0XDVtMWNr6y+zDCTBlvzagmYwDnL+RjlvTSLVgjPCakpMHJpDc= 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=BugsESx4; arc=none smtp.client-ip=209.85.221.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="BugsESx4" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-45ef1198766so37707f8f.0 for ; Tue, 02 Jun 2026 15:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440545; x=1781045345; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=s09INlj8seWn/YOle83dzShBKe394Jq1/oZpUANOzOk=; b=BugsESx4O/HaBi1zax3z3rH/2y+iaS1p1SKvCmtou+yoEmZ0mGoX3JN8+VdHkkLSjD 9oP9aa89cXWQYokQ79hX0UYNpVBWw51q02u/NoBWvAxJYAW6/COkOMgWKc+EMsFf08jh 1M3+knR49GHJmswpuNGziT0lMAt0jyk4Aevxb+VGP+Q9DyVfWHrJbBuX622Vu6px9fDd uTRSjSD1+c0j+hkFxO9S+xM5Q6nqwL2KIOWR/UQl8z/XmNeKc0cSkVWJu7TIDraWl567 Aii1+Wp8JdvCJZ+2w8dKc4l53c+xN8VJNdzTCMrr9GLmWmhlemdE34GYAAu+4N80ZX/R Al3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440545; x=1781045345; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=s09INlj8seWn/YOle83dzShBKe394Jq1/oZpUANOzOk=; b=nRpDEuA+o7MK9/NFyUHQ6LLEfO7yB2B+M7pcDeNpcE4s+jsJNR+vqRziaUVFSRl4U9 /PBl20IDcarOVWsQsdMul7CA29TNlQiXjpKNv27embAbJxzHy59mdHoWdmE44yLkPXbW 13rJzJvvmu47TMtRJaJZCtIKuyL5nZZcQndZwrqkf3HwW3OaNGn8XlRtShCLNIsjcrdu A2OvNjLJ26sMBPhvPTa97YG6LGWE6Kzorvy5e9dJ4KAUJCVQAiLRTjMtSJkFL40gHsbE VyMx6WxcLFC8d33RtmL1fd0cmwCDGke8h3IqlJEH2F5Ex3PaEO8otvXjR19vcnNUReK3 eAoQ== X-Forwarded-Encrypted: i=1; AFNElJ8SWuuofdYEEK/ixDHc3YfzIsLxJkSs80fl4XelsGMYL9nC5INdXEH1GVgRgW0XAiGJRpIG37pC9RGKf8c=@vger.kernel.org X-Gm-Message-State: AOJu0YwdptVNPW0U/xSENLdrFhpZy85wzN85gFYCUKGE/4eXfpdlSjHW DFLcIydhJXgDnuFuBEgN9LzsZ4QR3wk5T6fTL5flmP1O0x1BTYpzwSJk4y1z0g== X-Gm-Gg: Acq92OFy8i+3CGH+pXCSspdLNTVSNXIkBfoOc5Tefgn3W3h4qdmyU0HNwLRqUpSQgVs w5Xs2RcchB6GvGaYRNQcOP0IW361R+kBTd6/FM6VvS8SLQ4WqiwkOzD1iDIHCTQHkbC4v/gPwed k1p5L6XFlToMmisT81YrXrPZfUvEGCD3+A6CiZJIt1rbQsUiSA2GznDDPasVeVfeHKYe0W3y0cq Yy6cvC/PtpqTw/S+4Q0eKeMT7W4jK1/LCvM9yc+2U9WEgmVtq+3t8oXMTd15+aveDkmJh+qekVo 3L4GFFSsluhXnn2rXzTLpImDp2SWdN5AF7k44BMf6gXc2X03oCXQ8ZB2r8UM3UrT33rqYcZRd1R akBG2vVmUHjcEJ8uabdtpbWGWojO1+3wFntSt3wTBWI4ORNMBr9qraQRL0K5+qbo/Y4P7LIKmiP CKN01Z4RC8oNZ1MENy3AiGDqAMDjXCs2s8TOoIzeIlyg== X-Received: by 2002:a05:6000:1acf:b0:460:118f:7a73 with SMTP id ffacd0b85a97d-4602130ddbdmr922848f8f.18.1780440545312; Tue, 02 Jun 2026 15:49:05 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:04 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:16 +0000 Subject: [PATCH v4 19/25] dyndbg,module: make proper substructs in _ddebug_info 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 Message-Id: <20260602-dd-maint-2-v4-19-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=19018; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=a1YwseQaE7rwdsmfJ7bSKBT6pGE1MSI+QaPHqlpLaow=; b=swHSwYnwjzhSTULr00VfyEqzOJJtaSCZzAHlHFzUeO8OdjwtOLOq6YXx9feLD6lcLx4aIH/19 NQQ2ehduIhgAi5Yup8qEVlgL/CAEnQq1AuR/0M7Bybfg23myMTs+rZe X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Change section names together, for more obvious name pairing. 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3: squash in section name changes. v2: Move RvB after SoB In structs _ddebug_descs & _ddebug_class_maps, change int length to unsigne= d int No use of <0 vals is contemplated. dyndbg: improve section names change __dyndbg to __dyndbg_descs change __dyndbg_classes to __dyndbg_class_maps this sets up for adding __dyndbg_class_users --- drivers/gpu/drm/drm_print.c | 2 +- include/asm-generic/dyndbg.lds.h | 14 ++--- include/linux/dynamic_debug.h | 40 ++++++++----- kernel/module/main.c | 12 ++-- lib/dynamic_debug.c | 118 +++++++++++++++++++----------------= ---- lib/test_dynamic_debug.c | 2 +- 6 files changed, 100 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 3a470e808e39..9b4d8e3baacc 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -69,7 +69,7 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_= DISJOINT_BITS, 0, "DRM_UT_DP", "DRM_UT_DRMRES"); =20 -static struct ddebug_class_param drm_debug_bitmap =3D { +static struct _ddebug_class_param drm_debug_bitmap =3D { .bits =3D &__drm_debug, .flags =3D "p", .map =3D &drm_debug_classes, diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.= lds.h index 9d8951bef688..ec661f9f3793 100644 --- a/include/asm-generic/dyndbg.lds.h +++ b/include/asm-generic/dyndbg.lds.h @@ -3,16 +3,16 @@ #define __ASM_GENERIC_DYNDBG_LDS_H =20 #include -#define DYNDBG_SECTIONS() \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) +#define DYNDBG_SECTIONS() \ + BOUNDED_SECTION_BY(__dyndbg_descs, ___dyndbg_descs) \ + BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) =20 #define MOD_DYNDBG_SECTIONS() \ - __dyndbg 0 : ALIGN(8) { \ - KEEP(*(__dyndbg)) \ + __dyndbg_descs 0 : ALIGN(8) { \ + KEEP(*(__dyndbg_descs)) \ } \ - __dyndbg_classes 0 : ALIGN(8) { \ - KEEP(*(__dyndbg_classes)) \ + __dyndbg_class_maps 0 : ALIGN(8) { \ + KEEP(*(__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 91546a99014b..8fc315d0e5a5 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -72,8 +72,8 @@ enum ddebug_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; @@ -81,21 +81,33 @@ struct ddebug_class_map { enum ddebug_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; + unsigned int len; +}; + +struct _ddebug_class_maps { + struct _ddebug_class_map *start; + unsigned 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 { u64 *bits; u64 *lvl; }; char flags[8]; - const struct ddebug_class_map *map; + const struct _ddebug_class_map *map; }; =20 /* @@ -114,8 +126,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, \ @@ -155,7 +167,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_descs") name =3D { \ .modname =3D KBUILD_MODNAME, \ .function =3D __func__, \ .filename =3D __FILE__, \ @@ -242,7 +254,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 @@ -252,7 +264,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 46dd8d25a605..bd7899a91755 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2774,12 +2774,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_descs", + 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 f164e11c1853..29086aad436b 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 { @@ -159,18 +157,18 @@ static void v3pr_info_dq(const struct ddebug_query *q= uery, const char *msg) * @_vec: name of a member in @_box */ #define for_subvec(_i, _sp, _box, _vec) \ - for ((_i) =3D 0, (_sp) =3D (_box)->_vec; \ - (_i) < (_box)->num_##_vec; \ + for ((_i) =3D 0, (_sp) =3D (_box)->_vec.start; \ + (_i) < (_box)->_vec.len; \ (_i)++, (_sp)++) /* { block } */ =20 -static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, - const char *class_string, - int *class_id) +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; @@ -241,7 +239,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 */ @@ -262,8 +260,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; @@ -626,13 +624,13 @@ 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 u64 *new_bits, const u64 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 @@ -684,8 +682,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; u64 inrep, new_bits, old_bits; int rc, totct =3D 0; =20 @@ -759,8 +757,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) { case DD_CLASS_TYPE_DISJOINT_BITS: @@ -1007,8 +1005,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 /* @@ -1029,10 +1027,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 /* @@ -1076,16 +1074,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; @@ -1118,7 +1119,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 @@ -1170,7 +1171,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 /* @@ -1178,12 +1179,12 @@ 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++; } else if (nc) { @@ -1192,7 +1193,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug } } 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); } } @@ -1205,10 +1206,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) { @@ -1222,19 +1223,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 @@ -1381,10 +1381,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 @@ -1395,7 +1395,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; @@ -1405,16 +1405,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; @@ -1424,19 +1424,19 @@ 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; =20 ddebug_init_success =3D 1; - vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in _= _dyndbg section\n", + vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in _= _dyndbg_descs section\n", 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 c049580d2152..e6b2422ca671 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 u64 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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 A0C993D4137 for ; Tue, 2 Jun 2026 22:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440551; cv=none; b=B089JTP1lysmc2gBa126fMrm8ZiiIo89BygHSAJS7RLdL20HNm5HF7kmgz4TOD5w4dKBt3dxaSuaiazJSyTuKyw090UguuqWcCnLDjWh2gDw90vhaYKDt5PYyOBmZvEOYiHybLHFtHxqmkiYci4Df27iVg5woxLVxiI5N8H3W8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440551; c=relaxed/simple; bh=Z1Y6Y/lN5cW3h0OfB1fz/4unyD5Ttaclg3mMzAi4dCY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N3Sa3lG3LzsEB7ejmDwQMdaPdZtIDn4JUd5ROx/uUCb7OO8BMdzyZs2Lmvt25vvqhFZFMIvgCcFc33axN9I60lYFSYF1yjgoPerlScOtAWnnbyxCxvFEiaIjsPVbJlQZUkg8e7+2KZ0S2Wwls4crwCOB5PJVWQsGn9ZzUA1prB4= 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=OjK4GTyM; arc=none smtp.client-ip=209.85.221.49 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="OjK4GTyM" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-45ef616daf6so4553458f8f.3 for ; Tue, 02 Jun 2026 15:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440548; x=1781045348; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sloEL2et+rScEj5ryw/ymmbW0pcpXUQyItBuc5/IW+w=; b=OjK4GTyM+hZLvQZxo/N9bhstJOF2KctmyCPjAA3iBYTaLCPuDC5rRdChcMNek8cilC NxPaq7pNRNuQQ/whhxEAWSgt8nFKbQzazlW8DIfMUAudpQnscUJW6S1vvCwZ19PMpJR3 Owsli1pu2x3nY+D11HYtg9a91s0gnSoP4FWl3aaC+9IImoqtXrJhfXcFL7ENGwuqdfCN QDlEdnmYAKOhQWM7TYgvUQydh1DUbD5OVRPm3GpDOi2yA7KWO4hxnUBRHARXtOq2t9Wr OFdVrK1ZTKBWAYccG7rdL9I3odoX4j0bKVhpr2wHKxRhBQTDW65d1L2lMnvh9U3lm0Xd +pZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440548; x=1781045348; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sloEL2et+rScEj5ryw/ymmbW0pcpXUQyItBuc5/IW+w=; b=LU6jjh+1yWEyp9fkjIC0yk2hhChV9LyqXN9S5Ll8nEAI+VrDMgbWK4Zk7820cvXZMB N56nSK8Ucg/feFEaSLC8m0hkPcyiDm5bLdF5Vys+llqPkwpR1WAmD1Nvm273xNiBKREq 8NjI/DEUMEvjyqf/AVfk7RCDGCu2V9AcY3JRaC2I2n5lrptmG+/dcB96sWZqNW+gj4m5 NXAtP7dGEAjTmMTY9+zh1mthxwIHLIXvFv7s26s/6/0mkacugWdkbmumKyPdB9NxFLem ibY59M4nrXbIml9Nlx182PvyeyBd+fpYO1rxTfRtUGhcCaJPCuR8+X48d0yoJrN+HluK usjg== X-Forwarded-Encrypted: i=1; AFNElJ8kYqBx7HsJir3af0pnyWwjk6eebOsQNP8RrenUa8S8Afr3fuYCu2zt9CG/wL5xA+S94ppflrBD5oPyvK0=@vger.kernel.org X-Gm-Message-State: AOJu0YxLHBxe+sk2qYp7hwJ/aEWKW3L27EcwAiuhuW8C/0FF2UxrBf/4 ybnLt0o6CLz8dv3MLQ83VaD8/AjJOdJ9sYSe1qC1a+MIk5qMPfyZCNI6 X-Gm-Gg: Acq92OHrTHUFtEQ84D3Wgqd6bGhIeRUUUIDrAlq56YdXI46Yy1HTcj1dhwaVwP2tx8b mEyE0+XtpJ4UMabLVe91sibI7GgHSmWxgk4sbkVODy9duottRv9SlUQL8cxuUXNyB8OE8qKMwYO 2wWVfe2WjBZoIob2lUmNAWUSijyXB8IuKYa7iTNdYA92FKe0YhIv1yrj4HgTdZ0hbwP5jEKXI7C PW/wizjw8+P/m6R+ut+oHp0CuIvF6bLlGhaBMUEozL6Zt/h6DSFTJiRSQE0tDruyJwu506Hp5tf aOYKaVInho1GsIh9tWO0v4bZjcvTaaYHztPNMv0fno0G/BlL4VjDhIAu4WaYuuKI2FDInRIgx07 Wb6EPMSqIZdWUhKI7JvX4X+CjaBjkdVisocc+6iwShbXvAyD5ddJF15zuhF66Lr1ycYCeOyg4kQ NY47eVH/RNMgoWUbAv+rnD97kB//Wk3Fo2KlPr98OFpc5wMrqqZUzv X-Received: by 2002:adf:f787:0:b0:45e:ebe5:2010 with SMTP id ffacd0b85a97d-4602185df32mr395619f8f.33.1780440547817; Tue, 02 Jun 2026 15:49:07 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:07 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:17 +0000 Subject: [PATCH v4 20/25] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info 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 Message-Id: <20260602-dd-maint-2-v4-20-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=7732; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=Z1Y6Y/lN5cW3h0OfB1fz/4unyD5Ttaclg3mMzAi4dCY=; b=fGSsz6AgkWDvMtSBE2DnPcZZQJGON4xwO0QWnQR8uo1UeMFZRN0SRe8NWWbvmBKlDVxKqvgZl lxad52gICAoCPKJ4zoNkZAit7PFTHNinfk6lnU5Uj28gRtZrbYA568v X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB old-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 8fc315d0e5a5..e4a62cb73267 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -97,6 +97,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 29086aad436b..c15b692ffc60 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 @@ -245,10 +244,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) { @@ -260,8 +260,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; @@ -281,7 +281,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; @@ -1080,12 +1080,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 @@ -1113,13 +1113,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 @@ -1180,7 +1180,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); @@ -1194,7 +1194,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 @@ -1202,27 +1202,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); @@ -1234,7 +1233,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 @@ -1297,7 +1296,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; @@ -1317,7 +1316,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; @@ -1415,7 +1415,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 @@ -1426,7 +1427,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.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 15CE83D45EA for ; Tue, 2 Jun 2026 22:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440553; cv=none; b=a/ScdZfoag8fdZVRb0lWrT9Vxmy9kIbe7P/8TkZiJJ2zTeRERtRp8yQFE2CG+hiVOcNHy9o5u7ccwkIjvEjxyJtk8dOGkrl9OeWmy9Zk1u4r6uun/BCUC5agvcESRfn7J3AXb4hnd49IyT54eBXF54K8gyfCP7pja5bYRdVzoCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440553; c=relaxed/simple; bh=+3u25R2k2CdkONqYGWxvFW2luG05oZKja972BI/5Ht4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aDl7GiJOJBSqtbKE4mmxnDXnfQ80ws4MfPDoTE/QZrbCi998Ltc8d7tk/f/Q0LfXavrL0VCNOASCI6lGBJQOUMHC8wprCSvqKbDeKopcxxUIthjIXXiYm13e8eUPbZUt2gXp7wvbQD6tSFd+R0ZFM/XaQc6UeuALZDUKBguexw8= 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=MjDDtABi; arc=none smtp.client-ip=209.85.128.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="MjDDtABi" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-49050ff7cbdso111346865e9.2 for ; Tue, 02 Jun 2026 15:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440550; x=1781045350; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EjEFWr76AQqSw2M5qV2f/lpUyzp+VWKfHIVgFJLQv10=; b=MjDDtABiauuk+RUrA7JvoBMzHLAL4gZevA5+3faeNJQ0V5YcAm66NXfAjS4MWrOpYm hYtRvNzf6i19zbpprxSALJIoRxu540DMbg1faU3APWCAU8ZEg02dAYWcR295H6ZYQKkd UnycIXo2FG77N32HOg38pKH7MXpdgIBdFBIhxbwqBkm/uDpmVtxVsLxAkeNnLrHQJS9V vs7zSRJJ+3l0fYgUjbe9ml6HueKs09NXlByuRMVP9VZbDKcdk29ZONXFP9DTBcf1uhyZ KFDJRZlkkhPUg+qmfEF9ztioTQDbcrFpPikp3We/OTAdH+XVUKXyTy7SMzX2gQtDXYgu iy+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440550; x=1781045350; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=EjEFWr76AQqSw2M5qV2f/lpUyzp+VWKfHIVgFJLQv10=; b=F2SUMu69DSwDivVCSUr72BbTtFUAARwZPqSZWcwoZQgKUF37MVVbN6VgPgCS5jmSzG jH+XAF3Is/D3Q/7bZqOKZOB1gJeax7+RQHcWUFjw45D9VWi3bUOpJ5oqmp/aaw+T3HOr A/4k4S6MXQCvhkOWUuf72wuf5jrfY4mDJ06EwwtlStoiSli+PJZ9Ck5+WSEkc0B45W10 wkMEHVhXkxvWcoVE59djKpUJEbxUAmGGlG/vsE/OsRGNoiiPDqrMgslXKbOILhH1UIYr eSb5B2cDZtKgkA3EudHOYY2djRZ1RGKuv0s5r2B/Q/HsBKiUXGCF3dXOSk4PTLyTit41 7L2g== X-Forwarded-Encrypted: i=1; AFNElJ82Iav/A9BLKQSH9NUiWeNOYUEE65heKeZv6MxldgcXRUAPoKDk48Zc+0I6YCWIKdW5uxPcyQQJafcd0y4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywpa22+U8saEulKclYu2TaWschGz3b94GWThNck81hAvgyazloy VzR4virUPZfIgCmSxrfhtFHJHXB2m5UII5onSnWXfrU8eJNtxLaYfvLJ X-Gm-Gg: Acq92OFR20W1uxqr+0PSWftFkKh8wDx2inPBrBsEuPK/kk9VK3CVaYYC6SrLDtntwYC 5Zhfv7orliE+yMyqvykwRg5QztkcyHW0CeuqrFYShNGW75OfXCrdfsy9ECPFtNov9UW73kP4GMq 0l/l1R0ZYH1H/W7csfO9SBbQ6tHhzJ3IzTj5LJgEbsg6lvQ1C1hmF9tRbQUQwSJ7ILXi8dah5CM bgpkgUReXbF7DkuVbjXCIYhLv21c9s8eXebxrmArKRdsJRn7zo+tNvNy6311D+w/+CsG8+VO9bT 8hdYgygRZ8+ztwxrWqV/RmsTLClLO7MgSkdIEL0HqUalCKuonpRHRxrCQd6Z/4WdvQEgEAi2Z76 yyfXVdyU7QTfhBMv19gonFURih6ZCXlbdTbNsqhw8caeFDgv+wJVU3v01P3oGCcnIHDVb1Up0em L/KirSEzT1VBftpp8Cir+NnIQ7IdCEHIOPX9EFgy3rNQ== X-Received: by 2002:a05:600c:3104:b0:490:b265:7940 with SMTP id 5b1f17b1804b1-490b5ebd2d0mr10787025e9.23.1780440550416; Tue, 02 Jun 2026 15:49:10 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:09 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:18 +0000 Subject: [PATCH v4 21/25] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module 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 Message-Id: <20260602-dd-maint-2-v4-21-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=5917; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=+3u25R2k2CdkONqYGWxvFW2luG05oZKja972BI/5Ht4=; b=4kehgvsl6FS6J0ZJB6KBKBTiT++oD1Wavj5nbRSlyVY0opN4/nukJzkp8RUjCVQSXKYN1rhA1 7ZXyI/jZ2VYB9HvjfdsnYRwKPs8LFAB7cV8RLJhe+MXHOaAodn10hi2 X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= The body of ddebug_attach_module_classes() is just 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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3: expand block-comment in ddebug_add_module v2: move RvB after SoB finish hoist - drop old fn - ddebug_attach_module_classes the v1 rev left the old ddebug_attach_module_classes in place, but it is completely redundant now, since it already lost the list-linking job it was doing. It was being cut out later in the patchset (in the unsent API adaptation phase), but for cleaner review, lets excise it now. OLD all-in-1-series (pre split into reviewable chunks) 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. fiuxp --- lib/dynamic_debug.c | 80 ++++++++++++++++++++++++++++---------------------= ---- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c15b692ffc60..996daf0a05b5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1169,34 +1169,34 @@ 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) -{ - struct _ddebug_class_map *cm; - int i, nc =3D 0; - - /* - * 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++; - } else if (nc) { - /* end of matching classmaps */ - break; - } - } - if (nc) { - dt->info.maps.len =3D nc; - vpr_info("module:%s attached %d classes\n", dt->info.mod_name, nc); - } -} +/* + * dd_set_module_subrange - find matching subrange of classmaps + * @_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) + * + * Narrow a _ddebug_info's vector (@_vec) of classmaps to the + * contiguous subrange of elements where ->mod_name matches + * @__di->mod_name. This is primarily for builtins, loadable modules + * have only their classmaps, and dont need this sub-selection. + */ +#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; \ +}) =20 /* * Allocate a new ddebug_table for the given module @@ -1205,6 +1205,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; @@ -1217,17 +1219,21 @@ static int ddebug_add_module(struct _ddebug_info *d= i) return -ENOMEM; } /* - * 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 is a partial cursor into the + * builtin dyndbg data; the descriptors are the subrange + * matching the modname, but the classmaps are the full set. + * We find and set the relevant subrange of classmaps here. + * + * The modname string is in .rodata, the descriptors and + * classmaps are in writable .data. All are immortal. + * + * For loaded modules, mod_name points at the name[] member + * of struct module, and the descriptors and classmaps point + * at the module's ELF sections; all have lifetimes matching + * the module's presence. */ dt->info =3D *di; - - INIT_LIST_HEAD(&dt->link); - - if (di->maps.len) - ddebug_attach_module_classes(dt, di); + dd_set_module_subrange(i, cm, &dt->info, maps); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.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 DD74C3D5646 for ; Tue, 2 Jun 2026 22:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440557; cv=none; b=sKn2yqHI4pM5FommAiil02zX3V8PYBmr7Roi5AJGz7qr4cAJFsLBMz/Kravik+yu0JfFoAsDnhXaMLSEyyb+cyurTUqjwxGdbjrh7bSDrXsFmuFSTucW/A7jhijVv/mr/Ep/rdX3AAK8+in/48WasCr/B4BdwQQfhKk5p0icMR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440557; c=relaxed/simple; bh=lZo1ZwCzw1HsSSPAASSDUG29+dnu3/idhHrKphEKq70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BLByq+8Y3ZTMwM15wFRsUGP1S0Ix/517ROyMctgV4iSm4AJOGLH4ZdvPcWPfieyC3OxJE9MSo8EsDic8gN7LAoJIUiTRxk1gTuwV2aS2IGqWjNbhHbdIk9c7A8Yw6w06swkfq8HVpHeSY9B9ATchrwe4pwzlz4Mjfq4jM8q1wGI= 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=gVlirMXq; arc=none smtp.client-ip=209.85.128.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="gVlirMXq" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4908b92904fso67089265e9.0 for ; Tue, 02 Jun 2026 15:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440553; x=1781045353; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IygGhm9kuf41mq4yQ0C6MVtWUwR88txz1bUI5vUU+BQ=; b=gVlirMXqoavJtmQuXcWT1NPgNduj5iROhWiJ/zGpVKgJJcJ7FFgeAEl62IMo/Je38G BiwDyQ2yaUF2kLhpHGvGFngBPJlNu0Rr+KXpGUhqTXPPif9PJ2o4h5zDHOysyLuBswim BASpZqvz6+/3LnS8tVkGHK41YQC34hgpoYbPgLsBLR1Sec/1tp2pK/rd5wHafYFCNToH v7PF97t8QYb4URia/OhSVUhHfyIZRNjJ68k0SErqb1wvGXH3SDOLATx+ysvI2xrQ1t+V HR7A+4XlVd1A0foTe/tjHCF/NwFBtC5e7nBB7Z4fVjOeGk0dhY/YIpnfB6iwMc7NxNll w+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440553; x=1781045353; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=IygGhm9kuf41mq4yQ0C6MVtWUwR88txz1bUI5vUU+BQ=; b=UOgmPmPsE7B0Q2IhWTtTIIxd0tRkVepSTxxCDdZtYVymAfQ3BNsq9TsjT7stjBCKVs WluIm0k/JlsWr8Sp7ywiM1MI/CHHr/W+WNoX5naVI2jYnoUBsf5tfOiPIswOQ2CTP1GS bjgZyD8eer+2mSysmz8gtZUCXu8WqoBTQ4Q/kyUd4NRw1QbbztPy4kkkxoMPjwzqoGQB UwVKi47DEbgEYQHatBGnuYCBYHiw8XSlYmp5HRufff/tiuvBiaAk3Ij59WRCnnCK09pU HzDWusrXOycs4SBbtFvqWBoxeGrHZKImtv0IDtOJSVBAdQQSbl5TSuF/xDV5VEBeauW5 1IJA== X-Forwarded-Encrypted: i=1; AFNElJ8EZpg522QYJnW76wmf1m6XsoFwU8OkkDv5tmG7WqU3Gi0oJfpR6AUAJKQBb87qIhyKKP3LmPtSEfK3b5Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzrQ33RD/B+irsU0Ts6acFmoVift1nSBdcVVRO7IfbcKa2m2HFA zne/bFuNgGim8PJo0iWSfxbfAASKbV4ryvvKs2k2mWHO68nKV2XtpX3b X-Gm-Gg: Acq92OFN31U6P9VJhz4aLM2GERSdsR7gnOzBMAy1jin4FT5Z4VK2N22y4RDOf2iJsdw r5D8Xf48/uJLoNZPOQ52FGwm6IHYa6JRQF9Lv1Hzz3fbuugpMhIoulVZs2N2FRL03O7sYioTE0s kxUN/gyTtFkt9nG+GX2qNDfswxWBippTCODcU4kK0SM3zD6zTlWjJuY/pinKQcJLJSDEyKFMTFA E3+Vvbx+1t4bnnoOI/bM3Yk8kZ+/AmUo8bTgHwRaxPoIT/XVYt5XLV2FqLDXT1ptA1WJx1A7QYR xEn9q5xjwMt72Q2kwb0HYsT+5zLPz6dtyp9G2mD8HD0F3h+Lxi8uS1BLIO8vOJZgaTEkYvLdmam nXiBtFAXtz6E5G0LKYHzN1fTn/0kavTxR1K6D2TdfxF9xqaHgwm50MGWD0WC6rLY5XCTWqQ0/oC +q1wyuFo6A9asljbrKu8m9BjmgMvvQgZiddMMRT2+w0eJberY4Vzfu X-Received: by 2002:a05:600c:3150:b0:490:3bad:3784 with SMTP id 5b1f17b1804b1-490b60de830mr11022245e9.18.1780440553275; Tue, 02 Jun 2026 15:49:13 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:12 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:19 +0000 Subject: [PATCH v4 22/25] selftests-dyndbg: add a dynamic_debug run_tests target 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 Message-Id: <20260602-dd-maint-2-v4-22-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , =?utf-8?q?=C5=81ukasz_Bartosik?= , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=13257; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=lZo1ZwCzw1HsSSPAASSDUG29+dnu3/idhHrKphEKq70=; b=DmnkSXiB0uqHymu5fqWRAi4RCcgYvoJN+rpT74y9XcfhBkPGQZ+mFR1oe1wbAwpPcRhKUTSdX AxqYc3XQ1byCnnVa9TKQv4Q7gx1rh+3/TlBNLg3DySrs4cgjPltjoQs X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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. Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v4: squash down a few missing "" quotes around $vars v3: use ksft_* exit codes v2: drop commit-msg mention of yet-to-be-submitted tests move RvB after SoB script fixups per sashiko review 1. CONFIG_DYNAMIC_DEBUG=3Dy is set correctly. 2. All subshell captures $( ( ... ) 2>&1 ) are fixed. 3. All echo variables are safely quoted to prevent word-splitting. 4. Standardized on modern /sys/kernel/tracing/ paths. 5. exit $exp_exit_code correctly propagates failure status. fixup-quoting-selftest --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/dynamic_debug/Makefile | 9 + tools/testing/selftests/dynamic_debug/config | 8 + .../selftests/dynamic_debug/dyndbg_selftest.sh | 258 +++++++++++++++++= ++++ 5 files changed, 277 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6cf80e7ac039..b3d41824220a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9087,6 +9087,7 @@ F: include/asm-generic/dyndbg.lds.h 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 6e59b8f63e41..17c4ddbcee89 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..ec478b17873d --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/config @@ -0,0 +1,8 @@ + +# basic tests ref the builtin params module +CONFIG_DYNAMIC_DEBUG=3Dy + +# more testing is possible with these, +# but insisting on them here skips testing entirely for such configs +# 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..1239f1e10591 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -0,0 +1,258 @@ +#!/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"" + +# Standard kselftest exit codes +ksft_pass=3D0 +ksft_fail=3D1 +ksft_skip=3D4 + +[ -e /proc/dynamic_debug/control ] || { + echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=3Dy ${NC}" + exit $ksft_skip # 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= $? +else + # if no config, try runtime probes + modprobe -n test_dynamic_debug 2>/dev/null ; LACK_TMOD=3D$? + # assume builtin dyndbg if control exists (checked above) + LACK_DD_BUILTIN=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, got $3" + [ "$3" =3D=3D 1 ] && echo "Error: '$error_msg'" + exit $ksft_fail + 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 $ksft_fail + 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 $ksft_fail + 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 $ksft_fail + 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 $ksft_fail + fi + if [ "$output" =3D=3D "$1" ] && [ $3 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not closed" + exit $ksft_fail + 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/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/tracing/trace) + line=3D$(tail -$2 /sys/kernel/tracing/trace | head -1 | sed -e 's/^[[= :space:]]*//') + else + buf=3D$(cat /sys/kernel/tracing/instances/$1/trace) + line=3D$(tail -$2 /sys/kernel/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 $ksft_fail + 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 $ksft_fail + fi +} + +function basic_tests { + echo -e "${GREEN}# BASIC_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP" + exit $ksft_skip + 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 + +for test in "${tests_list[@]}" +do + $test + echo "" +done +echo -en "${GREEN}# Done on: " +date +echo -en "${NC}" + +exit $ksft_pass --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 554263D525E for ; Tue, 2 Jun 2026 22:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440559; cv=none; b=uv1puTQlantjpC960Ud6/l8XUdvnMmdO16dnPM0CkacwPb3VGquS8A9u6ns9KfYR+FlgMmHXWDfRS/Pr88TiDECdc5AFPA80zBy0zDbdvkeOfoaMGXttux+1xdYXGI3Cg9FnOMSVnvzIyj6+UVjS2Q+4enQDD/ZWI6b81p7aO0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440559; c=relaxed/simple; bh=h10PnN9dZij/9KIShcmtDym4aMWTMKg/65aOZIHej50=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eizwSapFgd7UUtxuoLH6XV6/Y/xrFgcD2QoJmAHaNahUT1hZ2Fnj7gFxkDP7B0wxuNhIIvqW6z+9o4WIXpsTu5duqhaGYYFenMFVdv7C9bLo4bOA/Nj5m1YGK8aNK3j8fnywgmzqJJyf85iVPwfJvYYh2plZ+/6sQXsSvDgIV6w= 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=hVsUFmZo; arc=none smtp.client-ip=209.85.221.49 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="hVsUFmZo" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-45ef616daf6so4553564f8f.3 for ; Tue, 02 Jun 2026 15:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440556; x=1781045356; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yYycUh0v045JLMzHv+cDjWaRSMlpTVGG8/fmLB5h0j8=; b=hVsUFmZo9NhegcRQLm4XlNHcL1hCCoseELCkAlexbymlZF2+OcJ8KQmWV+w0ZRFPxc ntWjw0FIf69vg73Nx5I9VXoTjQRU82RYB97ofed2vBVjK8w9hewnD7JCTYbZPAyDv2r9 mOeYpJILzA+u+EjY5s47KUBrbLP9enwlDUWmQnGZyLYUkJnlU12GMDERuWfF++7QpI6T sO9h2IcqQ48WEWc6ZoRWUZzINVrOOHrhVC+nBP+/mlDfFnwzkfOxDVa7Vv6OC+HAMESf Bi25bMRLF1+9AaUfrD5RixkeBDtIO/+q8fH91IkHIm/mRxMwCd7FTGzG7kJ9YVgQfmkR 0Ghg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440556; x=1781045356; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=yYycUh0v045JLMzHv+cDjWaRSMlpTVGG8/fmLB5h0j8=; b=rliM2ajqJXd4GBIdJooDRhM0Yc++uHb1SXr3o2sW0FzvqxbHoW3S18VW7lKdN1PBz6 0cbAnohpEPiMW31WTfNZMuSGVy6snIewtnjAhMqXH2MGYS6EVBIAAikxaXdBV/Hoyw0H yMVHlbKBfzcstSNj0hm9ygnMYgpwMV2PgboamiRO0w8dWob7lk9PcJUmQ5MZAN8pGa5B wEddDuBmJSj59CZ2nuw2m+ed/8sooevPT7sAWFhNMQ9Sh5lLlUMb2cLe1AoKJ7J/eJ/Y AhSuMdOU6QgG3nDFbVd7sRoVNDgB9XVtBaWGqyYQY2SpW1qMKzr0Yi4a3lkW1upPPO4w oOyA== X-Forwarded-Encrypted: i=1; AFNElJ/dAXKmW3/+V4ijScyaYIlzVRQes9UO3DwI3/cYugveRl3XTJtN5YB0uyZgYuHlswSrHWFM7uaISkq8j7U=@vger.kernel.org X-Gm-Message-State: AOJu0YxB3YcQRmLw+gxjTSBW1i9bvJ2LRGCq6GC1vHTXIasIsWpXFCge fLpocCSV9aZOpOi2uoY+WvafZts6VWjQwHrLNLltUb+KiLuTFfNHcx/X X-Gm-Gg: Acq92OF3RLrzhuMSeoF69uzTXTzblRxIs8/fQGQCea1t23hL0wzvLKOHwiE8UvBTYiU XevUqXqMI3YxpkoYtaRiST0Fpm0266GfOzRV72sIm2Ls7sysyePm/XrOwJn1ZsnsytfwN6XthEd +tc60RLLRtt1KjND05GBEikXq9sjqRsVX3EjDG2ke10fY75foKFFqk36lsVE6ovA+8N0/j1WExn /kMFI1foaNFPsZL/xQCd09VDWBkcaVyfUpvlFP0kGuB+PxWZnO7sCfh5kRGk40TzHDxh1D27iW7 HuFxs9AMcYgIiUXDYRkrquOIoied6eMTNx+jrJzGwNNTB7S2TgIHkSQUfXxtbFJzWSQKI9e1g1g Tdt8BlWZpZBqVPhq/8xU+e+KDOFIK86fN2y1HUpWLNFkSamIQrpQLAp9hOSqkQFeBJh8n78OPKx 9dy/c+FK3lbcfds+nvBgY0GS5G8BJ/kVIzr0iAKMBaFQ== X-Received: by 2002:a05:6000:186:b0:45e:ce49:43d8 with SMTP id ffacd0b85a97d-460217815a2mr476777f8f.4.1780440555875; Tue, 02 Jun 2026 15:49:15 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:15 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:20 +0000 Subject: [PATCH v4 23/25] dyndbg: change __dynamic_func_call_cls* macros into expressions 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 Message-Id: <20260602-dd-maint-2-v4-23-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=3131; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=h10PnN9dZij/9KIShcmtDym4aMWTMKg/65aOZIHej50=; b=nNRaRJnI6DmZfuQY2gv8wXs0tGfSMAFNC8nitrIbwD9TVpVCkTFOsGImAavGQUVyhdgdI2ALY opxK2UqBAt6C3hL60gGtbqcEnPcfAnMLTunbF8bSh/6ISOWnc9ixKTB X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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"); Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: fix statement-expressions to return 0 (not void) like their respective fall= backs 1. Add 0; to __dynamic_func_call_cls 2. Add 0; to __dynamic_func_call_cls_no_desc 3. Convert the disabled fallback of dynamic_hex_dump from do { ... } whi= le(0) to ({ ... 0; }) move RvB after SoB --- include/linux/dynamic_debug.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e4a62cb73267..2d6983186f37 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -224,24 +224,26 @@ 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) + 0; /* match no_printk return value */ \ +}) #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) + 0; /* match no_printk return value */ \ +}) #define __dynamic_func_call_no_desc(id, fmt, func, ...) \ __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ fmt, func, ##__VA_ARGS__) @@ -321,10 +323,12 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dev_no_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ groupsize, buf, len, ascii) \ - do { if (0) \ +({ \ + if (0) \ print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \ - rowsize, groupsize, buf, len, ascii); \ - } while (0) + rowsize, groupsize, buf, len, ascii); \ + 0; \ +}) =20 #endif /* CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_DE= BUG_MODULE) */ =20 --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 EACFE3D8111 for ; Tue, 2 Jun 2026 22:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440561; cv=none; b=nva8QK8yZeTtAGFPKtek5sze6bHSV1SH/8ZpZWqsIWj6TtHXMV8p9VhvZ14HzKwOUPbXrXDTKcmAz5CJumyMN7P5J9AC9S/QjEW9Q7s4K0OlYISomwe1OVl8/GNQNkRoAPgOgcHH95ly4CU92L5iy/Fh/c14zYBwZRDycRGKC7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440561; c=relaxed/simple; bh=mS8zYCuPveoKc7T4Im/jzVvP1HCLKypYVHp0g2j6Skw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PQn2keFmziB97RsDhtMexvHz0pF8nqha/gaiJLE6B5ZY61jwHCwSF738bQbE9I0UKxpXjuNGzPIekqepGU6D5Qd7+aZ7O8wy6gw8WvjUoKeidPOjepg5YqEJUR0qKK+IwlpT/B6Sqn1TPUjjh5mn6fYyKzB9KJAyX6ihQyXF7xo= 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=qFsqdD53; arc=none smtp.client-ip=209.85.221.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="qFsqdD53" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-45eeba68948so4423679f8f.1 for ; Tue, 02 Jun 2026 15:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440558; x=1781045358; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FNu2VyRhrQI8zsAEpIkLCzKPvvxJoe9LgPS0NWOwvYU=; b=qFsqdD53t5NGf40QWrX0VJm44bJkQvgEQrlqBu6+91KE8LYiZoTL8Yn34JnWaSU4qv zeanv5V4qQkF3qQyYXPwmmiN4bHaUkDBxeBQKl/E6npWCLzbOC4ZP+JSj3cEgXLOy/Zx XraVuDxKJlCIQ7415hlry2sG9FFqXvdikpdDbeELfUfwWMotTG0nMlDWYARIt+4KWFMt qlWYN3VFI2jXusrcncPe5oLwAK0fos9EGax4TBEP5YhlFTAhimLJxQXzDA7Ez06Av8Yf kYR/tW0RK94QluNL2LPgSkTrpZ7WyfQ/Cth9hDCpUp/OvLJ+m2lE0W2LxOBkOFf5smyv QI2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440558; x=1781045358; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FNu2VyRhrQI8zsAEpIkLCzKPvvxJoe9LgPS0NWOwvYU=; b=pY6BqAguz1ZujfvIQkOkW2x/vkdWHUc2bdxRhDuwmWebjovjbqUxKQFP75D8isPZZu jUcjdlX/zrZxQKVhKScz61lgqpltv97NnTk4/nGtc62NqZLsePeLrJWzHWoLlf1SStMs Yi1o+DOF1S1QPmSOZpboDc9eUrE5SM6xOn1bWT471bl52dsJM2+q2T6RSCDScUKgHZ2m rSzOjGtjOehfDs6Tap/7zFAl8ekA1ST7Q8/Wl8EJ2+s585PTq1ll7jRgO2pabgMAvMv3 70ST73Wrvfzc0prtptIeVUkg5hD8u+UeaYE3kx0m0HTDdQ/coBFEmSBThdbLu/1HpgK8 /YYg== X-Forwarded-Encrypted: i=1; AFNElJ9Gycz1cDUq4O6uRhrp/mfg+GQaTgN4zLAGD62T/D16fZwH6BzHyN7H4RXfCcLYHkZQ0fHaRw1e/rmMR40=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4anntUe0edyE8v80MDF6ANxw8hsbA/ikrm9DtE9/ccZt38KLj UEUKhoCKUEEiloyMoDHZ6VMgZIqikQJwACe99vDbQ5dl/z+dl9cTuzzb X-Gm-Gg: Acq92OEZm0qa/Kg0i3YRceSIKvVbzbgMCWBkBWKwWQ+4hlXxIh11dOmCcTx9UNuR8IZ VnC/m9S3mGmFO6JJxqZv8ziqFYIQh1WLmq+UIq6PzH7UqjA1zj22Zz/OMBtYll+2Wfji5w97kuc Y9bXOpo5+DG7Cm/ZMeEgGKOrOVN/lqORoQabS0TjcEGV026CS2uJHezdRcolIpA7PLvmPCT8Q47 J/TJSPML4jyZufBR7lKqUuvgDH7noQ3lMYmCnK7t4HRHGrNddAadEoUXXIb9JwfnMcs0CKqTMgx 2pB3K/CoJts006q56TjlojNprVZEFE2GanRn3xl2wFwqAHsgljZNZccE52jd/jHelYk2Ikf/Gp2 ysupBxqRTwkvP6T/TF0UsMMVvTf9SCPQ3GBAdCfFArFd/Ye88L3ipHhBFuhqvdoeS7QR/zI5y6r eN+wYi90i3WERFufja0Gq/XY1O08mPI68+p/rK2agFng== X-Received: by 2002:a5d:44d2:0:b0:45e:651c:47bb with SMTP id ffacd0b85a97d-460218513b2mr497138f8f.28.1780440558379; Tue, 02 Jun 2026 15:49:18 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:17 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:21 +0000 Subject: [PATCH v4 24/25] lib/parser: add match_wildcard_hyphen() for agnostic matching 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 Message-Id: <20260602-dd-maint-2-v4-24-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=4121; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=mS8zYCuPveoKc7T4Im/jzVvP1HCLKypYVHp0g2j6Skw=; b=VXb9s6BILwbRYg9yQV7eipRGBEsG95GCuf6QT72hEVacy+qZBYi7X8O5FuSb5Iz5M4W1FDq67 p9yjueJ/OsVCVSt5ROCmYhB9K2zwhc/6uV7MVoRWpT2QeQ8U6P+qRVG X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= This commit introduces match_wildcard_hyphen() as a variant of the existing match_wildcard() function. It treats hyphens and underscores as identical characters during the matching process. This is necessary for subsystems like dynamic_debug that need to match module names provided by users (who often use underscores) against names stored in the kernel (which may use hyphens, especially when using KBUILD_MODFILE for built-ins). To avoid code duplication, the core logic is refactored into a private __match_wildcard() function marked as __always_inline. This allows the compiler to generate optimized versions for both the strict and agnostic callsites with zero runtime overhead. Signed-off-by: Jim Cromie --- include/linux/parser.h | 1 + lib/parser.c | 58 +++++++++++++++++++++++++++++++++++++---------= ---- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/include/linux/parser.h b/include/linux/parser.h index dd79f45a37b8..a3cc7bc5fb93 100644 --- a/include/linux/parser.h +++ b/include/linux/parser.h @@ -34,6 +34,7 @@ int match_u64(substring_t *, u64 *result); int match_octal(substring_t *, int *result); int match_hex(substring_t *, int *result); bool match_wildcard(const char *pattern, const char *str); +bool match_wildcard_hyphen(const char *pattern, const char *str); size_t match_strlcpy(char *, const substring_t *, size_t); char *match_strdup(const substring_t *); =20 diff --git a/lib/parser.c b/lib/parser.c index 62da0ac0d438..d5be01fa9adf 100644 --- a/lib/parser.c +++ b/lib/parser.c @@ -268,20 +268,13 @@ int match_hex(substring_t *s, int *result) } EXPORT_SYMBOL(match_hex); =20 -/** - * match_wildcard - parse if a string matches given wildcard pattern - * @pattern: wildcard pattern - * @str: the string to be parsed - * - * Description: Parse the string @str to check if matches wildcard - * pattern @pattern. The pattern may contain two types of wildcards: - * - * * '*' - matches zero or more characters - * * '?' - matches one character - * - * Return: If the @str matches the @pattern, return true, else return fals= e. - */ -bool match_wildcard(const char *pattern, const char *str) +static inline char dash2underscore(char c) +{ + return (c =3D=3D '-') ? '_' : c; +} + +static __always_inline bool __match_wildcard(const char *pattern, const ch= ar *str, + bool hyphen_agnostic) { const char *s =3D str; const char *p =3D pattern; @@ -301,7 +294,9 @@ bool match_wildcard(const char *pattern, const char *st= r) pattern =3D p; break; default: - if (*s =3D=3D *p) { + if (hyphen_agnostic ? + (dash2underscore(*s) =3D=3D dash2underscore(*p)) : + (*s =3D=3D *p)) { s++; p++; } else { @@ -319,8 +314,41 @@ bool match_wildcard(const char *pattern, const char *s= tr) ++p; return !*p; } + +/** + * match_wildcard - parse if a string matches given wildcard pattern + * @pattern: wildcard pattern + * @str: the string to be parsed + * + * Description: Parse the string @str to check if matches wildcard + * pattern @pattern. The pattern may contain two types of wildcards: + * + * * '*' - matches zero or more characters + * * '?' - matches one character + * + * Return: If the @str matches the @pattern, return true, else return fals= e. + */ +bool match_wildcard(const char *pattern, const char *str) +{ + return __match_wildcard(pattern, str, false); +} EXPORT_SYMBOL(match_wildcard); =20 +/** + * match_wildcard_hyphen - parse if a string matches given wildcard pattern + * @pattern: wildcard pattern + * @str: the string to be parsed + * + * Description: Same as match_wildcard, but treats '-' and '_' as identica= l. + * + * Return: If the @str matches the @pattern, return true, else return fals= e. + */ +bool match_wildcard_hyphen(const char *pattern, const char *str) +{ + return __match_wildcard(pattern, str, true); +} +EXPORT_SYMBOL(match_wildcard_hyphen); + /** * match_strlcpy - Copy the characters from a substring_t to a sized buffer * @dest: where to copy to --=20 2.54.0 From nobody Mon Jun 8 05:25:47 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 3BA073D2FF4 for ; Tue, 2 Jun 2026 22:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440566; cv=none; b=rmv/Y57NK4YTIkdb5NlgjXu4ge2rmsxgH5M0lDQL5ls6mG2r846Ip/leJFPYalKkueKN37icGO+IBcmX+EqZ6YAp8e3/UuIgAUN8/iJ4goBMJ6+fyaC29RzVh3IJmkV8wgBsfdXLBWkfRT30I4oZdrJ9x/56dCQ7d5N52qqEfQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780440566; c=relaxed/simple; bh=lthlKNyUq5gUtWvLVtrD/SKctmL38wo7iVjBwbNR+uY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HIfyDKHaL+1WXhOfc1B95hXKmxo5QAEOkPLX/OtqKMKabUhXREyvd3bEExMA+BXHv64NTZ9FOdx+VPyLEahVqZELcCT9M2z++MZitANS8eiv5FDk2O3B6Gpt3A8vU4IMzzW7wp0XpT0aIo7LiQxxzEKAM/WZgBZZTtZkjg/HyP8= 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=D2TNV4nb; arc=none smtp.client-ip=209.85.221.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="D2TNV4nb" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-45ef1629ff4so3688308f8f.0 for ; Tue, 02 Jun 2026 15:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440563; x=1781045363; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QCgszUrgNi7grQDH6VE2VsdkLUzjuVRFv4kl/ONnNts=; b=D2TNV4nbX1LlPxC3y8ziQylITCeLqO6irzPn1Y3v3tIZ9dZIiuy1AxNs7P+XCO/Da8 fmKavKlccct4BkfkUwrpLIHZKCLQcCQ91zYhQk0IX+kjH+HZyDjAW8RkV7fakM3OPKnw Cc61u3wWQPxiQwzL/93MiAY9IT7PT8EfojQINc0RISz4I59N5uPLbiuyP5d4PhWSBgJz LZlVgcgMGRa+ZuzyHbucaD4wmsefVM02MtrmhVVdbclQsIwR2NdVFHJUOAfmQyezmlH9 yN7J6uNRaz7hVO0A3LvB9+EgoU2gfp/qMCfp0eP0Bo0Mku7CnxxfANv860FdYgV9BfyL GPWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440563; x=1781045363; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=QCgszUrgNi7grQDH6VE2VsdkLUzjuVRFv4kl/ONnNts=; b=W+qwQ7yomzXppKNONJWWUrWiIMLixc/meFC0H8f0DLjMrIkq6NCpMNhd9ZwuLV6m86 958wE3w1QwieWCTk6FykVvLnhva/HUs2iKZPyIl9WJ+7Jjdm3/8/kQiO259xbFrqTp2f UTdC0DOSv4vZFcECvdaqehkhaKHgIprFsmFGcUX6iDpAqjKSLYdEv/SocDHkqJkbPzbX XKhzQeNtgNBelRkS6f6iNqkusrhlBYvMNO1Fl2uIOETCUarz8qlGL0Y/lFBx3uPH82NT uTkJIb/GTZzQL9e3Wh+N5o0Gv6+WKprOM5z5J07AyTt6cNTrcqronislGery5SgiLyR+ ZRPw== X-Forwarded-Encrypted: i=1; AFNElJ/u28Ik4Bm9A9ol6RboBn402kO/RW0gmVQ16ly9Xhxqzg8TBSIuAyBJQjDBk4ruttMum59lft9gTLgDk8I=@vger.kernel.org X-Gm-Message-State: AOJu0YyNu1vt5Sl2KAsfFzpsQqZIcl79/mVtuyWzp8//QrvH/HV7inTh rPWo1W/+v5sPfnQ26D4FBEIhBzCqXYrc6l4YDQPJnWP87j1cF1HDW8zR X-Gm-Gg: Acq92OFYYugXVPE3k8tcxtrYqdUGvnlNWTDkHlAI3EBOhZYEOoN/rIEZKCilUPd++qm 8X7y28SE33BQ07Hv9fRDSr28oHeCJ3z9NwZN9IqxTKNthrNZ281/EEIGbBBQ447UnHoRXRBQF7T TafowlR6ZznZ7zKrxD6i1UMx4D9tWlUi7NQNtRc6z36pky1VUpa3fzYRk4vG+lkJkG+scfg34rr I6YWF5DNuqUUQkwOqdJauZSl8pBT9HEEVGm3nP/GPcGJlSMK5xEA80oBd888oDQ/QpxVSqZoqm5 JZ2k0b3z8GvbKL+g36VOW9744Y5CZhsSW1q3oesvK6r4dayeldvohr2guanOcvUYzE4H7+/Kiuc ihsGUbBRDJkLEPjANj6MgQrCBhaiyn419PCPbb/gzTE5n3zSwiYLdf4plBdUfmhfyHGRIKxjMiU HSF1ZStT3toTCApbV0tVlY8jN4f2iDa47KyuDewHOdFQ== X-Received: by 2002:adf:e00e:0:10b0:45e:93b2:37bb with SMTP id ffacd0b85a97d-46021781c20mr451609f8f.6.1780440562462; Tue, 02 Jun 2026 15:49:22 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:49:21 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:22 +0000 Subject: [PATCH v4 25/25] dynamic_debug: use KBUILD_MODFILE for unique builtin module names 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 Message-Id: <20260602-dd-maint-2-v4-25-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=13699; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=lthlKNyUq5gUtWvLVtrD/SKctmL38wo7iVjBwbNR+uY=; b=ZR2ERRpc7QxcWHTdurm0228LMQX3bNexpUtw/VCDnnM06DWx133ipZnZNguxNUs9x4RBoiZn0 6P6N2XWxty+BxCnjt8MUHPdzE82vXQAACHjyiLkEthIPu1kXpPKwwVo X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= Historically dynamic-debug gets its module names from KBUILD_MODNAME. This works well for loadable modules, as the module loader has always required them to have unique names, but for builtins it is basically kbasename(srcfile), which sadly gives us many modules named "main". This makes the following ambiguous: bash-5.3# echo module main +m > /proc/dynamic_debug/control since it would affect 4 independent modules named main: bash-5.3# ddgrep =3Dm init/main.c:1265 [main]initcall_blacklist =3Dm "blacklisting initcall %s\= n" kernel/power/main.c:49 [main]pm_restore_gfp_mask =3Dm "GFP mask restored\= n" kernel/module/main.c:2862 [main]move_module =3Dm "\t0x%lx 0x%.8lx %s\n" drivers/base/power/main.c:149 [main]device_pm_add =3Dm "Adding info for %= s:%s\n" We can improve this by using KBUILD_MODFILE for dyndbg's modname in builtins, and KBUILD_MODNAME for loadables. The above control-file entries then become: init/main.c:1265 [init/main]initcall_blacklist ... kernel/power/main.c:49 [kernel/power/main]pm_restore_gfp_mask ... kernel/module/main.c:2862 [kernel/module/main]move_module ... drivers/base/power/main.c:149 [drivers/base/power/main]device_pm_add ... While this is a user visible change; [params] becomes [kernel/params], it is not a behavior change; we now match the query-module against the subsystem/module name or its kbasename (the simple-modname), which as before, matches all 4 modules. This allows queries to be specific when desired: "module init/main", while preserving the existing meaning of "module main" The deeper reason for this change is not obvious. If any builtin "main" module were to add a classmap, it would attach to all "main" modules. If 2 "main" modules defined separate classmaps, both modules would inadvertently share both classmaps. Since classmaps map classnames to 0..62, and independently defined classmaps are most likely to start at 0 (unless author is planning to share the 0..62 range with other classmaps), we have a setup for later reserved range conflicts. Having unique names prevents future conflicts. This solution isn't perfect: 1. it changes displayed [params] to [kernel/params] etc 2. its mostly redundant with "filename */main.*" 3. "module power", "module module", "module base/power" might be better but would break old queries. Adapt dynamic-debug selftest: 1- Add 'test_subsystem_module_queries' to verify path-based module matching. 2- Use dynamic counting with precise regexes to determine expectations. 3- Reorder tests to run slash-query verification immediately after basic tests. 4- Update basic_tests and comma_terminator_tests to use 'kernel/params' instead of 'params' to match new path-based names for built-ins. And adjust Documentation Signed-off-by: Jim Cromie --- v4: use new match_wildcard_hyphen() to allow dash vs underscore equivalence in query-modname vs KBUILD_MODFILE string, noted by sashiko. v3: new patch in rev-3 use KBUILD_MODFILE to provide modname for builtin modules, giving unnique values that KBUILD_MODANME does not provide. --- Documentation/admin-guide/dynamic-debug-howto.rst | 40 +++++----- include/linux/dynamic_debug.h | 17 +++- lib/dynamic_debug.c | 3 +- .../selftests/dynamic_debug/dyndbg_selftest.sh | 93 ++++++++++++++++++= +++- 4 files changed, 126 insertions(+), 27 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 9c2f096ed1d8..8befb69575b7 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= \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" + init/main.c:1179 [init/main]initcall_blacklist =3D_ "blacklisting initca= ll %s\n" + init/main.c:1218 [init/main]initcall_blacklisted =3D_ "initcall %s black= listed\n" + init/main.c:1424 [init/main]run_init_process =3D_ " with arguments:\n" + init/main.c:1426 [init/main]run_init_process =3D_ " %s\n" + init/main.c:1427 [init/main]run_init_process =3D_ " with environment:\n" + init/main.c:1429 [init/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:\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" + init/main.c:1424 [init/main]run_init_process =3Dp " with arguments:\n" + init/main.c:1426 [init/main]run_init_process =3Dp " %s\n" + init/main.c:1427 [init/main]run_init_process =3Dp " with environment:\n" + init/main.c:1429 [init/main]run_init_process =3Dp " %s\n" =20 Error messages go to console/syslog:: =20 @@ -161,17 +161,19 @@ file file kernel/freezer.c # ie column 1 of control file file drivers/usb/* # all callsites under it file inode.c:start_* # parse :tail as a func (above) - file inode.c:1-100 # parse :tail as a line-range (above) + file inode.c:1-100 # parse :tail as a line-range (below) =20 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:: - - module sunrpc - module nfsd - module drm* # both drm, drm_kms_helper + The query string is compared against the subsystem module name of + each callsite, as shown in the control file. The simple module + name is the string as seen in ``lsmod``, i.e. without the + directory or the ``.ko`` suffix and with ``-`` changed to ``_``. + + Examples:: + + module nfsd # simple modname (as from lsmod) + module init/main # subsystem modname (as in control file) + module drm* # both drm, drm_kms_helper =20 format The given string is searched for in the dynamic debug format diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2d6983186f37..aee6f3d0916f 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -8,6 +8,17 @@ =20 #include =20 +/* + * Pick the best name for the module: + * KBUILD_MODFILE includes the path (e.g., drivers/usb/core/usbcore) for b= uilt-ins. + * Fall back to KBUILD_MODNAME for modules (loader requires unique names). + */ +#ifdef KBUILD_MODFILE +# define DDEBUG_MODNAME KBUILD_MODFILE +#else +# define DDEBUG_MODNAME KBUILD_MODNAME +#endif + /* * An instance of this structure is created in a special * ELF section at every dynamic debug callsite. At runtime, @@ -128,9 +139,9 @@ 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_class_maps") _var =3D { \ + __section("__dyndbg_class_maps") _var =3D { \ .mod =3D THIS_MODULE, \ - .mod_name =3D KBUILD_MODNAME, \ + .mod_name =3D DDEBUG_MODNAME, \ .base =3D _base, \ .map_type =3D _maptype, \ .length =3D ARRAY_SIZE(_var##_classnames), \ @@ -169,7 +180,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg_descs") name =3D { \ - .modname =3D KBUILD_MODNAME, \ + .modname =3D DDEBUG_MODNAME, \ .function =3D __func__, \ .filename =3D __FILE__, \ .format =3D (fmt), \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 996daf0a05b5..b6c5634096fa 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -248,7 +248,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, =20 /* match against the module name */ if (query->module && - !match_wildcard(query->module, di->mod_name)) + !match_wildcard_hyphen(query->module, di->mod_name) && + !match_wildcard_hyphen(query->module, kbasename(di->mod_name))) continue; =20 if (query->class_string) { diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 1239f1e10591..26cca9f24799 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -76,9 +76,9 @@ function handle_exit_code() { # $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 +# "-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" @@ -223,7 +223,7 @@ function basic_tests { check_match_ct =3Dp 0 =20 # module params are builtin to handle boot args - check_match_ct '\[params\]' 4 -r + check_match_ct '\[kernel/params\]' 4 -r ddcmd module params +mpf check_match_ct =3Dpmf 4 =20 @@ -238,8 +238,93 @@ EOF ddcmd =3D_ } =20 +function test_subsystem_module_queries { + echo -e "${GREEN}# TEST_SUBSYTEM_MODULE_QUERIES ${NC}" + ddcmd =3D_ + + # Find how many 'main' modules we have in total (by basename) + # Use a more precise regex to avoid false positives like [irqdomain] + local total_main=3D$(grep -c "\[\([^]]*/\)\?main\]" /proc/dynamic_debu= g/control) + echo "# found $total_main total 'main' modules" + + if [ $total_main -eq 0 ]; then + echo "SKIP - no 'main' modules found to test slashes" + return + fi + + echo "# testing 'module */main'" + ddcmd module "*/main" +p + # This should match modules that HAVE a slash and end in /main + local slash_main=3D$(grep -c "\[[^]]*/main\]" /proc/dynamic_debug/cont= rol) + check_match_ct =3Dp $slash_main -r + + echo "# testing 'module init/main' (specific path)" + ddcmd =3D_ + ddcmd module "init/main" +p + local init_main=3D$(grep -c "\[init/main\]" /proc/dynamic_debug/contro= l) + check_match_ct =3Dp $init_main + + echo "# testing 'module main' (basename match)" + ddcmd =3D_ + ddcmd module main +p + # This should match ALL $total_main entries due to kbasename matching + check_match_ct =3Dp $total_main + + ddcmd =3D_ +} + +function test_hyphen_underscore { + echo -e "${GREEN}# TEST_HYPHEN_UNDERSCORE ${NC}" + ddcmd =3D_ + + # Find a module with a hyphen in its name (e.g., from the control file) + local mod_with_hyphen=3D$(grep -m1 "\[[^]]*-[^]]*\]" /proc/dynamic_deb= ug/control | sed -n 's/.*\[\(.*\)\].*/\1/p') + + if [ -z "$mod_with_hyphen" ]; then + echo "SKIP - no module with hyphen found in /proc/dynamic_debug/co= ntrol" + return + fi + + echo "# testing hyphen/underscore equivalence for module: $mod_with_hy= phen" + local mod_with_underscore=3D$(echo "$mod_with_hyphen" | tr '-' '_') + + # 1. Enable using literal hyphen name + echo "# trying hyphen name: $mod_with_hyphen" + ddcmd module "$mod_with_hyphen" +p + local count_hyphen=3D$(grep -c "\[$mod_with_hyphen\]" /proc/dynamic_de= bug/control) + check_match_ct =3Dp $count_hyphen -r + + # 2. Disable and then enable using underscore name + ddcmd =3D_ + echo "# trying underscore name: $mod_with_underscore" + ddcmd module "$mod_with_underscore" +p + check_match_ct =3Dp $count_hyphen -r + + # 3. Try kbasename with hyphen (if it has a path) + local base_hyphen=3D$(basename "$mod_with_hyphen") + if [ "$base_hyphen" !=3D "$mod_with_hyphen" ]; then + ddcmd =3D_ + echo "# trying hyphen kbasename: $base_hyphen" + ddcmd module "$base_hyphen" +p + local count_base=3D$(grep -c "\[\([^]]*/\)\?$base_hyphen\]" /proc/= dynamic_debug/control) + check_match_ct =3Dp $count_base -r + fi + + # 4. Try kbasename with underscore + local base_underscore=3D$(echo "$base_hyphen" | tr '-' '_') + ddcmd =3D_ + echo "# trying underscore kbasename: $base_underscore" + ddcmd module "$base_underscore" +p + local count_base=3D$(grep -c "\[\([^]]*/\)\?$base_hyphen\]" /proc/dyna= mic_debug/control) + check_match_ct =3Dp $count_base -r + + ddcmd =3D_ +} + tests_list=3D( basic_tests + test_subsystem_module_queries + test_hyphen_underscore ) =20 # Run tests --=20 2.54.0