From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.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 51CCF2D3228 for ; Thu, 11 Sep 2025 21:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626730; cv=none; b=r3FBMP6BRVaou9zgFbjfROmJwCb8bXCJU8aCEWR89Mm52Op5oCy+gibj4yNFjSrv1Z/Evkac4GqHLoJTp0KQEqe8PBidwODkHHUFkYTDjXYKJa3RrdmwnjWKJUWhKA7mmf9R9Emh15ywh0+8c0pJ66hxm8rARufAax0KxUuyjhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626730; c=relaxed/simple; bh=B8dcsyyggwYCkYkKNypzvAZE2goYIgWDA5Tm6W1R3oQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HiRASeSWl5KlJ0c1/aL6T5J+V1eSeAzaegvZaAUvL+31l9W5cTsSzFMC9kdg6jxqn7tRg4c5hHg/SiS24KrTTrx+bkO84snf0nh09+af4xrAk21ipF+ryFxkv4WNrGutI3//fl+JnFqvXwY/27013cz5AWVgrlKN64Bbg04nvkA= 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=gGAq35Tv; arc=none smtp.client-ip=209.85.166.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="gGAq35Tv" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-88432e91223so28300139f.3 for ; Thu, 11 Sep 2025 14:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626728; x=1758231528; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7BFoISqrXfzunSW6Z4lpDyEbHwjrfmpqrwUs/T2P0T4=; b=gGAq35TvBKcIicmklCp+xUU4vnLwk4QZencGm/d8mqUTC1pR/NxAOShLtN2wD9+mcG SH+DeBYf3N56OKg4NW+p+MNzk6+bxoiKLQfnB1oOqbYZW2NdtTSSYaTd6djx5wrJW393 TzpzPyZ3/YTkMxZGfuKmBAnal7rQN9mEwIvzB390niGrqJHWG5h+1XB6tNAf2FPSIXwp Ivercm3+y0Bqn1yp+KJCl0gUYHiAXEZZ7W/poRJR0EHaRDKHEv+cXTyTbcrlob8mPkrU 5XACgu+yBW3rUg8YHaRXo2vOiyK5h2wHvFyukkfhGCTCY2nvyNSvaH6v1Gvtq8MO39Uf H9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626728; x=1758231528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7BFoISqrXfzunSW6Z4lpDyEbHwjrfmpqrwUs/T2P0T4=; b=hem1HO7+H3IsKxMxscybFsJqbToiKtSCzkplH2nwT9yR0+2jyTTOfUu3unogW0YUcv cDCvehajj3rh8BKr3FwjP+RsjxdptPyEYq5VK1pZlkhTB0PGuRSvuEcMsgLRvCPqKMbL 6t0uXldbmqSj2T2L1UVFf+rNJ1yDLAXiSVwpxLze+ENVvopz3A8vrxW4QXwiDxcy4zhb eA7c/AIVUEjKMUViWmcq8BtNwZNzCvjeZaLkcAiT2YgxhtPGqcc2NxUkdeNMe18BOFqF 3iNwoN5OSIehxMzHKyR2Xz2UQhNxjP1rz4vwXtWtM/rMxnmz9Z2OT+TgZ0G2pjFxs/W1 OokQ== X-Forwarded-Encrypted: i=1; AJvYcCU2CQR1EIjiWGcWjowIraXfpBGzbAPviuz3QLCoc+ceioY3eSc6NxlaF+XN3uGUCvRVK4B2sDgd+oIOqzc=@vger.kernel.org X-Gm-Message-State: AOJu0YxqnqwaCmy7M3VgW4RWAnkuDel21cN25PhNgw1PRBHQ1KA+upf2 3gBhhWEtuHcYgtczPkoRa/y5DPNeOeq0eBB6tj8w2fGdEGh40fnhYVDQ X-Gm-Gg: ASbGncsiKOACPpowH8JG07xyuRPnGgOWOwTvXf2xrW5+xjfrmM81dpq5oC9GnEx7y2i Y4gUIQnttTvuF/wKMkmJzsrTaVVujqfdZMRwTPyYTJdxvGyqm2g/lOnQ9WWu1NWgnmRNOLMx9M/ Y54s2ieBbtGY4It3mt4mf2j9DaeVBvX9W7jkQ7sS0cUVh/kD/Ceha0bizD/GM+gdp8xvWGVV6Ek s91+IZAN95sljnUBDYx2gttRpYlaRebY0F/YEjYioD8ENCAqwZDDDV0vfgjYjju8wox4pVchK9E ORoRO3ljxUSrpFlMf7WQq2qW2QdW/GX4WhEDDcmwvlafUGhWiCAebPeLaaZYPTqn8FIOPO01XEE gdP/KoSS+j0zXLNY5yn+AjTNPvEkVZUcapObdL7xdWjge2suJDZrwAuVkfmuPJC39Xi0kmAzFfC Oo6uW7iSwPPs3EjS06GG24noWE X-Google-Smtp-Source: AGHT+IFAsaxAsCEMyCugeiaW65S9mBpUgJy3/vIKxqg9NbJkKq6OXxYsC0/dbs4FSKSJPklmvSkSdg== X-Received: by 2002:a05:6602:7506:b0:887:1d1f:c2cf with SMTP id ca18e2360f4ac-890322345d2mr149713239f.3.1757626728253; Thu, 11 Sep 2025 14:38:48 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:47 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 01/30] docs/dyndbg: update examples \012 to \n Date: Thu, 11 Sep 2025 15:37:54 -0600 Message-ID: <20250911213823.374806-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit 47ea6f99d06e ("dyndbg: use ESCAPE_SPACE for cat control") changed the control-file to display format strings with "\n" rather than "\012". Update the docs to match the new reality. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet --- -v2 fix missed \012's --- .../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 7c036590cd07..4ac18c0a1d95 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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.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 27A0521D5BC for ; Thu, 11 Sep 2025 21:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626731; cv=none; b=kJSAfXiWkkalrl5DAMAURhSMm3c2lCm0WChaA5RBH6/ExYp1fBYkoo/P8VZ7RWPJjSkVz0a3sZ/eEOe2/8XaPaVXNN9of8w5APbNC/4s2ZppboFF0NGD4PZoyYfSDYrYxJ7bRl0d9ykqx9YOYXzw6xn0Y/X7ScAbOyWYcMo3KWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626731; c=relaxed/simple; bh=sPUfeSm5BrFc1JGDfQfBW2rqApZnuuum7JmLHXwQcOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L3nVybej5H/93slomv8Jtcm4+F4N/01lnrATwTEkOp+Ew5la4Izp8boYJBQQhELOO+QozdcxEY7xT2y5FuNrMsuQ9vYyn+r2LsB0VXNeEo94AkJg/RYK5qlBdyMeqVSpmU6aSKvOpNHKqYk3uKQuCev3yR4oLbe+ObXxxENT+PQ= 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=jXDYUqkZ; arc=none smtp.client-ip=209.85.166.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="jXDYUqkZ" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-88f49be4c21so34962139f.1 for ; Thu, 11 Sep 2025 14:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626729; x=1758231529; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=upmZ+84nb0PGLfZ0odEvQVtU0YnnK5GejiW4j5Z157Q=; b=jXDYUqkZIfafaaj564KOcErXS5ZpLDxorFCOtZp67qqNG1qB9tr76exfynfa7cZy4y UKcbgXoqrH9VlBhEsYwZMo4fwHBPam09gXnbLuHuUg23T8W3aJBQWzfTIgwZNKplLX4d dXLv42xlGN0n2MVxy2BCE6G2xgwRlru6Erq4IdPQvCgc3Um06Xglbq0/q7M5f1KmZPNV 4m1rsfO3j0p36bP1iD344l7ZaEaycXGKn9G4zo3ArAcFwFkyzRiMJKCwGw4r1ggOrF6R 2C9X1wz6GINhyBZq7xFucFWrDxxqv5ryzAMftciDTHSC6Y+tI9sfli6OJmbSmOmDLRZb 0q/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626729; x=1758231529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=upmZ+84nb0PGLfZ0odEvQVtU0YnnK5GejiW4j5Z157Q=; b=My409qU42+GACzhC+NVNNHdWU3SmhO/QkY2V+zJmEyoLuja05nwyd7DIQ+tdxriFFX +tt7Z5DOxqQKv6oC/xtO8y7AIumqKPpILU9RLIxyXEs46+lUL0fDXv0mOAZcwENx61Nd PEFL748kkmJiKxmchtySmhXwHMkuulrJKV6Xiw4VRcSGfCnpkhb+OLgdxILJ7NY3nNNb fg6KFQAVn3i4gSQUxcldrKxPKxgdJCMeO/sgbyQFh0ukLF7/E25cFmmtCiJi2uidfNGb UIn0b0sh4+x9w9Mr9STzKx2uTFzCGFOtVoUJsXWdx/xgY7cgM2q2ZSZ9LJuiApe6ridI zm4Q== X-Forwarded-Encrypted: i=1; AJvYcCVdLxa3MK2AYvvLSvA9lJfOsZwB1z9RhT/5G9SHU+i5DWjffOXUeLDcJcjy8Xolj1ZYE0xKONpfhX6OxRE=@vger.kernel.org X-Gm-Message-State: AOJu0YyKczOUSTSybq5jW2Qolts9CwdHCKrfPRhh0PrgLGa+5qsgXH0p as3GDOqgiJWX5Cv7ZTeAELtJ4xeDxJBe8k73EWPVsqyvGhGXS4ebgQ+m X-Gm-Gg: ASbGncvGqDM4y44kQwQ4R0wMjyzghRDv7qVbRjwbs30hqF0gss+0TTfujpDIFfpLNrt AUmE3dkhEwHlEFK1AtzOYFv8P92Pzu281fEklOnG9ij4cL949UEIgNUfuRJekyBl9G0d+mzGcdd QAN55JBh22tfwkb3GsMjeOQA+dcP9x9n+YwFhITBE5b68/WL6GWFQaPMXk7xYOPDYylXfDVN8st 3EQgVjxWipUT0wqu9k0SivepL5nIn9gSGoa0V+spU74ZRw2cRcUnSNoTHTFMnkG5hl7rIjj8LgN 4mF1PeIXQysFVIRLz5BxXg4zfbw8aWcOL5A1COWPabMSmPDZA8ntF7WHd3dyp8YDWZsBkpDmHF4 3xhfgnkXxkuuunm144nm7S+1c3l4efdsELlsvRy8DGV5KmM1g8miu5PX0/JWXl59Wyd+ExDjf54 3IwGU= X-Google-Smtp-Source: AGHT+IFu8y/WUPR1ooMKGsVlSMKShA3ec98P60+uCdhE86rchCRKo5RimU6XdoYh0nHTIMRHf5T/Aw== X-Received: by 2002:a05:6602:6408:b0:887:6330:d5a4 with SMTP id ca18e2360f4ac-89032dde9d3mr121777439f.5.1757626729147; Thu, 11 Sep 2025 14:38:49 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH 02/30] docs/dyndbg: explain flags parse 1st Date: Thu, 11 Sep 2025 15:37:55 -0600 Message-ID: <20250911213823.374806-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When writing queries to >control, flags are parsed 1st, since they are the only required field, and they require specific compositions. So if the flags draw an error (on those specifics), then keyword errors aren't reported. This can be mildly confusing/annoying, so explain it instead. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- Documentation/admin-guide/dynamic-debug-howto.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 4ac18c0a1d95..63a511f2337b 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -109,9 +109,18 @@ The match-spec's select *prdbgs* from the catalog, upo= n 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 +Note: because the match-spec can be empty, the flags are checked 1st, +then the pairs of keyword values. 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 | --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.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 348F42DEA8E for ; Thu, 11 Sep 2025 21:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626733; cv=none; b=d1sKY2SMHdgzSbpEWmK7DygPk2qHftpmHOFxPirWeyUD6Jv2pXOLSExwVn8IJegC2WCO8n2Wk5opl4q8zQA7LZzHCIFKGSJn1nY+Khh8y7gsyy2pJ0xdgTMuRu7O6U4WE/a57k20IAbdU5u9kc/DcoHjJZQYWxBDhJUsP/qV0vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626733; c=relaxed/simple; bh=9KA9wrUk/+sc2aQPuLDuiC0POPJjUDsXmXxrrpGdqRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YohvLSBTXZl4z/R4X6HDHDga8ZDdKtz9nsWczwllMCVcgSaPT0JAhpnG7rtmwTNewQrdf9zPFwNn4vx7/cIGrBZcKbSTXvjpq0UCG5CjBe8Wf6rDpKR5Vi1DyuZv4azBYS5pl9D1xatNK3k5k+0p+PIhSHZ50COLDvM1lheR3f4= 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=YRWRnkZc; arc=none smtp.client-ip=209.85.166.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="YRWRnkZc" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-88428cb5dfdso22008239f.1 for ; Thu, 11 Sep 2025 14:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626730; x=1758231530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cTjH4sGVjFOYrHuOXXQp8+DmE+GbVi2pPpgMotQBb8c=; b=YRWRnkZcOv05qVU1ZNgOeE3LNPAEU+/CJleeY2FYYSZo/JeEANdbrO6y6tD6ULcipi FHwdr7CDyHGB2i79mWkdLBMYpnMrLkuJQuQlU/0dT/7BxkB+zG9GKobvWQ+1Mi69i+6m zxGLHBW5lAn9FFWcRTPmZ9JVdcwWk/csoYyr67xaC3QlA29E/pTPyT5oFQbZ6u0/pUgq fNzu2apq8E/W6BByf7K6OsBQGUaISkESsnhdppJJtBoebbnbnbRvIvJPXdiuUJE4C5ad 8wTiTRiNRaahggsUeli3fIk37pMQuOivga4ACh7gkUqUWh+ZfXT3eEhEo4WHaHyR6XaX F97A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626730; x=1758231530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cTjH4sGVjFOYrHuOXXQp8+DmE+GbVi2pPpgMotQBb8c=; b=A61bt6Up5nojmzCXW9+pNp9W+/x6VItg9vdHQnDNu6eF13XCX3ZsEmiCHe3Ym6bds0 EkmuC4uCMYpcQl0NqzqyAZ4FNA/mRrnoxGVRM9sZUkqwwj/BXlOdG7o/8uCyETLnWTxp 1SbbeVkQ4OzqcEzKX+2Di0lTgbcfzPdP0mPvFd1o+3AjJUqeu/vtbeGP7ZYuUoTuzdU2 GGLchNGjPs+eEOM7SID5DbJIh1ab5VLP3YicE1SpdPl0BjKseUtQ2KhriUZlIq4mRTmH FV7u3+rfdrXlIs3CLS4DLBWjtJHh5hxX5+53tR0oKyJhtcDbOPrkj6fyF5jsYqUQkdHw e8+A== X-Forwarded-Encrypted: i=1; AJvYcCVV3Y8HvPn2Aag/ltZRaRQj7Q/GwApWLIPd22CDMU4LK0MEZb5UNJSgatNDe3RPdYFy2hyika0BO2Puu9g=@vger.kernel.org X-Gm-Message-State: AOJu0YxLOHvO6NJ/nzwmjR8VwOVn9ijDWKWnpDvdMxuFEajrLcBgRf/7 MnLo4ByHv+g4sIyEx9d122gHiIMng2MKuFWehc3IN80/agr+nISJVyuF X-Gm-Gg: ASbGncvj3VFYV6cQzinTm/W+6hp0jYhOei5XeGrNN7H/OOVTasQW8uSOFnu6gq6ZD+5 Hfkg5AhXCKWa7S0GAxJ12eyyeeErOTEOU8MBVjcnkCdIgw3QJX3h/iKcB0Et+zSCNlyjVJZV5Xu t/eQPmUtwDrzwxGcZ/iGqTrvn8oNY6lcxsrhToerlGyF//8A/eaYDsUkV+gkJhKudJWy0z5zJ+3 TuEM3CYXL3V8I5HWGlu0mMpR7XKMLn90qkwkr2kr9Br0Arlpeq2txGCjD2cejVYBMFczmVVrMvo zzAkaH6k75XfoUq+nKTXvdLrx2d7HoqECnPQdUUVd3LPrZd6FAQn1nrIIEv3SzDhWEs9KQGifSX MQJmIIHmF418yJK96K6qlH33RsPr/3e21+fxgUbYVmBFXuz7tpYWBV6cCLejzyDcl2m5CrihTLe LEkb0= X-Google-Smtp-Source: AGHT+IH1gSOvZ6qDclEA8b31MsAeYLLhFpNn+2r0dhyXlNIow1l+kg8aK2bzsc7ZhNqQBPhd6sA9qA== X-Received: by 2002:a05:6602:1585:b0:883:fc4a:ea55 with SMTP id ca18e2360f4ac-8902748830bmr161927339f.3.1757626730270; Thu, 11 Sep 2025 14:38:50 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:49 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 03/30] test-dyndbg: fixup CLASSMAP usage error Date: Thu, 11 Sep 2025 15:37:56 -0600 Message-ID: <20250911213823.374806-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit 6ea3bf466ac6 ("dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes") A closer look at test_dynamic_debug.ko logging output reveals a macro usage error: lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =3Dp "LOW msg\n" c= lass:MID lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =3Dp "MID msg\n" c= lass:HI lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =3D_ "HI msg\n" cl= ass unknown, _id:13 107 says: HI is unknown, and 105,106 have a LOW/MID and MID/HI skew. DECLARE_DYNDBG_CLASSMAP() _base arg must equal the enum's 1st value, in this case it was _base + 1. This leaves HI class un-selectable. NB: the macro could better validate its arguments. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet --- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 77c2a669b6af..396144cf351b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 /* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 11, MID, HI }; +enum cat_disjoint_names { LOW =3D 10, MID, HI }; DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, "LOW", "MID", "HI"); DD_SYS_WRAP(disjoint_names, p); --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.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 58D4B2DF14F for ; Thu, 11 Sep 2025 21:38:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626734; cv=none; b=XR0TxfAM9iLtIDjdpXoF4lfCPMKNuoexvwfoSeRHHPQoQFsMygaRJaLkaYMEFNVb3KAsFMzZqwmtB6BCovQvms/heLNortsZMD0PgeABkK8OIFHjCEHwzgmHkg2aGWYZj3MZ31U8aeUkpZ5INwF6VCw+lRK/mLdbE2UaZPG0+2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626734; c=relaxed/simple; bh=xfWOQ2T373ADf+tcgIBcHrGpfWd78TIqVBMM75aiZ8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t6MH5bsu/iOxmuo+uAlhKhkyHepxdUDVl7HxIOK3DhM/v3TTQpVfwGq06JGLlpFm1JLQz6Dhsx6+QcLvXj3J+C1CwHQ0P6u7mqZG9QiIxEO04r3LEYeemN4ru12udjnEcxXzfuaSxMnh79Tiiihty50j5tv1+hvhRrcU9FBUYME= 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=C2KK5Qks; arc=none smtp.client-ip=209.85.166.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="C2KK5Qks" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-887764c2868so99302039f.1 for ; Thu, 11 Sep 2025 14:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626731; x=1758231531; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCaJXGEEoKxacl2B/5AyBFFUSkEK+Qm7rR3SS8wI7Gk=; b=C2KK5Qks/dIwHmqxj2lY/TCr6bdz5h1ZjVewhg3pUiY5QVSizpAW7av8dkKvpF7rqQ 0o88KP0aDkEmXhed7RjsK9zm5xFyQMn+FfYsLCSZFJuSxNAQCV2csrLjKlFNX48tx7Ui bI7P2OYC5x3xxRI2svmzTI/XoxwODzv+psPOYBsENgDbUdgNG1r3ynNX3WW08s7k6GJT P6tymqkmRccHlx9x3uikzZvWaxdJnlVnkuhRD8eDEGStv6B69grnEar93L+RQV5LNCRx NfeN5PEDnYIsxkh3eD/VtWzvPUOh2g7a8K4dk+gZlakGvjYqGq8qcVSAYKz15mjeByKK fdyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626731; x=1758231531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCaJXGEEoKxacl2B/5AyBFFUSkEK+Qm7rR3SS8wI7Gk=; b=Naz34glhT8bN94DIjlvF4x3d4CFPQxtoje+mdJQqX1JW4VdG1HolFPOOzmaTB1qboJ jLu2cd6UZ8og/lS41ONctifJtWlEM/JiMscRAJLN+gSqCLr7T328OF1o7+FTYUm1JBcE ZCIx7O22i8S3sfpBhzO8PL81ViRxlZW5xaUdZevBd40rZaxAv0TdTnzsects9D6T7E6H Qs+rin4CBPVWE78uVKSaGxws9q//akHteEUfz44u2C8songdH1XqHKyaqFYmqFJLsXgH df0kq/pSuSbmC2sSx5ped/I/kSt/e/WoAZNkjHyCtR1Y4vQ4bbEZYbpqC54LIwrqsKy8 CgwA== X-Forwarded-Encrypted: i=1; AJvYcCU2U2JqNa5f1eIJd8Z/J511Bhh1UJUCuNAhYgmiuKokhh0McqR9DUzOaLLkT2BJPGU/jX7Z0L3z2K8VYgI=@vger.kernel.org X-Gm-Message-State: AOJu0YyR8jh8WlFe2i1ZlWdd7xE7wcKispEyZ4TEUOtu8NZcdGCQY3gK JznrB6lwDHPAaqriPcWGJFZdxRKmEXuV9SjSG57TIXbTt7nQz1qZc8HxzRlbWw== X-Gm-Gg: ASbGnctmzONSSW6AeYT3XgbE09DiBEMGWML+6CPpoIHnNJlzkMUC7+zCTgOyFKKT4Rd 5H20WbYR/IUTYSqJA8a9quu0ASVMuJVkobykvMmEhtbnnacjJTtQ+ETu4rK/NFvrf6OhshwAa2f pM6pB+lQqp2audsZ+Zn5AoGcl0skECW9mPzZBaw/K6F+jrswmd3yG7umGkkTwjEHGJkfGJjX32E WrJ3aw4TpZTT2u76+Xh7H493LdgFAYrCPBUx1TdQk+AAinz+UJKZZ0ukIN0jM165OwTaiz3/qU/ /MkKKP0mceT7ZVXsGp5qeWvnBNqSdp0/3LurK48Utuj24DgoaConX/YkeSz2hoWV2BO8G0B7RSi 3zRS9Cr5oKXBFK1eEmA8gHoIYx3IeWZvNQ8uuWcbZt0ZMSDbL449hn9tXJuAHttmrD18M8A7Y24 5jYhQ= X-Google-Smtp-Source: AGHT+IGiax82XsUothUdCl5sAN9TU31U37fERUoxmlfD7pa0eSePddsRUvkK8lkSCbEZ8kTAikGGFQ== X-Received: by 2002:a05:6602:3f88:b0:887:773f:6c89 with SMTP id ca18e2360f4ac-89034710bf0mr122833339f.11.1757626731288; Thu, 11 Sep 2025 14:38:51 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:50 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 04/30] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Date: Thu, 11 Sep 2025 15:37:57 -0600 Message-ID: <20250911213823.374806-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a dyndbg classname is unknown to a kernel module (as before previous patch), the callsite is un-addressable via >control queries. The control-file displays this condition as "class unknown," currently. That spelling is sub-optimal/too-generic, so change it to "class:_UNKNOWN_" to loudly announce the erroneous situation, and to make it uniquely greppable. 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 5a007952f7f2..147540c57154 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1154,7 +1154,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 40FB32DF3D9 for ; Thu, 11 Sep 2025 21:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626734; cv=none; b=Qg6d/HjgWlQNVIXHS9Z0munQ6406MTMd7KuRmQwdMzWhuKlbmZwyMj+qyCTzAmlRpymrc0NQ0SIqNVsK1NZGY4CLs+lkrZBlpzdqQesgJYNyFU39gGVJdz6bf4/YA2Aq3JL4zEct0qR0qQNyG6GYrtRyVk6nv7/S1H8liFRxnVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626734; c=relaxed/simple; bh=aKMTvHoFGMDwM92wFBmpn94LIVdnLgrI2RnhwdRN0GY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QANr+BsBAPu1cGLLcmZ7HmDmTflPzsNmAOmQY5Ta/dCmuXhzjKRzpahwjXJccDh3GGRfJuWGYeBMyySTBA++itI4cDqhy/G701F+S6ucTJwdWXZHb3ZBBPpLvXgxgXhTOSeiUbqY5AvMsS+0gPcQxEVC1XkQ2nSOy8Fr5cvUAlM= 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=Hid792jo; arc=none smtp.client-ip=209.85.166.46 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="Hid792jo" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-88de776ab4aso48723539f.3 for ; Thu, 11 Sep 2025 14:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626732; x=1758231532; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+5lAaOOjCc4ULiFrsiLFYK9hqRtLQli7F1TlUXtnya4=; b=Hid792jomubTdwx5JMDv02Md49ng0hEUpAO4poBUT2/XPQZYwppCPiogYLXXzTLoBa wIEGttEWCKiadOOfcpJzaKoN6xdW8Tjht/SzHOojNizYG1yS3Y1O3o+2c2SNnwUuTIQm ASRYQul8TITiZux7o13h/UwXLrOx3lcZuucyVmT4W3k06tggWhvsKcmEbGY3WxGIgLfO fytxfSz+QusfDyrcr5BodRdXg1A6O1teA3MdxDfIzt1Lxq71BEsY0RvNJtiSOAwnjt9P T/3SoXz8/VXC+jFQ/px7yhgNwGsWK5hWSPb8Rrsf3BVjpPkLjNslMF/ZxcWI/96bnv9D uIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626732; x=1758231532; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+5lAaOOjCc4ULiFrsiLFYK9hqRtLQli7F1TlUXtnya4=; b=JE12jnX5ODF1e42269zh8EzLPCBiR7VgRxcLxt5+LIh39BpAOcOPl50RQPh1VS0Xcc UtY6V7eO9PavBsG8Gm+6ayq8URNdG7qBGAqoFDIUnjB8jvaU7Zy+W7URKTziV9iAod4S WabWdYcNKHVarQNzMTwsUv5P8X61Qqq0SKwMJw2K3y07CRbA4pK9n69e505KSzr4n5+r PDlla1RujOkw3lDULZJNTa1oePVV82SNo9/oaLL0KTGyL2Rd4fnYc889TUNWPs2M6SEQ FZ6cKQlstFUnL+DpZgYyZWpmtrAUVhvgn6T2itrGQkL/c/dG50KG6g/jReawDaehkOxK emSg== X-Forwarded-Encrypted: i=1; AJvYcCVYUsTyGfpuTrS1bGedvazW+JxZdWVqc8L43JMVJkhsLLkNJvquRGreldAV2sRZHbekUMpyG3Y0KioFC6g=@vger.kernel.org X-Gm-Message-State: AOJu0Yxwi24QJo8rJ+dS8N1PEHzUtK9LoWcnvvvtVqcefI12lgqK8A1J kpSKvmQD3VRRh26OYWInEoiIj7R+MCSjQclZmW1kpKE44Q2EKZkKaMbL X-Gm-Gg: ASbGnctHzAIMXmdXk/VHO3yGpSpRRm+uxuGQ5mMOXHdRmmFtnspR3PI7VYbO5pZoghM 6vX8sz5mwvdgWPPFjx5V1u9Jwnayqw9aQHg/d6DnwwY++QI7EnqMQMWX1jeOmxSeyHjKhnnBlKE 8yDAeqFDMMQyUgxbleX2XNGFpqDoRVdSUG10A9oewwubbbICyVhBGCpedZ/UWEg/wW6/APZtSK+ P2XPnvkFZR5qKXJtf6QgPo27LU3dqdBABQZ3Loh1xvw+nX85bwHjWJJkfFyZZWQ735ZQyLf5ApV a3qOYg9qswvxXMEopI5yXtB52zNqGyH7mztma5x9S/TYKAYgknQGllD6Zg1+e4U68i17q3UQVMB YUKqubG2RDlYFZ0DslqB3fAUxIOaeKHQNNAznwcTFKL7IN/CHxBS5k/sKTNGCmLGbQYL1jHtVRw HYnEgRzGmCKfH/cA== X-Google-Smtp-Source: AGHT+IECIzuZpAKsEFWFlKexW899VlLOvzhON2InCMoHuSwn0vJlnSXcgdlZwIYxof02sui39joAHA== X-Received: by 2002:a05:6602:6c01:b0:876:adf1:b263 with SMTP id ca18e2360f4ac-8903280ad34mr125504639f.6.1757626732193; Thu, 11 Sep 2025 14:38:52 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:51 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 05/30] dyndbg: make ddebug_class_param union members same size Date: Thu, 11 Sep 2025 15:37:58 -0600 Message-ID: <20250911213823.374806-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct ddebug_class_param keeps a ref to the state-storage of the param; make both class-types use the same unsigned long storage type. ISTM this is simpler and safer; it avoids an irrelevant difference, and if 2 users somehow get class-type mixed up (or refer to the wrong union member), at least they will both see the same value. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- include/linux/dynamic_debug.h | 2 +- lib/dynamic_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index ff44ec346162..b9afc7731b7c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -124,7 +124,7 @@ struct _ddebug_info { struct ddebug_class_param { union { unsigned long *bits; - unsigned int *lvl; + unsigned long *lvl; }; char flags[8]; const struct ddebug_class_map *map; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 147540c57154..55df35df093b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -799,7 +799,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) =20 case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: return -1; } --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.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 E94392DFA2D for ; Thu, 11 Sep 2025 21:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626735; cv=none; b=WB4WAD5M/uL+m0I+H78DK7pBKhfFK6/w1UfFJ/Ap03qYfEfCuSOqE9VYef62Q0cZedtSd5V4jgGdquAEEnLMl9rmFP4JFnJ4gVXH5W09sulIj/ZBiqvykeda71HrZj5pg62a7h0IQlwd4F4TGhEYztmqBdEaznXhovMRw+p5rLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626735; c=relaxed/simple; bh=fpFcDi6ztz3oxTgd6RA0bYt2S3BzBQJFxjJY2ObCcT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CE2jlqyMC2We4evDTPSB115zmTyKjnumAXgybnwsyT5zfe7iusoCqKr7zOsX5bFuT8v2raJyQ5NgzPwgg+51FFHZNL5b+Tt+U/zcERnD++o524gqZ6PHHBPbd8hsqnJf1Jq6wk0t6privYXKgRkxI717rqRnSg3ZY3QQXSKV0SU= 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=QSkOG4hu; arc=none smtp.client-ip=209.85.166.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="QSkOG4hu" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-88428b19ea9so66677639f.0 for ; Thu, 11 Sep 2025 14:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626733; x=1758231533; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VFKSLN6BiOw7bUnN4PQUQFUZxRNUkszMTNMdPxBofl8=; b=QSkOG4hu9o18LlBvi3DXLxgd8+ZE1zaXWCs7ougSXF+iUSTHxP2fW43dKGnWVckdvp MbFlZ/Q+JOI2NT8kmUuCB9TLFCRheBL9LZeA8zsCAfdgWf5ESc8q4plf7pfX8xl/eFrS qHBgyEV3mnh4XD0bG2pn4oVDSBs+WALxwwI6g5SbtgmIJmfu9pArqnbFT56pEDByuXyV VGWXxflthnqh1pJDI82K4fEnfkFcPqRACJIiR9U8auYS8FaWBFf+HbckvnVUGP/gAQcd zcUGZ9IQ6dM47oC44sseV5SKFmFwHIhu9ve6s13FvhoPw2EMR6nOyk2pjKKGmLzjh4QX L+Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626733; x=1758231533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VFKSLN6BiOw7bUnN4PQUQFUZxRNUkszMTNMdPxBofl8=; b=vZvtuXoTVHHMKGzlotNSSb3xy9/vpKYur1BbO8kWjCE/FxlN9mzvI9gNRdqePxDZml Uap1MqMplSc9HKWXe7MaYNoxnVT/GGvOX0qi7dvjDQSSjNIBP2d36wBX8dR8Rp7repbz adCHy7kR9Z7jQ0eqZ/1wOTCaLB5qwAlUqNuO5inZ/nToIrYc1VlgJhaePMSkoVUjEBeJ Hs1qsa8wp+EzXhi/lgV27vNmQNGLdUvBPo287Nzwas/9buvjdzfuKSQncA5C2MJpg8Hk Mv871DBfFAE5ssF6eEVXShMWSeETLu2LMIbYfeoKvV2Qrf6S7pAr5BPtRc+MQ81uHmNj ViDA== X-Forwarded-Encrypted: i=1; AJvYcCXrP0EaQ29ULpmc3vwZDLyRItuAAUtf0w4NDM3UE1vlRrRuhVSiNmK9vgetSMNsk38eA/eravIBpvPoovQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxiudiPqf0BC+6JM+aiLNgar8gqAAJz5SSWkV1is1ZlUfcLpxUP 7Gys2J2y/oL0BP7RZ7mIBbfnNnm0Ma6PHH8dbIbQUGJ3ZWb8Yn6Vwgik X-Gm-Gg: ASbGncuv5PeslKlaOu2sGEPLnq3Lc3lOfreAYOPK8oeUYToYVxkeUEL3qt4f4qUuZRl RMI04M/ytXL/Q0VRey4rAffAwMjgdGB5oZlzW4TGYtLE8tAW2Pmuw3uEhXq2LVcrPXHuQlMdtLv 5oaO878GJHlv/lDWWfUAeRjV/xcYkrcmmKyzqAgLPaOyqTlFNBsnBGVKkd2ErgNXBKvGy5Pg9mW FcqTfIVkxdm8v4qvRzjZJYj2Aqo1KUVOEgvzDuufurEEwlku0IpnEKJT/R3UoRvSfudzElfmeZA 41dvX55sWhlu5RYzo10Xda8/CUjW3r1Oe+MchUthNVNtay7WvJuAg6l+16yh9X7sU9dpdRxWuzK gewDNwwdRM5y7kNaigaDEENCCDaKmg2B6L9VUYnNpvrLDHHegFFQsR8gHK48I8brmT3m2mOI1me W4sgXxFv928McXfQ== X-Google-Smtp-Source: AGHT+IFBY5zUTFu6EZw6SiZDd2+zTRUptGzCdAlCjq66qwlqZ54EjENB9XTXxGyYv6RxSPaHAcUXJA== X-Received: by 2002:a05:6602:1510:b0:886:c49e:2839 with SMTP id ca18e2360f4ac-89029f4127fmr168162639f.9.1757626732974; Thu, 11 Sep 2025 14:38:52 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:52 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 06/30] dyndbg: drop NUM_TYPE_ARRAY Date: Thu, 11 Sep 2025 15:37:59 -0600 Message-ID: <20250911213823.374806-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ARRAY_SIZE works here, since array decl is complete. no functional change Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- 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 b9afc7731b7c..ac199293d203 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -107,11 +107,9 @@ struct ddebug_class_map { .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 /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.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 F37B02DF138 for ; Thu, 11 Sep 2025 21:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626736; cv=none; b=okSDYWyvuaPFs8xDAMD0RIOKNrDtLSUDK1YXLBtrcSjCYvUuM51BI3y/egAe62Wm4JSPKwA9EZO3Q8l0yozJfzMlmPSpkMCZld1fCZu2KVU/YaSGDniYY9GsKhC2+tjUPeMvTiVgkj5G89y0h50XjSjm+uPXFxshXtfXYtGaV98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626736; c=relaxed/simple; bh=kfrqrzBKdI5m1IsAj48HkDg3z3FjqKlovuaaRAQV+k8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DliHpQ3D6FmUAXtiCRFS5uOHXiW/GSLV0ytyPhzoUH36JApL3Ny9uY+BMnafdNdJSM+F3+e5E0MF+suutE29GGLEP28aQB5dQC71pj9SrEe8fTAAWePgzQ0zlzbBYf78xXXROH6sXMJ83V9HukdD0wx4zDmWAUDu10+dgTBq/j8= 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=nUZmkrhn; arc=none smtp.client-ip=209.85.166.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="nUZmkrhn" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-8877677dbaeso29816439f.0 for ; Thu, 11 Sep 2025 14:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626734; x=1758231534; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pU2dh1AcXNpIKiB0LgzN/RHkM4liyYcW5Vvv24TZfyg=; b=nUZmkrhnrkcDAdfjmFRmXtVELBAbNFuVbIFJgveuEbUxD5XeTh5mzYk+uxdYurTx7+ jfAsH3kjRBqHc7/3FJXdVCrbIpyh2cb4lyFhAQnv6GeTwXcNBJNN0VHZTIaZgGvXAYcC bZnkA4+aP+19L+AHfcHKWYmGL1EcG/S1LsTQ23VrfnZoC2qrSg4L3ar6S0puLbtCEo0H eMxQtgvshtHPx5SY+KBDkVvUjxo1w/7naqx3BNEpZqtrLqbUfUjsoj6fwh3We3bB3PJJ 7FbOh/4qN+mN4u37qcmKsvCBHiii94zdbjNfvwYp17KUba6GXjlTkOnS6m9P5rCiaF2S GJDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626734; x=1758231534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pU2dh1AcXNpIKiB0LgzN/RHkM4liyYcW5Vvv24TZfyg=; b=cfrH6cCxm3jPvnapJA4eF9hYQm7JVoCruMDcXTNplDUKPz+COfwg8iMti7vtLqpGCA Pk/77qSZjoIQAFxGyyKFOVgI6badIjwC98ZacK9MfKJAr98y5gkx338Tgp5ah200G6Hm VaK71KzHPENsv7POfwvUBAzEcju+2717pYdPUgu1lhZqcfAVG2smJz5Xodt9cabiAIic cWLvIz0LYy/Ba/yQDtHHYZG9d4ups1Me6MeRvPc5QspyLXG3or7h42X/FszBfjPLPAEV +6PjSJ5kRaiPek3sC3lx4bn6DxB1GN3XsISwAk3uY5H/WlCCa1zbqB47/ojpx4lE3IM9 Udzg== X-Forwarded-Encrypted: i=1; AJvYcCWcaLI+94+G/ID5wRAEZH8v/uJgf4o02Y7i7GWxPQ5lmTintFLabGt13i/yzLWOuWpwT0xqOlXjaKeJTyI=@vger.kernel.org X-Gm-Message-State: AOJu0YwaEy1y+syk0lqB0y4Ds6TVW0onfRU+PdE93H/M5qteY2T5U3sj 7KhANIObI9Hz8w98bdRO++qvf9eqacWykUc7bvd/YTZuIHrUsuqLRib/ X-Gm-Gg: ASbGncuJIwdqEAuzxidB2JkV/nnJW6BUeGmPELcBQYjcyumg1fwd5Zi+3Rp+Z+ledk+ UqnDKZ5ExShz49R7E24bnKpebiE5pw9eaffs4E7XDDZs5iLBmd23T77sXhmrImYdThTru+PzvlX CyJTXDJzFJaty1va5t1OBx3RKOx5SyYk/XwppnTcXOrX3bUHodZWJA9nEGrDtdth1ZkTJZHYHaa ugB+hq5C/7bE34Z63u6+i9ebfDgy2weKOt7lrbB0GpxkG5x0ezwXfKt3b/43DFGsT0IdKuTnIkc qvtvfae7LNLBXrXx0avi4KYDWy4W15+nQrMZeTSlqz2vzfBNh2mXQHNvoND4XO4rHY/n8psmRi7 vxR6C0awMda91sB1BldWLiq7rkLD43k+VzNK7QLr5VGP/ZiZHpZL/Id6AbXxybpi1XtXjJlbFVP Oy3PjPOTG8de7/lw== X-Google-Smtp-Source: AGHT+IGq/bsKwq5FiX0eWOdjNgWpXbASW1tUrX21YO7tYwHijODsZ+hrvU5H0+HSy9a0/Sga6ta6cA== X-Received: by 2002:a05:6602:6011:b0:888:826c:1902 with SMTP id ca18e2360f4ac-8903280bcf2mr143062639f.2.1757626734072; Thu, 11 Sep 2025 14:38:54 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:53 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 07/30] dyndbg: tweak pr_fmt to avoid expansion conflicts Date: Thu, 11 Sep 2025 15:38:00 -0600 Message-ID: <20250911213823.374806-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Disambiguate pr_fmt(fmt) arg, by changing it to _FMT_, to avoid naming confusion with many later macros also using that argname. no functional change Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 55df35df093b..2751056a5240 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -11,7 +11,7 @@ * Copyright (C) 2013 Du, Changbin */ =20 -#define pr_fmt(fmt) "dyndbg: " fmt +#define pr_fmt(_FMT_) "dyndbg: " _FMT_ =20 #include #include --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.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 2F66B2E0B4E for ; Thu, 11 Sep 2025 21:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626738; cv=none; b=S4LQ2QnxI0rHOTgFGrLmXkqm0k55hxKCiZAfhlPTHzewQ78T0pVXd7ymYStzeYUZjD947FRzpIVLLK7HUq2a+Ze4WfwQkolnJNWwYs11zG295CAjSv7jXxgD9NsywNuB//kfyg6Cr93T2gXUj6vtsTjQFfokPxsn8iYkI7dhU3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626738; c=relaxed/simple; bh=hD0GIkum0W39jX0UxEzb2WfDmaFO56evPVGPATON4xA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OGhIUH0YWFDhd4EThysPLrE5klgyX+dYafW4M9j3CGjnNwSHcC36ckdxMpsAjJ6DCj+Onip0yzl/PHZJ41YwG0qOoZ9lU5xGCagv6dt89rnU5Ao1TpyEcAq6oYx/PiWdW27SpifdWxRaK9gnPaVupruIjMk3+8FxA7hEv1ohmHI= 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=WogDl5sU; arc=none smtp.client-ip=209.85.166.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="WogDl5sU" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-8876462a34aso45618539f.2 for ; Thu, 11 Sep 2025 14:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626735; x=1758231535; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qxHzW7+krO7PJKBXdtqexN2OJeKAsxXfOckL+sZhGvs=; b=WogDl5sUPNIPZH9azW7u7rFL6iSgVuIV1udFahONSX+5SqTcjL+HnrLhSMm6Bdrmn2 h0UMNUE4/onZqEyNC4hBNAEYg/Fmd5LkIhqlCBSHX4PzZkFx9SHW83r5zZQ1Ka3vngzF KW2WGAK4b/PDu1xj0LnKDQvW0w2I7am6jkSKjYYbgg9i09k8xKeIQ5euRdta2AwElPu0 +qFQlmedwhg0SQ6DiZ0fvLuFkwhbDnFvF2+zGKZPfj+KDYghPezk2Geio9QhbrLVE5bO C8cNQyW9GeR6dpd4iHFl7AmCqT0biLwvJjJb98czxzUWxPV4XglY8iu+Clb88hTwVcDJ lRrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626735; x=1758231535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxHzW7+krO7PJKBXdtqexN2OJeKAsxXfOckL+sZhGvs=; b=os2qVg2raqX+o9Ea7d1n2Iw5bJtaykUTdGz97cvksZOzQg0/LyPxXPd7gBuJTVsMs5 brBmgX+TUeLUo22yJSfQejEncq5C0R1CVL1X9LqqrpVnf4aDyPhlGzQws3iO1pZGoVta BvbCwJqxCCX6HR+0x8wySitba8tFUdWJwQrfvegaWELmdlTkhCn7JhBZ46M1RktpRJaW XFv1D4y8Zhv1ue4/dMATzcdi9aqt9mANBc2ArECZLVaL4nOowwG1obgd4aVTzRSnS9OZ 1Lcs0B+J1m3LH65hrU781/yg5H8FkPNbpV6N5aMMfDREXG4Y12ub+WriK9sCw+m8aqli 17UA== X-Forwarded-Encrypted: i=1; AJvYcCUj48bDR6roqnzxJm/dF13WhiZ0/xcc86EM+82/AYUmWzzZjvrDoA2nwXrmT2DN4cL6HibfWkZdCkBJAhk=@vger.kernel.org X-Gm-Message-State: AOJu0YzGH1veDNKO5/sFyppMKPDfdjqtsIWYHJ2ZXyuv3KV1plnyMFNG ZWlLtHlQ3oWmXYcydC8nh+Fi5CRnBK8Zjlym2WWoKESmQCe7zEVxll2T X-Gm-Gg: ASbGnctODjEqB/ukAY60H9NO6xx6MWe/PiItWenxcFaaAZwCZ3lYrCVFeEN5ZsIGX5N MjmfoO9WNnFtXYo+/lVtmsdDrFSaFG/tkLM3pSS/9eNyXL5FRjD3Mgfmsjt4JBUC5TGaTdb8XkG rUj5s/jXSIwJanV8/Vfc8hqSo4lsPSyfK2n0yAmJns2QnlP8ikGWH/WT/+ZdyHJ80hb77uhdDt/ 8V2Oa7siC7PxoXHupRu0eZVzBY0Al+4IP5gIUluCvStRVWJTfFqpI8zEUxHH/DeuVM62wHxXl8u pCtY7xSJuMCMguTVh1P/KhzPVeS1iFV4H8qT62U3AB4sjXsYEQCSIkKwpzql/DiD5Tvl+BMBCHd c+lEQmvClXuSNGH9ZE8tvrAp0dP525s+0/2c+ol/BDqRkg69+vFHd28Lm7Zw60fJVXllmjx/TSi CG2wg= X-Google-Smtp-Source: AGHT+IGh9KtrmwUXbBUhRbdqOIpY0X9fwGiso9A7YS8mL36vMA5p6Pja1GH+UWJw/1itbJF3jNefkA== X-Received: by 2002:a05:6602:6cc4:b0:886:c53c:9172 with SMTP id ca18e2360f4ac-89034fbf057mr112259139f.18.1757626735164; Thu, 11 Sep 2025 14:38:55 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 08/30] dyndbg: reduce verbose/debug clutter Date: Thu, 11 Sep 2025 15:38:01 -0600 Message-ID: <20250911213823.374806-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" currently, for verbose=3D3, these are logged (blank lines for clarity): dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' dyndbg: flags=3D0x1 dyndbg: *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: parsed: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0 c= lass=3D... dyndbg: no matches for query dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs That is excessive, so this patch: - shrinks 3 lines of 2nd stanza to single line - drops 1st 2 lines of 3rd stanza 3rd line is like 1st, with result, not procedure. 2nd line is just status, retold in 4th, with more info. New output: dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' flags=3D0x1 *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs Also reduce verbose=3D3 messages in ddebug_add_module When modprobing a module, dyndbg currently logs/says "add-module", and then "skipping" if the module has no prdbgs. Instead just check 1st and return quietly. no functional change Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- -v2 squash several verbose cleanups together --- lib/dynamic_debug.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2751056a5240..d9268d051a10 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -264,9 +264,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 @@ -499,7 +496,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--) { @@ -513,7 +509,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) { @@ -529,7 +524,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; } @@ -539,7 +534,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) struct flag_settings modifiers =3D {}; struct ddebug_query query =3D {}; #define MAXWORDS 9 - int nwords, nfound; + int nwords; char *words[MAXWORDS]; =20 nwords =3D ddebug_tokenize(query_string, words, MAXWORDS); @@ -557,10 +552,7 @@ static int ddebug_exec_query(char *query_string, const= char *modname) return -EINVAL; } /* actually go and implement the change */ - nfound =3D ddebug_change(&query, &modifiers); - vpr_info_dq(&query, nfound ? "applied" : "no-match"); - - return nfound; + return ddebug_change(&query, &modifiers); } =20 /* handle multiple queries in query string, continue on error, return @@ -1234,11 +1226,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(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.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 3CD632E11DF for ; Thu, 11 Sep 2025 21:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626739; cv=none; b=Fo9Ca+lIEnVK74baTszfgFbmsdkN1EKNKyYv3ttc0GmUYM8brWtXS9XOFeS3qTKJPiafCBH+xAZXQIWm6iWNRw/OOzf4fgn4LYsFDrhJnxWuLS1dkI9NkW25IR1+GMtd4gMQRO5cqNx4hk5Av+rJJzMfSAv/Z3AFYxWExMMxEes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626739; c=relaxed/simple; bh=9/CNm/qErK1SavMH1/i1nBZVahomfVgVs/AAjSYrEHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GGYaqeBhHTBJ2CkEEH5ns6n5z8sj1jvfNmklXULC/mKZWkgyMZdFdhZGZ+44WwOdQ3by/QiYa/JZqe8eyf/9EzB+nQa2rdpacXDHd/jFudrxrzFjgpo941BEYfeWRKC/dRUqugRiCEBc4MUY88Q2im3TR9dUc5VKIEFS7SO5GAc= 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=VK6QsqKf; arc=none smtp.client-ip=209.85.166.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="VK6QsqKf" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-884328c9473so27507139f.0 for ; Thu, 11 Sep 2025 14:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626736; x=1758231536; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QSi3Wv5G5XIofYUm4EK1Li8HBZbPI3ZGv4Q8D6oYWPg=; b=VK6QsqKf5MSkhlPKzl2p4lA6P8wL7t7tPW4IA/bpsq+Mzt6+yP0YBv4c9uJexh7B0C CWpkzsJ5Q4ma1hpNUCI+YPdAPI1m7/pBaB0eJ0SX9FYSppmMLRtIIEgDALFco0faDx8M GZjIrVRJiVnwM/cTXzoVIUK05v9VuYMHAaGdo+3Yr4qFu/dICug5U+20HXIbSGHP0gpH Onb+xq9V2T6+SxiR3l7nPH4MSJjc+y9lQcLHMWyj0BvWkBllpOEKBVANDB19D898Tkcg 1jzU8u7C/RoOgJvmsqBGoolCkbrIyJFVGO355gwGWWseaIf9jzbE8G7MRGDd3qEnTp3O vYjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626736; x=1758231536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QSi3Wv5G5XIofYUm4EK1Li8HBZbPI3ZGv4Q8D6oYWPg=; b=gBlxlOJQSDR1Yv5us2gwR57AX37gNKKLEY4eN9aLbcYpPcxuQM0gj4CT9ds24EtGYv kX4AzWoMX1qcqLJ3hgHFk0Scp5JHLC+zvPy3OC4sRx9/3bFZ/tVDLK8XkXCYwDdP1zQg Q4BrSPlT6ReYZakagU/1nQsjGuA+tw2s4jx0Di2FOzm9vgcsNYV5lYHCYYyoN/2Y6Qfv eXnz8n+sqGfaM2eCsHxqJVvEYSVjh8ydStMd76pf3adSg3s5H7ACOKhFI+hTkVomgIC5 5OV2DjEyjF+0mPXP/T9lg+7TT61t9+qmotCXmFTurRA6pyAllHS0pfDx9dLJJlU5K8x3 76Zg== X-Forwarded-Encrypted: i=1; AJvYcCUaK4Eh5C6bI6QGc/GGP6W0VrlptewMLLiiM82XZytaXLfDjhUDGHAyxReNLFgPEQxSM/mIlW70aVifYJ0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1dLJpKK/P1764OUh4dYuekhyE86oFZMsnnDiqvKvik21bvseD CY2GYVrCyAxDdh5D98r/1UWQ8dYrLP4ppMhVG6Jp/geMwmcE8lfkg3+6 X-Gm-Gg: ASbGncs0h8WTmGuxb1sxuLAZJAy1F/X4dsmjQdX9VkWo3XrXE3sfSfvkRzErdSgqNxt f+NxHmv+dXJis2YqFigDJSnNlOQLp11n48ImIwrzUgKK8qAMjlDdFUurRlgbUU0QITR9kPGV1cC dTi5935wvaNuEUXYb2SaBNl0hiG9JcYzozuryryx5aq2c9ZHE25FRhtm70VuvO7WSXsKuitzaN2 8itj8JeH9Q7RquO6JYHt4Bo7nnuw/1XnhnIQdRp9IWwfcKN8fJmppp3qbcEgfLbi2MmnfDQ16cQ yCaV4etk1fcciMqlgxVuecHnWAwGNUOLH655S5lZ8uEPJIdLlS8AO2wYC29dehqEOM76lNMPSc2 NXoO3w+LJ/+WXOsHCCnFPKBU7jmUFndaADJdH+s+zJexkoj3kKtmsEQaPgP+ceZTbc5cvPjU3Sm vEXco= X-Google-Smtp-Source: AGHT+IFnnqui7lMtpiykBUjwTnYQcYRTI2kmmrqbgCsEOh4j6FVsYibaGMcAvqDm+PkSnPY4OF1raw== X-Received: by 2002:a05:6602:2d90:b0:887:55d0:c208 with SMTP id ca18e2360f4ac-88ec3b3037dmr804627539f.8.1757626736258; Thu, 11 Sep 2025 14:38:56 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:55 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 09/30] dyndbg: refactor param_set_dyndbg_classes and below Date: Thu, 11 Sep 2025 15:38:02 -0600 Message-ID: <20250911213823.374806-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor callchain below param_set_dyndbg_classes(1) to allow mod-name specific settings. Split (1) into upper/lower fns, adding modname param to lower, and passing NULL in from upper. Below that, add the same param to ddebug_apply_class_bitmap(), and pass it thru to _ddebug_queries(), replacing NULL with the param. This allows the callchain to update the classmap in just one module, vs just all as currently done. While the sysfs param is unlikely to ever update just one module, the callchain will be used for modprobe handling, which should update only that just-probed module. In ddebug_apply_class_bitmap(), also check for actual changes to the bits before announcing them, to declutter logs. No functional change. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3 s/modnm/mod_name/g --- lib/dynamic_debug.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d9268d051a10..96cd31c457e2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -593,9 +593,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]; @@ -603,7 +604,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)) @@ -612,12 +615,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 @@ -672,7 +679,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -682,7 +689,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -696,18 +703,9 @@ static int param_set_dyndbg_classnames(const char *ins= tr, const struct kernel_pa return 0; } =20 -/** - * param_set_dyndbg_classes - class FOO >control - * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type - * - * Enable/disable prdbgs by their class, as given in the arguments to - * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative - * levels by bitpos. - * - * Returns: 0 or <0 if error. - */ -int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +static int param_set_dyndbg_module_classes(const char *instr, + const struct kernel_param *kp, + const char *mod_name) { const struct ddebug_class_param *dcp =3D kp->arg; const struct ddebug_class_map *map =3D dcp->map; @@ -744,8 +742,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: @@ -758,7 +756,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: @@ -767,16 +765,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.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 31E252E1EF5 for ; Thu, 11 Sep 2025 21:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626739; cv=none; b=jPGTQMmfs5BpAcyoA5ae9SMpF+5hAmsNIbpkQVqKcUcP+Dfl4YUHT8OXm22jkhEiEwkmt97lz5xA+cP+ODli6lv9eqDKI+Bezx5WO+O6mCodSnwfs8hZLKsRtNYpV60BBL3RGSNUnFUyqlRkzp/5PzB8oJld68Pa/8RWY4lxgxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626739; c=relaxed/simple; bh=O+DrJ+WIzxL0KCL50VNkBHjTweV2OInEHiE37yzYWsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NM9eDRBcIXhGGN8xP2Eymyl9kqXAiQyyJ6/eDA18gaGpr18ygM0qeRCWWis2lje5HPDtymCmkiEk9GITTJa6WSX+bA4w381MS5653J5h43br+7SWZXpeTaThxfqIVYpINpKuNGno9/trGUmEue9rpJq2Wwr/0m0eEerIrqSGczo= 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=FSSgliQK; arc=none smtp.client-ip=209.85.166.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="FSSgliQK" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-88c4a7ff3c5so39272739f.1 for ; Thu, 11 Sep 2025 14:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626737; x=1758231537; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i+G5LpRSmzQv8Uk4Lzh4jg4DDwzNtpQJGLN6ei9qbCY=; b=FSSgliQKJzYcnJ3x5VxM3FSGLxJQOR8UL6wSMOgGOiRUea+OteNJDphV6wJ7GmhN2+ 8xi+RPVaxQ/Q2XGzOqKeZpU23hneaj4nSZy+f0A/0lP4AZzMaUhx99fS4A8jN1xrMVCT MlEzlTS4He6SeUEttDc+gRmrDLS74YQFtYutdc5SWei32GHmDhYpzSe5a1N6J4mbWtaq MK7piBaLQ1z+dmKi/FsQnNoZZP74W9DmRIc2cUFea16AfMR6PLksCfMCM+4k9hNAofgF AGW1Y8SFwG75nZFP2n1eAOircAWuozLvzFQjj66KpeRHQ4QiHzxz5DQuMv7F0zDLVBQF eYUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626737; x=1758231537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i+G5LpRSmzQv8Uk4Lzh4jg4DDwzNtpQJGLN6ei9qbCY=; b=YN7ySRZZsYE8sNrrpWMKsYFcDuh0fMKh8rScKXVw3TztjgEUwuzvXuEAVdukUchs2r 3Wub2IiSSnxbJpT0qB+aW+Yd/Eh3eeMEliuk+56YJQvH/Dg9nqTmdFJBxqwBYWvE6VBz h2nFngyaxtWmANOYMzYjTRC+6u3ADs7CFWfz9edS6naTfSBpZjqrQMKnIqFaAx4mWGiL 8X2jpGWSGYXdAzhSGhuqNwFffhLfOTKau3/zuxggRXyRB8qkCNBeJKWl30NJdGK4JQEO dW/duUTe3DSs1FjofEWdNyCqRoBLzg3Gb9r2OrcEjlrxz45yTuU00OLpY4jW4UrziHM5 Sbug== X-Forwarded-Encrypted: i=1; AJvYcCUJ2143gDPAicStXWrXnpSvfevBu/4rWwAA0Ar/1N/nUFpG8byr4xuYe71WxFFkfm1A6GHmr1cDtDvxJmM=@vger.kernel.org X-Gm-Message-State: AOJu0YwksfFKGJk/sXpo48rckXz+LCJvMeitx9dX7z0Rf/8YY6gdJ6z2 mOkyG4VRr47phFoBBGTU5q6IgIqX7ZNNVuKvecAePr3c7kuZNL4tDUT7u9xlLg== X-Gm-Gg: ASbGncvTX2/+w0GuRlWi4NUoXlIpYcvh+R0h2qUhYYo3CoOm9KV4fK/2PRZsUIcixMp fKiFJAQsoq/HtrDFLR80TwhdC4UuglJRqbcmRoBl+A+fn7OidKcLC7pSRgP8vrfEbwiOzXIv3p4 xSTVhZIJ9NqF1QS6IqNLdaTLDON0yhEXbFAOuLlwDcjPMW/LBF4Q1rOxLsSLG/faUqt8bGM8TfP m6HVBC5M72Mxludn9+Ga+UzZIucUx3/5FDxa3ciFjV5mNNo30MbJ1/mMDjUhQKFJ8+gTv2SzZfO z5XlgghpQo376D5F6wGkx7Qg7YSqo1yGnknB6gOHj/AqhBc1aWve+vxk7Z6zT8qtNlUBXrtmXgc O0FJpH8EMhN//PEtlQXQRh8bJsLmRZ9GVHAPI411vG6MtLyKF30wSIIAuWyeqS6n7uLqDd/o1MJ IZCoAQYcafjsaLWi5L008jO03K X-Google-Smtp-Source: AGHT+IHxDfbt2xYanVoqyvJ+YQ/rRdbo84JuCpdy+RWzo3qH3dtLWN9+qRNluXReqftvujFsucGd7g== X-Received: by 2002:a05:6602:3897:b0:887:6fe0:e742 with SMTP id ca18e2360f4ac-89032426fe4mr131060439f.6.1757626737156; Thu, 11 Sep 2025 14:38:57 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:56 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 10/30] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Thu, 11 Sep 2025 15:38:03 -0600 Message-ID: <20250911213823.374806-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" old_bits arg is currently a pointer to the input bits, but this could allow inadvertent changes to the input by the fn. Disallow this. And constify new_bits while here. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- lib/dynamic_debug.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 96cd31c457e2..08d095dd19ef 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -595,7 +595,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 @@ -604,12 +605,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], @@ -621,9 +622,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; } @@ -679,7 +680,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -689,7 +690,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -743,7 +744,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: @@ -756,7 +757,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.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 2438A2E2850 for ; Thu, 11 Sep 2025 21:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626741; cv=none; b=sDpuZj2qGywP77YBhqG90AZm/vfBmu9wAg7rnLs7YoCYvbE7h7ft3kdwNJB1gJsa5trl4outa19/SOaQqnAQSeKI57yMTtxSRMo43/5vuABwzccLikWItWliugjt+KuHNU/+Q4kH/vIvUSxNJVWg8DmrK5EnnTzech6xjf3gjl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626741; c=relaxed/simple; bh=rK4z7rclwfK0c037dAKPfOpjg7IlFZUJaEv9EBcl1IQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oVZAmpTpHgW61XogDzo6idfjHvE3z0SpZxJRFC3P91pYjnOLaQg7HyTaY029yBqrsGAnO58rd1nMUPoTph/UicinWSnKrocA2EJtqUA3T/EJgucMJIpiYzvxB27/t92qywzql+IbD1+8vKDuEDfP989VqAVYBqnlkap8LFhMqNU= 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=eSM8DLyH; arc=none smtp.client-ip=209.85.166.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="eSM8DLyH" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-88432e27c77so33075239f.2 for ; Thu, 11 Sep 2025 14:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626738; x=1758231538; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NxIlY2yM45eMQeCF3YJ//hYD95SXkEqZOPug5RB/i/U=; b=eSM8DLyHjIznDZrogEYR8xeo8Zo/qcbAK7eQjbDIZwf0rFiTpsyM/DZ2KEO7X7h72V vjeyq2a9/7uzc6iBgsbFsSPXLfb+2Y9Oc5tXW+/KHoU1wY9kQ5RIIZvBxhIBTViMad92 fERo1OLZBJC5um1mkQvQdhPUX9LV42bUhIHPceCGkREc1Excp6cHqCPFmGq8SUztIDmX ScQPlR8zJFPFFKcB+JcYkUzyZE2L7nhw4ADutmWyE8XErC8Is7Rlmab3HZ5sVH9uvp2M o+aZEmH7kAEYXTOHKr2sI7Q8JYrRubcHQQ6aMhzD7eDfF8biEYaMDFVLgNAE0wiivUV6 uQnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626738; x=1758231538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NxIlY2yM45eMQeCF3YJ//hYD95SXkEqZOPug5RB/i/U=; b=aY5IqQUQ5FugksHQXCMzGwT4atFtoU2uZzQ9P8tamG4gemLDSWuLJ28mxAiXU1H5Hs 5XRxjjOkCtdPhdrAiK+9x6PWMlG7aViQThCbZ7gVg6z+Cqn14U8OAOLlbBThTdjjh7o9 qfPTz8tfLkI46N9MPFsHTNq8I7QQajY2AXfyaf29ehqGZkuVYHPMYOw+33wS3QaKdAYU b83wOzMEDV77JzTw8wqYBo482yGsLdmgP290rECrWP2WsjFfjLAtIlKwiXz825/pLT5G 8ObdKkaDPORsjtJuB+JS/bIHWCc4P62LJWsPp1HVBqvKiuNEXVomHo8bWfhLxSRDATGk B0HA== X-Forwarded-Encrypted: i=1; AJvYcCWc9qNRzbf/1ho/Wu0X2sq+onQcPp1JpElJQbFDs1e0jm0fxsKg2FSq3/gn0GBcODT+dJ3C3oiVUZyWUEU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu3hZY06r65YczGeeQLcXpZvcIQRtvYmM24ObYVGYPZaFN9JuL fR7GZUZ9wIFevmL/nc+vb8GyFk0dRfhwKTY3T3n/fhQwkOEf2v9m3sOxVV0rzg== X-Gm-Gg: ASbGncsGPKt7ip3wFbr+llGsljOmGd2a6mwcjrv35lF1WTiwZ9z+fCnnWZcFlK9IXiZ qLf8zmq7PtxF4Z4o27gbG/mjN1X8y2FErH9yP5DSGmbgdcC3KCeds78CUG6L/mE9LD4X3efS0sG hoIUgfP2wg72iO/2keCTx1GBpKJnRLJPr0w0gw9yNfsDh9W47OXlymHD8v1uxRvQRCqBvXTSlUa 9zSi1Kwd4hWfzVEnFKw2I82O54ZJxlEVLz+huXK99OP+7MQ4Z6v6OUWpO5tgDT0OO7+uM3tA/rP QeB1tGDH5BXLJsTNPPcFmULpinTbXMOVcvvyENRSbYwaIXa3JtN4XKCie0bd+xIQfF4jhXf1NDe 4OmwjGiJ7yyzFQE46JXkJel8bO2P51zterybkbnK388jbpLqfmxFysmdHlFlMUn7oyKWn5vXgih eBUNo= X-Google-Smtp-Source: AGHT+IGCUUKaqzOUldNrJ2pIH/y8mLgaqS+P+tG9o2ue3Ar7AFF6BCqwAirhaPjPphM2vwo7H6z7MA== X-Received: by 2002:a05:6602:7192:b0:886:e168:e087 with SMTP id ca18e2360f4ac-89036ec048cmr93840739f.13.1757626738402; Thu, 11 Sep 2025 14:38:58 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:57 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 11/30] dyndbg: replace classmap list with a vector Date: Thu, 11 Sep 2025 15:38:04 -0600 Message-ID: <20250911213823.374806-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Classmaps are stored in an elf section/array, but currently are individually list-linked onto dyndbg's per-module ddebug_table for operation. This is unnecessary. Just like dyndbg's descriptors, classes are packed in compile order; so even with many builtin modules employing multiple classmaps, each modules' maps are packed contiguously, and can be treated as a array-start-address & array-length. So this drops the whole list building operation done in ddebug_attach_module_classes(), and removes the list-head members. The "select-by-modname" condition is reused to find the start,end of the subrange. NOTE: This "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie at least one step closer to ddebug_init(2), which already splits up pr-debug descriptors into subranges by modname, then calls (1) on each. (2) knows nothing of classmaps currently, and doesn't need to. For now, just add comment. Signed-off-by: Jim Cromie --- v3- drop __outvar as promising magic it doesnt have --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 62 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index ac199293d203..e458d4b838ac 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -83,7 +83,6 @@ enum class_map_type { }; =20 struct ddebug_class_map { - struct list_head link; struct module *mod; const char *mod_name; /* needed for builtins */ const char **class_names; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 08d095dd19ef..283926530a43 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 { @@ -148,12 +149,13 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) } =20 static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, - const char *class_string, int *class_id) + const char *class_string, + int *class_id) { struct ddebug_class_map *map; - int idx; + int i, idx; =20 - list_for_each_entry(map, &dt->maps, link) { + for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -164,7 +166,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 @@ -180,7 +181,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); @@ -1122,9 +1123,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 @@ -1208,30 +1210,31 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, - struct ddebug_class_map *classes, - int num_classes) +static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { struct ddebug_class_map *cm; - int i, j, ct =3D 0; + int i, nc =3D 0; =20 - for (cm =3D classes, i =3D 0; i < num_classes; i++, cm++) { + /* + * Find this module's classmaps in a subrange/wholerange of + * the builtin/modular classmap vector/section. Save the start + * and length of the subrange at its edges. + */ + for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { =20 if (!strcmp(cm->mod_name, dt->mod_name)) { - - v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, - cm->mod_name, cm->base, cm->length, cm->map_type); - - for (j =3D 0; j < cm->length; j++) - v3pr_info(" %d: %d %s\n", j + cm->base, j, - cm->class_names[j]); - - list_add(&cm->link, &dt->maps); - ct++; + if (!nc) { + v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", + i, cm->mod_name, cm->base, cm->length, cm->map_type); + dt->classes =3D cm; + } + nc++; } } - if (ct) - vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); + if (nc) { + dt->num_classes =3D nc; + vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + } } =20 /* @@ -1263,10 +1266,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); @@ -1379,8 +1381,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.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 8DE7D2E36F8 for ; Thu, 11 Sep 2025 21:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626742; cv=none; b=nyWpdKb2XKfXCFHrXzKnC9uPdudG/fbU0QI/YKwfqCqFDGej2ySwKyWWurTbVYSPg2oVmjoomXayU/pUaV/gGXfpHPZ3lfVMa8kzSSAwMzs2oWG21+5Rd913PPggkttvwXUz2w8dIJ/K+aTI6BHaawPwusT9wxZgpdk3LuT2YJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626742; c=relaxed/simple; bh=mz4pmSNtikpHGQKcU360KSG8B6f7Exi+ES9uDoE62vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n53O4t0N1xRtg814Q4zxl3tu406pRqAzYWAq7xCW7kLbt/KCa+N2URU/9IMmX6RVVtpGgBxYgQw6c0cFzW+XyESJb9M7nyHf9Ga/guIMuEvqDX1cwxc4lxHvRXMSQWEChEJ//1cJZrS5p71ge6SczG+c6jpLw+jWjZ6LLeVuIrI= 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=NWDBw6uA; arc=none smtp.client-ip=209.85.166.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="NWDBw6uA" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-88762f20125so88064439f.0 for ; Thu, 11 Sep 2025 14:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626739; x=1758231539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FcE2j/B1mQgeocNkBmpDERPavffRGmULzplmDVYobd8=; b=NWDBw6uAX/Ff7XGC+OjNRLuJ34J502Q590TnlPN875rFd1sZ/jcZPDEHIfo7qvZVX5 PIZKEaMPFicFIZfkygIGPIHdaWjxx+1vyAF3aEEFhucL+T0rKgc15M4+NRAVmwgc8ho7 LuVjJPDblyFklCFeOLvjCOqlO3yga2tip2bhT5ycYhMfl1ZeuyL6Vc0pG8hFePDCBt3N 3IgGDK9kRNpJq422AlzFivdmo4YkkDTV2m/amBOYokX7At2ch7Dl2izwOBzG5zjQznjF /zaffJzpXiR3u1ZsaaSHHEQgXUuBzE0av/sOoG3BHr6VIthcDxlX605R/f1qJa3sOMQm NI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626740; x=1758231540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FcE2j/B1mQgeocNkBmpDERPavffRGmULzplmDVYobd8=; b=L805ZqwXkew+zN4L/5x/GeUPXupgZDm37rsf5M98FFiL5nPe7dLrEyReif5Rl1yJlV DEMkkXrvioN7JSqjPQCf6zIIRcCGtw8QflW/NZ3oY/pOGgNPdaZyeklEDYkDiw0FwcMN OmLBnx4kFfsL1mwa2SMZOJgylGcBOYjFpfulYVQmTX8Ofd2KW8Yk5E+MwRDFFHavg/DN AyC5zvga08YeMHWG7UartyiqH2ckNyqWtnqQ2tSy3nvMOdjG8fOwMtLhwEzyYkwXoZnn e4U8WnaiE5kgRF1U8rIrLOPV3ffEBiZDPARq6JoB0jE9Hz1/sEk1jsE/0bZox92uFOS1 D4+g== X-Forwarded-Encrypted: i=1; AJvYcCXGS3s3bPPSdnI2yqgtrKrf8JJr+s+4nQxcmU0sQYyx0pSDbM3M4VFfyK8nXnCrplVKaEvdpTTAf3Pl/cw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0gFa0vw+i23GzEa9l0CpXm1Fzjfs/2bXH4Jut73aM7sYUbI14 MD781uiCciVw7/Xp4vxDOufK3o8iPaz+csW+Rn2/6TjOoHL9tQgMBhK0 X-Gm-Gg: ASbGnct3zhq8ZEjuNxPs7zCL5RyfUXcW/ztDdybl0Ep00JpfCSi8T5EG2MM0KbxwlRD v8k+3NzBPkEAQ8tBBcOIJ9QA/lBfIFs7T++Cqq5yTcsGc0sr6w5A2iGpfRZKi0t56Yhv9SshNlY VLPCJl9H62mVHB10azvGSHLw4do6Ee9K6Au8uULveyZZtxKRjYf4HaoW7so1+x+Vcn4P1E5h1IS 3CASiJxvyJTe2P8FImPIevjy9eZFDajqCF7j3zjiva/bzhsgdsvjueA+A2ioFI5aVNji6q5Gxk6 gkjjsZ35ytw8BI4rLM99mK1UppvNRIj9SxwYQeyAX/YD9rcaCJLddd7tew6IcjhKKSXKR9v0PSh 5vPL2/Rw/i8JXEMOY4O6JLLWC+eQCHIJmHIfJA+Z29CfJveHgn0W+QmykCW1I+EbICyAiMMxUN1 J5TzQ= X-Google-Smtp-Source: AGHT+IGdKubNvCzkSRxRI0QKSMony/uatnUWgsFeYs2+bRkQDBiR4PdkBuI4Dyt3fdUN3mrh5Ya4ug== X-Received: by 2002:a05:6602:2351:b0:887:1472:e991 with SMTP id ca18e2360f4ac-89034be4658mr105297139f.19.1757626739562; Thu, 11 Sep 2025 14:38:59 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:58 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 12/30] dyndbg: macrofy a 2-index for-loop pattern Date: Thu, 11 Sep 2025 15:38:05 -0600 Message-ID: <20250911213823.374806-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" dynamic-debug has several __sections, each with , num_, and it iterates over these with a 2-index for-loop. These loops are fiddly with the 2 names. We have only 2 such loops now, but are getting more soon; lets embed/abstract the fiddlyness in the for_subvec() macro, and avoid repeating it going forward. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- 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 283926530a43..ddcaa87f3b02 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -128,6 +128,20 @@ do { \ #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) #define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) =20 +/* + * simplify a repeated for-loop pattern walking N steps in a T _vec + * member inside a struct _box. It expects int i and T *_sp to be + * declared in the caller. + * @_i: caller provided counter. + * @_sp: cursor into _vec, to examine each item. + * @_box: ptr to a struct containing @_vec member + * @_vec: name of a sub-struct member in _box, with array-ref and length + */ +#define for_subvec(_i, _sp, _box, _vec) \ + for ((_i) =3D 0, (_sp) =3D (_box)->_vec; \ + (_i) < (_box)->num_##_vec; \ + (_i)++, (_sp)++) + static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { /* trim any trailing newlines */ @@ -155,7 +169,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; @@ -1220,8 +1234,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 89D2E2E3B18 for ; Thu, 11 Sep 2025 21:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626743; cv=none; b=RfjfPWDl5Ag04WYNzz5Pmx/oUpcfPhqZnNbRJJl8jf7cXcQuKdD/kbjJEe0LTjH5yMKeTxw5InkSa66Z3qnpPmBoPqmq+VK9CJ/UtGQZB4JFwTcQF6wLivPQWDhGqeWKlUPN8J7hGIEoO5o2WKnhSpjT7RQVWJ15yZ06CBMfepI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626743; c=relaxed/simple; bh=iMHKQHA3tjs9UQ7SjiSntNwXKBEfD825xQLKxsfFxt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eINee2MarusZysJkhGVILKZrUcTejMFnf9Ey2bHXJvacfuPxCUsJbBb9KbOYRuJlfWVRgmp0ihBDf4g/Frhoq+miW65AvVTCqQKyyaXQRE2YoJDr9lp54lKLi3GWqHogZ5j1oiipHG49H1dGLborv84IgBVqvWchBm4p4f4XdQ4= 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=gnpE2se7; arc=none smtp.client-ip=209.85.166.46 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="gnpE2se7" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-88432e91223so28307939f.3 for ; Thu, 11 Sep 2025 14:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626740; x=1758231540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PUjBG8W7JviM3Ypn5iExypGYjiK1aXkryX0lsVYOg2Q=; b=gnpE2se718enzfQtqKUdM7i97yblTOLTo6bw0Ljxk9IZuiaPl2iibpYoT4rCIpz3MF jqNVKiaT7awphXqVGfoSigstJhWE+yHx7An6kdvaXuukc1O5nYo7nbmIWrMRViCwoknU 2sM0k7aVtZgjzgMvfg28aGbXBhHshhJZ8eS49YyB7CWuIs6nuRjCxL9U7An2+zSLfvs6 qb8okMehbX0+g790NN43QI9JV+S9NgK6H45/imUTcZ1k3yUzcpDEGd6Q/7NsiTnEYhll t6wRM0cwizvbewwxt74Va7HzV4CSOt4a52zX170L2iOMYMkP1KFKvwRR54VKwCwb6mJd qdYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626740; x=1758231540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PUjBG8W7JviM3Ypn5iExypGYjiK1aXkryX0lsVYOg2Q=; b=kJrzCcz6YUgqvrG9sLpB8Nn95bw0Aw0j2ZS2zFrnqC1HmjM+hEjhf4vG0h3z3LM3Hn 6akdTGtt5edME5PccBugkgrNeTyAPXKpFdLJdeMsXm4G+xw+b6BmCTnJUHN9Y3fAhNj2 jFt6Dc3BJWYjsZqgqi/NzBVJ+QWlrAoVP6y5gdeOZNpGng8AWFhX2+kHMhemQ0ftTqPp FIaqQoyqvEX4IdXo7z/KKfCOi7o4axeRUebS/x3rSN9j7uYzPCtqdqQtXn3qVtwrEPSN PQldcDxn0SKXX3lrvFgtpTaNtH+wDBkmj/Y/x3MSUMf8tadUxuzCcOlfdf6dGHxy00eW NzaA== X-Forwarded-Encrypted: i=1; AJvYcCVWy45L65xwoY9hefeynbwfrIrckxYuGCrAtTnDUXbj+wOBzMi5lgTpv6HHG6+/ZgkMmr2p+oHbtZtqoGY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8C1ziLKlmPMex0HMMfd8h40u5vUj3Wn11MLUOvnRYuGUtmLmn onD8f+AnEVDx0uSNIc1z1WflsjpCAfHnCaIZNqKfJPSI4mkrzQLtggFj X-Gm-Gg: ASbGncuKtYDNbl5AMrxjYKnvm1f7OFfyYS7jTgiBr9G+ItTpXYytFyNp8CqEAWYb9Tq 7MqA+dy/gu8EfVzrQIMCtHMaevZ/f3xYlz6gIHBvF1w6Cws8lbC814p6LvGP8rSVaQ9klW/hK8J BqFg0Qj4H3ZApo6QaBW6ToDv4Mf2jcRYeWcXT+y7rub3g1kBkcbikKQbSuvAXWzPPq/GZrDoRIx 86U9BUAhISUJDCxZO5hZ4qZ7iRwG7FuR7fLUiRq4WeregburHhe+pt9wi1g8H0ngnlq24ZYUMXL hP9crR3PjXs/LAk5sMjsUU3SMItDjiJl52DBHV5Vu9mBQZXIhke+Wfr6lo+aU7bC+9JMcRmM4oM 9oQwPCJ7mXNywo7SbOYxV0I5Xqt60DOxVNO36AlMQ3xTLc3ARjJqKz6Wb5Y8MnwY6v439qJhQBH +KkOI= X-Google-Smtp-Source: AGHT+IFy+M+sM5H1leUcrJZuOhZH5FegT+n18iAnK5oozu4QUtKLeKOnXdtqce8YIcWAmq2x+j4OYg== X-Received: by 2002:a05:6602:6422:b0:88c:3a35:ff43 with SMTP id ca18e2360f4ac-8903451f48fmr131460739f.15.1757626740483; Thu, 11 Sep 2025 14:39:00 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:38:59 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 13/30] dyndbg: DECLARE_DYNDBG_CLASSMAP needs stub defn Date: Thu, 11 Sep 2025 15:38:06 -0600 Message-ID: <20250911213823.374806-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a DECLARE_DYNDBG_CLASSMAP stub/do-nothing defn, so that callers will compile properly with CONFIG_DYNAMIC_DEBUG=3Dn Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e458d4b838ac..2a6ebc3c1459 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -91,25 +91,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 ARRAY_SIZE(_var##_classnames), \ - .class_names =3D _var##_classnames, \ - } - /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; @@ -134,6 +115,25 @@ 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 ARRAY_SIZE(_var##_classnames), \ + .class_names =3D _var##_classnames, \ + } + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -300,6 +300,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(_var, _maptype, _base, ...) =20 #define dynamic_pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.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 CEB912DECAF for ; Thu, 11 Sep 2025 21:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626746; cv=none; b=gVafb0LZXoIUL67l5nxcrGKz7KQJ3mFqFkmIKCVqnpcrFvNf9Xf9S06VbO9HWBlL26fXjkNEEZBNBs+1eIiXe7wHHZVKiV/BUaDkSG6gsoztJfgcpJab56Ly6H8tjJ5PFAUxKEaZ2S2lHqwLwoN5n5C1uHRiD3YyGjrGcojTbHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626746; c=relaxed/simple; bh=r8UBXOkqI1wUpvB2qPeAbF1uurUqBO2vhuylqV/W/o0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G9gfU+VCC51GbRUI0mKF7VmhCoqi7EQKL175S3WfrMyjt03zo08Hlw4fe8qgTgI1JDfNKYPmU/btDeir/uHIoD250s5hvK7BrCjBBrHqWOurZFwiWaOdNVlYci8mUK2Mwf6zZiBCGmhEMFahcophsyfK4wU179kHOYzaG0K1QB0= 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=Pmm6NWQQ; arc=none smtp.client-ip=209.85.166.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="Pmm6NWQQ" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-8877b60f7a5so42963139f.3 for ; Thu, 11 Sep 2025 14:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626742; x=1758231542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1uMeonYavxOTIJl8DB+R0rzIUn8Tw7J2bJttoO2WoIw=; b=Pmm6NWQQwOelg+QzpHfQ9AWJi15dAqULlQ3fBImmnbKbudb/EFKinWjJwuLxhM4wMe mXgfMYHKb4iXWT2bJEkrXEfI9mh+trKFFdoXVvz8kSqut/7gVMXYXYdzTVDHuYU1fwy5 I08JE2/xJ/WSI9DCFqq/nN3GIZ4RDpZABuL3hzNGF/Cg9vzICjplnD8ivgGsrOJdGFyZ cs2q2JMAdSU2UOhcf2T+PBe0qcb55evZiKcMYM+ahLZEbYUdx8F+IEVAGfKfpSJH3qIT A6Y4Vy9UWjSeeCMSkF4g9OhbOxkJ7t+2Ro8jVM2sqRuM7NzNfYl01vcFw1cgWk3dI9xK B/CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626742; x=1758231542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1uMeonYavxOTIJl8DB+R0rzIUn8Tw7J2bJttoO2WoIw=; b=SeoBWu/CEZorDXtHN3H9gPCvvQS5FGMMTFO0Pu5zCUSHF0BoRt0OMjz94j6bsJrMjc 2pyTs4LHnCc2+/eiUoG48RpjXyPOzZFc0VbcwbZ97LIVO0pt4PSb3n6/6lTPlSol9au2 oBod5wwU5YpK16FeJevroU7H0SmRNB/LbW7CmZyYfrcLlqL++7wCVBgoB5RyvvlL3zo5 AfOxFu67Eqo2OyOzCQVyOudv00o9D9XQ2z9xrK1kJTrBMVZQMLriOmbQfp1KoCTvjpe8 fpRLsSvan6BmJi03owy+vRuLVeFisyza7vYD+myZ11fffVgxEjfh0ccAd4VVZk7hBugL QeFA== X-Forwarded-Encrypted: i=1; AJvYcCU1Hfl0lKgkghGtJ7HkG+epMJ4jyzG9FMKDX+p0jSudt7IEfYX0yYVQY5F6VXg+B80g6UhB8qEuVutPtKs=@vger.kernel.org X-Gm-Message-State: AOJu0Yxym1dRsmxHOMOas6C8qFoUxGnQX8cj6OFtQoX6J4PhG3h04DSX MJCHRmsOfxAiOYIAmFj+UQWo+UMYfr2pJ5QSvK0OAeMB8iUaO8VyHbEl X-Gm-Gg: ASbGnct6SPMx4MxB682gyApP06XTrkl7e9xT786iPrOAOWU1YPZF7l5OKZ0IfjPWUWm gDqbqDfldyi+UZqBE8m+s49VsEYmyl1e5XMY0fffYAPnewJb16mRyl6zOzH9bAEMcpglx/v3xkC VlSNrnmrIn4CfJOAV0ReyHsJ/mOkddPuRXuZQCd/D473tkBWT0XICioeQ1Ua5fwhEHbi1h+3c9F BZqG6MdGXdX21Azyjtov5ru8ANGK24vZgJpUTf4CYpl8/9zJ5c9p0MpXvOeojEwjFC3vzb4j7dw sQzDSKlYNwL8WqLVxqUzgilzyGHNgJH+JvhX8+oDNjYBjLfxYw30rH000JxVsqfcRox05t82t2P eMvgAgKpzjhKLc5g3ino6JnOKMLWdVUzW+6Pig1ohJ1O8DPSs9ISTO3rJO6YDoCBWFIbcEaBESE slmwsWiTSt/84dFg== X-Google-Smtp-Source: AGHT+IGQ53s7SCfV02RG8LhrjQG25CQK+DSHXv9b5XXq8JnTsaMNv/q7RAwPD286ZeUutu0RD3Td4g== X-Received: by 2002:a05:6602:48d:b0:887:56f5:26a2 with SMTP id ca18e2360f4ac-890352a9a52mr121716039f.14.1757626741460; Thu, 11 Sep 2025 14:39:01 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:01 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 14/30] dyndbg,module: make proper substructs in _ddebug_info Date: Thu, 11 Sep 2025 15:38:07 -0600 Message-ID: <20250911213823.374806-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" recompose struct _ddebug_info, inserting proper sub-structs. The struct currently has 2 pairs of ptr,length fields distinguished by name. Several for-loops operate on these field pairs, soon many more will be added. Looping over these blocks by respective field-pairs is repetitive and fiddly, differing only by the field-names. Before adding a 3rd section and compounding the fiddly details problem, make proper substructs of each section, with the same named fields. So this patch does: Adds 3 "vector" structs, each with { *start, int len; } components, for _ddebug_descriptors, _ddebug_class_maps, and _ddebug_class_users respectively. 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. Bundles these 3 vectors (subrange-refs) into struct (reformed) _ddebug_info, where they're __packed to close the paholes introduced otherwise. The common fields allow improving the for_subvec() macro by dropping the ugly num_## 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. Also normalize the the __section names to "__dyndbg_*". struct module contains a _ddebug_info field and module/main.c sets it up, so that gets adjusted rather obviously. The __packed attribute on _ddebug_info and the 3 contained structs closes the holes otherwise created by the structification (which was my excuse for not doing it originally). Signed-off-by: Jim Cromie --- -v2 rework towards front of series -v4 rework after stubs-macro Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 4 +- include/linux/dynamic_debug.h | 40 +++++++---- kernel/module/main.c | 12 ++-- lib/dynamic_debug.c | 107 +++++++++++++++--------------- lib/test_dynamic_debug.c | 2 +- 5 files changed, 87 insertions(+), 78 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index fa5f19b8d53a..6fbdee197821 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -365,8 +365,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) *(__tracepoints) \ /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) \ + BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2a6ebc3c1459..bf686d1ab012 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -82,30 +82,42 @@ enum class_map_type { */ }; =20 -struct ddebug_class_map { - struct module *mod; - const char *mod_name; /* needed for builtins */ +struct _ddebug_class_map { + struct module *mod; /* NULL for builtins */ + const char *mod_name; 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; }; =20 -/* encapsulate linker provided built-in (or module) dyndbg data */ +/* + * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * For builtins, it is used as a cursor, with the inner structs + * marking sub-vectors of the builtin __sections in DATA. + */ +struct _ddebug_descs { + struct _ddebug *start; + int len; +} __packed; + +struct _ddebug_class_maps { + struct _ddebug_class_map *start; + int len; +} __packed; + 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; +} __packed; =20 -struct ddebug_class_param { +struct _ddebug_class_param { union { unsigned long *bits; unsigned long *lvl; }; char flags[8]; - const struct ddebug_class_map *map; + const struct _ddebug_class_map *map; }; =20 /* @@ -159,7 +171,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ - __section("__dyndbg") name =3D { \ + __section("__dyndbg_descriptors") name =3D { \ .modname =3D KBUILD_MODNAME, \ .function =3D __func__, \ .filename =3D __FILE__, \ @@ -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 c2c08007029d..8515a6184be0 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2689,12 +2689,12 @@ static int find_module_sections(struct module *mod,= struct load_info *info) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); =20 #ifdef CONFIG_DYNAMIC_DEBUG_CORE - mod->dyndbg_info.descs =3D section_objs(info, "__dyndbg", - sizeof(*mod->dyndbg_info.descs), - &mod->dyndbg_info.num_descs); - mod->dyndbg_info.classes =3D section_objs(info, "__dyndbg_classes", - sizeof(*mod->dyndbg_info.classes), - &mod->dyndbg_info.num_classes); + mod->dyndbg_info.descs.start =3D section_objs(info, "__dyndbg_descriptors= ", + sizeof(*mod->dyndbg_info.descs.start), + &mod->dyndbg_info.descs.len); + mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", + sizeof(*mod->dyndbg_info.maps.start), + &mod->dyndbg_info.maps.len); #endif =20 return 0; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ddcaa87f3b02..53ce28255426 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 { @@ -138,8 +136,8 @@ do { \ * @_vec: name of a sub-struct member in _box, with array-ref and length */ #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)++) =20 static void vpr_info_dq(const struct ddebug_query *query, const char *msg) @@ -162,14 +160,14 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, +static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, const char *class_string, int *class_id) { - struct ddebug_class_map *map; + struct _ddebug_class_map *map; int i, idx; =20 - for_subvec(i, map, dt, classes) { + for_subvec(i, map, &dt->info, maps) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -194,7 +192,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 */ @@ -215,8 +213,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 /* match site against query-class */ if (dp->class_id !=3D valid_class) @@ -609,14 +607,14 @@ static int ddebug_exec_queries(char *query, const cha= r *modname) } =20 /* apply a new class-param setting */ -static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, +static int ddebug_apply_class_bitmap(const struct _ddebug_class_param *dcp, const unsigned long *new_bits, const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_map *map =3D dcp->map; int matches =3D 0; int bi, ct; =20 @@ -652,8 +650,8 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, /* accept comma-separated-list of [+-] classnames */ static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long curr_bits, old_bits; char *cl_str, *p, *tmp; int cls_id, totct =3D 0; @@ -723,8 +721,8 @@ static int param_set_dyndbg_module_classes(const char *= instr, const struct kernel_param *kp, const char *mod_name) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; =20 @@ -811,8 +809,8 @@ EXPORT_SYMBOL(param_set_dyndbg_classes); */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { =20 @@ -1063,8 +1061,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 /* @@ -1085,10 +1083,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 /* @@ -1135,12 +1133,12 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) #define class_in_range(class_id, map) \ (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++) + for_subvec(i, map, &dt->info, maps) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1174,7 +1172,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 @@ -1226,7 +1224,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 /* @@ -1234,18 +1232,18 @@ static void ddebug_attach_module_classes(struct dde= bug_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for_subvec(i, cm, di, classes) { + for_subvec(i, cm, di, maps) { if (!strcmp(cm->mod_name, dt->mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", i, cm->mod_name, cm->base, cm->length, cm->map_type); - dt->classes =3D cm; + dt->info.maps.start =3D cm; } nc++; } } if (nc) { - dt->num_classes =3D nc; + dt->info.maps.len =3D nc; vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); } } @@ -1258,10 +1256,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(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { @@ -1275,19 +1273,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 @@ -1434,10 +1431,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 @@ -1448,7 +1445,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; @@ -1458,16 +1455,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; @@ -1477,8 +1474,8 @@ static int __init dynamic_debug_init(void) iter_mod_start =3D iter; } } - di.num_descs =3D mod_sites; - di.descs =3D iter_mod_start; + di.descs.len =3D mod_sites; + di.descs.start =3D iter_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1488,8 +1485,8 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); =20 - if (di.num_classes) - v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + if (di.maps.len) + v2pr_info(" %d builtin ddebug class-maps\n", di.maps.len); =20 /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 396144cf351b..8434f70b51bb 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -41,7 +41,7 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 06= 00); */ #define DD_SYS_WRAP(_model, _flags) \ static unsigned long bits_##_model; \ - static struct ddebug_class_param _flags##_model =3D { \ + static struct _ddebug_class_param _flags##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 AA8072E5B2D for ; Thu, 11 Sep 2025 21:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626746; cv=none; b=Gm8Udv7t2t6LPM0UzvtgpM5XuEF0CzaiObSaNa4lJXIRQMNQgj/cuXQd5jPly01Y4EUoVCZRaXR1i5cpE2uCKUB7IWqgl2MJIxgM4xnhH9b5Q+TROsDPh/azwYQC+DRirSpHLuulZS/ByHY0Lqw+ShR9VGc5CcyC8pc9VfpLQvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626746; c=relaxed/simple; bh=zvTNU21/57sLu7CPtDOAy5ER8/SrrXIEsXuQaR053aA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rWZnPS/ffJ+ZlMu8tLfcV0qkR9ozjZ/wazgH7SYxQp9xzsk5txVuHsLRDI+IgpOuiqfSjPvhxMArNqjvA2E4EdooSbJBU8S3FE85WZGlctvS9sFqWSzaBSuJ/dBtFtnc5GVxvztlq6S3XRE168Gio/LlWbusxxUJJUoAELdR1/A= 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=GvPAJo2L; arc=none smtp.client-ip=209.85.166.46 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="GvPAJo2L" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-88703c873d5so31198739f.3 for ; Thu, 11 Sep 2025 14:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626743; x=1758231543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=foiN7sqtth4khBjBEFbfAhEsiysHlMC95zuU+aZAUrk=; b=GvPAJo2Lr+jvV2E/WGvhpZdXstpLs9dQQRU/C0ywtDmuCMnl2ALuELnLJV1g+YsQf1 cLAS79yUQdLu42H43uMgMYK3cJi5Js0wcpTUT7vg2MreuhdlvDy+P5UakJZ90QSPbfHv XNE74d9e5t9ZeHinyYnzW2xp6qjW9/PtRIg0ChiuX7TZSpIKNeUCGF5Ozh/a04x2EOIe QwIKrEDHkZ9El4DflLYqOxFPTY+5mwnOPCYNA1JGNLtW1peYbXSBKW9pSQMGYjV3ZXoN MB7HvNl/D5HX2749VoGqdKEt63TsITq+wcbARSzzyyAwbzRMMhPJysmDfFUVuVDXlSQ6 J/Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626743; x=1758231543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=foiN7sqtth4khBjBEFbfAhEsiysHlMC95zuU+aZAUrk=; b=lBjxxLHcJYb/YPauWn174OkYkIKDbeyAyDzoDHiLz2DCOw2rZRzNaLiLpxVPCbgoFA +pjVE6d9aulCMLzpxJvcArdyanLfij+VCJuH+01r5vWTsLe+w8uAURF5SCgW6cejYv94 wrDm6zlDdsk3VGDsjbUsrnwVkCQDDRIbuXoWdKfpMgcltcE9Uit7UGleE8N+fCbyel3D 4nvLF+S2GB2NJT8phrldoZmgUZh8LZmLAKVPNTmLQn1wJ2URjfn+6Dj0FH0HOEAlkli+ /ROWxKC/O5NbKQSRZ7k+vy6z7tpvDlIjTA59itQ09AjddswoQIGyEUYZKFLAB6pzpOLg JirA== X-Forwarded-Encrypted: i=1; AJvYcCUKQTAJTG5+KnUp3BC0ft2Bf9D0xFFr2lh8QzLZDni9vPviMOsfbZgOSR7LNTEIJlvxOFYQ1NPc5IG5ESk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywlu9A6daRSYlUhWm/4j5YOAEgfgPFLrJabaQTmvMPq+t5YVb31 WkLHUshSry+DtitkgrAVvG/N9tCInRuOUG3Cg5wx+g5KQ9NsmxFAsKz5 X-Gm-Gg: ASbGnctEDoM+oZNbBhgqWVhSeRGzUZJxTjP+IEQjCPxqTiVFh80HlLql/xZzhDM6LoF 6Y9SQmZZ4e0HiiumD22Ve8hfdcJrZiZ830uDIGaFwgctdBzMtdVqrUzIUAW5Qbca8zXBRKIvzo6 drwrC62neEYtv+QGXmYgj+f7J1P0wBpmi1a6YwIlk4z83cUzmkxDMgboBW4M5jl0OraCheX2t9Q 8AHUcmLBm65Qpgd1tolERyjx0WWbTmiXQbC78GNHR8VxzFzVujQ+vcmSkjqXxd/jekYCPE1z7n0 EI9AvAlZw5bLVfjyJhmPfpmK82ZTpu6xVOhSJLcdt3ct9e3Ck+UxQdKQoNCM738Ax4RsjiwCu0l qLmS8QIguBfQfCUvhRuCvv1r73u5VSBTri0KcDdXIwenyHE+9biEe1UvmAF+mw6AgpZdYgPJWA0 edYUE= X-Google-Smtp-Source: AGHT+IG6bNiWR/GEXPQU1VwlGR3gL03B4V2LHYK7NtoK3MBviqChFxmGl4CrN3XnjiQoxU8RId2mew== X-Received: by 2002:a05:6602:483:b0:887:62d2:4622 with SMTP id ca18e2360f4ac-890369e764dmr120056139f.11.1757626742688; Thu, 11 Sep 2025 14:39:02 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:02 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 15/30] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Thu, 11 Sep 2025 15:38:08 -0600 Message-ID: <20250911213823.374806-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The body of ddebug_attach_module_classes() is dominated by a code-block that finds the contiguous subrange of classmaps matching on modname, and saves it into the ddebug_table's info record. Implement this block in a macro to accommodate different component vectors in the "box" (as named in the for_subvec macro). 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 effectively does the same for builtin pr_debug descriptors; segmenting them into subranges by modname. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 56 ++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 53ce28255426..bbbdb8aba071 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -161,8 +161,8 @@ static void vpr_info_dq(const struct ddebug_query *quer= y, const char *msg) } =20 static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) + const char *class_string, + int *class_id) { struct _ddebug_class_map *map; int i, idx; @@ -1224,30 +1224,34 @@ 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; - 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->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++; - } - } - 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->mod_name, dt->info.maps.l= en); } =20 +/* + * Walk the @_box->@_vec member, over @_vec.start[0..len], and find + * the contiguous subrange of elements matching on ->mod_name. Copy + * the subrange into @_dst. This depends on vars defd by caller. + * + * @_i: caller provided counter var, init'd by macro + * @_sp: cursor into @_vec. + * @_box: contains member named @_vec + * @_vec: an array-ref, with: .start .len fields. + * @_dst: an array-ref: to remember the module's subrange + */ +#define dd_mark_vector_subrange(_i, _dst, _sp, _box, _vec) ({ \ + int nc =3D 0; \ + for_subvec(_i, _sp, _box, _vec) { \ + if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!nc++) \ + (_dst)->info._vec.start =3D (_sp); \ + } else { \ + if (nc) \ + break; /* end of consecutive matches */ \ + } \ + } \ + (_dst)->info._vec.len =3D nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1255,6 +1259,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di, const char *modname) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; =20 if (!di->descs.len) return 0; @@ -1277,6 +1283,8 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) =20 INIT_LIST_HEAD(&dt->link); =20 + dd_mark_vector_subrange(i, dt, cm, di, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.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 E88A32E62CE for ; Thu, 11 Sep 2025 21:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626747; cv=none; b=uW9TfZQZTNnqMqMNnRhtMZdn3Lf9brWeMs8s0xEIAaMJsAy12bs3GgxakSXd6I94fMMgVT9hkmHT/w58OuMjDJ4GGIsNY8i5gAN8JzYjB+RhAJacol3IXZvEetvQqPOXPjp2IYmN8iZ3RB7IhsbTxaVHLJ0NIVpI1U1ZtOOFxKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626747; c=relaxed/simple; bh=6WeSLIcdWxH0KnY4snBRfJjiQ+Ag9hQk04tWp5V1Fhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=egeH7R+rKpQAzH8XG50Ie3U4Ex3CL+Z5JmthEPDjfFi3i1B44dqNGvFaxg5yy3ghTubFv4WuKbfKj69U29jGg6/att5amWm29swN1jCXleCdUBETE1h6L9afOOSIAC/RnDtCKB28C9kPCb9bhouINFSxGthYmZQmaujLYmhR5Qo= 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=IaZQL/iN; arc=none smtp.client-ip=209.85.166.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="IaZQL/iN" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-88f49be4c21so34967039f.1 for ; Thu, 11 Sep 2025 14:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626744; x=1758231544; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YGD+sflpYLyKJkUQPBfbt5KFEJrqeRR2/XNh6nVffG4=; b=IaZQL/iNI4HBsUw+wT0nMIl4adV74OJBx6Umgr1tfWCoSl45+EP5cYfXA7G/Xr4Bec VkgfycWEkm/V92RVF1FwM1qtnl2fHwXvsTc1K0aIB7cyGOh0aGOD9kiGvzTHupHcfh1R SNndOAiaf2cXO4xSZRaOspGxdDKh4AsD7M1LW+Xb93dJImfNXqyhJB3Pdxrq3rD0f91X H8Ic8/zwmYiHseCkUt4QLMZY6Ggpq/Y89EuuEQXnvCMTtJOYEV963lRcdzZyHVFaPQur VJw1xR3sMeh06Q2hGNdQ+0FoYjs5WHSCaRNy4dSNqJ2HGnbPPEZTNRgvRRZR/DQQTFMq lWxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626744; x=1758231544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YGD+sflpYLyKJkUQPBfbt5KFEJrqeRR2/XNh6nVffG4=; b=ilVgyRiaqAC9hbSzUKag80WS5mM4nGYBq1Em/cBF9EEuPqAsBYT+OFuW3d67ywxKmc vdf18uQXVC27MFM/VsmQ86HY4yO3vn343r7swVMoVzlqbqKUjzzZzetd8CyC4Cp7azQo Nvqx/V1Sx8uV2ZZs0mSTSyCfI4jYu1NYBeIytq1Wp1z907BretQh4USQOjxf5QOKdOMm 21/T5AVduHOZ7wP5jpy5K7m0jc/9FBWFJSTHJBHxMlvQn9/Fk1oxG3auQ7Z22KGsv4Xd ZWttIaHaj49mQxiUpu7dQtmMQi/NSpohNYbXXBA0OUFGgNj6arVJmTBYiLTwV7ijTvUy 2Jdw== X-Forwarded-Encrypted: i=1; AJvYcCX9AsrMYL62g79n+BTCLGcg9fM5EgVMWhdjB0+1JQEGcOQZU/UNRjjsuGcWAR+QLmV6uAeh5dL83uH/St8=@vger.kernel.org X-Gm-Message-State: AOJu0YyUSd5nnjLzfvIAXTvawiWbkl4PbAbz+HxCwNfIvvi8LRxoRbRb rb83b/FaSn64qE/lDbz8raGuUUdDynczBaE9rgDEF8gX6Na28jxrCxBLzMsOdg== X-Gm-Gg: ASbGncuanWNmibODTnwY9A4NMWaVsK8tVMTH4QWWNdCjO0/RXGUGKGvoIOZk+AO5X1e bAyazyNhoVbmuRuFaDmHJmOkGbfeZQLH4WOdSZJdcXnuk0TGBScos4GrxhKAs2kbYE1Wv7Hpw75 tng2mMhPn0af1xbdQAnQO6cJYqyKrjlrcNEC6Bc6vOE8fBpQNXHdFxjf/SQ2BWsKlMiUnAoss+N 85wBgJTmvH7QaM0uXuJpgWDhrtf/Ob1gagZspPh+vgQitEnOx81x+9CgTubGLtMCmGWBJHjVvON BGD+Bkf5p4G89dAJ52P47dhUDxviVQot6tVnx3+aJwpEwCFi6y+8rZSpBjsXFKqlN3wo0UaQ8Ce FBJe4mMDAPOoOaYT5sLYTTvQPBwEIOzSpoKS4jynkgxD/36lHc+OhvNU24DSlH0NE0gRyDrF0ko e3h07bPJqC2EvDSg== X-Google-Smtp-Source: AGHT+IGPTmfL1+pCXLOTpBUodDtAAGyn92kEQZ3Cnaeq6TthwPSBlWGT4RJ3RXRXhAb5DaKeihjwZA== X-Received: by 2002:a05:6602:2c94:b0:887:5ebe:bb9c with SMTP id ca18e2360f4ac-890349f737amr126136739f.14.1757626743677; Thu, 11 Sep 2025 14:39:03 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:03 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 16/30] dyndbg: move mod_name from ddebug_table down to _ddebug_info Date: Thu, 11 Sep 2025 15:38:09 -0600 Message-ID: <20250911213823.374806-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct _ddebug_info already has most of dyndbg's info for a module; push debug_table.mod_name down into it, finishing the encapsulation. This allows refactoring several callchains, passing &_ddebug_info instead of &ddebug_table, and hoisting the "&dt->info" deref up. 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 --- -v3 more s/dt/di/ internal interface changes --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 45 ++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index bf686d1ab012..a5602fd23d8a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -107,6 +107,7 @@ struct _ddebug_class_maps { } __packed; =20 struct _ddebug_info { + const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; } __packed; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index bbbdb8aba071..09f19155d7f0 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 @@ -201,7 +200,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, =20 /* match against the module name */ if (query->module && - !match_wildcard(query->module, dt->mod_name)) + !match_wildcard(query->module, dt->info.mod_name)) continue; =20 if (query->class_string) { @@ -269,7 +268,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, + dt->info.mod_name, dp->function, ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags =3D newflags; @@ -1133,12 +1132,12 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) #define class_in_range(class_id, map) \ (class_id >=3D map->base && 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 (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1166,13 +1165,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 @@ -1224,7 +1223,7 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.l= en); + vpr_info("module:%s attached %d classes\n", dt->info.mod_name, dt->info.m= aps.len); } =20 /* @@ -1241,7 +1240,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug #define dd_mark_vector_subrange(_i, _dst, _sp, _box, _vec) ({ \ int nc =3D 0; \ for_subvec(_i, _sp, _box, _vec) { \ - if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!strcmp((_sp)->mod_name, (_dst)->info.mod_name)) { \ if (!nc++) \ (_dst)->info._vec.start =3D (_sp); \ } else { \ @@ -1256,7 +1255,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_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; struct _ddebug_class_map *cm; @@ -1265,20 +1264,19 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) 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(sizeof(*dt), GFP_KERNEL); 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); @@ -1292,7 +1290,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 @@ -1355,7 +1353,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; @@ -1375,7 +1373,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; @@ -1473,7 +1472,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 @@ -1484,7 +1484,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.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.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 B030C2DF15C for ; Thu, 11 Sep 2025 21:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626747; cv=none; b=sCIZdPhWvTUcNUQv7E/OTY2IxGoXj5+vtjQBskytoX7wsGnWkdF/Zfhv/XVj7YcnAY9s/pz22lNciCqQ9hoCki6Bl78jbo/2yz1cEI3araSqYEBm88ny8DFN0LxtFtni7sOMCfyQtmH7NwTGZ49c3fE4s4bn6q0vYQJlYTxOfGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626747; c=relaxed/simple; bh=jH+1l4qvp+4+lZDHMaIkMAYILxYBcnRulcyT51Irv+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o3TggzNXi/K1fLdmweTjhIA+LRQeRb4gZKbC0mPyOA2O+jpKavbfx4DX/kiaLeTytgJJmi1fIj4VDJXP7up2yhRUjBOASb37YP38zysCM9o+3gmK52Ag/xpDY86Y3ok9LSPJUDhcEf1FX0fN982Dgz903p/FaxMpFtP65/SgDw0= 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=ZYWwDowG; arc=none smtp.client-ip=209.85.166.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="ZYWwDowG" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-8876462a34aso45623239f.2 for ; Thu, 11 Sep 2025 14:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626745; x=1758231545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2F08ZZZT/FKEY+flM6t+Sw9oooRo+K4owCqyCQDFHC4=; b=ZYWwDowG8q7+HoamOXHLBkukS6NC5xOQn6OaEYdmF3Ps3jOPJ4hMqeJ8A8MN6Sq3MY IrI6SAjP81cyalYPXGrq8owZ5059C91XzBUPUBqqwUuvQeA3IcFiVVCJmpOQnDs8XsBx tS01iBSNfknfP1VwXMki+9Qs3UUoXtWXCqIwwR1O9AWo0wwm1TW6kvJQcSFzGOsB+jT5 C0s8V5ecZOGoCDoYqTgvAqUIrP2d37XyimO8avJF+97cqN1aRrZfi0Rnmv3wuwIBut19 tf3rsN/NLtpVXZmT8E4M/VjMLRutINjXHH6XSn5QFaLP7VLwIJgJ9Y4Y1WJz9HyKOhmk X2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626745; x=1758231545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2F08ZZZT/FKEY+flM6t+Sw9oooRo+K4owCqyCQDFHC4=; b=TsIvIKc+bDybDO1FDUkeEWSNz2iJuye0lO1VHsfYkziwVHiUM1Oc5M76va03f/bhgS T6PaFFOgjLvkq0ZGRWbJ3+nFSojnZz2rCMWvDAoJRhrfji9Ogkxlh7c00BVRANh6xtrW qj/Q6XKz6hyfKJWpv+6UxW5DDd30v/pm2RKuabMG9jZhFpFkQXpTi7tEzOAOW44BDOIY PqHlIOyaQIkv4cRAX4xvRu4LQAM9Tgas4q4YqjeFSXoFzU/Odj3MlF5C9/XQxJXGW8K4 RpN/1RUeyRxcb//uqUN8AhDunKaKuJ01Rb5+nsyQWa6XFImXMxI6eXkPsTmXyHZ+e0l5 J4DQ== X-Forwarded-Encrypted: i=1; AJvYcCURmFqh38bAFfpaLKwTqXOnKVsmIcE6EI3OokpHJ6BA0ZkKe0knrKz2TqWenAPm2lEJqmVCeV/Yu4Pl0aQ=@vger.kernel.org X-Gm-Message-State: AOJu0YywKcUsznGMlo8OvxxV6ON+6W8frSelamp0hZASFqmFRP5lbxh6 4zIiebzjKh05mn5djGI5IMZP6uBlONEQAEvaod9ZxT19xw3JmktZuA9bh8rJtA== X-Gm-Gg: ASbGnctZ6R2Gn+EoaLb+UxD7SaOX9Vgno5KXEP+ve7KIVSFL6ACv/aED0X5ARcoskmy mMBL4ahu/YoPOj88MFIH6phiICit2lXxhEa3sMeF67dVc/usTZhPd29jn3hOGRglUcgRPqS+oy0 fPYjr8ZhvXMBijavYN/jY5m6Q+CRsOslRbJaimp+O3bM8WTZUyRLO2ySd0JGNcoiYZiUgY5w8Er 66duY//0BgaP0AQ4yuFxLH7gIRPr3oR0FlC8L/BaQ0PIwT98v3qpctr5FYUoYzyDg0xpaZk0DCH 4EO2R+05NRB2NxR//0mNY+fAyJbLeQpbEKvuX5WTtm958YoP0GGfupYlvJk8Q33oOkk/YgcIiI6 FWok5DSjyP5jDSJzSV73Fyl1AvjcRyPRyf+ies+M/VoPw+oDrHauR2LoZfMPci3VnUTF2zCVIaq zVV52Qo28PM5SA1w== X-Google-Smtp-Source: AGHT+IHh07YJ0dPd7o6T57rzkZUr0eU+hHCd+Zpud+VDBkavvP+RM021o7JeEC9oQ2FcWf9iQlJ+nw== X-Received: by 2002:a05:6602:6cc4:b0:886:c53c:9172 with SMTP id ca18e2360f4ac-89034fbf057mr112308439f.18.1757626744629; Thu, 11 Sep 2025 14:39:04 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:04 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 17/30] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Date: Thu, 11 Sep 2025 15:38:10 -0600 Message-ID: <20250911213823.374806-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the DD_CLASS_TYPE_*_NAMES classmap types and code. These 2 classmap types accept class names at the PARAM interface, for example: echo +DRM_UT_CORE,-DRM_UT_KMS > /sys/module/drm/parameters/debug_names The code works, but its only used by test-dynamic-debug, and wasn't asked for by anyone else, so reduce LOC & test-surface; simplify things. Also rename enum class_map_type to enum ddebug_class_map_type. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 23 ++------ lib/dynamic_debug.c | 102 +++------------------------------- lib/test_dynamic_debug.c | 26 --------- 3 files changed, 14 insertions(+), 137 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a5602fd23d8a..b6f3689912fe 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -58,27 +58,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 @@ -88,7 +77,7 @@ struct _ddebug_class_map { const char **class_names; const int length; const int base; /* index of 1st .class_id, allows split/shared space */ - enum class_map_type map_type; + enum ddebug_class_map_type map_type; }; =20 /* diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 09f19155d7f0..2cd28a64578d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -646,76 +646,6 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 -/* accept comma-separated-list of [+-] classnames */ -static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) -{ - const struct _ddebug_class_param *dcp =3D kp->arg; - const struct _ddebug_class_map *map =3D dcp->map; - unsigned long curr_bits, old_bits; - char *cl_str, *p, *tmp; - int cls_id, totct =3D 0; - bool wanted; - - cl_str =3D tmp =3D kstrdup_and_replace(instr, '\n', '\0', GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - /* start with previously set state-bits, then modify */ - curr_bits =3D old_bits =3D *dcp->bits; - vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); - - for (; cl_str; cl_str =3D p) { - p =3D strchr(cl_str, ','); - if (p) - *p++ =3D '\0'; - - if (*cl_str =3D=3D '-') { - wanted =3D false; - cl_str++; - } else { - wanted =3D true; - if (*cl_str =3D=3D '+') - cl_str++; - } - cls_id =3D match_string(map->class_names, map->length, cl_str); - if (cls_id < 0) { - pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); - continue; - } - - /* have one or more valid class_ids of one *_NAMES type */ - switch (map->map_type) { - case DD_CLASS_TYPE_DISJOINT_NAMES: - /* the +/- pertains to a single bit */ - if (test_bit(cls_id, &curr_bits) =3D=3D wanted) { - v3pr_info("no change on %s\n", cl_str); - continue; - } - curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); - *dcp->bits =3D curr_bits; - v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, - map->class_names[cls_id]); - break; - case DD_CLASS_TYPE_LEVEL_NAMES: - /* cls_id =3D N in 0..max. wanted +/- determines N or N-1 */ - old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); - curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); - - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); - *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); - v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, - map->class_names[cls_id], old_bits, curr_bits); - break; - default: - pr_err("illegal map-type value %d\n", map->map_type); - } - } - kfree(tmp); - vpr_info("total matches: %d\n", totct); - return 0; -} - static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -724,29 +654,17 @@ static int param_set_dyndbg_module_classes(const char= *instr, const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; - - switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: - case DD_CLASS_TYPE_LEVEL_NAMES: - /* handle [+-]classnames list separately, we are done here */ - return param_set_dyndbg_classnames(instr, kp); - - case DD_CLASS_TYPE_DISJOINT_BITS: - case DD_CLASS_TYPE_LEVEL_NUM: - /* numeric input, accept and fall-thru */ - rc =3D kstrtoul(instr, 0, &inrep); - if (rc) { - pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); - return -EINVAL; - } - break; - default: - pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + char *nl; + + rc =3D kstrtoul(instr, 0, &inrep); + if (rc) { + nl =3D strchr(instr, '\n'); + if (nl) + *nl =3D '\0'; + pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } =20 - /* only _BITS,_NUM (numeric) map-types get here */ switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: /* expect bits. mask and warn if too many */ @@ -812,12 +730,8 @@ int param_get_dyndbg_classes(char *buffer, const struc= t kernel_param *kp) const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: case DD_CLASS_TYPE_DISJOINT_BITS: return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); - - case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 8434f70b51bb..9c3e53cd26bd 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -74,13 +74,6 @@ DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE= _DISJOINT_BITS, 0, DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 -/* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 10, MID, HI }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, - "LOW", "MID", "HI"); -DD_SYS_WRAP(disjoint_names, p); -DD_SYS_WRAP(disjoint_names, T); - /* numeric verbosity, V2 > V1 related */ enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, @@ -88,13 +81,6 @@ DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEV= EL_NUM, 14, DD_SYS_WRAP(level_num, p); DD_SYS_WRAP(level_num, T); =20 -/* symbolic verbosity */ -enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, - "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); -DD_SYS_WRAP(level_names, p); -DD_SYS_WRAP(level_names, T); - /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 @@ -102,10 +88,6 @@ static void do_cats(void) { pr_debug("doing categories\n"); =20 - prdbg(LOW); - prdbg(MID); - prdbg(HI); - prdbg(D2_CORE); prdbg(D2_DRIVER); prdbg(D2_KMS); @@ -129,14 +111,6 @@ static void do_levels(void) prdbg(V5); prdbg(V6); prdbg(V7); - - prdbg(L1); - prdbg(L2); - prdbg(L3); - prdbg(L4); - prdbg(L5); - prdbg(L6); - prdbg(L7); } =20 static void do_prints(void) --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.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 84E002E6CCA for ; Thu, 11 Sep 2025 21:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626749; cv=none; b=Trchi7dpPyh6br+L3i8/+5XwzI/EH0ZWnkxG1z8dnZTkngsUAFG2k4fiuFv8GAP7rWZsTxchWNBGODNfLo0aX6cmgP4lf4BGZEuoTglmBAnYGIfSxYyq/GsZXmtJBtjSkSICMltbIJLOaPx7AQ1TtRko7KDLhqOR1aJtPNhhiNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626749; c=relaxed/simple; bh=u2LgYL/weefCO0g4JNOX+VfbumRRUP3TffOVTW7hox0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rNxXixocoiVVSWYxP5y3uxGCZk86GWVwF0xdda/O9wAaLiZha1sT7Do3yK47Jag/V9+RWLicwzM/1JP3/uz6rRmbxRaJUMX0znxbXdkjCQDqB4DpNC8sX9OEkRFTa1h+q+vhgJCFvqOw2qNEZmMVSw4LA6Kx7HZgc/wCkBDOT+M= 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=j11TMcg4; arc=none smtp.client-ip=209.85.166.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="j11TMcg4" Received: by mail-io1-f48.google.com with SMTP id ca18e2360f4ac-887764c2868so99321139f.1 for ; Thu, 11 Sep 2025 14:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626746; x=1758231546; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vTh88YLCdVPZqVEjKJc4gkTA3wG+fp3O2SyVwqN9AHk=; b=j11TMcg4LWypNKBXui5qy86sJtVaOs9WqybAqJbUIKEHX7yrNCyBhhjWzP0wGPAnOW t8RFdENt0CUh/bWcaW2BUscJDeKCmX4hvrn78PhqOpo3Vy2WXhYlfRzsVbm9CwQh6+32 1KJPzDkhO3OANpiL3RnifyEP32S10+pmmPWAHBdiztzhvGbCb3wmn9Vw0GEvVAKXgzow YbcUx2M0L9orwqaARYv5NwPtkBTgzHo3g/a/9p8IkxLJD/J11BOJtZUUWatKnVNca5X1 OBPC9U4I5yfXJAdow38sy42eYKi6Tfq3uZip7q3dTvwUeH/UWWcAsoOnZ7CTwvr0C/gz HacA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626746; x=1758231546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vTh88YLCdVPZqVEjKJc4gkTA3wG+fp3O2SyVwqN9AHk=; b=Ceecmsiwc9FyGw71ifIw7BoRnCyV/GfAnKKfUOVGooypM0YNHOvstofpnvxqG3Q7h0 qPpgMH/sCnJ/F91cBCUisArwyc6+Zoc9Q0bGO3txQXMvlPdo8xHcEO83yUKgoy0+SbEj ZbXv9BjBVyPnsbTwvC1EWsVak6gv2Tiw6FLoXcCgKBMiDHh3um9RiBsVUk6TJ+o/ULJm iV4O2HUapNY/U8diwnEy7e54BokczHVPiP90lKvzMoPdjQzGJO30rnMHcvJ8v/Z8HBDo UwGJk62StamIu1OQbteQc1l0LktzO14KttLH/GETfB9PUDBB1PGULk89T/3/YPvTcHqp aeqQ== X-Forwarded-Encrypted: i=1; AJvYcCXI5OSfzwrkbNQgHFoHFvf6vtm9vyVnGLRkdHVOHJWKQ5NSqKIhL8WJpyWVjPusi2SunKyF8ZQbVP0ZhqY=@vger.kernel.org X-Gm-Message-State: AOJu0YzCZ7vdiY+gkjKs8cbHdNNaInSXV7KzVZszs+x43DTms8YgYuY0 lpDLJGlPmimX0C+VvFmumym8w0NSbAFCuwAv23hHeKltFIdltoJQVD52 X-Gm-Gg: ASbGncsxFUfu/Gv9FJBUuc1uKfpEPlhuwp8JtzRLnpZlv50UJGHLBs2k9xNnWpShrdW d2wtf5qqcpoNzKZ5PGARNozdx++cdw43gZfGW7FYRRranXt6o/jRtHiUivYnP+BvB+n7t+hDIx9 /mO8ItnW8tF5u5IyWL0F29/RWgDMey8f4rByklOqL7EPHbB27MBmJQNLoRKHnEAid0c8Meaj5ht sz1FSOorxJBzYoumvkHvZFFv/VfSunxggFiO4vK/xjDfNex1eFfLtkzk8T3smfVnS3NOknpNe1r 1GbzLbUsJwaxtp9/cX/C5KI7NlgoHr3WWhu8mKxvIKH0soNH7vXsM1NkclB+Inu2ERLm8jTrET9 vpIi6LqSkJVQPnduG17CCEHvM1ZI5bfSVwwFRgQG2qfHjQhQZa27Dk71pnQ2YbxNEFH26BgZxhi HRFPA= X-Google-Smtp-Source: AGHT+IFSK6eJvnU9SdN1gpPQjq72VmjItcvbCHdrsfrXRW4iN709QzUzOot2wNRK/QHTesqmwcGskA== X-Received: by 2002:a05:6602:3604:b0:883:f419:e3a8 with SMTP id ca18e2360f4ac-890333a7261mr146630039f.7.1757626745516; Thu, 11 Sep 2025 14:39:05 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:05 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 18/30] selftests-dyndbg: add a dynamic_debug run_tests target Date: Thu, 11 Sep 2025 15:38:11 -0600 Message-ID: <20250911213823.374806-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a selftest script for dynamic-debug. The config requires CONFIG_TEST_DYNAMIC_DEBUG=3Dm and CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm, which tacitly requires either CONFIG_DYNAMIC_DEBUG=3Dy or CONFIG_DYNAMIC_DEBUG_CORE=3Dy ATM this has just basic_tests(), which modify pr_debug() flags in the builtin params module. This means they're available to manipulate and observe the effects in "cat control". This is backported from another feature branch; the support-fns (thx Lukas) have unused features at the moment, they'll get used shortly. The script enables simple virtme-ng testing: [jimc@gandalf b0-ftrace]$ vrun_t virtme-ng 1.32+115.g07b109d doing: vng --name v6.14-rc4-60-gd5f48427de0c \ --user root -v -p 4 -a dynamic_debug.verbose=3D3 V=3D1 \ -- ../tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh virtme: waiting for virtiofsd to start .. And add dynamic_debug to TARGETS, so `make run_tests` sees it properly For the impatient, set TARGETS explicitly: [root@v6 selftests]# make TARGETS=3Ddynamic_debug run_tests make[1]: Nothing to be done for 'all'. TAP version 13 1..1 # timeout set to 45 # selftests: dynamic_debug: dyndbg_selftest.sh # # BASIC_TESTS 95.422122] dyndbg: query 0: 0"=3D_" mod:* # : 0 matches on =3Dp # : 4 matches on \[params\[ 95.456797] dyndbg: query 0: "module params = +]mpf" mod:* # : 4 matches on =3Dpmf [ 95.483070] dyndbg: query 0: "module params =3D_ # clear params" mod= :* [ 95.483288] dyndbg: query 1: "module params +mf # set flags" mod:* [ 95.483399] dyndbg: query 2: "module params func parse_args +sl # othe= r flags" mod:* # : 3 matches on =3Dmf # : 1 matches on =3Dmfsl [ 95.508877] dyndbg: query 0: "=3D_" mod:* # # # Done on: Tue Sep 9 03:05:22 PM MDT 2025 # ok 1 selftests: dynamic_debug: dyndbg_selftest.sh NOTES check KCONFIG_CONFIG to avoid silly fails Several tests are dependent upon config choices. Lets avoid failing where that is noise. The KCONFIG_CONFIG var exists to convey the config-file around. If the var names a file, read it and extract the relevant CONFIG items, and use them to skip the dependent tests, thus avoiding the fails that would follow, and the disruption to whatever CI is running these selftests. If the envar doesn't name a config-file, ".config" is assumed. CONFIG_DYNAMIC_DEBUG=3Dy: basic-tests() and comma-terminator-tests() test for the presence of the builtin pr_debugs in module/main.c, which I deemed stable and therefore safe to count. That said, the test fails if only CONFIG_DYNAMIC_DEBUG_CORE=3Dy is set. It could be rewritten to test against test-dynamic-debug.ko, but that just trades one config dependence for another. CONFIG_TEST_DYNAMIC_DEBUG=3Dm As written, test_percent_splitting() modprobes test_dynamic_debug, enables several classes, and counts them. It could be re-written to work for the builtin module also, but builtin test modules are not a common or desirable build/config. Signed-off-by: Jim Cromie Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik --- -r3 turn off green at end drop config dep on TEST_DYNAMIC_DEBUG, since basic-test uses builtin params --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + .../testing/selftests/dynamic_debug/Makefile | 9 + tools/testing/selftests/dynamic_debug/config | 7 + .../dynamic_debug/dyndbg_selftest.sh | 257 ++++++++++++++++++ 5 files changed, 275 insertions(+) create mode 100644 tools/testing/selftests/dynamic_debug/Makefile create mode 100644 tools/testing/selftests/dynamic_debug/config create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh diff --git a/MAINTAINERS b/MAINTAINERS index c0b444e5fd5a..4259d63c431a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8455,6 +8455,7 @@ S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c +F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Mak= efile index 339b31e6a6b5..e13b55510e31 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -26,6 +26,7 @@ TARGETS +=3D drivers/net/team TARGETS +=3D drivers/net/virtio_net TARGETS +=3D drivers/platform/x86/intel/ifs TARGETS +=3D dt +TARGETS +=3D dynamic_debug TARGETS +=3D efivarfs TARGETS +=3D exec TARGETS +=3D fchmodat2 diff --git a/tools/testing/selftests/dynamic_debug/Makefile b/tools/testing= /selftests/dynamic_debug/Makefile new file mode 100644 index 000000000000..6d06fa7f1040 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# borrowed from Makefile for user memory selftests + +# No binaries, but make sure arg-less "make" doesn't trigger "run_tests" +all: + +TEST_PROGS :=3D dyndbg_selftest.sh + +include ../lib.mk diff --git a/tools/testing/selftests/dynamic_debug/config b/tools/testing/s= elftests/dynamic_debug/config new file mode 100644 index 000000000000..0f906ff53908 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/config @@ -0,0 +1,7 @@ + +# basic tests ref the builtin params module +CONFIG_DYNAMIC_DEBUG=3Dm + +# more testing is possible with these +# CONFIG_TEST_DYNAMIC_DEBUG=3Dm +# CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh new file mode 100755 index 000000000000..465fad3f392c --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -0,0 +1,257 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +V=3D${V:=3D0} # invoke as V=3D1 $0 for global verbose +RED=3D"\033[0;31m" +GREEN=3D"\033[0;32m" +YELLOW=3D"\033[0;33m" +BLUE=3D"\033[0;34m" +MAGENTA=3D"\033[0;35m" +CYAN=3D"\033[0;36m" +NC=3D"\033[0;0m" +error_msg=3D"" + +[ -e /proc/dynamic_debug/control ] || { + echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=3Dy ${NC}" + exit 0 # nothing to test here, no good reason to fail. +} + +# need info to avoid failures due to untestable configs + +[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=3D".config" +if [ -f "$KCONFIG_CONFIG" ]; then + echo "# consulting KCONFIG_CONFIG: $KCONFIG_CONFIG" + grep -q "CONFIG_DYNAMIC_DEBUG=3Dy" $KCONFIG_CONFIG ; LACK_DD_BUILTIN= =3D$? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG=3Dm" $KCONFIG_CONFIG ; LACK_TMOD=3D= $? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm" $KCONFIG_CONFIG ; LACK_= TMOD_SUBMOD=3D$? + if [ $V -eq 1 ]; then + echo LACK_DD_BUILTIN: $LACK_DD_BUILTIN + echo LACK_TMOD: $LACK_TMOD + echo LACK_TMOD_SUBMOD: $LACK_TMOD_SUBMOD + fi +else + LACK_DD_BUILTIN=3D0 + LACK_TMOD=3D0 + LACK_TMOD_SUBMOD=3D0 +fi + +function vx () { + echo $1 > /sys/module/dynamic_debug/parameters/verbose +} + +function ddgrep () { + grep $1 /proc/dynamic_debug/control +} + +function doprints () { + cat /sys/module/test_dynamic_debug/parameters/do_prints +} + +function ddcmd () { + exp_exit_code=3D0 + num_args=3D$# + if [ "${@:$#}" =3D "pass" ]; then + num_args=3D$#-1 + elif [ "${@:$#}" =3D "fail" ]; then + num_args=3D$#-1 + exp_exit_code=3D1 + fi + args=3D${@:1:$num_args} + output=3D$((echo "$args" > /proc/dynamic_debug/control) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 5 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function handle_exit_code() { + local exp_exit_code=3D0 + [ $# =3D=3D 4 ] && exp_exit_code=3D$4 + if [ $3 -ne $exp_exit_code ]; then + echo -e "${RED}: $BASH_SOURCE:$1 $2() expected to exit with code $= exp_exit_code" + [ $3 =3D=3D 1 ] && echo "Error: '$error_msg'" + exit + fi +} + +# $1 - pattern to match, pattern in $1 is enclosed by spaces for a match "= "\s$1\s" +# $2 - number of times the pattern passed in $1 is expected to match +# $3 - optional can be set either to "-r" or "-v" +# "-r" means relaxed matching in this case pattern provided in $1 is= passed +# as is without enclosing it with spaces +# "-v" prints matching lines +# $4 - optional when $3 is set to "-r" then $4 can be used to pass "-v" +function check_match_ct { + pattern=3D"\s$1\s" + exp_cnt=3D0 + + [ "$3" =3D=3D "-r" ] && pattern=3D"$1" + let cnt=3D$(ddgrep "$pattern" | wc -l) + if [ $V -eq 1 ] || [ "$3" =3D=3D "-v" ] || [ "$4" =3D=3D "-v" ]; then + echo -ne "${BLUE}" && ddgrep $pattern && echo -ne "${NC}" + fi + [ $# -gt 1 ] && exp_cnt=3D$2 + if [ $cnt -ne $exp_cnt ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO check failed expected $= exp_cnt on $1, got $cnt" + exit + else + echo ": $cnt matches on $1" + fi +} + +# $1 - trace instance name +# #2 - if > 0 then directory is expected to exist, if <=3D 0 then otherwise +# $3 - "-v" for verbose +function check_trace_instance_dir { + if [ -e /sys/kernel/tracing/instances/$1 ]; then + if [ "$3" =3D=3D "-v" ] ; then + echo "ls -l /sys/kernel/tracing/instances/$1: " + ls -l /sys/kernel/tracing/instances/$1 + fi + if [ $2 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does exist" + exit + fi + else + if [ $2 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does not exist" + exit + fi + fi +} + +function tmark { + echo $* > /sys/kernel/tracing/trace_marker +} + +# $1 - trace instance name +# $2 - line number +# $3 - if > 0 then the instance is expected to be opened, otherwise +# the instance is expected to be closed +function check_trace_instance { + output=3D$(tail -n9 /proc/dynamic_debug/control | grep ": Opened trace= instances" \ + | xargs -n1 | grep $1) + if [ "$output" !=3D $1 ] && [ $3 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not opened" + exit + fi + if [ "$output" =3D=3D $1 ] && [ $3 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not closed" + exit + fi +} + +function is_trace_instance_opened { + check_trace_instance $1 $BASH_LINENO 1 +} + +function is_trace_instance_closed { + check_trace_instance $1 $BASH_LINENO 0 +} + +# $1 - trace instance directory to delete +# $2 - if > 0 then directory is expected to be deleted successfully, if <= =3D 0 then otherwise +function del_trace_instance_dir() { + exp_exit_code=3D1 + [ $2 -gt 0 ] && exp_exit_code=3D0 + output=3D$((rmdir /sys/kernel/debug/tracing/instances/$1) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 3 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function error_log_ref { + # to show what I got + : echo "# error-log-ref: $1" + : echo cat \$2 +} + +function ifrmmod { + lsmod | grep $1 2>&1>/dev/null && rmmod $1 +} + +# $1 - text to search for +function search_trace() { + search_trace_name 0 1 $1 +} + +# $1 - trace instance name, 0 for global event trace +# $2 - line number counting from the bottom +# $3 - text to search for +function search_trace_name() { + if [ "$1" =3D "0" ]; then + buf=3D$(cat /sys/kernel/debug/tracing/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/trace | head -1 | sed -e = 's/^[[:space:]]*//') + else + buf=3D$(cat /sys/kernel/debug/tracing/instances/$1/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/instances/$1/trace | head= -1 | \ + sed -e 's/^[[:space:]]*//') + fi + if [ $2 =3D 0 ]; then + # whole-buf check + output=3D$(echo $buf | grep "$3") + else + output=3D$(echo $line | grep "$3") + fi + if [ "$output" =3D "" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO search for '$3' fai= led \ + in line '$line' or '$buf'" + exit + fi + if [ $V =3D 1 ]; then + echo -e "${MAGENTA}: search_trace_name in $1 found: \n$output \nin:${= BLUE} $buf ${NC}" + fi +} + +# $1 - error message to check +function check_err_msg() { + if [ "$error_msg" !=3D "$1" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error message '$error_m= sg' \ + does not match with '$1'" + exit + fi +} + +function basic_tests { + echo -e "${GREEN}# BASIC_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP" + return + fi + ddcmd =3D_ # zero everything + check_match_ct =3Dp 0 + + # module params are builtin to handle boot args + check_match_ct '\[params\]' 4 -r + ddcmd module params +mpf + check_match_ct =3Dpmf 4 + + # multi-cmd input, newline separated, with embedded comments + cat <<"EOF" > /proc/dynamic_debug/control + module params =3D_ # clear params + module params +mf # set flags + module params func parse_args +sl # other flags +EOF + check_match_ct =3Dmf 3 + check_match_ct =3Dmfsl 1 + ddcmd =3D_ +} + +tests_list=3D( + basic_tests +) + +# Run tests + +ifrmmod test_dynamic_debug_submod +ifrmmod test_dynamic_debug + +for test in "${tests_list[@]}" +do + $test + echo "" +done +echo -en "${GREEN}# Done on: " +date +echo -en "${NC}" --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.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 86F352DF3CF for ; Thu, 11 Sep 2025 21:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626749; cv=none; b=ADVx13yf7WF5z8MOyKVv8SmgWu8mkMskCWIouTqPWdH8+bFMOZRlFYPiEdHsy49Dv+1lpQH8zk64ttJG1XtLHQ0iQygr2Rn/g1IcaKYQM3zXSn+/0R4uq50dba/kYvuQjjp5h/nVD1wb5E9rre0maBHK/yhleFhy0L7hwx0QxF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626749; c=relaxed/simple; bh=imH4oGjtC/DVv6V74aFKG/eXjYLLf9oli7Nh0hAHYa0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JJLDYV3hkZApuEznPjVhc3pYw2QKOLTI1w+h0UESXeMKHtJZY5YMxnPsXmTlSxTVvLxQXKd08lgKatPUNPzU27w3qbbRwYBABrbUc4XV6jvLLIhbBCyTMvZM13girbmKWpa3ET+JUg2Fls7TM652PTqMgZOAZhRhN2zzCE1tSzA= 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=ERgowJjs; arc=none smtp.client-ip=209.85.166.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="ERgowJjs" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-884328c9473so27510639f.0 for ; Thu, 11 Sep 2025 14:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626746; x=1758231546; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bBVZWusQDNba37/oJBvqNeU2d7R0nqKRYCmReL4RLfo=; b=ERgowJjsMnEhuU3AHrFnmCoUVkwmVt7wyfM4nUN5kxKAeXEFQ+B5w2yWSDVm7kbK9x Kwo/d+qIVXVfd/BAGVXgVg5NwLGXE5i27qLhhau7+y7wN8vXvp2gQVuQvgzbw4J0MrKj l3bL9JMHkcSlGKwc/awB0TymvPctPI4DEVwP4UAbAgioEaIELPRstgsEq1jYwCCurJlE mAAuuyhBKfTGqvlk/JIZ2x63fr0vMrVzQcXqZKpTx/0DDzXvFafWtSEW2LQ1v+p12G2h haMov43WtLmXi8tvUdRnTyBnKUvnYSf8xz5TSwq1JC/RC5QNq328nBI88r4cjYfD/fI6 uKPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626746; x=1758231546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bBVZWusQDNba37/oJBvqNeU2d7R0nqKRYCmReL4RLfo=; b=I5F8yCtVuT7YPbJd8S9DH+mzSkiz0zwDYHpRn7/FuPe7UXOQd5+Uj4wtFhRrdxs7HT RqAiMXjN0HafOyskZqr/5SF92Ii/rDbx4tnFuwcYG92HLTkaMfFOBWtNCbAUKRJvvrRm KZscg7inOIpE2hE0lBxaB8Xf6SoodP9S8qh7UCzd7zo1+Nma5VNdQXkceVEnucmQZS72 EFEF3FPuRwe15MvFXzDp1JnZ9rAQxyFdgsyp9fH8YHB1l/A1w//XNSXz8bh+nEparUJs ekTTSVa7EqqfNcGTsGXTxUFVCDBG2MrdHfzndu1FY008gRN6x0F99aY1lorl2R3HnmdR 9aCw== X-Forwarded-Encrypted: i=1; AJvYcCW+yMvaZyPKDMrnQ5RX+4SJIuQLUMR9vM97NB+F5rogydUs65PaollRUCKJS4RVHRtyPhrHxxT9HSXFPXQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzs9HqlwOG44tcDlS48IACdQv1b9bDWJWU89IdhgqzUMI8SUGIu LA+oR8/b7ObH2EfOGpdD8m/HhXKA9FRKo2nbPfOSD/+mpNfihgcJSFds X-Gm-Gg: ASbGncseJlgc792al4TbJw7z5dyq1r9m4HZnVv9WZZNUxntevQ44/WJdqU1NmI2Iv4P x4qDmacbgEQiv9uPkqEMPdLC0bAWB4owXKMIb8zQc4Xi0GgHYzKzbyDa0YJ5hGX6HC06Z87T0k/ J+/FeWnrC6adg5elBnJNuGbC0kBylpB/sWQ7CEZrgLKpemaxf2lIY256u8U5dG7VgOl6Mgq1xdq q3379l5IMVvsrrg5QknfKYfKonemnBUAe/Vf4jCIT7f8VO1uDS1PHgJ45eflGtoTKOlFxlja9I0 AUPdCz6yNUd46ecHvezIz6SyZLjThg/6mdwgx4ZY1iF8D76Oj8DKDBUVEGYDdVpVMIecyLaQnsy g8M15ovdBKhw232lS5SarZuLpQnLs2NUBOLxWPyDpzqbCqpGVtD9t3bWAZKkw7ukJdDkW7X8VUB siPk+Sz9JNx9qfXg== X-Google-Smtp-Source: AGHT+IHYtJcTWnc/cq5Ri6ps3srDsSmMJL9tKwhFikXfRBeZA97aRQKju+koXUHbj1+UQ2neoDZNZQ== X-Received: by 2002:a6b:5a0d:0:b0:884:125c:6949 with SMTP id ca18e2360f4ac-88ec393cd49mr689570139f.7.1757626746543; Thu, 11 Sep 2025 14:39:06 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:05 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 19/30] dyndbg: change __dynamic_func_call_cls* macros into expressions Date: Thu, 11 Sep 2025 15:38:12 -0600 Message-ID: <20250911213823.374806-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Xe driver's XE_IOCTL_DBG macro calls drm_dbg() from inside an if (expression). This breaks when CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy because the invoked macro has a do-while-0 wrapper, and is not an expression. if (cond && (drm_dbg("expr-form"),1)) { ... do some more stuff } Fix for this usage by changing __dynamic_func_call_cls{,_no_desc} macros into expressions, by replacing the do-while-0s with a ({ }) wrapper. In the common usage, the trailing ';' converts the expression into a statement. drm_dbg("statement form"); Signed-off-by: Jim Cromie --- --- include/linux/dynamic_debug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b6f3689912fe..68568a71f265 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -217,20 +217,20 @@ 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__); \ -} while (0) +}) #define __dynamic_func_call(id, fmt, func, ...) \ __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ func, ##__VA_ARGS__) =20 -#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ +#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) ({ \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ func(__VA_ARGS__); \ -} while (0) +}) #define __dynamic_func_call_no_desc(id, fmt, func, ...) \ __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ fmt, func, ##__VA_ARGS__) --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.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 539472E6CDC for ; Thu, 11 Sep 2025 21:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626753; cv=none; b=EwZZb4hO8kVi0mqkRL8c0AevRHQtye4qiQ9wa40Jymex9VB0fzvTiQ2KHt3hVx3i6AVxRVkltBj1wexIIYLYFqkc2w61vOfRi7G10nXlXftOP8AWiAEb2zJEjo27qTMYuT6nOSZoP+Em3OMjG5Hru1VAm+NsPwW/tTlzkt7SZFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626753; c=relaxed/simple; bh=56nHnHFuscau02YQ5wagmxwPIkye6C1bLpLmQJ21oLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0dVoNmEQj4Tq+l9EzJqVvAMGpkOZAK+WsH2OYFC3HlyzaL7dFwuTljW3c7Jm4fngUXjBTlsLidAq/2iF4eQKNkbu94VlbtmJYTg6eWXdx1hZdDiEETbeYv+umiTE8MZ7s+iRG8aES4wsACSE/jzGB7n7p7Kj8ktxifvJ0zK/nE= 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=J/xQLMDo; arc=none smtp.client-ip=209.85.166.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="J/xQLMDo" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-88432e60eebso33439039f.3 for ; Thu, 11 Sep 2025 14:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626748; x=1758231548; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+8DJpydPithBjDhGLR51l5sJF5LcEStKywKwc7/Kuz0=; b=J/xQLMDoTDq0DDIVD84m9+1kOUaQBGhxxUiTJ7ypQGpeHg14ZN3inUN+zWDBuzL5Xl hChaY5lChwGlbHoAMRUxVHS2c/7V4uakPwaWA1GRG2HPP4i9rRd29zFG6HjrweU1rZ06 lH1lkv2OH+NV03zN7Unhynx3vzX8VP0XCnIpDeFsKBGl3w+vTYdnWyUIMSxOToow/Ry4 j6RCoxiaZdhY22jyqx3wjCEWxt8+e53f2qZ7xbt8i2Z9etLoLF2SHcQ7OCxb7wLI+adH EIbSzMHPDApzFNbG3Uyq0lUwJdb6L2dtUUD5IWC9+9bgO0ywNE52EpmTGuzxsZ3zncwE XS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626748; x=1758231548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8DJpydPithBjDhGLR51l5sJF5LcEStKywKwc7/Kuz0=; b=eqIEIr6t8M1Hri5lnczNX8rvxS5tRTbAYGe/LudBjbImzCdIW11/9xD4pdAJ6+hRi0 H7XNeAbiD387ccDhlD0vcgDmJihNL/s3yAu19RCm7iucZh+BfJ48alWA4XDA1Uhtqq3T fgBOdPQvHPjOdWfAh/V1Ya6d1QKG2eU1mu0II3807OxVh2xDXcFeH1GA3nK5Tpk7EL9K aBr3YYO++KsDLKS5juIwJK4lUJgDdFCLslSSR4yB5CywwzIUhc6ekv4z93n00CZRgF2G G9gzFPDVjRsVIk/k/zBpxNBjpnbf3cXqet/pV9kRM6olQEGq3MwAskRjQFBQm//YIShU 4IAA== X-Forwarded-Encrypted: i=1; AJvYcCV04F/Lj7T8/j1bZZMmZ7Hv0nPE0/nHzHsWXh2UpX0RTBkFXNbgct1AEUOUk1fcQtThN4wHaz+DHMgQgxw=@vger.kernel.org X-Gm-Message-State: AOJu0YzYlYs6fEClYIATzAfPR+JYKqZISRPUwNg30qo8FCchxmtCfuRl iNI6MiQgQ/DJ8Z88ybbIFup2grm+2YMObpqQv6H9AdWK1gSBk8NKniKO X-Gm-Gg: ASbGnctmt4OTDurp05MKh+0sD1jkbP8rdblX4BJkrjkefzTnhI4sWSKo3tyskdBmCkz RyRhMgD1Ce8kL42qsoQUIXLOuvo97t8rkzoE3/VHLEMIs8tU3LIhQjPxFaV6aRIDyJMFeh6Arlq I8kHgUv/0+ftoDzKMCZUpd3ny3lLUXso7+rFFPIlHk/A/B+v6smoJlx2bIh6vRGWUIsSDgDbKJo PnbY2PsF9sxUYxf1JXaeaUwwliHPwkrKGiK4TbyTZyZY589aVTwkTwGrrepFDl8wTwlF7U+Wggx YayfjHsvz8ucJJjT2rben8d3GX/cGS5TV19qEw18mVbmpcVClE8DrQB7yPJWugTzADc8wWoHzeu pkyFeLCZQcT1yAXSfdMYBwWZ2pgq3f0v1yBXtXNHXwpKJScVf07GVbllY1aemV8bc7hLfn9Nwpd Ob8VpXTWLChtRTzg== X-Google-Smtp-Source: AGHT+IG+VQdDnzzvWLaFYXMhju9U+S7X9F3rFkbthp9HNupiOi4g0BFZ/Eooz0uLUkgY4tJxl26s0g== X-Received: by 2002:a05:6602:2b94:b0:875:d675:55f2 with SMTP id ca18e2360f4ac-8903261b040mr151338439f.7.1757626747836; Thu, 11 Sep 2025 14:39:07 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:07 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH 20/30] dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP Date: Thu, 11 Sep 2025 15:38:13 -0600 Message-ID: <20250911213823.374806-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") But DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic K&R rule: "define once, refer many times". When DRM_USE_DYNAMIC_DEBUG=3Dy, it is used across DRM core & drivers; each invocation allocates/inits the classmap understood by that module. All must match for the modules to respond together when drm.debug categories are enabled. This is brittle; a maintenance foot-gun. Worse, its the root-cause of the CONFIG_DRM_USE_DYNAMIC_DEBUG=3DY regression; its use in both core & drivers obfuscates the 2 roles, muddling the design, yielding an incomplete initialization when modprobing drivers: 1st drm.ko loads, and dyndbg initializes its drm.debug callsites, then a drm-driver loads, but too late for the drm.debug enablement. And that gave us: commit: bb2ff6c27bc9 ("drm: Disable dynamic debug as broken") So retire it, replace with 2 macros: DYNAMIC_DEBUG_CLASSMAP_DEFINE - invoked once from core - drm.ko DYNAMIC_DEBUG_CLASSMAP_USE - from all drm drivers and helpers. NB: name-space de-noise DYNAMIC_DEBUG_CLASSMAP_DEFINE: this reworks DECLARE_DYNDBG_CLASSMAP, by dropping the static qualifier on the classmap, and exporting it instead. DYNAMIC_DEBUG_CLASSMAP_USE: then refers to the exported var by name: used from drivers, helper-mods lets us drop the repetitive "classname" declarations fixes 2nd-defn problem creates a ddebug_class_user record in new __dyndbg_class_users section new section is scanned "differently" DECLARE_DYNDBG_CLASSMAP is preserved temporarily, to decouple DRM adaptation work and avoid compile-errs before its done. The DEFINE,USE distinction, and the separate classmap-use record, allows dyndbg to initialize the driver's & helper's drm.debug callsites separately after each is modprobed. Basically, the classmap initial scan is repeated for classmap-users. dyndbg's existing __dyndbg_classes[] section does: . catalogs the module's classmaps . tells dyndbg about them, allowing >control . DYNAMIC_DEBUG_CLASSMAP_DEFINE creates section records. . we rename it to: __dyndbg_class_maps[] this patch adds __dyndbg_class_users[] section: . catalogs users of classmap definitions from elsewhere . authorizes dyndbg to >control user's class'd prdbgs . DYNAMIC_DEBUG_CLASSMAP_USE() creates section records. Now ddebug_add_module(etal) can handle classmap-uses similar to (and after) classmaps; when a dependent module is loaded, if it has classmap-uses (to a classmap-def in another module), that module's kernel params are scanned to find if it has a kparam that is wired to dyndbg's param-ops, and whose classmap is the one being ref'd. To support this, theres a few data/header changes: new struct ddebug_class_user contains: user-module-name, &classmap-defn it records drm-driver's use of a classmap in the section, allowing lookup struct ddebug_info gets 2 new fields for the new sections: class_users, num_class_users. set by dynamic_debug_init() for builtins. or by kernel/module/main:load_info() for loadable modules. vmlinux.lds.h: new BOUNDED_SECTION for __dyndbg_class_users. this creates start,len C symbol-names for the section. TLDR ? dynamic_debug.c: 2 changes from ddebug_add_module() & ddebug_change(): ddebug_add_module(): ddebug_attach_module_classes() is reworked/renamed/split into debug_apply_class_maps(), ddebug_apply_class_users(), which both call ddebug_apply_params(). ddebug_apply_params(new fn): It scans module's/builtin kernel-params, calls ddebug_match_apply_kparam for each to find any params/sysfs-nodes which may be wired to a classmap. ddebug_match_apply_kparam(new fn): 1st, it tests the kernel-param.ops is dyndbg's; this guarantees that the attached arg is a struct ddebug_class_param, which has a ref to the param's state, and to the classmap defining the param's handling. 2nd, it requires that the classmap ref'd by the kparam is the one we've been called for; modules can use many separate classmaps (as test_dynamic_debug does). Then apply the "parent" kparam's setting to the dependent module, using ddebug_apply_class_bitmap(). ddebug_change(and callees) also gets adjustments: ddebug_find_valid_class(): This does a search over the module's classmaps, looking for the class FOO echo'd to >control. So now it searches over __dyndbg_class_users[] after __dyndbg_classes[]. ddebug_class_name(): return class-names for defined OR used classes. test_dynamic_debug.c, test_dynamic_debug_submod.c: This demonstrates the 2 types of classmaps & sysfs-params, following the 4-part recipe: 0. define an enum for the classmap's class_ids drm.debug gives us DRM_UT_<*> (aka ) multiple classmaps in a module(s) must share 0-62 classid space. 1. DYNAMIC_DEBUG_CLASSMAP_DEFINE(classmap_name, .. "") names the classes, maps them to consecutive class-ids. convention here is stringified ENUM_SYMBOLS these become API/ABI if 2 is done. 2. DYNAMIC_DEBUG_CLASSMAP_PARAM* (classmap_name) adds a controlling kparam to the class 3. DYNAMIC_DEBUG_CLASSMAP_USE(classmap_name) for subsystem/group/drivers to use extern created by 1. Move all the enum declarations together, to better explain how they share the 0..62 class-id space available to a module (non-overlapping subranges). reorg macros 2,3 by name. This gives a tabular format, making it easy to see the pattern of repetition, and the points of change. And extend the test to replicate the 2-module (parent & dependent) scenario which caused the CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy regression seen in drm & drivers. The _submod.c is a 2-line file: #define _SUBMOD, #include parent. This gives identical complements of prdbgs in parent & _submod, and thus identical print behavior when all of: >control, >params, and parent->_submod propagation are working correctly. It also puts all the parent/_submod declarations together in the same source, with the new ifdef _SUBMOD block invoking DYNAMIC_DEBUG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer. These 2 modules are both tristate, allowing 3 super/sub combos: Y/Y, Y/M, M/M (not N/Y, since this is disallowed by dependence). Y/Y, Y/M testing once exposed a missing __align(8) in the _METADATA macro, which M/M didn't see, probably because the module-loader memory placement constrained it from misalignment. Fixes: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- + avoid stale di in add-module review apply-classmap-* after locked list-add V-Ive-lost-track: rework the main design-review comment block add @_base to class_user, and inner _USE_ - can deconflict with defn v4- rework after stub-macros v3- undo 1.9 simplification of ddebug_find_valid_class() ddebug_change needs map to see its controlling param change internal callchains to pass di, not dt v2 a. building 2 .ko's from 1 source file is weird; add a clear comment at the top to justify it (basically cloning) ln 138+ in commit-msg is insufficient. b. retire "DYNDBG_" name shortening b4 adding _CLASSMAP_* macros. c. s/dd_class/_ddebug_class/ d. s/\bddebug\b/_$1/g in header: chgs 1 struct and UNIQUE_ID bases v1.9 - commit-msg tweaks DRM:CHECK warnings on macros: add parens extern DEFINEd _var, static classnames change ddebug_class_user.user_mod_name to .mod_name simplify ddebug_find_valid_class return val improve vpr_cm_info msg format wrap (base) in macro body move __DYNDBG_CLASSMAP_CHECK above kdoc for DYNDBG_CLASSMAP_DEFINE v1.8 - split drm parts to separate commits. preserve DECLARE_DYNDBG_CLASSMAP to decouple DRM, no flag day. fixup block comment v1.7 - previous submission-blocking bug: missing __align(8) in DYNAMIC_DEBUG_DECLARE_METADATA on ddebug_class_user caused corrupt records, but only for builtin modules; module loader code probably pinned allocations to the right alignment naturally, hiding the bug for typical builds. v6- get rid of WARN_ON_ONCE v?- fix _var expanded 2x in macro dyndbg: This fn formerly returned the map which contained the class (thus validating it), and as a side-effect set the class-id in an outvar. But the caller didn't use the map (after checking its not null), only the valid class-id. So simplify the fn to return the class-id of the validated classname, or -ENOENT when the queried classname is not found. Convey more useful info in the debug-msg: print class-names[0,last], and [base,+len] instead of the class-type printout, which is almost always "type:DISJOINT_BITS". And drop ddebug_classmap_typenames, which is now unused. [root@v6 b0-dd]# modprobe test_dynamic_debug_submod [ 18.864962] dyndbg: loaded classmap: test_dynamic_debug [16..24] V0..V7 [ 18.865046] dyndbg: found kp:p_level_num =3D0x0 [ 18.865048] dyndbg: mapped to: test_dynamic_debug [16..24] V0..V7 [ 18.865164] dyndbg: p_level_num: lvl:0 bits:0x0 [ 18.865217] dyndbg: loaded classmap: test_dynamic_debug [0..10] D2_CORE.= .D2_DRMRES [ 18.865297] dyndbg: found kp:p_disjoint_bits =3D0x0 [ 18.865298] dyndbg: mapped to: test_dynamic_debug [0..10] D2_CORE..D2_= DRMRES [ 18.865424] dyndbg: p_disjoint_bits: classbits: 0x0 [ 18.865472] dyndbg: module:test_dynamic_debug attached 2 classmaps [ 18.865533] dyndbg: 23 debug prints in module test_dynamic_debug [ 18.866558] dyndbg: loaded classmap: test_dynamic_debug_submod [16..24] = V0..V7 [ 18.866698] dyndbg: found kp:p_level_num =3D0x0 [ 18.866699] dyndbg: mapped to: test_dynamic_debug_submod [16..24] V0..= V7 [ 18.866865] dyndbg: p_level_num: lvl:0 bits:0x0 [ 18.866926] dyndbg: loaded classmap: test_dynamic_debug_submod [0..10] D= 2_CORE..D2_DRMRES [ 18.867026] dyndbg: found kp:p_disjoint_bits =3D0x0 [ 18.867027] dyndbg: mapped to: test_dynamic_debug_submod [0..10] D2_CO= RE..D2_DRMRES [ 18.867193] dyndbg: p_disjoint_bits: classbits: 0x0 [ 18.867255] dyndbg: module:test_dynamic_debug_submod attached 2 classmap= uses [ 18.867351] dyndbg: 23 debug prints in module test_dynamic_debug_submod fixup-test-submod fixup-test Signed-off-by: Jim Cromie fixup-h-decl tweak-hdr-cmts-cls --- MAINTAINERS | 2 +- include/asm-generic/vmlinux.lds.h | 1 + include/linux/dynamic_debug.h | 141 ++++++++++++++++++++++++--- kernel/module/main.c | 3 + lib/Kconfig.debug | 24 ++++- lib/Makefile | 5 + lib/dynamic_debug.c | 154 +++++++++++++++++++++++++----- lib/test_dynamic_debug.c | 132 ++++++++++++++++++------- lib/test_dynamic_debug_submod.c | 14 +++ 9 files changed, 397 insertions(+), 79 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c diff --git a/MAINTAINERS b/MAINTAINERS index 4259d63c431a..7d92c21693dc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8454,7 +8454,7 @@ M: Jim Cromie S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c -F: lib/test_dynamic_debug.c +F: lib/test_dynamic_debug*.c F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 6fbdee197821..94d3bc099c66 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -366,6 +366,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) \ + BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users) \ BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 68568a71f265..2c64f2401e51 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -71,8 +71,11 @@ enum ddebug_class_map_type { */ }; =20 +/* + * map @class_names 0..N to consecutive constants starting at @base. + */ struct _ddebug_class_map { - struct module *mod; /* NULL for builtins */ + const struct module *mod; /* NULL for builtins */ const char *mod_name; const char **class_names; const int length; @@ -80,10 +83,18 @@ struct _ddebug_class_map { enum ddebug_class_map_type map_type; }; =20 +struct _ddebug_class_user { + char *mod_name; + struct _ddebug_class_map *map; + const int base; /* user offset to re-number the used map */ +}; + /* - * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * @_ddebug_info: gathers module/builtin __dyndbg_ __sections + * together, each is a vec_: a struct { struct T start[], int len }. + * * For builtins, it is used as a cursor, with the inner structs - * marking sub-vectors of the builtin __sections in DATA. + * marking sub-vectors of the builtin __sections in DATA_DATA */ struct _ddebug_descs { struct _ddebug *start; @@ -95,10 +106,16 @@ struct _ddebug_class_maps { int len; } __packed; =20 +struct _ddebug_class_users { + struct _ddebug_class_user *start; + int len; +} __packed; + struct _ddebug_info { const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; + struct _ddebug_class_users users; } __packed; =20 struct _ddebug_class_param { @@ -117,17 +134,86 @@ struct _ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) =20 +/* + * dyndbg classmaps aims at the common kernel debug-print design pattern i= s: + * + * 1. run-time control via sysfs node (api/abi) + * 2. each bit 0..N controls a single "kind" of debug-message + * 3. a message can have only 1 "kind", not several properties. + * 4. "kind" is a compile-time constant: 0..N or BIT() thereof + * 5. macro impls - give compile-time resolution or fail. + * + * dyndbg classmaps design axioms/constraints: + * + * . optimizing compilers use 1-5 above "magically" so preserve them + * . classmaps.class_id is the "kind", the category. + * . classmap users are modules + * . every user wants 0..N + * . 0..N exposes as ABI + * . assigning non-conflicting ranges across everything is madness + * . no 1 use-case wants N > 32, 16 is more usable + * . N <=3D 64 in *all* cases + * . modules/subsystems make "kind" decisions + * . "kind" is often an enum: DRM has DRM_UT_CORE..DRM_UT_DRMRES + * . some "kinds" are BIT(N) & sysfs_val + * . making modules change their numbering is bogus, avoid if possible + * + * We can solve for all these at once: + * A: map class-names to .class_id ranges at compile-time + * B: allow only "class NAME" changes to class'd callsites at run-time + * C: users must manage 0..62 hardcoded .class_id range limit. + * + * By mapping class-names at >control to class-ids underneath, and + * responding only to class-names DEFINEd or USEd by the module, we + * can private-ize the class-id, and adjust class'd pr_debugs only by + * their names. + * + * This give us: + * D: class_ids without classnames are unreachable + * E: user modules opt-in by DEFINEing a classmap and/or USEing another + * + * Multi-classmap modules/groups are supported, if the classmaps share + * the class_id space [0..62] without overlap/conflict. + * + * NOTE: Due to the integer class_id, this api cannot disallow these: + * __pr_debug_cls(0, "fake CORE msg"); works only if a classmap maps 0. + * __pr_debug_cls(22, "no such class"); compiles but is not reachable + */ + /** - * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module - * @_var: a struct ddebug_class_map, passed to module_param_cb - * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic - * @_base: offset of 1st class-name. splits .class_id space - * @classes: class-names used to control class'd prdbgs + * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. + * @_var: name of the classmap, exported for other modules coordinated u= se. + * @_mapty: enum ddebug_class_map_type: 0:DISJOINT - independent, 1:LEVEL = - v2>v1 + * @_base: reserve N classids starting at _base, to split 0..62 classid s= pace + * @classes: names of the N classes. + * + * This tells dyndbg what class_ids the module is using: _base..+N, by + * mapping names onto them. This qualifies "class NAME" >controls on + * the defining module, ignoring unknown names. + */ +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + extern struct _ddebug_class_map _var; \ + struct _ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_class_maps") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D (_base), \ + .map_type =3D (_mapty), \ + .length =3D ARRAY_SIZE(_var##_classnames), \ + .class_names =3D _var##_classnames, \ + }; \ + EXPORT_SYMBOL(_var) + +/* + * XXX: keep this until DRM adapts to use the DEFINE/USE api, it + * differs from DYNAMIC_DEBUG_CLASSMAP_DEFINE by the lack of the + * extern/EXPORT on the struct init, and cascading thinkos. */ #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ static struct _ddebug_class_map __aligned(8) __used \ - __section("__dyndbg_classes") _var =3D { \ + __section("__dyndbg_class_maps") _var =3D { \ .mod =3D THIS_MODULE, \ .mod_name =3D KBUILD_MODNAME, \ .base =3D _base, \ @@ -136,6 +222,26 @@ struct _ddebug_class_param { .class_names =3D _var##_classnames, \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. + * @_var: name of the exported classmap var + * @_not_yet: _base-like, but applies only to this USEr. (if needed) + * + * This tells dyndbg that the module has prdbgs with classids defined + * in the named classmap. This qualifies "class NAME" >controls on + * the user module, and ignores unknown names. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0, __UNIQUE_ID(_ddebug_class_user)) +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _base, _uname) \ + extern struct _ddebug_class_map _var; \ + static struct _ddebug_class_user __aligned(8) __used \ + __section("__dyndbg_class_users") _uname =3D { \ + .mod_name =3D KBUILD_MODNAME, \ + .map =3D &(_var), \ + .base =3D _base \ + } + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -287,12 +393,18 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 -/* for test only, generally expect drm.debug style macro wrappers */ -#define __pr_debug_cls(cls, fmt, ...) do { \ +/* + * This is the "model" class variant of pr_debug. It is not really + * intended for direct use; I'd encourage DRM-style drm_dbg_ + * macros for the interface, along with an enum for the + * + * __printf(2, 3) would apply. + */ +#define __pr_debug_cls(cls, fmt, ...) ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ "expecting constant class int/enum"); \ dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ - } while (0) +}) =20 #else /* !(CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_D= EBUG_MODULE)) */ =20 @@ -300,6 +412,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include =20 +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) @@ -346,8 +460,7 @@ static inline int param_set_dyndbg_classes(const char *= instr, const struct kerne static inline int param_get_dyndbg_classes(char *buffer, const struct kern= el_param *kp) { return 0; } =20 -#endif - +#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 extern const struct kernel_param_ops param_ops_dyndbg_classes; =20 diff --git a/kernel/module/main.c b/kernel/module/main.c index 8515a6184be0..a554dab32133 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2695,6 +2695,9 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", sizeof(*mod->dyndbg_info.maps.start), &mod->dyndbg_info.maps.len); + mod->dyndbg_info.users.start =3D section_objs(info, "__dyndbg_class_users= ", + sizeof(*mod->dyndbg_info.users.start), + &mod->dyndbg_info.users.len); #endif =20 return 0; diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ebe33181b6e6..bf4184d91562 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2970,12 +2970,26 @@ config TEST_STATIC_KEYS If unsure, say N. =20 config TEST_DYNAMIC_DEBUG - tristate "Test DYNAMIC_DEBUG" - depends on DYNAMIC_DEBUG + tristate "Build test-dynamic-debug module" + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help - This module registers a tracer callback to count enabled - pr_debugs in a 'do_debugging' function, then alters their - enablements, calls the function, and compares counts. + This module exercises/demonstrates dyndbg's classmap API, by + creating 2 classes: a DISJOINT classmap (supporting DRM.debug) + and a LEVELS/VERBOSE classmap (like verbose2 > verbose1). + + If unsure, say N. + +config TEST_DYNAMIC_DEBUG_SUBMOD + tristate "Build test-dynamic-debug submodule" + default m + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on TEST_DYNAMIC_DEBUG + help + This sub-module uses a classmap defined and exported by the + parent module, recapitulating drm & driver's shared use of + drm.debug to control enabled debug-categories. + It is tristate, independent of parent, to allow testing all + proper combinations of parent=3Dy/m submod=3Dy/m. =20 If unsure, say N. =20 diff --git a/lib/Makefile b/lib/Makefile index c38582f187dd..4f3d09a46641 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -81,6 +81,9 @@ obj-$(CONFIG_TEST_RHASHTABLE) +=3D test_rhashtable.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD) +=3D test_dynamic_debug_submod.o +obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o +obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o =20 obj-$(CONFIG_TEST_BITMAP) +=3D test_bitmap.o ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy) @@ -215,6 +218,8 @@ obj-$(CONFIG_ARCH_NEED_CMPXCHG_1_EMU) +=3D cmpxchg-emu.o obj-$(CONFIG_DYNAMIC_DEBUG_CORE) +=3D dynamic_debug.o #ensure exported functions have prototypes CFLAGS_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug_submod.o :=3D -DDYNAMIC_DEBUG_MODULE =20 obj-$(CONFIG_SYMBOLIC_ERRNAME) +=3D errname.o =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2cd28a64578d..54f93d1d0ff2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -29,6 +29,7 @@ #include #include #include + #include #include #include @@ -43,6 +44,8 @@ extern struct _ddebug __start___dyndbg_descs[]; extern struct _ddebug __stop___dyndbg_descs[]; extern struct _ddebug_class_map __start___dyndbg_class_maps[]; extern struct _ddebug_class_map __stop___dyndbg_class_maps[]; +extern struct _ddebug_class_user __start___dyndbg_class_users[]; +extern struct _ddebug_class_user __stop___dyndbg_class_users[]; =20 struct ddebug_table { struct list_head link; @@ -159,20 +162,37 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) +#define vpr_di_info(di_p, msg_p, ...) ({ \ + struct _ddebug_info const *_di =3D di_p; \ + v2pr_info(msg_p "module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \ + _di->mod_name, _di->descs.len, _di->maps.len, \ + _di->users.len); \ + }) + +static struct _ddebug_class_map * +ddebug_find_valid_class(struct _ddebug_info const *di, const char *query_c= lass, int *class_id) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i, idx; =20 - for_subvec(i, map, &dt->info, maps) { - idx =3D match_string(map->class_names, map->length, class_string); + for_subvec(i, map, di, maps) { + idx =3D match_string(map->class_names, map->length, query_class); if (idx >=3D 0) { + vpr_di_info(di, "good-class: %s.%s ", map->mod_name, query_class); *class_id =3D idx + map->base; return map; } } + for_subvec(i, cli, di, users) { + idx =3D match_string(cli->map->class_names, cli->map->length, query_clas= s); + if (idx >=3D 0) { + vpr_di_info(di, "class-ref: %s -> %s.%s ", + cli->mod_name, cli->map->mod_name, query_class); + *class_id =3D idx + cli->map->base; + return cli->map; + } + } *class_id =3D -ENOENT; return NULL; } @@ -183,8 +203,7 @@ static struct _ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table con * callsites, normally the same as number of changes. If verbose, * logs the changes. Takes ddebug_lock. */ -static int ddebug_change(const struct ddebug_query *query, - struct flag_settings *modifiers) +static int ddebug_change(const struct ddebug_query *query, struct flag_set= tings *modifiers) { int i; struct ddebug_table *dt; @@ -204,7 +223,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, continue; =20 if (query->class_string) { - map =3D ddebug_find_valid_class(dt, query->class_string, &valid_class); + map =3D ddebug_find_valid_class(&dt->info, query->class_string, + &valid_class); if (!map) continue; } else { @@ -569,7 +589,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) =20 /* handle multiple queries in query string, continue on error, return last error or number of matching callsites. Module name is either - in param (for boot arg) or perhaps in query string. + in the modname arg (for boot args) or perhaps in query string. */ static int ddebug_exec_queries(char *query, const char *modname) { @@ -700,7 +720,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, /** * param_set_dyndbg_classes - classmap kparam setter * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type + * @kp: kp->arg has state: bits/lvl, classmap, map_type * * enable/disable all class'd pr_debugs in the classmap. For LEVEL * map-types, enforce * relative levels by bitpos. @@ -737,6 +757,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) default: return -1; } + return 0; } EXPORT_SYMBOL(param_get_dyndbg_classes); =20 @@ -1049,12 +1070,17 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i; =20 for_subvec(i, map, di, maps) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 + for_subvec(i, cli, di, users) + if (class_in_range(dp->class_id, cli->map)) + return cli->map->class_names[dp->class_id - cli->map->base]; + return NULL; } =20 @@ -1135,9 +1161,85 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) +#define vpr_cm_info(cm_p, msg_fmt, ...) ({ \ + struct _ddebug_class_map const *_cm =3D cm_p; \ + v2pr_info(msg_fmt "%s [%d..%d] %s..%s\n", ##__VA_ARGS__, \ + _cm->mod_name, _cm->base, _cm->base + _cm->length, \ + _cm->class_names[0], _cm->class_names[_cm->length - 1]); \ + }) + +static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { - vpr_info("module:%s attached %d classes\n", dt->info.mod_name, dt->info.m= aps.len); + const struct _ddebug_class_param *dcp =3D kp->arg; + + /* clamp initial bitvec, mask off hi-bits */ + if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { + *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); + v2pr_info("preset classbits: %lx\n", *dcp->bits); + } + /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ + ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp; + + if (kp->ops !=3D ¶m_ops_dyndbg_classes) + return; + + dcp =3D (struct _ddebug_class_param *)kp->arg; + + if (map =3D=3D dcp->map) { + v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); + vpr_cm_info(map, " %s maps ", mod_name); + ddebug_sync_classbits(kp, mod_name); + } +} + +static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +{ + const struct kernel_param *kp; +#if IS_ENABLED(CONFIG_MODULES) + int i; + + if (cm->mod) { + vpr_cm_info(cm, "loaded classmap: %s ", mod_name); + /* ifdef protects the cm->mod->kp deref */ + for (i =3D 0, kp =3D cm->mod->kp; i < cm->mod->num_kp; i++, kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); + } +#endif + if (!cm->mod) { + vpr_cm_info(cm, "builtin classmap: %s ", mod_name); + for (kp =3D __start___param; kp < __stop___param; kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); + } +} + +static void ddebug_apply_class_maps(const struct _ddebug_info *di) +{ + struct _ddebug_class_map *cm; + int i; + + for_subvec(i, cm, di, maps) + ddebug_apply_params(cm, cm->mod_name); + + vpr_di_info(di, "attached %d class-maps to ", i); +} + +static void ddebug_apply_class_users(const struct _ddebug_info *di) +{ + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, cli, di, users) + ddebug_apply_params(cli->map, cli->mod_name); + + vpr_di_info(di, "attached %d class-users to ", i); } =20 /* @@ -1173,6 +1275,7 @@ static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; struct _ddebug_class_map *cm; + struct _ddebug_class_user *cli; int i; =20 if (!di->descs.len) @@ -1185,26 +1288,29 @@ static int ddebug_add_module(struct _ddebug_info *d= i) pr_err("error adding module: %s\n", di->mod_name); return -ENOMEM; } + INIT_LIST_HEAD(&dt->link); /* - * For built-in modules, name (as supplied in di by its - * callers) lives in .rodata and is immortal. For loaded - * modules, name points at the name[] member of struct module, - * which lives at least as long as this struct ddebug_table. + * For built-in modules, di-> referents live in .rodata and is + * are 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->info =3D *di; - - INIT_LIST_HEAD(&dt->link); - dd_mark_vector_subrange(i, dt, cm, di, maps); - - if (di->maps.len) - ddebug_attach_module_classes(dt, di); + dd_mark_vector_subrange(i, dt, cli, di, users); + /* now di may be stale */ =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->descs.len, di->mod_name); + if (dt->info.maps.len) + ddebug_apply_class_maps(&dt->info); + if (dt->info.users.len) + ddebug_apply_class_users(&dt->info); + + vpr_info("%3u debug prints in module %s\n", + dt->info.descs.len, dt->info.mod_name); return 0; } =20 @@ -1354,8 +1460,10 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di =3D { .descs.start =3D __start___dyndbg_descs, .maps.start =3D __start___dyndbg_class_maps, + .users.start =3D __start___dyndbg_class_users, .descs.len =3D __stop___dyndbg_descs - __start___dyndbg_descs, .maps.len =3D __stop___dyndbg_class_maps - __start___dyndbg_class_maps, + .users.len =3D __stop___dyndbg_class_users - __start___dyndbg_class_user= s, }; =20 #ifdef CONFIG_MODULES diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 9c3e53cd26bd..6c4548f63512 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -6,11 +6,30 @@ * Jim Cromie */ =20 -#define pr_fmt(fmt) "test_dd: " fmt +/* + * This file is built 2x, also making test_dynamic_debug_submod.ko, + * whose 2-line src file #includes this file. This gives us a _submod + * clone with identical pr_debugs, without further maintenance. + * + * If things are working properly, they should operate identically + * when printed or adjusted by >control. This eases visual perusal of + * the logs, and simplifies testing, by easing the proper accounting + * of expectations. + * + * It also puts both halves of the subsystem _DEFINE & _USE use case + * together, and integrates the common ENUM providing both class_ids + * and class-names to both _DEFINErs and _USERs. I think this makes + * the usage clearer. + */ +#if defined(TEST_DYNAMIC_DEBUG_SUBMOD) + #define pr_fmt(fmt) "test_dd_submod: " fmt +#else + #define pr_fmt(fmt) "test_dd: " fmt +#endif =20 #include =20 -/* run tests by reading or writing sysfs node: do_prints */ +/* re-gen output by reading or writing sysfs node: do_prints */ =20 static void do_prints(void); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) @@ -29,24 +48,39 @@ static const struct kernel_param_ops param_ops_do_print= s =3D { }; module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); =20 -/* - * Using the CLASSMAP api: - * - classmaps must have corresponding enum - * - enum symbols must match/correlate with class-name strings in the map. - * - base must equal enum's 1st value - * - multiple maps must set their base to share the 0-30 class_id space !! - * (build-bug-on tips welcome) - * Additionally, here: - * - tie together sysname, mapname, bitsname, flagsname - */ -#define DD_SYS_WRAP(_model, _flags) \ - static unsigned long bits_##_model; \ - static struct _ddebug_class_param _flags##_model =3D { \ +#define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) + +/* sysfs param wrapper, proto-API */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ + static unsigned long bits_##_model =3D _init; \ + static struct _ddebug_class_param _flags##_##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_m= odel, 0600) + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ + &_flags##_##_model, 0600) +#ifdef DEBUG +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) +#else +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) +#endif + +/* + * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. + * + * To comport with DRM debug-category (an int), classmaps map names to + * ids (also an int). So a classmap starts with an enum; DRM has enum + * debug_category: with DRM_UT_. We use the enum + * values as class-ids, and stringified enum-symbols as classnames. + * + * Modules with multiple CLASSMAPS must have enums with distinct + * value-ranges, as arranged below with explicit enum_sym =3D X inits. + * To clarify this sharing, declare the 2 enums now, for the 2 + * different classmap types + */ =20 /* numeric input, independent bits */ enum cat_disjoint_bits { @@ -60,26 +94,51 @@ enum cat_disjoint_bits { D2_LEASE, D2_DP, D2_DRMRES }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "D2_CORE", - "D2_DRIVER", - "D2_KMS", - "D2_PRIME", - "D2_ATOMIC", - "D2_VBL", - "D2_STATE", - "D2_LEASE", - "D2_DP", - "D2_DRMRES"); -DD_SYS_WRAP(disjoint_bits, p); -DD_SYS_WRAP(disjoint_bits, T); - -/* numeric verbosity, V2 > V1 related */ -enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, - "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); -DD_SYS_WRAP(level_num, p); -DD_SYS_WRAP(level_num, T); + +/* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ +enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; + +/* recapitulate DRM's multi-classmap setup */ +#if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) +/* + * In single user, or parent / coordinator (drm.ko) modules, define + * classmaps on the client enums above, and then declares the PARAMS + * ref'g the classmaps. Each is exported. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, + D2_CORE, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, + V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); + +/* + * now add the sysfs-params + */ + +DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); + +#else /* TEST_DYNAMIC_DEBUG_SUBMOD */ + +/* + * in submod/drm-drivers, use the classmaps defined in top/parent + * module above. + */ + +DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); +DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); + +#endif =20 /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") @@ -115,6 +174,7 @@ static void do_levels(void) =20 static void do_prints(void) { + pr_debug("do_prints:\n"); do_cats(); do_levels(); } diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c new file mode 100644 index 000000000000..672aabf40160 --- /dev/null +++ b/lib/test_dynamic_debug_submod.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +/* + * clone the parent, inherit all the properties, for consistency and + * simpler accounting in test expectations. + */ +#define TEST_DYNAMIC_DEBUG_SUBMOD +#include "test_dynamic_debug.c" --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.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 D21272E8B6F for ; Thu, 11 Sep 2025 21:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626752; cv=none; b=lY5C1f9Hg1LLrG1HY3Bh+kFFZU3dCqM88HZByT7yzJ55C5Xv5CIpLkPX5nol4k9r4/9ZQvNx63Cy81qPVZ2BHr8WDvsLyGh9GEyQWlldtzUu5fcsdxnZOCC6pfrOTYrMBaaQNrCbda3EvlrBDUb3ZlKrw1xBUlGY0gVadi6H3bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626752; c=relaxed/simple; bh=aeDWjd1XVoWEBDg5Eyu5c86Bx9UHoc1Fx952BSdfPh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rLn/b1J9uUwMrp+UdwspN8fXQu9idYrF+qmIIzL4JNqBocoUlUqw8W9aEKp1yPVBEZCCPdDGjlK8EDmK4Esy+dRL/lkRqRkAyuJzHat+8IEEGa76craomNWh8qcDzBdD++yfGu1pvyHGEisHqwc34C8uTPe/jraBPL+WvJD5LHc= 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=KUjOz4Hr; arc=none smtp.client-ip=209.85.166.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="KUjOz4Hr" Received: by mail-io1-f48.google.com with SMTP id ca18e2360f4ac-88432e1af6dso91937639f.2 for ; Thu, 11 Sep 2025 14:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626749; x=1758231549; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C//yQQeTu+jEQ0EAFTF0I0EUgCZDFyfAeN4kEIk2I9c=; b=KUjOz4HrnO7pU0GJv8BhgJ3FZ5dJDVh5roXhuK4LmUDFJh0zYJXQOaxG9PCjOVE/Wr zU4Yqwe1LfhapfcJn9oH60nOzL0LjZ7BA05eKuH0Ex5PiYpu98/2lrIvWLX2dWfamJaI 3KmfGMgTfgm6pMZjpgWS7coLUpnMv8G1/yBnXQjHooqNbl9xJU6FiGw/inw7NShomQR1 jUhTFdPNm4r1abPq+Gwct86IR7yhbUaM7UaVl5ijvEcIdsqul1XZGVyakwAFNUXtt83R xb99v6RlfJDHV3LiNKb7kiRpQIc+xlRoENxgm1C30AQXyfhOmxJSZ1L88c5V80yGxaGh mfoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626749; x=1758231549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C//yQQeTu+jEQ0EAFTF0I0EUgCZDFyfAeN4kEIk2I9c=; b=PB1T1Tqznrf0Sz6MoN6TAbEVN3GGe9WAEPWbWhxfVC55Od+oFwAxNW1UV3w2rx0iGL UsPCaJAiUzs7P1oTtMmhZnvyKHrY8cxn5u5R6s1v3ZK1gjau1sfJSrCr7i2xE+F/Lvvo QW8g2qHKzzqPIQvmgxkjNMjYMkYYgFVoTwfZdIXp+Rmop33JO8Sw49qML4FuG3BjEgO/ rrRXgsIz4lR6/PBJjwgPKN2qWRpq94Xk6hNiK/TH32ocl2/t1es17hz904DY8IDE6GbQ xHLZW1IXQ0SxBAmMVYL280NzdD6XseXaRQgHmBJx4kmBmA9yNZAmyay5YffaryizorvP COjw== X-Forwarded-Encrypted: i=1; AJvYcCWWbzh0fPRznrd5JIs5d88x9nPkPEHNphxlvuvb4GsyB11obyu7QubnRWg5FxWXDKxQB9qwUnpLI0Lq10M=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6MJrcFOrfmVJChTXxmcMicVOEfvm+8MolxGgiEmf66l0SByJn 1CV9Yj6oHACTDb0ePPNipnqbmkYwAghy3V7zhydI9B7Nf1klftWNICkd X-Gm-Gg: ASbGncv9uuL1Fozm64eqar+hRuSoMA/zPuAOA0uL/h52QxRUuApFCXwYPw4Xv+U542w 6eNZXyQkehQpTSnF6WK/XH4kUY2DBvf3dQNnPu3x99nQnpEwG7nB6lqBmVfr1JlHn+rrLlwp3Xf Pch3ja6Wl1wCDjEjEC9ZfSfmrXL3bsAXXCRrDm0SPQweCK5d2D4YSAi5ieibTUK9xVz7VWfh6H7 HoSywFdGu4vTLT35I0Pb2q1Mxt3K5cks9BwbX4SRbh6hijPyxYu51lTBr1Qr2PFsRLwr9pUOStC VD6hJ3Ajd/2Fnl+eebu8QcILG3/Cv7LQRuKUd4lILTjjcvNEfQQAwnCBA9cSxgpyEZ6DZoxpKX8 o8iubo6twRrP3s64dSi0t2xHpQwOw4ZSU0rJHqGVG8EbdeAPfq/mTlp8CiIIaA4pq3Xma9yZR8I +k3G9Mcq+9VO6ilkxgDDLNx4EI X-Google-Smtp-Source: AGHT+IEpa3ns1mvC1S52O8YWI40otKMGoW9WOmC/VcZ+5bFrA/7iKWELB83NSsPYI3FR7mXchVaQpA== X-Received: by 2002:a05:6602:2dcb:b0:887:7a86:93e with SMTP id ca18e2360f4ac-890343323b9mr122515039f.11.1757626748722; Thu, 11 Sep 2025 14:39:08 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:08 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 21/30] dyndbg: detect class_id reservation conflicts Date: Thu, 11 Sep 2025 15:38:14 -0600 Message-ID: <20250911213823.374806-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If a module _DEFINEs 2 or more classmaps, it must devise them to share the per-module 0..62 class-id space; ie their respective base,+length reservations cannot overlap. To detect conflicts at modprobe, add ddebug_class_range_overlap(), call it from ddebug_add_module(), and WARN and return -EINVAL when they're detected. This insures that class_id -> classname lookup has just 1 answer, so the 1st-found search in find-class-name works properly. test_dynamic_debug.c: If built with -DFORCE_CLASSID_CONFLICT, the test-modules invoke 2 conflicting DYNAMIC_DEBUG_CLASSMAP_DEFINE() declarations, into parent and the _submod. These conflict with one of the good ones in the parent (D2_CORE..etc), causing the modprobe(s) to warn Signed-off-by: Jim Cromie --- - USE doesnt need conflict test against DEFINE infact its wrong-headed - of course theyd overlap. --- lib/dynamic_debug.c | 27 +++++++++++++++++++++++++++ lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 54f93d1d0ff2..b6a5219d71af 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1267,6 +1267,22 @@ static void ddebug_apply_class_users(const struct _d= debug_info *di) (_dst)->info._vec.len =3D nc; \ }) =20 +static int __maybe_unused +ddebug_class_range_overlap(struct _ddebug_class_map *cm, + u64 *reserved_ids) +{ + u64 range =3D (((1ULL << cm->length) - 1) << cm->base); + + if (range & *reserved_ids) { + pr_err("[%d..%d] on %s conflicts with %llx\n", cm->base, + cm->base + cm->length - 1, cm->class_names[0], + *reserved_ids); + return -EINVAL; + } + *reserved_ids |=3D range; + return 0; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1276,6 +1292,7 @@ static int ddebug_add_module(struct _ddebug_info *di) struct ddebug_table *dt; struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; + u64 reserved_ids =3D 0; int i; =20 if (!di->descs.len) @@ -1300,6 +1317,11 @@ static int ddebug_add_module(struct _ddebug_info *di) dd_mark_vector_subrange(i, dt, cli, di, users); /* now di may be stale */ =20 + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, di, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1312,6 +1334,11 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE("dyndbg multi-classmap conflict in %s\n", di->mod_name); + kfree(dt); + return -EINVAL; + } =20 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 6c4548f63512..1ba4be9a403a 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -128,6 +128,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_= TYPE_LEVEL_NUM, DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); =20 +#ifdef FORCE_CLASSID_CONFLICT +/* + * Enable with -Dflag on compile to test overlapping class-id range + * detection. This should warn on modprobes. + */ +DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +#endif + #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ =20 /* --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.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 DE4612EBB8B for ; Thu, 11 Sep 2025 21:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626754; cv=none; b=suF6lCc/kKJ1Z96v8RnLoLTaHwoGxNI4fANcG9Tfs6HcUkWmCHjIVZo5sMrVs5WKV7BpmLCXYYIvf1+CX/9CRHe3LQ2sD0CmMA2+1BTZD+L/3g2WWSGsQn1fzQhTruWAEvTcGXnDf+QD5AfwBkF3O1Jj9G7MtwNrWYedhzU2UYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626754; c=relaxed/simple; bh=Stb9gWLH6uJuqT+1HZagkMDgNJ+3r9ifT5CAmLLMAl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I4QSTu3ScdyJkztvDp82n/024YNM5eJg3hOZtS99NqazfeBoYZj5dBf+Uh/1kCopCQFo2iL/bfadSDDRHjSgngcTqxoJ8L1lgM+MddGuY+9fiDyDbHGx5pClTJp0lfQMW2KArmD7hycnHYjvVdg9Gc5L0+4aew7stXAcNpUZksM= 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=lANsnwSJ; arc=none smtp.client-ip=209.85.166.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="lANsnwSJ" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-88432e1af6dso91939039f.2 for ; Thu, 11 Sep 2025 14:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626750; x=1758231550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W0XzNWaGxbCntgrurWhYrm4iEPkiXeipxXgUvuzvBHw=; b=lANsnwSJdGeTYnCgTVtfAzCudWWfOR5kZaVh+4mhZAcNX83B7R4ZAMOJVmr1wegroF Gea3/QeNPFNLhUxDmCGkCgkAJH3IMVJjaY2eLpEWkljTMcVQGnEgO6jArodHJGHTOeSL jYYdKojB8wz5AuzHdvwxEZrcsGiRh/koK1dX10hIn/j5E5Z/dIh9nCLVDQP+o6JLyoHW bPYwQlHDf9Ge9VQVTpMHhplf+Zf2fYC+IWrouPn1prUN/YW4y+n/pjE1f8wcUr9ilsYG wA3YKEJ3XMR2+tAUQZkWnWBwcQjdeUAFJudLechLLRHDijv65c9V8BNVROdzG8JGNNNj SqBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626750; x=1758231550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W0XzNWaGxbCntgrurWhYrm4iEPkiXeipxXgUvuzvBHw=; b=KuKNUl3a4O89TrKZP62EoM4hxr2YmaZ+BehRw4ioR2xijbLzc0b6N1GBzXX+0li7ln P4uIipJgCwQPTobTy977cmsnIjFhoF0kD/GMQ3HAp0vDqktm2PajdrZxp3DIQ1DGZIQf mwCQ/UMnzL1pnghBmTtZc1csAxzodIBnP292Pl3hVQAyJLUsm1hTY+yW+IARpWirzyZe a1o3RPFWo00utIvLjhqsixJOHGRhQHn/a5AbmdSmMzdipmYpVzyMlbV2u53QWy9DZUyB KdZdoD5TFNi8/TB1DpwnzM52b8vACpN8jYiQ/nsXktuoGaO6PSmjD/EimEke+BylC8vz 3oUw== X-Forwarded-Encrypted: i=1; AJvYcCWc4iNDw8NmgcpTd/GCoW66Ogb9qMxQNxruUYEgyHc73WwxOs6b/J6PHUJSjtpoy/59CsH0q/VoVQ6caF4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5EP59dguRO7Fc9GMd6kkg9eZZLYc/fHW9pfBFmsNmxw2OjY8X H69RkcHTilpVpMM+CGeLe/AiXl5kIsahQw3zqohrzpBg9N9XBdF2has6 X-Gm-Gg: ASbGnct6oa1rx+xVWlGJOv5wUN9zoQmgqOquj4yY7Tr8lD8xh6r4/GqVw/aE5DWF3qi dK96i8ewhVRAvMvlym/ughD0Rkci1aiLUOBXkIDGscLnOi8zSkSmIyO0knIbCyTqXPJti5ds22M BKW5pJofmIgfL2a+exU1mdComAYqZC6smE0CuDiwWa+1QeI0AwWIPxZUNUWvTiLM9H2yO64oMDa lyfFI+WHYt8JfbeBObant9oQ52Viz34Etbv4gyj7iheT4oZ+pWBbWEw7eQkepsIbqV9aIAklcBV 131i9MGcwNrbISc1Ec5xPmBM5L1uVPTtjUILMDZvp2puLX54ZpBwqoxsYAKQ4namgXB14e8WzO8 ETIcIh1anNqouppsPqqL2Tp+WlHCRpWye9zOCjsI+P6O0Or2vqlIzrqZz7T4pq5DaK78/Lry3EB 46dPI23eBEpLws4Ah8wE+z19jV X-Google-Smtp-Source: AGHT+IGPEwXrxn6n0S7/ZE+Uf+F5x6+mjgx7v8qaZx2zlfhPwr9AtRp6Hg3uPX0TJjiA3OVC01GP4Q== X-Received: by 2002:a05:6602:600e:b0:887:29c4:d64d with SMTP id ca18e2360f4ac-890351afe7fmr149942639f.19.1757626749633; Thu, 11 Sep 2025 14:39:09 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:09 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 22/30] dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time Date: Thu, 11 Sep 2025 15:38:15 -0600 Message-ID: <20250911213823.374806-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add __DYNAMIC_DEBUG_CLASSMAP_CHECK to implement the following arg-checks at compile-time: 0 <=3D _base < 63 class_names is not empty class_names[0] is a string (class_names.length + _base) < 63 These compile-time checks will prevent several simple misuses, and will issue obvious errors if violated. 4 such examples are added to test_dynamic_debug_submod.ko, and will fail compilation if -DDD_MACRO_ARGCHECK is added to cflags. This wouldn't be a useful CONFIG_ item, since it breaks the build. Signed-off-by: Jim Cromie --- v4- deconflict after pulling macro-stubs forward v3- $macro_name =3D~ s/DYNDBG/DYNAMIC_DEBUG/ prev- - split static-asserts to __DYNDBG_CLASSMAP_CHECK - move __DYNDBG_CLASSMAP_CHECK above kdoc for DYNDBG_CLASSMAP_DEFINE silences kernel-doc warnings --- include/linux/dynamic_debug.h | 9 +++++++++ lib/test_dynamic_debug.c | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2c64f2401e51..b96f069290bd 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -180,6 +180,14 @@ struct _ddebug_class_param { * __pr_debug_cls(22, "no such class"); compiles but is not reachable */ =20 +#define __DYNAMIC_DEBUG_CLASSMAP_CHECK(_clnames, _base) \ + static_assert(((_base) >=3D 0 && (_base) < _DPRINTK_CLASS_DFLT), \ + "_base must be in 0..62"); \ + static_assert(ARRAY_SIZE(_clnames) > 0, \ + "classnames array size must be > 0"); \ + static_assert((ARRAY_SIZE(_clnames) + (_base)) < _DPRINTK_CLASS_DFLT, \ + "_base + classnames.length exceeds range") + /** * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. * @_var: name of the classmap, exported for other modules coordinated u= se. @@ -193,6 +201,7 @@ struct _ddebug_class_param { */ #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + __DYNAMIC_DEBUG_CLASSMAP_CHECK(_var##_classnames, (_base)); \ extern struct _ddebug_class_map _var; \ struct _ddebug_class_map __aligned(8) __used \ __section("__dyndbg_class_maps") _var =3D { \ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 1ba4be9a403a..b2bdfdfb6ba1 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -133,7 +133,7 @@ DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); * Enable with -Dflag on compile to test overlapping class-id range * detection. This should warn on modprobes. */ -DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_= CORE"); #endif =20 #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ @@ -146,8 +146,19 @@ DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_C= ORE + 1, "D3_CORE"); DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 +#if defined(DD_MACRO_ARGCHECK) +/* + * Exersize compile-time arg-checks in DYNAMIC_DEBUG_CLASSMAP_DEFINE. + * These will break compilation. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_neg, 0, -1, "NEGATIVE_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_big, 0, 100, "TOOBIG_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_str_type, 0, 0, 1 /* not a string */); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_emptyclass, 0, 0 /* ,empty */); #endif =20 +#endif /* TEST_DYNAMIC_DEBUG_SUBMOD */ + /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.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 96F14311974 for ; Thu, 11 Sep 2025 21:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626754; cv=none; b=XxLHegRp8KQwI6xQH4R4MJ8YrtEfSCSQxYHfWQAXh1I5YdfgiEHHJTxy7WcjrpL/0jg596hvfHJxmAyGpg74lMjtGObn5lgwxDNLpVBzB4f+cR8UzpSaSZX6iFhbjJA/w3B4v4VpR7zSKXmbPGT2liInX0KfF8mxqIz8luD6GTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626754; c=relaxed/simple; bh=jYTp9B54aHLVfgeXIg3NyIskdozVnt9ZijXB+1faPyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z20zCp5/acE6ozalytRhUqJAzpUspILAZLoU0CwNym4TLLktge0RU7ayHP2LC/QglQjDbfIGqm4zmNVdfUcvMQMfZUxQoQvqhzFkYiYuJWXlBP0fpcWKGFVySzTWxtm3TeejIb+ilm6w+NqlpkuYd2GFA+b+S2RSsaWxGQEnLgI= 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=U/czUfLM; arc=none smtp.client-ip=209.85.166.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="U/czUfLM" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-8877677dbaeso29821539f.0 for ; Thu, 11 Sep 2025 14:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626750; x=1758231550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wWtqPHzvZoScVts3x626CqF+Swe2KDKHU2aMYO19y8E=; b=U/czUfLMyJNA96dbl7MtsEqMij1Uhc2dAEremF2fAv3/hm9+L9khEFpJ/II381rfs5 fC7Z8Vng0vChcPFPSJVNC8NPZbYK1bey455pQsPsCVxojsNu0/lgAuO8AYHHICJZNCUV Nz2Kf5IptgdKLUADIL8mLvJSC7rWrelXv9YCTh1AmYRMjNSHsYDYl/2NmsiKs5QsT/Fb 5y8j4BqzlLbUrfujrUDK4ky80GU4ERsTkzwVgln7Kir3PHjeZnF97Se8NQnqSEgu5JAb zIs6DaJv8p+E4O4OTZlYNX8qF1CUUamBJWFGa+C5AHrsbQjWFotyQmcxNv3IT7puEy1p 61kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626750; x=1758231550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wWtqPHzvZoScVts3x626CqF+Swe2KDKHU2aMYO19y8E=; b=LB+W4+uCsqBQrkOscnDFQUxYCpIGvsf5uvmbB1c695A9WwftIhUJk3Vcm39Nz7Y34X u7Y7YVg39a9IXZvsUFp1H+smoaS3cO0B5nJORrQda2hfElE/FWUQG8wfTnDNjraS1Sli R4YM4HWzcPd/EDh9PiYdoCz14NMTKltUU8pLfO09dkDeYQ44knpIqXFE0s+uS0HLDJyr vc0pngVmFEAqgsMXkJNy73ubD2Z6YvHJUYjoZ6i17sVG71FLDzAwLIgcQOTAi7NHsVWu 4MKNZs9Bewoi9SbtZCDcoikJDwQqOsKgR0dTQWTyhGi7e5I0wV4uoNGW6vaXQBqIj8n+ uGUw== X-Forwarded-Encrypted: i=1; AJvYcCWLnPntxDGy2upTG4tKBbdGZHdsXEHWCLHmx9h+PnmcGlITrzaP0A3AOtPwVYdfpj14wTDdC8Cs5eBUNBs=@vger.kernel.org X-Gm-Message-State: AOJu0YyByV+xnyiLpwWe3IBeXVt+Y3LjdUw2ENWIqDfKiEBfKr1GS0KL DKug2jJll92iavnOYPMLL1Q4j6muZJ1BtMPLbLegLyfIHmfaoJxXisnq X-Gm-Gg: ASbGncsE8Gn4yvVreVLTg/eeJcWL6laBQpn8+5Mtc4p5vMXj1vHyRKEyPs3ialH1kKF j/hY2cJuhxP90X0bSFDcQy6foS2VadPAw+V6/8pLz/QzvM1uUaHpt6xzlpwZZuYE3fOm/RXdodP 7Fuclphxt3xWRBKiVC555odDOEuWlYXgQMTtC4VYIZtl5q80J4EY0TimF0knyeSJpX/YtnEgqn/ 0d8aiWrQxy9qUkhiIjik27MJjfAxhz00dhp2gnNWg9uT73buAqBsH9MOEdmg2//Y3an886FSvzr rpXr6iLCmQHiqySdVIKl29CP2PyrFfF2PID1BUwvXs0muLNZcg9mhxuayxwTVi5ASutDEZvft/a KK0LTvm9Ise9ciHZ9bzFLGiRxkXnOJXG5jg3BpoyvSNnwN/2lvJutFU76PYvdHJpc7P9I7qxiG5 4trVnHwJLXhIXncA== X-Google-Smtp-Source: AGHT+IE5LddwjuBNCTtYiX9X9AVovxOJ//0BaqdW3KbJpOPnh+BMlS5K5COQlhpLlD6jCU5d7XYB5A== X-Received: by 2002:a05:6602:1591:b0:887:574d:dfbb with SMTP id ca18e2360f4ac-8903451f4cfmr111537339f.11.1757626750604; Thu, 11 Sep 2025 14:39:10 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:10 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 23/30] dyndbg-test: change do_prints testpoint to accept a loopct Date: Thu, 11 Sep 2025 15:38:16 -0600 Message-ID: <20250911213823.374806-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" echo 1000 > /sys/module/test_dynamic_debug/parameters/do_prints This allows its use as a scriptable load generator, to generate dynamic-prefix-emits for flag combinations vs undecorated messages. This will make it easy to assess the cost of the prefixing. Reading the ./do_prints node also prints messages (once) to the-log. NB: the count is clamped to 10000, chosen to be notice able, but not annoying, and not enough to accidentally flood the logs. Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index b2bdfdfb6ba1..fa81177e8089 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -29,18 +29,25 @@ =20 #include =20 -/* re-gen output by reading or writing sysfs node: do_prints */ - -static void do_prints(void); /* device under test */ +/* re-trigger debug output by reading or writing sysfs node: do_prints */ +static void do_prints(unsigned int); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) { - do_prints(); + int rc; + unsigned int ct; + + rc =3D kstrtouint(instr, 0, &ct); + if (rc) { + pr_err("expecting numeric input, using 1 instead\n"); + ct =3D 1; + } + do_prints(ct); return 0; } static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { - do_prints(); - return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); + do_prints(1); + return scnprintf(buffer, PAGE_SIZE, "did 1 do_prints\n"); } static const struct kernel_param_ops param_ops_do_prints =3D { .set =3D param_set_do_prints, @@ -191,17 +198,20 @@ static void do_levels(void) prdbg(V7); } =20 -static void do_prints(void) +static void do_prints(unsigned int ct) { - pr_debug("do_prints:\n"); - do_cats(); - do_levels(); + /* maybe clamp this */ + pr_debug("do-prints %d times:\n", ct); + for (; ct; ct--) { + do_cats(); + do_levels(); + } } =20 static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); + do_prints(1); pr_debug("init done\n"); return 0; } --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.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 E6CF931C57B for ; Thu, 11 Sep 2025 21:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626755; cv=none; b=S8gqP99IwiRneADS3v2xgbdHbtZHtWNaOjck8VHDdLd9p7Sox0ZuP2GC6OCgQcIF1VbQCskOf3U/BdgP53swFDlHliQDp4COUStfA4LVucIAjuZ2WuuCjHWspCLJIWGSmJ9DiPxBrLp5/P8+7a8oUQm4/1PV8VVhTIp7lAMmTzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626755; c=relaxed/simple; bh=S+68avOFBqf5C4De21lDrUWxtxOfEE7gYDlFBK10YCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ia6n9+YnOeGrSpqRT9cxS+rZt82rZVyUpHROb0u4uvkIV1Tr8ZBDeC2MyzqXZi0AuDC9GcxvY6GiGLr7jBcNUo648LjXjc+0sfU9HahhbjQKYHTUBeI4aZ/K9fa45Gzljia/0QgoWLxqCMooGUD1ZdbqAB3/RqT6PYQOfhY4Gq8= 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=QIGeLNh0; arc=none smtp.client-ip=209.85.166.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="QIGeLNh0" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-889b846c314so35218539f.2 for ; Thu, 11 Sep 2025 14:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626752; x=1758231552; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HdcOGQQjGLjfYBL4dlDZ/eh+HVP7cV2y3UoDXTNblhU=; b=QIGeLNh0cGazRMU/fmEBSn/kx4WHYr7g4hexYgC2XVofD6Vm/p64Hng3GgHCUWSQLk 6xw5n557uDt0mMusjhnzVVKTGfk/lo/myXnvo16XA2upliuYGkIUCw7SFVnLjaKIgit1 vDtHAJCka4QZKbc0QsYhcLaXXE8dsdh693XUyKSVoPOz4640S1D+RT84WbrF0YpGHNEY F1NLoR4xdIJh7G29S8gB7w+clHW6TndXTKy/9bByp956EQwpkzbDmAPwBk7JPeC9Z+3d LWxYOMWoj/z2K5a4bTGcSyJ8qZOJqNG36mf4k0HSheXh6Qa8dLlse1W4PtuVizPqQr2j UkuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626752; x=1758231552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HdcOGQQjGLjfYBL4dlDZ/eh+HVP7cV2y3UoDXTNblhU=; b=XFArWPN8rQNsKB35UmK9i5sCeknS/6H0eGx9agu6Djm7FHokCBKewKhjUpNU6U12dX iMAkIl33GuwUUbSldSrxuy/LbBNj8n1J3lRQAzy5edx8nDqdcR+iBVx6561e0dFmj90d UkxSv1/ekWSyvEteUIkRw68GqF3H6+vAKvmm97d9KwL/nSIMdr0s/bBvXgFbOiRabfiV JZZKaUbXRhM2bncA3sunNKckcmy+CqhLLR/7LQlN3Br8KW3+OdAiXxTbUh7Mn0bB8fz9 TqzhBkI4VeRMzZ4GitQNSH3nX0GvT+1BE4cQjwO2nWPtnorDH3mtMWfcVd746py2d8Jr pO3A== X-Forwarded-Encrypted: i=1; AJvYcCWkklaw5ddcenRTCqZP3iRpuaPxts/hXTrUi5lHJOSsnYJPHClemnlqRdbF4Y4WEYG2npH6eJk/cv8Af8A=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzz/LEGQiMJRPUxN2TTPNf7eOu+KkivH7wO56g83BGzOy74W4R ArFYZceSHgjtZDbBaRK7Bg5oC6qg9ELFxF6Zd9cq5jF4TQO7Lt06xPI2 X-Gm-Gg: ASbGncsGOg6/5DJ6YYIE8+pwb2tv3D67NMEmqMcinjHft3RUP0tkIV6FXMB6zBm7EOS ihPax0biyZ2jHMw0oPSGGSinsDPX05BEymZelYNTuuy1wnVOBPbCzQYVsIV+lXR61BS2j7C7Zw2 fhYZZ4OwY8cfuBoUAcENonupi2Z3reTStA09f72XEiOu5PGpj6rUdo3GE8eDBeUhMrW2gnoboOn ME5jO/tCr0QgAR6+27K8pZHfExlTqC9SLuJ3XMAFo/kZQ6oTbrleN7Duyzz6eg3BZDN4+ilbKnQ whVETlYQlCU9FNk1rM0Ir0kDbzvv7eGVYwbFxvO4xW5lMkKSPCXfhp/aVVgjN2QSfjnjbZQfzg1 f7BH2i8bZh7HVlEKlhAb7jqkwntdTH9EJ9LP2J5CiocCExmuXpPHg1sKxhoEUxFFt8XOjmAvdMp rx+84= X-Google-Smtp-Source: AGHT+IE06gtrpYljJMiiR4CKSM4Ys3BekwEi5E5g3S1vGdVIcAKiYXH3OX1uGDSOiRPmwfUS3LsaDQ== X-Received: by 2002:a05:6602:15c8:b0:887:596e:fadb with SMTP id ca18e2360f4ac-8903423ca80mr121691439f.13.1757626751577; Thu, 11 Sep 2025 14:39:11 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:10 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH 24/30] dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API Date: Thu, 11 Sep 2025 15:38:17 -0600 Message-ID: <20250911213823.374806-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" move the DYNAMIC_DEBUG_CLASSMAP_PARAM macro from test-dynamic-debug.c into the header, and refine it, by distinguishing the 2 use cases: 1.DYNAMIC_DEBUG_CLASSMAP_PARAM_REF for DRM, to pass in extern __drm_debug by name. dyndbg keeps bits in it, so drm can still use it as before 2.DYNAMIC_DEBUG_CLASSMAP_PARAM new user (test_dynamic_debug) doesn't need to share state, decls a static long unsigned int to store the bitvec. __DYNAMIC_DEBUG_CLASSMAP_PARAM bottom layer - allocate,init a ddebug-class-param, module-param-cb. Modify ddebug_sync_classbits() argtype deref inside the fn, to give access to all kp members. Also add stub macros, clean up and improve comments in test-code, and add MODULE_DESCRIPTIONs. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- -v10 add stub macros -v9 - fixup drm-print.h add PARAM_REF forwarding macros with DYNAMIC_DEBUG_CLASSMAP_PARAM_REF in the API, add DRM_ variant --- include/linux/dynamic_debug.h | 40 ++++++++++++++++++++++ lib/dynamic_debug.c | 60 ++++++++++++++++++++++----------- lib/test_dynamic_debug.c | 47 ++++++++++---------------- lib/test_dynamic_debug_submod.c | 9 ++++- 4 files changed, 106 insertions(+), 50 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b96f069290bd..4ceb69f0e493 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -251,6 +251,44 @@ struct _ddebug_class_param { .base =3D _base \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM - control a ddebug-classmap from a sys-par= am + * @_name: sysfs node name + * @_var: name of the classmap var defining the controlled classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported classmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in a private long int. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ + static unsigned long _name##_bvec; \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _name##_bvec, _var, _flags) + +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM_REF - wrap a classmap with a controlling s= ys-param + * @_name: sysfs node name + * @_bits: name of the module's unsigned long bit-vector, ex: __drm_debug + * @_var: name of the (exported) classmap var defining the classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported clasmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in user @_bits. This lets drm check + * __drm_debug elsewhere too. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) + +#define __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) \ + static struct _ddebug_class_param _name##_##_flags =3D { \ + .bits =3D &(_bits), \ + .flags =3D #_flags, \ + .map =3D &(_var), \ + }; \ + module_param_cb(_name, ¶m_ops_dyndbg_classes, \ + &_name##_##_flags, 0600) + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -423,6 +461,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) #define DYNAMIC_DEBUG_CLASSMAP_USE(_var) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _var, _flags) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b6a5219d71af..440fe2f483a3 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -666,6 +666,30 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 +static void ddebug_class_param_clamp_input(unsigned long *inrep, const str= uct kernel_param *kp) +{ + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; + + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + /* expect bits. mask and warn if too many */ + if (*inrep & ~CLASSMAP_BITMASK(map->length)) { + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", + KP_NAME(kp), *inrep, CLASSMAP_BITMASK(map->length)); + *inrep &=3D CLASSMAP_BITMASK(map->length); + } + break; + case DD_CLASS_TYPE_LEVEL_NUM: + /* input is bitpos, of highest verbosity to be enabled */ + if (*inrep > map->length) { + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", + KP_NAME(kp), *inrep, map->length); + *inrep =3D map->length; + } + break; + } +} static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -684,26 +708,15 @@ static int param_set_dyndbg_module_classes(const char= *instr, pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } + ddebug_class_param_clamp_input(&inrep, kp); =20 switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: - /* expect bits. mask and warn if too many */ - if (inrep & ~CLASSMAP_BITMASK(map->length)) { - pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", - KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); - inrep &=3D CLASSMAP_BITMASK(map->length); - } v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: - /* input is bitpos, of highest verbosity to be enabled */ - if (inrep > map->length) { - pr_warn("%s: level:%ld exceeds max:%d, clamping\n", - KP_NAME(kp), inrep, map->length); - inrep =3D map->length; - } old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); @@ -1171,15 +1184,24 @@ static const struct proc_ops proc_fops =3D { static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { const struct _ddebug_class_param *dcp =3D kp->arg; + unsigned long new_bits; =20 - /* clamp initial bitvec, mask off hi-bits */ - if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { - *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); - v2pr_info("preset classbits: %lx\n", *dcp->bits); + ddebug_class_param_clamp_input(dcp->bits, kp); + + switch (dcp->map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + v2pr_info(" %s: classbits: 0x%lx\n", KP_NAME(kp), *dcp->bits); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0UL, modname); + break; + case DD_CLASS_TYPE_LEVEL_NUM: + new_bits =3D CLASSMAP_BITMASK(*dcp->lvl); + v2pr_info(" %s: lvl:%ld bits:0x%lx\n", KP_NAME(kp), *dcp->lvl, new_bits= ); + ddebug_apply_class_bitmap(dcp, &new_bits, 0UL, modname); + break; + default: + pr_err("bad map type %d\n", dcp->map->map_type); + return; } - /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ - ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); - ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); } =20 static void ddebug_match_apply_kparam(const struct kernel_param *kp, diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index fa81177e8089..83c4d571a8c9 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems like DRM. * * Authors: * Jim Cromie @@ -57,24 +58,6 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0= 600); =20 #define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) =20 -/* sysfs param wrapper, proto-API */ -#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ - static unsigned long bits_##_model =3D _init; \ - static struct _ddebug_class_param _flags##_##_model =3D { \ - .bits =3D &bits_##_model, \ - .flags =3D #_flags, \ - .map =3D &map_##_model, \ - }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ - &_flags##_##_model, 0600) -#ifdef DEBUG -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) -#else -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) -#endif - /* * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. * @@ -105,12 +88,15 @@ enum cat_disjoint_bits { /* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; =20 -/* recapitulate DRM's multi-classmap setup */ +/* + * use/demonstrate multi-module-group classmaps, as for DRM + */ #if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) /* - * In single user, or parent / coordinator (drm.ko) modules, define - * classmaps on the client enums above, and then declares the PARAMS - * ref'g the classmaps. Each is exported. + * For module-groups of 1+, define classmaps with names (stringified + * enum-symbols) copied from above. 1-to-1 mapping is recommended. + * The classmap is exported, so that other modules in the group can + * link to it and control their prdbgs. */ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, D2_CORE, @@ -129,11 +115,13 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS= _TYPE_LEVEL_NUM, V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); =20 /* - * now add the sysfs-params + * for use-cases that want it, provide a sysfs-param to set the + * classes in the classmap. It is at this interface where the + * "v3>v2" property is applied to DD_CLASS_TYPE_LEVEL_NUM inputs. */ =20 -DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); -DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_disjoint_bits, map_disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_level_num, map_level_num, p); =20 #ifdef FORCE_CLASSID_CONFLICT /* @@ -144,12 +132,10 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict,= 0, D2_CORE + 1, "D3_CORE") #endif =20 #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ - /* - * in submod/drm-drivers, use the classmaps defined in top/parent - * module above. + * the +1 members of a multi-module group refer to the classmap + * DEFINEd (and exported) above. */ - DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 @@ -224,6 +210,7 @@ static void __exit test_dynamic_debug_exit(void) module_init(test_dynamic_debug_init); module_exit(test_dynamic_debug_exit); =20 +MODULE_DESCRIPTION("test/demonstrate dynamic-debug features"); MODULE_AUTHOR("Jim Cromie "); MODULE_DESCRIPTION("Kernel module for testing dynamic_debug"); MODULE_LICENSE("GPL"); diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c index 672aabf40160..3adf3925fb86 100644 --- a/lib/test_dynamic_debug_submod.c +++ b/lib/test_dynamic_debug_submod.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems, like DRM, + * which defines its drm_debug classmap in drm module, and uses it in + * helpers & drivers. * * Authors: * Jim Cromie @@ -12,3 +15,7 @@ */ #define TEST_DYNAMIC_DEBUG_SUBMOD #include "test_dynamic_debug.c" + +MODULE_DESCRIPTION("test/demonstrate dynamic-debug subsystem support"); +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.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 A5CF0327A2C for ; Thu, 11 Sep 2025 21:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626755; cv=none; b=DooG5JvhOt1p0KXdpsrzpKMpbHOiPzU//JPHLfPY3Asor9vgGxd7ZWwL5Gg95S0Zs+EHG5D9kIylxtodObdtlgJVCCK3eADfSp035rlQ87Yc+fDp9o0btVmhS4AoskgdSX7Q1T/hfyH+htuB5Uy/JCNDtg3XIUzrxtMGRx/tpZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626755; c=relaxed/simple; bh=0y8tQXdcPB2L7E0a0QqA24/a8+3TwtpEi/wWOnoCupo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V3zSE8wzBvjXttc5Tfelnxsxgu+fim5TEeGdcZE774VH4vNICsKXtF3COfdoEBpe3mLyJ2B3wfsSRZ0ZhZUHpKYSzcLDfUNBEJvNf679KyNiIfbfHao/WP/Zt2iNnAAYd2W5YrtBwR1RBkbAVVOMnKSnSVq2RkbMALl4TDzmjcA= 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=VLf2dXol; arc=none smtp.client-ip=209.85.166.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="VLf2dXol" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-88762f20125so88077539f.0 for ; Thu, 11 Sep 2025 14:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626753; x=1758231553; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=llgmacej1inhZdixBhbo0c+/OM0TIwP7M6hLrupTHpw=; b=VLf2dXolE4+wK0lhlIqWM07U8L+Zses3o/M7q4QkIpy4Koj52TaAaFtrAmYPrNOwkc d1D8dQyulPuJpm8dttq7WacNnNIP6sMZIDgaz1fOA29DDVON6cckG1n5trKiAmiO5oA7 LSbQLd+hT95fLiHBqYit8U5JTqc44SGbzaDZIn+vYR1J7FqNtlzx0ce/GT4DsGZfA/pa 509kp36nGIrebtTa9ZWdIoY4WFU9nfugZhr4H1m/vpERi8GpBtAqiDrLc+dvDXyOunqY +R+d4mQApYLx9fEBKYIneZmH+zuVnsmzxXUmB6XkOe/dEE6mmrGfp/VBTmw4jTPjww/f 7gww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626753; x=1758231553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=llgmacej1inhZdixBhbo0c+/OM0TIwP7M6hLrupTHpw=; b=qHP/wcGba6E/OHLTrRrq/bx03vTHV8DQioZeGwtvAqHDzbphbsF+ocHnQeg7mVIprz n5j0Pv+hj+kFXzozI3SPIfB5fCoQ/uHrgO51nQ7S42XLvRmi75kM+VCnAgzGkUu/DmVp OKYsYbXuaLcrA/fOnduFSl+4RvLm4MwRyp3OO+aPzu1CQWRju1JOcvAU7RM2k7Vk1cA9 bGhtKlBEqRP6LoNQnQ1ij48Lr+82hSW1riS6K5bKmhkZEbV8JxbcqxCCGspS80Ag2bCm fXUQ/3ty9JfbQDnrgP6Jf/782ppziAvQLR1Haue1gi9+SE81zvx/oIxY/3YAeInKqyon E7Wg== X-Forwarded-Encrypted: i=1; AJvYcCWCYg1c40se92SA7MJuKoUZWggkM2cM3GeXF30iZ/aV6Fax3E5t2ApVZd66g2ejHjvYvVT87l+XnwrQMX0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx10JzPZ0ekk5OmQhSonjQgTUKHMjTOkBS/ZYtwee0QT9t8XnuN s1iOVtKErlAgQlp1t5QVdDN705Txjezjju34SJJPZKKvI2rregt89LsyraKzDw== X-Gm-Gg: ASbGncuQJ1+DKLjKQ8VSAhM8x7gox3sDSVupKb/mG2rfsa9sE8vWTuy6JQsYKzyoo3F 8e5DetItYdH8sNUpre/agXOEZAgqzoW582mZGq8AULHaQpdl9pd0Rc4GnWutuGudPJLiB8kAHqv OIAez/IZrJQ7502HYaaipyS9GGzuz7PCv+kPmflBekVAsfOoCv0a6LWgjr7qK+eRErWCMwJovj4 DgD5qkFWxLwqpY9vq/Rymulf+LDe9AfFSsoqcP4Tsx9s+BTVOSVjgrwciBZQTWE+qw6PjJPyX9o radyAVgYJuV/GK6gRvp0QmuQdhAACneSBBIVvhNDwRGGcJ9wqC9DtmZTjJDF/nYK1mMirDnxUht 6PoCoNA3F1Sue/upKJXp1ZZtLn2NeR+Evh+4DdiQ0IKNfJeR5m5GIButm7lOH3QvTb92qQKbWDJ 1hTuA= X-Google-Smtp-Source: AGHT+IESAW2JSmdJUX0oyOH/lAOalZ4BMH3NBiiOx/LvIoO9hqFymfc+Gpl1dS63M/xDNiq3L8mtzw== X-Received: by 2002:a05:6602:7216:b0:88c:30f3:32c9 with SMTP id ca18e2360f4ac-89033c6d33amr134528039f.15.1757626752607; Thu, 11 Sep 2025 14:39:12 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:12 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 25/30] dyndbg: treat comma as a token separator Date: Thu, 11 Sep 2025 15:38:18 -0600 Message-ID: <20250911213823.374806-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed: :#> modprobe drm dyndbg=3Dclass,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p or as a boot arg: drm.dyndbg=3Dclass,DRM_UT_CORE,+p # todo: support multi-query here Given the many ways a boot-line +args can be assembled and then passed in/down/around shell based tools, this may allow side-stepping all sorts of quoting hassles thru those layers. existing query format: modprobe test_dynamic_debug dyndbg=3D"class D2_CORE +p" new format: modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+p ALSO selftests-dyndbg: add comma_terminator_tests New fn validates parsing and effect of queries using combinations of commas and spaces to delimit the tokens. It manipulates pr-debugs in builtin module/params, so might have deps I havent foreseen on odd configurations. Signed-off-by: Jim Cromie Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik --- - skip comma tests if no builtins -v3 squash in tests and doc --- .../admin-guide/dynamic-debug-howto.rst | 9 +++++--- lib/dynamic_debug.c | 17 +++++++++++---- .../dynamic_debug/dyndbg_selftest.sh | 21 ++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 63a511f2337b..e2dbb5d9b314 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -78,11 +78,12 @@ Command Language Reference =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 At the basic lexical level, a command is a sequence of words separated -by spaces or tabs. So these are all equivalent:: +by spaces, tabs, or commas. So these are all equivalent:: =20 :#> ddcmd file svcsock.c line 1603 +p :#> ddcmd "file svcsock.c line 1603 +p" :#> ddcmd ' file svcsock.c line 1603 +p ' + :#> ddcmd file,svcsock.c,line,1603,+p =20 Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: @@ -167,9 +168,11 @@ module The given string is compared against the module name of each callsite. The module name is the string as seen in ``lsmod``, i.e. without the directory or the ``.ko`` - suffix and with ``-`` changed to ``_``. Examples:: + suffix and with ``-`` changed to ``_``. =20 - module sunrpc + Examples:: + + module,sunrpc # with ',' as token separator module nfsd module drm* # both drm, drm_kms_helper =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 440fe2f483a3..9cb2c95a0559 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -299,6 +299,14 @@ static int ddebug_change(const struct ddebug_query *qu= ery, struct flag_settings return nfound; } =20 +static char *skip_spaces_and_commas(const char *str) +{ + str =3D skip_spaces(str); + while (*str =3D=3D ',') + str =3D skip_spaces(++str); + return (char *)str; +} + /* * Split the buffer `buf' into space-separated words. * Handles simple " and ' quoting, i.e. without nested, @@ -312,8 +320,8 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) while (*buf) { char *end; =20 - /* Skip leading whitespace */ - buf =3D skip_spaces(buf); + /* Skip leading whitespace and comma */ + buf =3D skip_spaces_and_commas(buf); if (!*buf) break; /* oh, it was trailing whitespace */ if (*buf =3D=3D '#') @@ -329,7 +337,7 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end =3D buf; *end && !isspace(*end); end++) + for (end =3D buf; *end && !isspace(*end) && *end !=3D ','; end++) ; if (end =3D=3D buf) { pr_err("parse err after word:%d=3D%s\n", nwords, @@ -601,7 +609,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) if (split) *split++ =3D '\0'; =20 - query =3D skip_spaces(query); + query =3D skip_spaces_and_commas(query); + if (!query || !*query || *query =3D=3D '#') continue; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 465fad3f392c..c7bf521f36ee 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -216,7 +216,7 @@ function check_err_msg() { function basic_tests { echo -e "${GREEN}# BASIC_TESTS ${NC}" if [ $LACK_DD_BUILTIN -eq 1 ]; then - echo "SKIP" + echo "SKIP - test requires params, which is a builtin module" return fi ddcmd =3D_ # zero everything @@ -238,8 +238,27 @@ EOF ddcmd =3D_ } =20 +function comma_terminator_tests { + echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP - test requires params, which is a builtin module" + return + fi + # try combos of spaces & commas + check_match_ct '\[params\]' 4 -r + ddcmd module,params,=3D_ # commas as spaces + ddcmd module,params,+mpf # turn on module's pr-debugs + check_match_ct =3Dpmf 4 + ddcmd ,module ,, , params, -p + check_match_ct =3Dmf 4 + ddcmd " , module ,,, , params, -m" # + check_match_ct =3Df 4 + ddcmd =3D_ +} + tests_list=3D( basic_tests + comma_terminator_tests ) =20 # Run tests --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.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 84B22329F2F for ; Thu, 11 Sep 2025 21:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626756; cv=none; b=mXriOCkRXByfu1JXDUssy60ZbrDT/1ee3RyZ+76cn9E1ilvNB9FFnptVA6hl9SA8Jh/78rBJSO93CpxKN/cVFwc7rOZwaTdd2m4O2IpIwVDRQ3X+l6Q+58dtrvlGXNOdyQPErGgykJpLBJSPfnv/N3l4lccJnUcfmNWgyBFLZaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626756; c=relaxed/simple; bh=kYBlYY7aBzrfpvv8jq0U5AckDZRqdPeLya7ULfnxf9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k62/2QzyyH5N3rl9jHvHSpjvn5lXDsikeA/JD/BaYSx0FSWuJKXYmgUbtNiV+ZHNHMOino6tXgO318wRDyrIwmA801V/EeHy5bKThhfYW/D6bXEIHpDKoXkqInhW0A4dpCnSdihmp5wfMrLFBc0IYacx3Z5KNaSV2EvD963dhcU= 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=UsiT5cvx; arc=none smtp.client-ip=209.85.166.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="UsiT5cvx" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-88776dcac7aso47976539f.1 for ; Thu, 11 Sep 2025 14:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626754; x=1758231554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BbFerO6UxPrQxcGjjPDKdFxV7+8kL7Wgw3cGfnE1Lz8=; b=UsiT5cvxQ1VapT2fzUt5WrpWo38N83HWIiSmx5YUv3jLidivhocb4Sja+EcUqDuNy4 WLg7iL0sdeYDuKqC09+uvaZot8qJKHwuEvGwDVDmmvh7yaPMzkzf/eEyuAQnZ6a7NVyG CNlSa8Z7ZyF4HQ/5+m2fa2B0B01tJ6FDrq90O3232p55kw13V97n2sp8u9gNqPmtANAP nVcV2R9gRS1xm5TCooEUyK9HtuT7JDOVabDkjeMKI/tZiGtuEauGxmFb2J4Hnv4fs/Xc BU3KcBAjL8sXdzrOjNrebIvgW4E7f5GizGC3XOBBTVQwfYuAHu2WuiLAQc3RiIrHrDYh agaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626754; x=1758231554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BbFerO6UxPrQxcGjjPDKdFxV7+8kL7Wgw3cGfnE1Lz8=; b=qumtVoP36Q27XtP5NHwdbiIN32FuSigy7Lq8yAi2f6sX472TXPhsV9HdCtiEqBCUGp OT1kwBRBSV+Xod0rAZmS91IDInUFj+/ep6nNbQq2gJOoat0+G8OMJlAH7hZNUqsFChLG BiLIF0coIT5HMiOM3juH3num+05rVz60ndlEndyuJxIp0ztDfokc9SHEVwbMXFnv+ohr V0q19Tt6GXodYL/of2xMkPHIVUzVuCbSaCz0ctX7WgmmpiomMADqon4/cuW3JZ/I1/mM q0POB/Xp12+nVEpkWGTQclQyHPFrP7xnR2vbUByHufPjY4eW2+T/8FAW0McEkLlDMTeZ lKYQ== X-Forwarded-Encrypted: i=1; AJvYcCUvrb9tUu1WXFVeeXM7fOMAP4DO8j2AYZyPYCuQHve4lAGmDhc4Y2pHRmiNSzx0xcBvXIeUUJIlz2oJ6mk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxrx6RlvR1gMRVhA+8fpjcwWXJ5cfeKdZMniiFb3Dxo2dMz2o8Q 34pWclOqtedmfMrFY0oowinbxhe6UPRTCrw4S103Vqv9V7woI8lgfAHR X-Gm-Gg: ASbGncv/eBbf9qzHj587OYlkIFIYkfr9ytIVwmRJ5KHWxhUUrsq0Z/NTtpsOZGWgiyq z8XOERohruHfg+sLRlj0VmkBBRcMEKTn8Jurtbz+bB1Bh4AoVFLoq7EyGsdsS8XqGaldZ2STSdg i+9dQDZZbiwNkNP4cgnOh2wha/Au8wDY6zfCrHb/p62c4cH1jMFmqucCMqXFgrw9jrrSQGwuq/6 49qFXskbXm8VMA6idU+nR9x6jVCWnZ7D9PTcXTKLUvX/oYht9si4gd26P5yVBzfNFzgbIKAKP7k 47AXwCuYVnucTgMHhFF0t7zV3QwQZ1Qj23F3hCIy7y4rxCN5esLPGlrSiaikeRNIIlHVjvqc30C 5IiA3tN4sY/qD97Rqli1ojIYsI6WqWUVKMGqSrBOXvT+Gu/LAssP7lNoPKv7deXPc6BXUhrtOup 9yNkjY/qnwjZvEzg== X-Google-Smtp-Source: AGHT+IGIrMadyBnnytodYMBtXn/NVn8LrGaqu/QjA0Twm++Ed0Go98HFF+RGCwsUlB9+xXDB3VmH6w== X-Received: by 2002:a5e:db07:0:b0:881:8a58:3bc2 with SMTP id ca18e2360f4ac-890350b77bfmr109855839f.6.1757626753623; Thu, 11 Sep 2025 14:39:13 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:13 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 26/30] dyndbg: split multi-query strings with % Date: Thu, 11 Sep 2025 15:38:19 -0600 Message-ID: <20250911213823.374806-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit 85f7f6c0edb8 ("dynamic_debug: process multiple debug-queries on a line") Multi-query commands have been allowed: modprobe drm dyndbg=3D"class DRM_UT_CORE +p; class DRM_UT_KMS +p" modprobe drm dyndbg=3D< [ 203.902703] dyndbg: query parse failed [ 203.902871] dyndbg: processed 2 queries, with 0 matches, 2 errs bash: echo: write error: Invalid argument The '%' splits the input into 2 queries, and both fail. Given the limited utility of matching against the working parts of a format string "foo: %d bar %s", nothing is actually lost here. selftests-dyndbg: test_percent_splitting This does basic testing of classmaps using '%' separated multi-queries. It modprobes test_dynamic_debug with several classes enabled, and counts to verify that the expected sites show the enablement in the control file. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- -v3 squash feature, test, doc together gate new test, which needs test-dynamic-debug.ko test-percent-escape --- .../admin-guide/dynamic-debug-howto.rst | 8 ++++--- lib/dynamic_debug.c | 2 +- .../dynamic_debug/dyndbg_selftest.sh | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index e2dbb5d9b314..1ceadf4f28f9 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -85,10 +85,12 @@ by spaces, tabs, or commas. So these are all equivalen= t:: :#> ddcmd ' file svcsock.c line 1603 +p ' :#> ddcmd file,svcsock.c,line,1603,+p =20 -Command submissions are bounded by a write() system call. -Multiple commands can be written together, separated by ``;`` or ``\n``:: +Command submissions are bounded by a write() system call. Multiple +commands can be written together, separated by ``%``, ``;`` or ``\n``:: =20 - :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd func foo +p % func bar +p + :#> ddcmd func foo +p \; func bar +p + :#> ddcmd "func foo +p ; func bar +p" :#> ddcmd <<"EOC" func pnpacpi_get_resources +p func pnp_assign_mem +p diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 9cb2c95a0559..283d86115eba 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -605,7 +605,7 @@ static int ddebug_exec_queries(char *query, const char = *modname) int i, errs =3D 0, exitcode =3D 0, rc, nfound =3D 0; =20 for (i =3D 0; query; query =3D split) { - split =3D strpbrk(query, ";\n"); + split =3D strpbrk(query, "%;\n"); if (split) *split++ =3D '\0'; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index c7bf521f36ee..513f6cb1db1d 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -256,9 +256,33 @@ function comma_terminator_tests { ddcmd =3D_ } =20 +function test_percent_splitting { + echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on= % ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+p= t%class,D2_ATOMIC,+pm + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + check_match_ct test_dynamic_debug 23 -r + # add flags to those callsites + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + check_match_ct test_dynamic_debug 23 -r + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests comma_terminator_tests + test_percent_splitting ) =20 # Run tests --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.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 8053A32F762 for ; Thu, 11 Sep 2025 21:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626757; cv=none; b=IlZnZSuWwTNybHkSD2tcWj5K+rpVW1QgMfIJC6PWq9bc66LRX+qGWq7Ot3WjYmp2X4oBovwIOvPYcrzgBhtgsclKLW5JahBgcOA7r6IbZ6z2grjDI1O3bwy/NYtza1DJY8p4pD7n/5q7Zgxi9bm1AzYErtaAWcznh0fMLsU6AEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626757; c=relaxed/simple; bh=FtcFgwEejWjZvhm0rHNUUhymatBzn9CaDalgPyLWlVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LD4zcGCz8saAIRbIXZykx3KbPVW8Ffag7YGixIP8XKbxAh7DRNv63WOEqEzgrudwLhGL2jE7hSppbg3G6+NlqNG5LsDPdP3I5wEe8ib+IrxlON88eXEAN897DRixDBVW5M4OK8qc/VWoUHqNz8jZPdHPp1ONgHciF0NjjhSYRAk= 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=TyTfMJ45; arc=none smtp.client-ip=209.85.166.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="TyTfMJ45" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-88762f20125so88079939f.0 for ; Thu, 11 Sep 2025 14:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626755; x=1758231555; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f2CgSP+i6gOirYRCe6SP5XNRa5WFOHuIeP0ROyizXdM=; b=TyTfMJ45LetbzlY4gpt9IY22KauBZ42mC1Vcn9buHxnCPodgLFdu8uNN+QSz8oZv9B AUNS6WLHtszUjTnPPy8hDuOOmBi9DstO216ooFSFSKfqh+w2kljss1p1xa+ilIPTP2h+ HOpSFiMlROUUvvjL/9r6/WIOshu9s3DCWtgmr3r6H/kPc1v3PeuL7fJ26lfxYr3/FCkY hv3x6YFSkKxZ8SjRMkTR0/dKmDqseUePWohUtJUCCg2PsVJCbzn9MNRmuYT1avOkz8BR 4OsD14hEJpJDoEnvDgyE5yDDdG/ahhngWWfXc3oGyUR5vswocFqLtL4MDfC0oXziMFkf 67tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626755; x=1758231555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f2CgSP+i6gOirYRCe6SP5XNRa5WFOHuIeP0ROyizXdM=; b=OJxXdkLtC8oANN4FSf2DWzxyagN0xf+9ib4J72TLHpAtOzH+2qnQ+J4g5FelqlPCZ8 wWTZy3o1Dg92gvO0OlvZ84/HQq9eqGqnvaBP27TrqRbPrCk5cEnhnO8gPIaimIlpZ8LQ JNt8T5Qp3UXyi/nAR2+LDQRPV/ya0AEz0Iq9yVQ5sRPkvwr0861tfB2DBQEoxs4z7QQ4 G5MHSn0VymFA4neJ6IizYlJI0hPsQAtXOOQzgG7V8ElfFCwDB08egVpIMF3QEro1kTxa fhGX7Q9iWdnAvBXbkNzebCqr5dUs2KStWq3OjdGK1tqMFzrfXPRmfzo3oJ1ZO/RlmksP 3vSw== X-Forwarded-Encrypted: i=1; AJvYcCXwTdwnlKZLKmzZJ7x0VW110BKGdSoMDd50yfZHA1bEGE/Fw/tFQ2okuoHqE9TSnmYkHc4ndhuKj5/xbIc=@vger.kernel.org X-Gm-Message-State: AOJu0YzMrtQTQLwmNF+Wg1wrJl3GZS+M0MsWmfs+OdZkgLcXV/HFHIn6 j97O2n9h4fbppD2/A7c0l0Cjg4F2N1SzwfVYhCvQaCOQ8bDumbu4oIb5 X-Gm-Gg: ASbGncskhQhZJJeQVU1OFOdA3oZ0x+lys/S4jRLOed3YtZpOm1OjzVAoP5elq95MLxJ UJ1AbsoC2yFULYTy6vaSeS5eUVAPjIj6d4dL7dmHnuiemQLV4XtcpFHArMBohQFh1yYMoN0siUI /u8A8js4/sA/mxtBvkGx1891coxkVP+nxFOTN3hb9ru9VxEAPKk6FpLnCAe2Rs9y0Bov4FTNZye 5zEoeg15F6lzJyN8DrPH+NCl8GpIN6PT7b7retVqGiOW6zs/mfwvWGKiKNaWYy7MweYT7SZiDlR qFxAdeEBGZtjbWECVyCHYeQSvYOrMlKrCfXuANAf6s0DWqueQ2WGXm5cpzfKarPWAPB6nAG5B6E Sr2G6Ei8WOUBBjKaA4PTiKdKvu8hQX80PoxL5iI0shLoLW7s9NL033tb3Wb+YdfLwTKYrRsxYPC Fdpkz7jx1Crem1Lw== X-Google-Smtp-Source: AGHT+IGi0DsBkN4i1rRayYbwF56OCzmTqb1akdCBWnBpmYXeEm/h1+7sigjLQw1NfYWzcsMIU86vZQ== X-Received: by 2002:a05:6602:2d92:b0:88c:34c1:810e with SMTP id ca18e2360f4ac-89033c6af2emr132171639f.14.1757626754773; Thu, 11 Sep 2025 14:39:14 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:14 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 27/30] selftests-dyndbg: add test_mod_submod Date: Thu, 11 Sep 2025 15:38:20 -0600 Message-ID: <20250911213823.374806-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This new test-fn runs 3 module/submodule modprobe scenarios, variously using both the generic dyndbg=3D modprobe arg, and the test-module's classmap-params to manipulate the test-mod*'s pr_debugs. In all cases, the current flag-settings are counted and tested vs expectations. The 3rd scenario recapitulates the DRM_USE_DYNAMIC_DEBUG=3Dy failure. 1. 2 modprobes (super then sub), with separate dyndbg=3Dclass-settings check module specific flag settings 2. modprobe submod, supermod is auto-loaded set supermod class-params check expected enablements in super & submod 3. modprobe super, with param=3Dsetting (like drm.debug=3D0x1ef) modprobe submod validate submod's class'd pr_debugs get properly enabled The test uses multi-queries, with both commas and percents (to avoid spaces and quoting). This is the main reason the test wasn't earlier in the patchset, closer to the classmap patches its validating. With some tedium, the tests could be refactored to split out early tests which avoid multi-cmds, and test only the class-params. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- r3 - skip test if LACK_TMOD older drop -v used in test_mod_submod(). V=3D1 does it for whole test ifrmmod at test end (Lukasz) test-mod-tmod --- .../dynamic_debug/dyndbg_selftest.sh | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 513f6cb1db1d..09937dca3056 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -279,10 +279,83 @@ function test_percent_splitting { ifrmmod test_dynamic_debug } =20 +function test_mod_submod { + echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + + # modprobe with class enablements + modprobe test_dynamic_debug \ + dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+pt%class,D2_ATOMIC,+pm + + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + modprobe test_dynamic_debug_submod + check_match_ct test_dynamic_debug_submod 23 -r + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct test_dynamic_debug 46 -r + + # no enablements propagate here + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + # change classes again, this time submod too + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml "# add so= me prefixes" + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + # submod changed too + check_match_ct =3Dmf 1 + check_match_ct =3Dlt 1 + check_match_ct =3Dml 1 + + # now work the classmap-params + # fresh start, to clear all above flags (test-fn limits) + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + modprobe test_dynamic_debug_submod # get supermod too + + echo 1 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 4 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( V1-3 + D2_CORE ) + check_match_ct =3Dp 8 + echo 3 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_CORE, D2_DRIVER ) + check_match_ct =3Dp 4 + echo 0x16 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_DRIVER, D2_KMS, D2_ATOMIC ) + check_match_ct =3Dp 6 + + # recap DRM_USE_DYNAMIC_DEBUG regression + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + # set super-mod params + modprobe test_dynamic_debug p_disjoint_bits=3D0x16 p_level_num=3D5 + check_match_ct =3Dp 7 + modprobe test_dynamic_debug_submod + # see them picked up by submod + check_match_ct =3Dp 14 + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests + # these require test_dynamic_debug*.ko comma_terminator_tests test_percent_splitting + test_mod_submod ) =20 # Run tests --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.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 D43B5321457 for ; Thu, 11 Sep 2025 21:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626759; cv=none; b=Xt4OgKoCUtejJASotgc3s9jXzZLm8tbPUMMNQlJb4QQyGRkQgEjMulupcohLXTXJ8g24xVY3v50JVp++dL6K79Wzz/p3Bam8CPPsl2n1QqjDd2wlBUd9SsV6501c7R7Yt9WpW6MvD3JUNE1pH+ho99x8nQLcDAugzYo4EkWfrN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626759; c=relaxed/simple; bh=uFz8RTfQXvdzGLIr/58GeOXYAXhBAFxU1Y27KGB5G5c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d+a+ffsdI1Ds+8cEa/+XUPCd2VSGJU0xjmkTAV+X67oFt5aGrOw+rJrUj/PGgt1wM4UjgS74QnJ+dCrJDCSrkq7KFRpMKNicibFpXkJR3y1HDsdmSWDp3izivxa3ZPFqoQ7062xnx07SLDY6AfvrKmLU+q0jVgvAUIx+JiPP51Y= 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=SgdNqFFY; arc=none smtp.client-ip=209.85.166.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="SgdNqFFY" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-88735894d29so34848939f.1 for ; Thu, 11 Sep 2025 14:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626756; x=1758231556; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6S7bi7VcWuEj01wDDSALGaeIND7R7q38N/1Wb1VeyTU=; b=SgdNqFFYLcGMsxKZ2B/w5HFBEXTgx2RDH649JEOHRFlG3ckTRPYzLj0jojOGr8XjjR Ex2A6cgp5T5Xj6//qKrchiZzvyPCqVqJh91YT8Wq25NRgVaYhzYrF0PHigfSvC5HEZuR +sLMBgcVakKqz2H5d+v9KAJsv/8VztavrX6706s6sp+ybWAVDtrLSXwY7M0WSbgt7q6O fEGi6+YlZYgFEfXrtQYlriovrC0O5CrViX912rIYlZBGteX9EFhbCftQjKmNR65r2Ao8 2EiK82woahTucgiDtoJYm1D0cJWXlf0BD2wapEmupa68ZZppbcym8Cbo3VMN8wD7gNfP d3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626756; x=1758231556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6S7bi7VcWuEj01wDDSALGaeIND7R7q38N/1Wb1VeyTU=; b=T+XVs4C4YXlgCN+NauqHK4ArLGWLjSjX52JqZ5QsDlgqYDKsv3yZV7MBnmVX0XdIF3 SH3vyfe7Bwlq9FKQ/CAekBH+AisD6hH8u4KmDtP9l94kOkR/0gtuRjZGVlqwlIps4831 cyA7ZUcQ1OeyfjdZhQ6HFwCj8h3t/IyzLTS9ovKHm7o31oSIM0p5zk4Z91WXzz5zu5di dnNaS0tHqmzS1GDCJl4B8wCXIQ8oL2vNo/TuqH0BZsqPvyGV27ftmiqh/ejxZkjML0tQ yOt7NAgokkyI1KfYX0yTQF5VCBozJ6oIhuFTkTmSuGjdRPvAaGCmIb33hpVaNFuoyHJ1 HM1A== X-Forwarded-Encrypted: i=1; AJvYcCVi2FI0TTnB7T0Ro6KXajGI9dGlq/XbVIclqoQ9kkCAY4fvrZY/7xWffXP4fiM1SPew5zmd2/9Fyj4EH3k=@vger.kernel.org X-Gm-Message-State: AOJu0YxxowYECkCDE1Zalykfy8I6PteOn4/AyVRahcYp2OPuHRgj9FKP NnZWBItK9rvwWyEG/NdAVF8vKzGanUtj+4gEqQH+I+hvcLQnB2Jj9Njl X-Gm-Gg: ASbGncsJdmUpLvMi5wkGInbObdcGa/4j8SNF1vt3JaOd7vZuWQDlLwUnFusxv7kGqGk SjVQVSVz1jjEDa88BJfcDujEN/9Tj5vZ9oAgsQMYmkjq4Z0wj629wmlm362HzPSAsa75UR+vZnh 7a/cjLiYtiPJ9bwXcZwImrGTx1/bckb0DKVigGsMbQEJQprCvCvMYE4Bq8fMZ0kBzbwXEuiABbk K5ok0yp6ESgzFwl1XsFzcZXnrGgDxfqOPyPQQLzrbKsNTfcOKK17q1WOYcI6gV4stcCLzN1ZqlH 7dmmNJzmNG/L+b4cncXRmyDtwTSiuwUvasmaXGsJgYBH3nGM+xEfwFNM/uDg45K6Ydsb4jid9U6 O2pkb5Rhgqpq4SEs2BEpSJX0kXfgw1mDzLGTPS4313OXKu2bqxZMXOed3RTNJmkFZtdnWN1tyTV 05Xa/JkUqFy+QiMg== X-Google-Smtp-Source: AGHT+IE9D6mkMC7heM4taNKCXmh5N3pln1pJxHrNZt0ot5Rg7t6LQ4stcoY3I1h9nS7nDe01oxTFOw== X-Received: by 2002:a05:6602:150c:b0:887:7662:d5f0 with SMTP id ca18e2360f4ac-8903378d5c0mr116584739f.5.1757626755768; Thu, 11 Sep 2025 14:39:15 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:15 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 28/30] dyndbg: resolve "protection" of class'd pr_debugs Date: Thu, 11 Sep 2025 15:38:21 -0600 Message-ID: <20250911213823.374806-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" classmap-v1 code protected class'd pr_debugs from unintended changes by unclassed/_DFLT queries: # IOW this doesn't disable all of DRM_UT_* categories echo "-p" > /proc/dynamic_debug/control # Instead, must name the class to change it. # Protective but tedious echo "class DRM_UT_CORE +p" > /proc/dynamic_debug/control # Or do it the (old school) subsystem way echo 1 > /sys/module/drm/parameters/debug This "name the class to change it" behavior gave a modicum of protection to classmap users (ie DRM) so their debug settings aren't trivially and unintentionally altered underneath them. Doing so was 2-step: a- all existing pr-debugs got .class_id =3D DEFAULT - ints need a val. b- "class DEFAULT" was inferred unless a class was explicitly given This allowed all previously conceived queries to work the way they always had; ie select the same set of pr_debugs, despite the inclusion of whole new classes of pr_debugs. But that choice had 2 downsides: 1. "name the class to change it" makes a tedious long-winded interface, needing many commands to set DRM_UT_* one at a time. 2. It made the class keyword special in some sense; the other keywords skip only on explicit mismatch, otherwise the code falls thru to adjust the pr-debug site. Jason Baron didn't like v1 on point 2. Im not sure he's changed view. Louis Chauvet didn't like recent rev on point 1 tedium. My view has crystalized: drm.debug is ABI and API. Therefore dyndbg "doing" drm.debug must deliver the same operational guarantees; namely that drm.debug=3DVAL is accurate and true. Convenience or wishes for no-special-cases does not matter. The new resolution: If ABI is the blocking issue, then no ABI means no blocking issue. IOW, if the classmap has no associated sysfs/kparam, ie no PARAM, there is no ABI to guard, no reason to enforce a tedious interface. In the future, if DRM wants to drop or qualify this protection at compile or modally at runtime, we could talk. But thats their call for convenience. So classes without a PARAM are unprotected at >control, allowing admins their shortcuts. No such classmap usages exist yet. Anyway, this patch does: 1. adds link field from _ddebug_class_map to the .controlling_param 2. sets it in ddebug_match_apply_kparam(), during modprobe/init, when options like drm.debug=3DVAL are handled. 3. ddebug_class_has_param() checks .controlling_param 4. ddebug_class_wants_protection() macro renames 3. this frames it as a separable policy decision 5. ddebug_change() calls 4 when needed. IE when applying a class-less query to a class'd pr_debug here we need a new fn to find the classmap with this .class_id 6. new ddebug_find_classmap_by_class_id(). called when class-less query looks at a class'd pr_debug. finds classmap, which can then decide, currently by PARAM existence. Historical Summary: -v0 - before classmaps. no special case keywords -v1 - "class DEFAULT" is assumed if not mentioned. this protects classes from class-less queries -v2.pre-this-patch - protection macro'd to false -v2.with-this-patch - sysfs knob decides -v2.speculative - module decides wrt classmap protection seems unneeded now, TBD NOTE: protection is only against class-less queries, explicit "class FOO" adjustments are allowed (that is the mechanism). CC: Jason Baron Signed-off-by: Jim Cromie --- v3 - new patch v4 - drop fn-scope map var, with 2 local vars, renamed to purpose - fix for NULL ptr case. - Add loop-var to reduce many "&dt->info." exprs to "di->" - add 1-liner postcondition comments Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 14 +++-- lib/dynamic_debug.c | 114 +++++++++++++++++++++++++++------- 2 files changed, 100 insertions(+), 28 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4ceb69f0e493..588e03e8d157 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -75,6 +75,7 @@ enum ddebug_class_map_type { * map @class_names 0..N to consecutive constants starting at @base. */ struct _ddebug_class_map { + struct _ddebug_class_param *controlling_param; const struct module *mod; /* NULL for builtins */ const char *mod_name; const char **class_names; @@ -259,7 +260,12 @@ struct _ddebug_class_param { * * Creates a sysfs-param to control the classes defined by the * exported classmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in a private long int. + * + * Since sysfs-params are ABI, this also protects the classmap'd + * pr_debugs from un-class'd `echo -p > /proc/dynamic_debug/control` + * changes. + * + * This keeps class-state in a private long int. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ static unsigned long _name##_bvec; \ @@ -272,10 +278,8 @@ struct _ddebug_class_param { * @_var: name of the (exported) classmap var defining the classes/bits * @_flags: flags to be toggled, typically just 'p' * - * Creates a sysfs-param to control the classes defined by the - * exported clasmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in user @_bits. This lets drm check - * __drm_debug elsewhere too. + * Like DYNAMIC_DEBUG_CLASSMAP_PARAM, but maintains param-state in + * extern @_bits. This lets DRM check __drm_debug elsewhere too. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 283d86115eba..97070ddf31c6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -197,6 +197,48 @@ ddebug_find_valid_class(struct _ddebug_info const *di,= const char *query_class, return NULL; } =20 +#define class_in_range(class_id, map) \ + (class_id >=3D map->base && class_id < map->base + map->length) + +static struct _ddebug_class_map * +ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) +{ + struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, map, di, maps) + if (class_in_range(class_id, map)) + return map; + + for_subvec(i, cli, di, users) + if (class_in_range(class_id, cli->map)) + return cli->map; + + return NULL; +} + +/* + * classmaps-V1 protected classes from changes by legacy commands + * (those selecting _DPRINTK_CLASS_DFLT by omission). This had the + * downside that saying "class FOO" for every change can get tedious. + * + * V2 is smarter, it protects class-maps if the defining module also + * calls DYNAMIC_DEBUG_CLASSMAP_PARAM to create a sysfs parameter. + * Since they want the knob, we should assume they intend to use it + * (in preference to "class FOO +p" >control), and want to trust its + * settings. + * This gives protection when its useful, and not when its just tedious. + */ +static inline bool ddebug_class_has_param(const struct _ddebug_class_map *= map) +{ + return !!(map->controlling_param); +} + +/* re-framed as a policy choice */ +#define ddebug_class_wants_protection(map) \ + ddebug_class_has_param(map) + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -210,35 +252,45 @@ static int ddebug_change(const struct ddebug_query *q= uery, struct flag_settings unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - struct _ddebug_class_map *map =3D NULL; - int valid_class; + int selected_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { + struct _ddebug_info *di =3D &dt->info; =20 /* match against the module name */ if (query->module && - !match_wildcard(query->module, dt->info.mod_name)) + !match_wildcard(query->module, di->mod_name)) continue; =20 if (query->class_string) { - map =3D ddebug_find_valid_class(&dt->info, query->class_string, - &valid_class); - if (!map) + struct _ddebug_class_map *mods_map =3D + ddebug_find_valid_class(di, query->class_string, + &selected_class); + if (!mods_map) continue; } else { - /* constrain query, do not touch class'd callsites */ - valid_class =3D _DPRINTK_CLASS_DFLT; + selected_class =3D _DPRINTK_CLASS_DFLT; } + /* module knows "class FOO", if given, else class _DFLT */ =20 - for (i =3D 0; i < dt->info.descs.len; i++) { - struct _ddebug *dp =3D &dt->info.descs.start[i]; - - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - continue; + for (i =3D 0; i < di->descs.len; i++) { + struct _ddebug *dp =3D &di->descs.start[i]; =20 + if (dp->class_id !=3D selected_class) { + if (query->class_string) { + /* site.class !=3D class FOO */ + continue; + } else { + /* class-less query, class'd site */ + struct _ddebug_class_map *site_map =3D + ddebug_find_map_by_class_id(di, dp->class_id); + if (site_map && ddebug_class_wants_protection(site_map)) + continue; + /* allow change on class'd site */ + } + } /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -635,6 +687,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, @@ -1086,9 +1139,6 @@ static void *ddebug_proc_next(struct seq_file *m, voi= d *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 const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; @@ -1213,25 +1263,36 @@ static void ddebug_sync_classbits(const struct kern= el_param *kp, const char *mod } } =20 -static void ddebug_match_apply_kparam(const struct kernel_param *kp, - const struct _ddebug_class_map *map, - const char *mod_name) +static struct _ddebug_class_param * +ddebug_get_classmap_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map) { struct _ddebug_class_param *dcp; =20 if (kp->ops !=3D ¶m_ops_dyndbg_classes) - return; + return false; =20 dcp =3D (struct _ddebug_class_param *)kp->arg; =20 - if (map =3D=3D dcp->map) { + return (map =3D=3D dcp->map) + ? dcp : (struct _ddebug_class_param *)NULL; +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp =3D ddebug_get_classmap_kparam(kp, map); + + if (dcp) { + map->controlling_param =3D dcp; v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); vpr_cm_info(map, " %s maps ", mod_name); ddebug_sync_classbits(kp, mod_name); } } =20 -static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +static void ddebug_apply_params(struct _ddebug_class_map *cm, const char *= mod_name) { const struct kernel_param *kp; #if IS_ENABLED(CONFIG_MODULES) @@ -1251,6 +1312,13 @@ static void ddebug_apply_params(const struct _ddebug= _class_map *cm, const char * } } =20 +/* + * called from add_module, ie early. it can find controlling kparams, + * which can/does? enable protection of this classmap from class-less + * queries, on the grounds that the user created the kparam, means to + * use it, and expects it to reflect reality. We should oblige him, + * and protect those classmaps from classless "-p" changes. + */ static void ddebug_apply_class_maps(const struct _ddebug_info *di) { struct _ddebug_class_map *cm; --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.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 E61712E8B6F for ; Thu, 11 Sep 2025 21:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626760; cv=none; b=oQi9ICztSOYh1cEO284yQnN6JM36lQJ+QLKuSiUZ7KP5S6Sdy1Ta8oX3Q7lye3lzl+YW16YAr5zILfefBf0YVKfgzQyg7orVEhuQDwiB05/mNzw+WKs5PFS+TyKj6Cgyy08Hdn0yp4HdXOF6iAQrP7W7Jk8aDiJmxqlitDESgGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626760; c=relaxed/simple; bh=4Li+TNbKcqL0TAB0esACJFmyA2n7TEQJyXht92HSZD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pQdhcWhJ/a1fvmVf7mT55leJwLsG/j45OSMsjtHvc+rPWnn7S441rXqRXfaea7RvlEGVMLi+Q9x482kDXXJIfeveCzfqlzaqQS2Zt2csgkMe0TBzIwQQHl7cSPs6yoKIObgcvEyC1iDZey48qNpafizVHmYd4wJDz4C+3YpSvR0= 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=Gvnaixgf; arc=none smtp.client-ip=209.85.166.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="Gvnaixgf" Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-8876de33c86so96212239f.3 for ; Thu, 11 Sep 2025 14:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626757; x=1758231557; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0wygi4dkCvAxIjLq/ioBbAIy8T8pr9875pW4yDSmQbI=; b=Gvnaixgf3HQoc7R7OOSHFFFwqslPC9AZQIAz+/Ue83afqWprX9/rsB1a7AZqe7UzCx O5tALsjEubFATuDTUwHYTlKwkKBBXua8DljY3YEBkCO+uEz1WiNsAB7iDEXhz8hu3dXD F+1iCxo6yi2VYi32RxkoxID4llPXFPc6EFeinGNUa/8rH+8Ap9kT1CBBoqeSRrZEcigv EvtzTJxqWVzeUlB1ZEd3Qsu3JqM4MFJfqHzQJG3RjN0z85auSK2bIbBjdYCa3bV06tJq oG1Z7lpod3/cFJyUsmnoLq9FkZ/Qz85vuXyLehtre8wUQz4afd9oyV1Q+fCoYfx43hwf FV2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626757; x=1758231557; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0wygi4dkCvAxIjLq/ioBbAIy8T8pr9875pW4yDSmQbI=; b=luJ1kRl4e/SvmZwETKgDqJjcmSZlk9D5EgeQJ7tl20COCOlrKbJ3abkNrny6xgdd52 qIvcbKI3YcMq8dHmoAkXaY0QmTEkjroRE2gVbbnEI0Oro16ONaDZ9iJ80rU3eIG6yFhk XVN0mhX1kMXlihvHJWONaTL68uG+1GEPFkctH+OIX7AJaJdB6an+YxGp0qbQWYbqWM3B azWH+n9nKqwA3kVQzg64deKQCCJt4ifWk87FbZJ8ftglnDFopUl0rAXjjvtF6Dzm+EoZ B9AVLuMtYXcKsjOHa7OgOaB6xqkJyJ4g4Tcq/7dS3tskdtFghTU6F7VevqT9OsJOFG8k eJvA== X-Forwarded-Encrypted: i=1; AJvYcCXX87QXI7HfGrsoNnS1O8oSQhzUnWtM3/nLucotZNfqrauzbgGrDgBbptC7funsCJVS94KkS3ETOnRP2Mo=@vger.kernel.org X-Gm-Message-State: AOJu0YyYKA0Vf8oxb7vrSyeQHs/zx231YnSsbAfQXBhhv3SAuvWiNVaN 45bF0ErsSYT32g8Du0vznLKr55RKE5jGKQgDMSYHzmy3bHIT6t5XqmIgEUWLWw== X-Gm-Gg: ASbGncuvJ0WHlkEMvJ7+MyuJHHqlLsIVc15kcftHHO91znz1wvihgjVghVveqv2Kk9r S7LJA7zNg5xTlKH7+/IEHtlHSiwJj/fnKvS+I11ObM/qRRCipV5077SyilqwASBuOie2q9n4Tps uidDfQYtNsTIqRB08y8vRbdVNd9upIFMsc0LYa3Qv85cQIE+MuYCrEu9FOLsjCuhC1IFi1m70Xf LbwS3V1299SsfvMLzY8mpAI3EsfWRtUOcySp+ckrs8FrnjUmSRpnJXjuJVupXCVViQDp0ThmtXJ aL3lUq2UWpVmEMvxpb8CeYVdN3IjszpPq8Y2QbxH/WKrQvE+ThhNxbEe7nMMFFS5RjF3uFTPJRr T+rMfJLWuNSP4rtcnw48EEOdea4mPuRgBHsUWxiPqdHw0eqkhbgKF+vlUuCkc8d2d0NgYmDSmTV FjON0GUiUt/zA1Nw== X-Google-Smtp-Source: AGHT+IFDuJTgWowbFr7V5CKbhNLDixBhshWBZCmuQhefQH8Gegnt5Fq4qn7wJAtpl0LQpZzCKq4dDQ== X-Received: by 2002:a05:6602:7216:b0:88c:30f3:32c9 with SMTP id ca18e2360f4ac-89033c6d33amr134556439f.15.1757626756762; Thu, 11 Sep 2025 14:39:16 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:16 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 29/30] dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(clname,_base) Date: Thu, 11 Sep 2025 15:38:22 -0600 Message-ID: <20250911213823.374806-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The @_base parameter in @DYNAMIC_DEBUG_CLASSMAP_DEFINE exists to de-conflict a second classmap definition from a first, by setting different .class_id constants for all of the second map's pr_debug callsites. This gives the same _base param, and thus more flexible usage via @DYNAMIC_DEBUG_CLASSMAP_USE_(clname,_base). So now 2nd classmap used can be deconflicted from the 1st used or defined. 1st the range-checking logic is refined into two distinct macros, @ddebug_class_map_in_range() and @ddebug_class_user_in_range(), which are then applied to the lookup functions: @ddebug_find_valid_class(), @ddebug_find_map_by_class_id(), and @ddebug_class_name(). The @DYNAMIC_DEBUG_CLASSMAP_USE* macro API kdoc is adjusted accordingly. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 28 ++++++++++++++++++++++------ lib/dynamic_debug.c | 21 +++++++++++++-------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 588e03e8d157..d1e38158c485 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -87,7 +87,7 @@ struct _ddebug_class_map { struct _ddebug_class_user { char *mod_name; struct _ddebug_class_map *map; - const int base; /* user offset to re-number the used map */ + const int base; /* offset .class_id range to share space */ }; =20 /* @@ -235,15 +235,31 @@ struct _ddebug_class_param { /** * DYNAMIC_DEBUG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. * @_var: name of the exported classmap var - * @_not_yet: _base-like, but applies only to this USEr. (if needed) * * This tells dyndbg that the module has prdbgs with classids defined * in the named classmap. This qualifies "class NAME" >controls on - * the user module, and ignores unknown names. + * the user module, and ignores unknown names. This is a wrapper for + * DYNAMIC_DEBUG_CLASSMAP_USE_() with a base offset of 0. */ -#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ - DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0, __UNIQUE_ID(_ddebug_class_user)) -#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _base, _uname) \ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0) + +/** + * DYNAMIC_DEBUG_CLASSMAP_USE_ - refer to a classmap with a manual offset. + * @_var: name of the exported classmap var to use. + * @_base: an integer offset to add to the class IDs of the used map. + * + * This is an extended version of DYNAMIC_DEBUG_CLASSMAP_USE(). It should + * be used to resolve class ID conflicts when a module uses multiple + * classmaps that have overlapping ID ranges. + * + * The final class IDs for the used map will be calculated as: + * original_map_base + class_index + @_base. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _base) \ + __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _base, __UNIQUE_ID(_ddebug_class_user)) + +#define __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _base, _uname) \ extern struct _ddebug_class_map _var; \ static struct _ddebug_class_user __aligned(8) __used \ __section("__dyndbg_class_users") _uname =3D { \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 97070ddf31c6..486aa68670d8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -169,6 +169,12 @@ static void vpr_info_dq(const struct ddebug_query *que= ry, const char *msg) _di->users.len); \ }) =20 +#define ddebug_class_map_in_range(id, map) \ + ((id) >=3D (map)->base && (id) < (map)->base + (map)->length) +#define ddebug_class_user_in_range(id, user) \ + ((id) >=3D ((user)->map->base + (user)->base) && \ + (id) < ((user)->map->base + (user)->base + (user)->map->length)) + static struct _ddebug_class_map * ddebug_find_valid_class(struct _ddebug_info const *di, const char *query_c= lass, int *class_id) { @@ -189,7 +195,7 @@ ddebug_find_valid_class(struct _ddebug_info const *di, = const char *query_class, if (idx >=3D 0) { vpr_di_info(di, "class-ref: %s -> %s.%s ", cli->mod_name, cli->map->mod_name, query_class); - *class_id =3D idx + cli->map->base; + *class_id =3D idx + cli->map->base + cli->base; return cli->map; } } @@ -197,8 +203,7 @@ ddebug_find_valid_class(struct _ddebug_info const *di, = const char *query_class, return NULL; } =20 -#define class_in_range(class_id, map) \ - (class_id >=3D map->base && class_id < map->base + map->length) + =20 static struct _ddebug_class_map * ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) @@ -208,11 +213,11 @@ ddebug_find_map_by_class_id(struct _ddebug_info *di, = int class_id) int i; =20 for_subvec(i, map, di, maps) - if (class_in_range(class_id, map)) + if (ddebug_class_map_in_range(class_id, map)) return map; =20 for_subvec(i, cli, di, users) - if (class_in_range(class_id, cli->map)) + if (ddebug_class_user_in_range(class_id, cli)) return cli->map; =20 return NULL; @@ -1146,12 +1151,12 @@ static const char *ddebug_class_name(struct _ddebug= _info *di, struct _ddebug *dp int i; =20 for_subvec(i, map, di, maps) - if (class_in_range(dp->class_id, map)) + if (ddebug_class_map_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 for_subvec(i, cli, di, users) - if (class_in_range(dp->class_id, cli->map)) - return cli->map->class_names[dp->class_id - cli->map->base]; + if (ddebug_class_user_in_range(dp->class_id, cli)) + return cli->map->class_names[dp->class_id - cli->map->base - cli->base]; =20 return NULL; } --=20 2.51.0 From nobody Thu Oct 2 19:24:05 2025 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.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 AEBC6353346 for ; Thu, 11 Sep 2025 21:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626761; cv=none; b=Ny1hnhaAn2CVvTwOTAT2NkkZ2mUH6SsXw4F8UxgLyPuXZ5NGO2LPq/6e8sHuDkNqcaxogJ6B3oTQpsqXEs40uP2gSk6M0RFJtEyJMR8IiueJvE1F/o1MFHEf4/80jZHT0oJb2hLS0Xg3PQG8NgEgiicsiZZhNcfmACghCqfD9C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757626761; c=relaxed/simple; bh=SAMH6bX/vL3va8sFv4toy+dDvica3sbvYihqhhgIHr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kcvUym1nhDXJwBpwHaMY/QV4ETuo269ai3d5Qkous8o2VQjThPUhyIAigrpsA/3fw2Mrv9DHfOnaxM9SzDooJEp+flVRXwPv4bayV1sNselM4DS4rA+/kwtZ6pJA7I9Bpo5vDZw/DETBAfK+SAyg2IeeEOT0E7m1KUNI4avXRUw= 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=LSF1UUAu; arc=none smtp.client-ip=209.85.166.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="LSF1UUAu" Received: by mail-io1-f48.google.com with SMTP id ca18e2360f4ac-88758c2a133so103757539f.0 for ; Thu, 11 Sep 2025 14:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757626758; x=1758231558; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/3z8Tk8lrK8AXvTeNfDXtN9XLGvTU1P/hpcdsNXRN/Q=; b=LSF1UUAuGtAZPcws+phpd8lPyX7UDvXRksal+TMT+H5w8anzdmMeKLcDwhT+w1XjBD 06SoUOq1fdNGoigy7sQYeQqePN4Jsldp85eW447FoEMOV4gAS6noCeNOxdHCrJqHJBC6 jreATpI6wc+Ve67l92jGt2vZ/jd76XzOz8sDv9Ge8PwOK+lyF1LT3x2h6vbs23qLhevP OknbloTSofPCpSAG+ufrdRAEClaRylTRU58z7Wywt+fYcBt3IR/VCJBhdRg17cSMzlXV eUuapaJaQB0/TZpd2Ot9FdEm9DVSIT9bLzkiU7pz/BPk2TSbdwInhJShbQiiQcxulAKc G66w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757626758; x=1758231558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/3z8Tk8lrK8AXvTeNfDXtN9XLGvTU1P/hpcdsNXRN/Q=; b=DfCdUw39G87c4Nf0EZ11k89NqKNBhsRsdZtRbuZ9dxTzlZGBasstEMc79rESAAK5to 3j/BJqcbtfe28QgyZR0FSv+H5ahFM6nqLsEVPE0k6gFPxh5CI5flCio9dkXK+AdK6YSM wSNHNuEd7FRaA6iojZFEgIWb6OHf1GPXIfvUjYcoiYmvEcPe4gTbOaHE1MknJD2zP9WY l3pMqsE+uDNJZ59+A5ZtHLW3L/Biqml3mk5Wc2J8r4qev/WPLZVFa6a9pvsWm4uEwsTx 1CeIUt8DmvLiRPTCakZVXppO4WV8xRXBfpUXIukKEE1/n1FMJAD7+wbR8+Rnq+QKNQwx ul5Q== X-Forwarded-Encrypted: i=1; AJvYcCVAMigqP3tWEgUTOdgI/lmfFePFNOwSDdqhNzPy0J7okQzrsiiDB+pFPWB5IY3Be8R0bdrob/C8WYntdqY=@vger.kernel.org X-Gm-Message-State: AOJu0YwXhGJi1du6dDWkN6EWZo/lLR1lxGKcZ9vMhtM+ra3grVS4GxrA zOwCCOgA7ohHSppYjlCzDDKBgJZE/K+B+Q0p3yqh2lx8sDHo08eVrsqY X-Gm-Gg: ASbGncucInzwKaagrde6Z0yb7px/1ayhq6A3N8Hjze5rNgNeslXe4X3hu9cTWnjjF8K rRt9YPN3tlkiwz6TXasOyS1bOFlxuuSzXgca8/+WVvRk5ae9feb/zoBNn6ng+kqTF3ha5bzdzS/ dDWVJVLC51e5Om8TM+AL0NbOId3s9zS6Fwp6IreBL0BheaFxf/jiJ0u+utvLp1E7/RYGpO5t5Ct 4filwXGO9tW1XLDlVXgyp95bP875i37W+eLlSFAUwDh3oSpsBY+g9MLDuJ4vJ0qFKZWnLooqhQ8 bhqwHU5obGXvFo771vr7CKNAZgMerjmMDtogSSmHgi68sHCIeyoZJB1HKOCLBY3W3sgUS9zvP7k LyND++aOgqmtFM/okDMIcn6fg6dd9AHOKXwJk8B4vGX9CwukfgfUDFw3kDXhuyrzDwtv16h6hLv gHRhtknj1USsNVmw== X-Google-Smtp-Source: AGHT+IGh0GcENOAUp5idBZd9L09iBpK6xbRxEplx5rapSkwcsRu7LEbIzUFebORy2+6g+12n4y5PXA== X-Received: by 2002:a05:6602:634e:b0:887:76b1:59d9 with SMTP id ca18e2360f4ac-890322353ffmr127570539f.2.1757626757647; Thu, 11 Sep 2025 14:39:17 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-73-14-87-86.hsd1.co.comcast.net. [73.14.87.86]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-88f2d0bfdcfsm104024139f.3.2025.09.11.14.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 14:39:17 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Cc: gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH 30/30] docs/dyndbg: add classmap info to howto Date: Thu, 11 Sep 2025 15:38:23 -0600 Message-ID: <20250911213823.374806-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911213823.374806-1-jim.cromie@gmail.com> References: <20250911213823.374806-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Describe the 3 API macros providing dynamic_debug's classmaps DYNAMIC_DEBUG_CLASSMAP_DEFINE - create & export a classmap DYNAMIC_DEBUG_CLASSMAP_USE - refer to exported map DYNAMIC_DEBUG_CLASSMAP_PARAM - bind control param to the classmap DYNAMIC_DEBUG_CLASSMAP_PARAM_REF + use module's storage - __drm_debug NB: The _DEFINE & _USE model makes the user dependent on the definer, just like EXPORT_SYMBOL(__drm_debug) already does. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- v3- rework protection around PARAM v0.5 adjustments per Randy Dunlap v0.7 checkpatch fixes v0.8 more v0.9 rewords fixup-howto --- .../admin-guide/dynamic-debug-howto.rst | 129 ++++++++++++++++-- 1 file changed, 116 insertions(+), 13 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 1ceadf4f28f9..adac32a5cd23 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -146,7 +146,9 @@ keywords are::: "1-30" is valid range but "1 - 30" is not. =20 =20 -The meanings of each keyword are: +Keywords::: + +The meanings of each keyword are:: =20 func The given string is compared against the function name @@ -194,16 +196,6 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitesp= ace =20 -class - The given class_name is validated against each module, which may - have declared a list of known class_names. If the class_name is - found for a module, callsite & class matching and adjustment - proceeds. Examples:: - - class DRM_UT_KMS # a DRM.debug category - class JUNK # silent non-match - // class TLD_* # NOTICE: no wildcard in class names - line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single @@ -218,6 +210,24 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file =20 +class + + The given class_name is validated against each module, which may + have declared a list of class_names it accepts. If the class_name + accepted by a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a drm.debug category + class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names + +.. note :: + + Unlike other keywords, classes are "name-to-change", not + "omitting-constraint-allows-change". See Dynamic Debug Classmaps + +Flags::: + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: @@ -238,11 +248,15 @@ The flags are:: s Include the source file name l Include line number =20 +Notes: + +To query without changing ``+_`` or ``-_``. +To clear all flags ``=3D_`` or ``-fslmpt``. + For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only the ``p`` flag has meaning, other flags are ignored. =20 -Note the regexp ``^[-+=3D][fslmpt_]+$`` matches a flags specification. -To clear all flags at once, use ``=3D_`` or ``-fslmpt``. +The regexp ``^[-+=3D][fslmpt_]+$`` matches a flags specification. =20 =20 Debug messages during Boot Process @@ -394,3 +408,92 @@ just a shortcut for ``print_hex_dump(KERN_DEBUG)``. For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is its ``prefix_str`` argument, if it is constant string; or ``hexdump`` in case ``prefix_str`` is built dynamically. + +Dynamic Debug Classmaps +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The "class" keyword selects prdbgs based on author supplied, +domain-oriented names. This complements the nested-scope keywords: +module, file, function, line. + +The main difference from the others: classes must be named to be +changed. This protects them from unintended overwrite: + + # IOW this cannot undo any drm.debug settings + :#> ddcmd -p + +This protection is needed; /sys/module/drm/parameters/debug is ABI. +drm.debug is authoritative when dyndbg is not used, dyndbg-under-DRM +is an implementation detail, and must not behave erratically, just +because another admin fed >control something unrelated. + +So each class must be enabled individually (no wildcards): + + :#> ddcmd class DRM_UT_CORE +p + :#> ddcmd class DRM_UT_KMS +p + # or more selectively + :#> ddcmd class DRM_UT_CORE module drm +p + +That makes direct >control wordy and annoying, but it is a secondary +interface; it is not intended to replace the ABI, just slide in +underneath and reimplement the guaranteed behavior. So DRM would keep +using the convenient way, and be able to trust it. + + :#> echo 0x1ff > /sys/module/drm/parameters/debug + +That said, since the sysfs/kparam is the ABI, if the author omits the +CLASSMAP_PARAM, theres no ABI to guard, and he probably wants a less +pedantic >control interface. In this case, protection is dropped. + +Dynamic Debug Classmap API +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(clname,type,_base,classnames) - this maps +classnames (a list of strings) onto class-ids consecutively, starting +at _base. + +DYNAMIC_DEBUG_CLASSMAP_USE(clname) & _USE_(clname,_base) - modules +call this to refer to the var _DEFINEd elsewhere (and exported). + +DYNAMIC_DEBUG_CLASSMAP_PARAM(clname) - creates the sysfs/kparam, +maps/exposes bits 0..N as class-names. + +Classmaps are opt-in: modules invoke _DEFINE or _USE to authorize +dyndbg to update those classes. "class FOO" queries are validated +against the classes, this finds the classid to alter; classes are not +directly selectable by their classid. + +NB: It is an inherent API limitation (due to int class_id defn) that +the following are possible: + + // these errors should be caught in review + __pr_debug_cls(0, "fake DRM_UT_CORE msg"); // this works + __pr_debug_cls(62, "un-known classid msg"); // this compiles, does nothi= ng + +There are 2 types of classmaps: + + DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, like drm.debug + DD_CLASS_TYPE_LEVEL_NUM: classes are relative, ordered (V3 > V2) + +DYNAMIC_DEBUG_CLASSMAP_PARAM - modelled after module_param_cb, it +refers to a DEFINEd classmap, and associates it to the param's +data-store. This state is then applied to DEFINEr and USEr modules +when they're modprobed. + +The PARAM interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation +amongst the contained classnames; all classes are independent in the +control parser itself. There is no implied meaning in names like "V4" +or "PL_ERROR" vs "PL_WARNING". + +Modules or module-groups (drm & drivers) can define multiple +classmaps, as long as they (all the classmaps) share the limited 0..62 +per-module-group _class_id range, without overlap. + +If a module encounters a conflict between 2 classmaps its _USEing or +_DEFINEing, it can invoke the extended _USE_(name,_base) macro to +de-conflict the respective ranges. + +``#define DEBUG`` will enable all pr_debugs in scope, including any +class'd ones. This won't be reflected in the PARAM readback value, +but the class'd pr_debug callsites can be forced off by toggling the +classmap-kparam all-on then all-off. --=20 2.51.0