From nobody Fri Dec 19 10:25:40 2025 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 8DB9B248F4D for ; Thu, 9 Oct 2025 17:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032727; cv=none; b=uMVptm1xSttv2/yBAgpKUNlsg6zVRYf4R4JOBQG+cXb/IXMZ9ThlSPnekGaGcPc6yquq9S+bbmR4uNghD0SrVTX9EJ1BlOKMwZhnA+xA3pwJEsoZAbyIi4d5ooeA4rTpi/WG5Vsa1R3jKp7FHbHo3Bcg04Nz2J8Eahc2lb4gFNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032727; c=relaxed/simple; bh=B8dcsyyggwYCkYkKNypzvAZE2goYIgWDA5Tm6W1R3oQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b/+Mh/X5OingHolNNF0si36A+TrOuEqq87x6KHvmNXdvoJyUnzogO31kw1XwXIl1rnZfpeEpnO+3D+rDIyFm5+H0xJBywkt9Zb6TC6A1GjN4gbJNUrKcZZwVJyaUV+H0my6yOwI4cplwCRzDOlEUZesiqva6s/r4Foy/K9BE3qI= 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=dkFLngVJ; arc=none smtp.client-ip=209.85.166.172 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="dkFLngVJ" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-42f91f09a6aso4649755ab.1 for ; Thu, 09 Oct 2025 10:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032724; x=1760637524; 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=dkFLngVJsAdKNma/aUPsUkRdeks6ydSW8gKDO8s85c7fnWS4yFS1Lt4aRfEJa1IC/N +fJaslVd0Jor1usg7ThTFWuEuwCw2/BZwLDdgmnZbGwyADXCNAnGibDrTTJVbFGpPA/J 9R9wB1pVmxPsrOJF5EMGL43o19pcI28S62WRMtGH7DPfCZ0n81NFyqFbvNOxlOqLFC1w Nm5dei2mzi8RFm7IpMxTlZfRh53SJavoC1Vn+0f4PBELu11kRX8Rs2H79ifht2GSAePe M4aIanbmkcMqtM3VRoj+aS6l2Cl2M6k1zCsJb47BM3GYDyAk/lkH1QLifMNt96RMoe3y t18g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032724; x=1760637524; 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=KXm6Qyvo+16S/j1LB5oSWwqyhiQqKKNLH1uPxghuuBwTfE0xzdtGG18oz+RXUiaMic GmNG6b0x8l/HXGjM/W3yozQP5dt44K/+W13iDZ3HAoG0dcMcm1fi3uOVT47NL5jkF8M6 A+u6ElJ1ZLupKeJOJmpBrImEbV0ENiT7MuxUOtKeFde0MJI+/6SuINhHgS1irHkcoh9t jAMybaoKY2xnZtXpUX3znNNMEv9EqmcCKrfKFvJ4j4eBpSeQmCrKhKMNuyy5ApyfnRMN HApUDNeVoOB/NBGOSVTCHxC1/l7U6s6KEiYCicUGttP53Cyq+L6GrLiLELr0t7vZGldt A50A== X-Forwarded-Encrypted: i=1; AJvYcCXxZD9081B0gpoZjJvQuxO8guoYDqbJR2b7pcAidBJLS0upOr7EmHTwT8LQxnOumLnhC8Cs2gkEZnDRHF0=@vger.kernel.org X-Gm-Message-State: AOJu0YzGiIJ3url7LmTuI3EdaV8+Ji6res5dRZmcd2mrSLHQLOyOnoDU OQDoooVQzInFJVI2hnTMxTFVKwA01NWDFULewsdD12If7ker1vdTzok6k53UfA== X-Gm-Gg: ASbGncuZsW8fGiIAfwUdNn4hWUx7U2mqCLdTVqSsRGuKqd938L3bvrxHy6Tq7dgEHdw SZbx0aOs3pApD9Xb3jmilhyNIyd0nVYVklnVPenf44hhp7Km1jFhcBFFOrtbRlI+sLCmwzNmK7T inzvqX4tR2TMt7pDFEnWWPCIv0z17ZxZwcB+zUrOM9nJNtwKrngMXqQCOvYM9z8t9NrZSx0I9vj zM73y5Ry2gjq0/BBCc42YH37RdTONT062X99zG2lvnCtHKUcAggCrWSFTnpf32tHB161HhQaELe HQS5fjveL4vuGNdrTluzkLyqH8gxn4mkU2noU+EzetHjNUeboeoK/RAbCFixeOKkF9V9ixIGfzD AvcJvu6x7nO43q4JXL9m86V77w2zwa6Kk9sApjhiYqstzHF4drXnhID3bVN0OdXMlioHlYXfcBy K+29iVymQHc13u3j+y91XNW69+e0w= X-Google-Smtp-Source: AGHT+IFdvzN/Qe3kT6LC4KV36Vpx8Hont4QG2a9m6SfK0vqpuJ8k6n9bUCxYy5aRpvHqGEB15mxCww== X-Received: by 2002:a05:6e02:1946:b0:42f:96ec:50a5 with SMTP id e9e14a558f8ab-42f96ec51a2mr14056415ab.20.1760032724385; Thu, 09 Oct 2025 10:58:44 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58:43 -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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 01/30] docs/dyndbg: update examples \012 to \n Date: Thu, 9 Oct 2025 11:58:05 -0600 Message-ID: <20251009175834.1024308-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 E7D8224DCF7 for ; Thu, 9 Oct 2025 17:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032730; cv=none; b=FK/hFiIPtC7qP8VguPqrV3p5kg02SqcoDj2jVgrW8x6RNjhpIfG4bwHxS71qt6t55lYyk9zo8q5ai8c237/r+UXxJUwXG/tvClT90Cc/xb14zWw4vF01t3bpTqcdqQYbLW5O5/Ylu/6ew1h6cLa4W2Kjdpj6IgW1WemeahsrG1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032730; c=relaxed/simple; bh=sPUfeSm5BrFc1JGDfQfBW2rqApZnuuum7JmLHXwQcOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DFb+b7WhJHJa1Bp+Qow+BtAm2pWZxSYkSUzPdZwaAG9p8wN/aLK8kqLpuGyVVs1Vjsm2XwumkIZmdA/IYDUpUb24CZfda8djRKZdp0v9QbgSt+PGr+Fkt1eIbcyUAwyTGLmf6c/7LtsZRvMhs5YSD4nIOpbnrMycpsCqizJN4A0= 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=A3KrmDFB; arc=none smtp.client-ip=209.85.166.172 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="A3KrmDFB" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-428551be643so10120705ab.3 for ; Thu, 09 Oct 2025 10:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032728; x=1760637528; 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=A3KrmDFB7e23eDhEMzJ6oDTmsewP4fjscQ+2lLI1HJo2+FGQnu5fm0JG91TuRcoTba qYWiYnYLwYUdQSOgb71iRjogZwdwrNJ9PCr17kwYZLqm3ywxWfXFXYqpziv2jNqwltcj Pk/xhuVzZhmsK197H3lnt5JP6aJtNDp1S7THzYSGPkz0s3C6+kpTAcBls8NlN4LlLJwH H1nzjOOi3fnM5N/PrXpDJc1KErssx7wX4r2tAhpmQjrEhCP36/ZhJhom2RaeWRPi0QNH +zX5lH3wbSDIw9NqJsAqqUNNfWQe0qmhbRKPhfKSZ59haGRTsQlfFZCblQ5ipaQ+6RLX m6OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032728; x=1760637528; 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=kJkxPunYvD0x3jKWro4+X36yXg91JbLJCx/SAhSInvhNJ/z4IFwFz7dCJz095FbVib sns+CYaMh6UUxXeNJ33eFCayKmhTip7UMhljzX+49v8Zy3mEbtHKhQ8R2IYdurkl5/XX bSseIVExob17H7ju1yBxIZKGrtH0mjYONVOPF4aXd1h3KcKqHVNXklh8H/fWT7DEbrBB 8HjLjvunPzPTu8tJMM/qMnVDkIeDkQbQ9E7yYreRIzhNCrtNTgUVLIRyUYYMKpUnKmgY L/QVD7wZK1JF33kSGqtYCD3VTObURDvSSRAQslaXA/g9UKvgrlQ5ALDr3V0SCIecVtDK lSTA== X-Forwarded-Encrypted: i=1; AJvYcCUbm4B8fHJYTbTBnTanuVtyuksd8IzvYdrnFHmgf2tX+wH9eatAGs5Ti+2PY/nFSVLY2xwWvUNVb8Qd+LI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxdf1HN0q1IRNPV3wJuVSDDSSzjwrvvkivV51vUKiOtjeOzVuZ1 AsZUy0IJmPn3HCO4sgJkg9J9Ld+m6GJOopjmsXqXf4uP3waWxRhiT+5m X-Gm-Gg: ASbGncsT/fFlvANgEnl8bHfOdIBDayA6PBY0Fidh1cGinQguwWt48jJI0z9QTCflKYa hbT1IqeVyN7+mEplEl9LQCV7lnD2qTvg9hW+KPRE/JLv+Q0QRN0soU3JhVgoMJtX9mk1In+Csyx LcPoK+yFVksG8Hd6rivnRz53CDOPAN0ht+MJJMH3/6oi25Wm8F0a09szI1HOTG0Q1k5mqFcLBlP DN3h3mvLMSkghQmzBwe4GD0jE27GNgZYpcqxUhpRAPibSZYY7jPFfwsqTo+HBXSnZP0d8jQ3Kr4 CrCjTKR5AGj7krHKzqnpZB+/3b19NZue34AJ55u9BwduSHtdP+jkuhtDDuqfWv6W++rFYDCivi4 ll63uTaEkYDVhCFlI/GeoZqxWiAQLb5ywOuvK11uXcAp3xhKezlkDuV6A8XTHp1JSEbJiI3sdyp QOSg+NlZqGSrDiHLMdw0kobX11niDVo/UHeh3Tp+2XKGISDm3O X-Google-Smtp-Source: AGHT+IEP/KYeFsU48bhRAsguavBTqOpW4JiVNFuGMdDXElpSwlucCVx3RZG6w7iiJpXxsucAPDZNmA== X-Received: by 2002:a05:6e02:18cf:b0:42e:73f7:79c4 with SMTP id e9e14a558f8ab-42f873fb613mr81674845ab.27.1760032728078; Thu, 09 Oct 2025 10:58:48 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v5 02/30] docs/dyndbg: explain flags parse 1st Date: Thu, 9 Oct 2025 11:58:06 -0600 Message-ID: <20251009175834.1024308-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 EB37E25179A for ; Thu, 9 Oct 2025 17:58:50 +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=1760032732; cv=none; b=CBH+TR/WAdna+vN6DOxGDXVePsrrV6kflXsUpzqMAkwBm/Hx8NyDoeTCw+LJSwYFVOoyiZGePfkgJeptVr7wPP793jGTclRXRNMnngOVJbGnbMAPweZ9WXS+zD0PR+nuT7+lXwb7SfPG9JS9awLfBPNpDS1gpXK9cyk2UtRJh9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032732; c=relaxed/simple; bh=9KA9wrUk/+sc2aQPuLDuiC0POPJjUDsXmXxrrpGdqRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t6p9rQ9oxCpf344i+Ir/hfTG2ZDpu/Ay6hYY6wb3Q62GMgCEQRqOBLf8u8cPl6s63Kho7A2bxzM+bwObvNKogDdk1sw3y5JA0yU28TTtzVtP1komINXQ8sWugaPcZVjw93MayZicxplW/M+HKmF90IHwLRHrNliI2YfKC8wZHd4= 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=FJkOHzU5; 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="FJkOHzU5" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-9399ddb3ffeso117148539f.3 for ; Thu, 09 Oct 2025 10:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032730; x=1760637530; 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=FJkOHzU5BlsQ4zA8/7Ss9wgnIjsNKvqgEXziEKqKU1d/ukiZNSi8Pc+TXuCHAIM8B7 NtNKsmLhg87MUQ79LbxaL1sJeHAQvS6DbgLBBfbZM67IGCjJy8pmLHBmVaAOO+602Vts W5ONdh5lvZmHP18repqcMyj2D/M3penpo+oNDMFUl9VMnYx2jQfXRMokeyNDQmu5br/y /kK+bK89rbhpnDx9jZL6QvqMQk/T1kT5rklFiVLvpii8czIB6jXkftiFWoMCpwOn1QxJ voH14KTZs0WKo8LMT3GOe04rmcSmw/+vg7MP2TNmE5CrW069NgjLShYpb4JM15PFGiBl 9SRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032730; x=1760637530; 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=ZxW2X+7NGJ5OLrx5DnR32Z7xZaIQSJmAeAHqgZ1OIWhduJdQuQuIOu5Nn4HRo5zCVS KpPai5/1VSjlAVxObp0gWllkutdhqk/wgRZlhM2Qmvyiev1V+dYUG7YcB2GCR9NKV87t buzuvBisVIs8f+UkAsOlR5PtLOFMkylbUwnFc0U+lyOeMQMXZQT8fNPRMVbYTumvm9XM UDxAPDMU73xKcF27Uus8PYOuEvGqz6R9qpbxjQf1iWLnK5ssnlj5L2bgUTsWNVSchAj9 1KxYFmruNtlzg90KACQgVl8al10LitCj8FxGJE9ofIPlF23UFQNYDeG+mMu91GJ/WeDV FDIA== X-Forwarded-Encrypted: i=1; AJvYcCWMBWkYcWoB8QTd/4ntdXLT8osjuo/pCOCm4Q1nJD9uvfcK8Ow0w2lstiVeuXRqS9zIdne3DRWNaj8eyhY=@vger.kernel.org X-Gm-Message-State: AOJu0Yzxiq+M0ovRpq9W+KSaWZB0E1y72Ygm6uBsc2Trua7NJ1F4ofqc 5MjwOeS/Juy2ObzmJJpRYCwo1smimjTVUiNRZzLoFjgzy52VEStGEcnY X-Gm-Gg: ASbGncs/gwcxHXPtRA572AvOI4C/Ywl3c05Pk0TbXWk1c9l0cbqDY/xzyi7wQf9W8lq 6MZpl+beG33udgTa3lw5Hx4bS/5Tbt607CraJSvLgI50Aey/deA/wgt1swPXcp0hSUW/+hj9yeI xAOjQRjjPEXQCzi8jk/+PT6f+02GcMhSLkTBafX2KendwVN6YFfnPgq/Hw8Ou0cZtnpythw7Ad3 nahvAH8/jRTkNGu3CnHKruE8knlyoKF8BGdvF6MtOAOJDt3dmxMtWF1JHqj016m7OSKfijfm+wr F8rxoNhQQTUBEdu1lk9p9HwED+F/F085JcZy2Au33mqRFHwsuS+wpIF83R3THn6z5U5hadQcEiE g4qk1mWcyPjH9tQsT3gU2e+MvFL4fAASdCMs58Jmtmtx8fj4PnjWDgQ/MHsOBDnlZLBKtzONMXH c/3l1YLJRVcyv8RQCscZtEZUlR5zSwjTiUxctXFA== X-Google-Smtp-Source: AGHT+IGqp7iPYqC+hSmWS9kXElNlvxppUNSCrpXp6d0YnM0eWjcHcBKQts/HVhk5zAlEdOdTjEStJw== X-Received: by 2002:a05:6e02:1a44:b0:42f:8b94:c128 with SMTP id e9e14a558f8ab-42f8b94e60dmr60429525ab.28.1760032729943; Thu, 09 Oct 2025 10:58:49 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 03/30] test-dyndbg: fixup CLASSMAP usage error Date: Thu, 9 Oct 2025 11:58:07 -0600 Message-ID: <20251009175834.1024308-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A2B525394B for ; Thu, 9 Oct 2025 17:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032733; cv=none; b=CWxXLXnLCiNXXkwZkfoqmaGImsaCOnWwq4tZJ5cY2ucmYJuQbApuiu76rFxrxBpl8U+RaeMFYfMpy8HmYwrTUVuqw7W50Djq3AA8P4tVwLqXyTscgO1pyk6CwlCmyqfYtPL4Zg7Cq/FWzLRFNZPQRkbVbP7gv4nOd4bmw94LPsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032733; c=relaxed/simple; bh=xfWOQ2T373ADf+tcgIBcHrGpfWd78TIqVBMM75aiZ8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E7Pje2CVDaPNKEWulI4RWCtOae/7Iwsj2rrnqPCj+GNwa2nZdVbiB/ixb30q5jzd/0DOFSZ5N+yEuAeLy4fOvnfRF5931WJDt22lmfp4SPrxE579UCaCrkvCPJkBLjV6el0P83klQ0JuDUwtvCbqeOdRO3201N3dkVTss9taP7U= 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=jKSlUEEH; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKSlUEEH" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-42f5e9e4314so12590165ab.0 for ; Thu, 09 Oct 2025 10:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032731; x=1760637531; 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=jKSlUEEHaL/BQmC1dLqKdIxAsvvxQtfk4wZiic26K4932N7d8TRarNoJq33NOSZYbp ClGI4nw/jcfLogW4NJa2KyHe7B8WvgitqQ5SyBuLcb3Jm9XJpodWrkxN0iv72KMnAWHY 860m0VFVLlIZUv7qqgz+1kvOXYvbltZmtLz8TZvjMLy9weryBzn531lOge02TkbdSmU2 MfvSN0vz45dxoAWmtBKLdyloyJppDFxekPFjCwHuI6kQp63UmvZZPt6GvskPGAoHyg0/ h+gHhzebxalwRrb0LpZIKxZYtRooh4xNwt3whBoEk+FTRyrmXIUaG7IKxKoLVAtMi+JD /vnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032731; x=1760637531; 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=O0a57wi2SPYpjBT6O3rfHaJ9VNuuc7jF/o3ekzYEilrlR6LHqpZWNUIv6xPc3aeG3e aqn9q5EmXovnjwNkPHr6ilFRyURYg9OiUt/A5SJTErNUjR2F7yhrYcOnjkHkUAyZiIBz OfGUIg5nWSy6bm6XW4KRZrapU5Hg5G3zQU14zhHsmTHqWDZLvB30E/PUg1fN9l50Hi4U QPLf6Ykfl+UdbElJSJFi2v7OhEYS+o3TeeBbYt3fjFOv6TpRKc3nZVIJiNmCGHvw0cTH wwA8NtjcKy5pFqYgpoqFCNxkt3ThBUW+VYfvserFw9vONoWJB3JXVL7VsLVsNlLgzb3E 1/Cg== X-Forwarded-Encrypted: i=1; AJvYcCUqrZA36kHfGvhpO3pHP0ehe+CZUeIx3Xp4pbKemtyJf+Xrb5C7lVT/C5PgDS+g9un6tq1kHydN27L1j14=@vger.kernel.org X-Gm-Message-State: AOJu0YxpkCma85p+V5Mds6lFPtD50HwrdnI+uIq3+NsOhjpWDYvnyGRb TkxMsfS3H9/P053Z6dkMpuWT+QRhueLwK/ujeHCJihR5w0HyklgucXSn X-Gm-Gg: ASbGnct9xTAGUAocS/uJ2kZ+vYykoBa2m8obgfSVrkWfmfkMzuO151n8PQmlr29UUDR UH1Psxhv/PqcJm0gpnDc40s8Qp7iq5AdyBrAi2mmn4+ebKEYW0DD4QK5j0vzX469SEjnsRjOLd+ q47UmorJg1gvPLko/SPif0OUqqKFB5025KgxYSGwTsIL+9VNJsyHgdpThoxKDFMPHZSavOlIe1g LE4vbj0zF6hTnRIdGAN1fVno6Exxn+B2aFGnGnrh2yrSCzwh7thqlq1t5fEhgSufNo5fMOVpoQ/ R16uN5uRvcFqCmk5OvMM5ktV9hAOTDKjtS8w/9/VpSVO7H6bB4KP6mgkpa2RTYnJDkWazkds6bs XCtAb46sUetTWuTkOpvuzati3e3V1jF5bI9iaA6qY1bQEUK5ZssKd79+Ijg6kEp1sqU+D5WLOAA gwPz7UftQz7v3tSaGHMu4T9PHkYIP1RDAOf6JGrA== X-Google-Smtp-Source: AGHT+IFGYwQAi6/+LnQSrv5XVqN8PJXx4dyNZG3PIv3e3G7kxepvzgPF7iyA+hTKfqnZ5PXXLeiArQ== X-Received: by 2002:a05:6e02:4706:b0:42f:8eeb:499e with SMTP id e9e14a558f8ab-42f8eeb4a3amr54728835ab.13.1760032731025; Thu, 09 Oct 2025 10:58:51 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 04/30] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Date: Thu, 9 Oct 2025 11:58:08 -0600 Message-ID: <20251009175834.1024308-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (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 125C4255F52 for ; Thu, 9 Oct 2025 17:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032734; cv=none; b=QZyTYQ8iRpuGlI/Jt7wt25Twn35j1Ipwsmajrh1eWH+1kBSK05Jpv8NT3+SgrYzr5BITaHb1e+nL0oupauwaEUzXlDGe0OlGs18yqAgxynqb/pScxLDfRXDc2JMYQDhYln1YszAv1bipPwNs5GqClyGTbEq8xSeNR6Temjo7Y5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032734; c=relaxed/simple; bh=aKMTvHoFGMDwM92wFBmpn94LIVdnLgrI2RnhwdRN0GY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eOhFe54d+d6w3rYPrqMmNH5el21TtCFQJp4fPTYIR69UFA7XM55bgiWOmP6EYPJJ05RM0FLReOQRFkxYbM/JSDea6powwIVtVse7jc/SjoBk4bPiZCs4wMKcKFzqMIMs/7OgNvySoaOuq2pO6HzJM6TdQqWeLEGigHTkSNHs9os= 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=Al+PKoaa; arc=none smtp.client-ip=209.85.166.181 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="Al+PKoaa" Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-42f91d225c9so4294135ab.0 for ; Thu, 09 Oct 2025 10:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032732; x=1760637532; 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=Al+PKoaacIAQUTnuu3vlG3yF39cTBBX2hXYkvPd+bOor2+RwOyoHk1IctGhcBtEue0 pBdzB57X4GmT6LClV0nQKDfgM4WTU4HzhOwZ8VMkY1eYJ1kQM95XUVYHuu5pGi/HSFoI K9DTdiO1rxvZTS4jrBd0igjNpg5BGWQa1y3BoOir1yHyPb9DyTyCu9IHkbhn0RTW1N/I t68G8kDaRqxebHU4Lu82ZcE8g6juAhYmidIS6FtT/2oD2/7kKXjlyPLMrzHKVZobEOY1 VHy8mO+6Tpk9rhWjD4uXfbVCM+sfqpIGflH9Bi47ErTqQrN5DfHcvvhrhudB4e5xT5Ft ejrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032732; x=1760637532; 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=ENtzW7loAexTrxnfLm3E8Ycqd4TT2EG0x+CLf074kuOD/t3v5KOnn9FOQeRcu202hs SkQCPPSeK4OE5+M1e0W7EGVBVTlp525EZJgqpQz00+ZXqThFVSX2ukEzQABDoupxIw1Y 6aoGz7GIFyyxKzwb24UPKrx1cdZMljM1P5iTBsv9ZdBT25yhnBHN691gk20Fcq/7qSmq lqsDeXB41YhpUAl4LMXk1tyKa83rNkgz84EoBdBOr3HyIfnviKSpePutUHntoyT7DtVh HT+XARKDoVQ/AO2as0/vrKCWUQyr1balP8htt7G0o3F8yz0muwZtzmc2+RVQo9Bux8Xi QPog== X-Forwarded-Encrypted: i=1; AJvYcCXmSz9Ca3PVFN2H63dHaN0NY6pNeBIlmcZrEVXU3Ei7k6/9Rhi7GNGISxQ78M+anQri2H5Bnjr5GI771UI=@vger.kernel.org X-Gm-Message-State: AOJu0YwUrDBTQxAmMhAEGoc5r2PpMKCqwWNQPWjsED0+xLf8CP31dID2 /VvNCMI37bmlGCC/eTTDYopCn4by7XcERF0GIwHazA6AKR17cce919DX X-Gm-Gg: ASbGnctYPbS1y4fPOYVVfsNAOkdja/Wvs0ILxMdREprNeMk/T8pljqJwa+H0D14nb2y g9avk1ZlEafv80DWnsYLHszJ+3b9ly8oZSyKhXrWDqiWxVm75W8Kd0PMnAy22BR+tIyUF+yuzti lRlUCIz2Gzycuzkmc1c3PQR8mx4LeTUcjcBcnadNq63SjGfYK9Spd89kpq9Adre45Fn2h6vjyJQ Sb6zOhyZGk+Dpp5aJXtUA/qtJCQ92MAkEdsqy59PmiMKpJHChmp0oMMgyd7ZxQXQquKie79QFS9 DqVpMlEWdim8xTQZVbP0yXbKML/blGv+ARRncMKFit2uFh0j4UYctw2EOwjeo512/Hwqyh2A+Ed Z6D8kaywIvmqDH1eRHYNbozvlFKMLJpPACpqO3lMlCOmOUZmGgHfDjdYXI2vq8BaOeTKBrN0xbP LvuZ163Q6DDR2G07R/gNu3AL8kkq3bjB9cSkGXSg== X-Google-Smtp-Source: AGHT+IFFRLinxOs/9OTcYHa0TTaGH+h0f+hAtiRcea3Rwbgg5dAqda5gTWAF7gYArlA/stW+upYWUA== X-Received: by 2002:a92:cdac:0:b0:405:d8c4:ab8f with SMTP id e9e14a558f8ab-42f7c3b2655mr137425675ab.14.1760032732136; Thu, 09 Oct 2025 10:58:52 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 05/30] dyndbg: make ddebug_class_param union members same size Date: Thu, 9 Oct 2025 11:58:09 -0600 Message-ID: <20251009175834.1024308-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED6D257427 for ; Thu, 9 Oct 2025 17:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032735; cv=none; b=gOGsPofkTc6B/hc8E+XByvL9FqZLgGHdFSyEly9EDvM/UFCe/L1dESJSJUdfbjnTwLBsQvrWtfOXkHYVtqa7u/dQeYx4d/ONHCkbSbZLOL7b85YAk9m6vfcjbaMJi3fLP3xqhsONYFTr3Jr1k6LYFANNi4vbi9cPuAMVzYEX7Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032735; c=relaxed/simple; bh=fpFcDi6ztz3oxTgd6RA0bYt2S3BzBQJFxjJY2ObCcT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZRHtxknGdyMOBUDHnjS5vQ26rbZUaM2Jlmrg591ugtqpC9cmHmy8vcMOjXPEfVnBG+6hnb6qZqydnh/3Rm0EhJxrpeBnG/GCuDOMUHRLYneDIP3Zf2s7UV3CBCgVCmeFo1ZGRhpXQ3lRudC9xCZOHhNny5yYH4AxGRNtaaLLsIk= 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=k1OkzY+7; arc=none smtp.client-ip=209.85.166.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k1OkzY+7" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-912d4135379so51207539f.1 for ; Thu, 09 Oct 2025 10:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032733; x=1760637533; 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=k1OkzY+7p1NX8XpBijsE1Z6G+4abTDbHFFuaH6AZDZvHTSyPMMPBVqlaUN+sVVEEWx NwTSNLWBmDyEItR8HXIjQfSmncC2jsLhVI3NfI1loVjPrI8gV+WawAnI9bJTvejfJ2YE NlzXlgPz3ZPRCwb1kMAqjTwpmEfZVEYQ1kfyt+fO+4mLPh5C1ZM4iuWjN/YRqk+Y5a/b tPALXWF4pBdi8VlsOIjH1yY52FXUHUmRW2g55ltnmSTGs3fB0BjtoZXW9dFWgYWadPyM OhLMB8RnfLUqW41xT49zIP4MyOKYqRbEYu83lEXjiIx32354iKMLOupxCkFwYhI0zWBE nLNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032733; x=1760637533; 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=WJW1viXcAZwNmyU4GF/LuktYYhmITxCq1iOARBNAJ2tFK3BX6uZvsH80JX77kT7BJ0 ZNsaX1DsNqVbn+5fH6ngHdla5oA1W2jWaP3h1Az5SyHquMMoeo7ps29RBKFrSoSsZf1q 7f1Vg1clDTrqsgKnef00cUOWQKRJ7iuvUZo9l59NWQMUMt4OPmCKYHNUtTjqx644lAIN OETUZoTCtrmmnB1Fdlf+hQs5k4rQxqdXFDH5Ny05ZpKn4gVI7arZSqprwOrLguE4Lw1R fDtXJxM76XIYYVkEonEIU7y+dftN1L+Ntk1z4HyPBuJrzlECcWzxAKVco26rLcYl/tCU OecA== X-Forwarded-Encrypted: i=1; AJvYcCXwgscuQmBjVVzilrE9IECCnKdM9SEi0rHK7rgaITmazYpBDQpy+AnQBPARY3nJFXftcZMNb8n86Ov9TsM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4lcDlRYgjUZRI92Pqvrb/VpEkBcLnj9cw8ZIAuB1r2wVyDy5Y nofRpWfg9lhzb+aeDzDrpiSb5khYwXq4lAbo9Ry62TIIfnly1Y1IPlFo X-Gm-Gg: ASbGnctCTGlzEkWIf68fKn4svsR+M+JJm8qFTTapFnu4nFukgdBrd++Oh060dZh+aQC gVYue3V1ykK44hLXmkontQchpq8llie0vnHWDvk91Rg3iYGU70L5dURzNldnP5xFX27d2z+hF+k f76yzEwF98MJATO4ZCkb4vPVvbj7+3+yhFgSg2/jVGC9Jv9zMXdoRsDqaUtos+DwXxZrUKt/1N6 HXeD/fjeq9A640EmY+YCsS4Df3vt1PXV3Ymdh9JRcxF1UZZOXUvLGUTuJPWM+8Cn15SxkBZFSkJ 8FBVSGOuinevD1IQ6p+RBAQSQ6y3ys5sVFloT556M2uHSe6nfEjxibX3J+sm/pM66sHYw4Zr7r9 X2e9pF8eeRZMh2NNNyaYpG1RD7tmjqMKB7IGbRj6AtZ8z/q1Z+sEmWoZKCtfTvIyoqT6b5aiYky wbl598mFdzra1QNuSFQlxGucWH2HzpNV/2aM1h8w== X-Google-Smtp-Source: AGHT+IEFgHidntDfvFhDlZruUCJmrkaroGW1qP4eIEz2kkTaQPPkZf7Zvr9cHn+uTBEE/+gwDo4uRw== X-Received: by 2002:a05:6e02:1a89:b0:42e:72ee:cde6 with SMTP id e9e14a558f8ab-42f8736aa0bmr82269925ab.12.1760032733126; Thu, 09 Oct 2025 10:58:53 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 06/30] dyndbg: drop NUM_TYPE_ARRAY Date: Thu, 9 Oct 2025 11:58:10 -0600 Message-ID: <20251009175834.1024308-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (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 4D94B248881 for ; Thu, 9 Oct 2025 17:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032736; cv=none; b=h++ET3epko7I5y1w5rKLLlKdQJU+ZD8HTTn9P2OHV+xEPybkaHphc/9lYThWNJ7CYyX1k8u9H5h+2v6PO8VmaThjbNjahSjrexNiewE+W6q5nd2eyedX84OyEYnZo/a+lcrcFaj+P26+vtYRxIWu4k7jVenZ+5o8Z2M3JPcowoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032736; c=relaxed/simple; bh=kfrqrzBKdI5m1IsAj48HkDg3z3FjqKlovuaaRAQV+k8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dBYajwrS3b2vAUGJ0Jo16VBfXK73Hj/eDIdI/SVm4n/Zo0v5oGNtP6MrcK/r3Hq8N2o5OQoRZpuBYHWAHmGR5mUfLB4Iugvs/37tGTZBIQzdRNhYmI6Cgo4AMs0VuTRbyp+PpYeKbVpiiI43x5lmOTK9qMDo4X+AYk6VKo0SYbY= 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=Pauq1uOO; arc=none smtp.client-ip=209.85.166.178 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="Pauq1uOO" Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-42e758963e4so11459615ab.2 for ; Thu, 09 Oct 2025 10:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032734; x=1760637534; 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=Pauq1uOOnMlFCLzKseImvzy3FtHmpbiCxJ95hvT3ezSzYgC+ORwkX1uNVcE1rwDT6R QvEcBShqykyBwyANARmZg6V09ixbu4BFPr+Hr+amDbS+SKXSnGUg3avF2oBQnmq0LWQO ZsLwjE+GwGPKrOen9XxPngbyZaTI+zFQ+kQdMHy3GumuQJLk7lMXSkhFw+mfC09/pTJo VelF0iTdiOYy5QdG/IukmQM9BwWj4BbIP4DyOlEYrk7TxNCausfbNDOjZ4WF9FOLdPx4 k3PiDrNLGAZFq/5nRLb/73X92qp+0KrBn1s3oHVwpPa9gdDaq0OqjTl2EYeKoy2SexTX KJYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032734; x=1760637534; 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=DGyV1Qxlha5tm6bne2vS3+czR/2+D8tB/feWR2pS0PtObbU7gZu2Zev9+Tk2YPtaeq bOdhXcgqDul9f+x5SdCW6KkFrVu2CgI8ET3A/gsINpFjKYtK5VJNSo7oSzeGTxNvE7XY uuY7UT50/D0d6Ym2MxtlgNXMJslckxJSrh71D+5y/M9BO9fIMb9qeq31YACJxZMW4GQz EcpxJYWEpO/uSA6r8KBTQ+meZ2LCKfywOaqHQvpfeVmNpxSvwQ6NXY2M1ddFrj9zmwFd JooLRPeQ/arYvWdrQdRTQxBSFqVMra5CgoT+5PSLAQoZH0OVv66FRS7NYJL62KSHC+U2 lRRg== X-Forwarded-Encrypted: i=1; AJvYcCXERDmbPpcAfUdlsqa9PfIodUmMbn0w7G3vfvUtr5gdK9L53W6oOVVOHIDxt8+tMjOMsQeKiNoc5hbMB+U=@vger.kernel.org X-Gm-Message-State: AOJu0YxQW12h4ZwTB9K1B2/cW5egbsYrgenWjwI2H06iHqbr7bLrIpWF p8fsUxhqvi4wBvbK1aOphCEE7UcuRTOKqDQ0jVrnKQw2Aqh1NlMUAtyZ X-Gm-Gg: ASbGncs06BjeKYXeuzri0PKnGmZwrWxlYAn/N2vJEqPo58j8fD142GAWTgEBYNcMkCN tqRwMiNDBvBfTtt8uQEUN5eWM5MTNf1ZiJqetm0kvukj973xMNrG+UUzw/av+mpZdjllCYSHBcM X6o6gnGihdrSc+d7O4/EKvuhssP7P7x3Ppz5g8OiyTYTqNQK4iyHXEfiNoc6ceU2o6Xjb+JloOa 5Ux9nzlfdCHgHxEl0BAEUaKz+ahRJO4+qNJtk2k47+q3zH0ZhxqJEQtqypsb08C11sHpkDZ9ZMJ v7LtLupsMtrEviab9p6knaSSvoIXi2M2uBOdcbmSBqkR3oIkltY3xQ3ZuQ66Rc8AIzaKW9ciNdv IDv5Ml2h6LL0Q9y154NshcZempsDHJhIUnZ+4nliPpYaEbIx8QrTiQVBPO4zrV94p0Jdk2Fxgko DTdXP4eH/oxyVkV0rO1rJlrHoDJ6c8YEXp410hBg== X-Google-Smtp-Source: AGHT+IGG3nRCWoDD4V/nkCQ4bWDSLxtN1n0qdt7xwh20BiNzOL9cD9tMw7g0yxq5IwKvmpy6qvXj6A== X-Received: by 2002:a05:6e02:270a:b0:425:951f:52fa with SMTP id e9e14a558f8ab-42f87376e77mr84960835ab.14.1760032734175; Thu, 09 Oct 2025 10:58:54 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 07/30] dyndbg: tweak pr_fmt to avoid expansion conflicts Date: Thu, 9 Oct 2025 11:58:11 -0600 Message-ID: <20251009175834.1024308-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 9522B258EF6 for ; Thu, 9 Oct 2025 17:58:56 +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=1760032738; cv=none; b=lV0zfUOqJIEpRUbN4TaFneNiYvWEFeOH1iArobaf4Y11UhJkfhgbe4Cec+Gu1w1jyZv8AGNJVIkDsom8swcgIZ/1xYIXd0BdV+uS0BUU+Oc3DoHNmLJGyS8g6Ty9v6qJ+qUOUYQXcjatYvjNSDdo3PE0Y4q/2/N4xiRgui/Mbuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032738; c=relaxed/simple; bh=hD0GIkum0W39jX0UxEzb2WfDmaFO56evPVGPATON4xA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oXqL4j048roKLD1tu2Z4j0WPVtR6lUj+mzPK8DqVU2KJSklH2iUEfrrHWj88Cf8VMMJlGWa4Qw68anPMe+rTds9ws6kysDdExtJXbUrGT1tzmryDDVRx7xRq0Y7XL5hsVa1VVtb4p1qNhmRFCzStlUdDuc1w3W0QX6xXVE/25bU= 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=k4N6nPYf; 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="k4N6nPYf" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-88703c873d5so41943539f.3 for ; Thu, 09 Oct 2025 10:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032735; x=1760637535; 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=k4N6nPYf5h6luSr4mQwcNc/229h5wy8Ow3KZ+Lda5FP7cl8AU7r6qzBUWnQlzQOO5p a/z/8M7kGORt6e4AP3xPGs4OFDZDk13JPGOKP8qOt/w4zrY3Ty1M/el+OwH4WsCUKM/H QsFLMOgqOgFtDWzp7ahehwz/aqPDewBbiCJRuhPQlKonEdO6f7L4uEYcrGpgI1SlGpeL WHG5KIciZt5DTpFFu1werxKmuGnyYgJ3hk5CfR26GUbN8bR2PAAhCXOTTEMxTrzxPhx6 MhNmrYcU1/QcSt/tTUN/iI6npF1DjlJ6wZNI75HqTkFzLLyfnw8CWQ3BCBV1rLwqVPxv HxGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032735; x=1760637535; 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=WTl58EdMTnOrZ+D4znEpA7Cl8piwxZ7Mi8m6sDzUVLbakFEvRfTn86D+NvUviSPt+U 1Dd//NMpQ/iDfeJEdagNGSyuPmEGxqHmAuw2iBDr4Yx7ZuMJJj1s9uWHkTXZ2Lf/rQg/ /Z27GeMbsluzhj7E1QVlmvjjD1m20F5BPLouIPL7qNVTCQgeF8XQsnmPxH/g9Cq8mZAl 3DsBHJK9+TW5eRHyezvH6ijraCaSrELeszI0KKPkdx/AKeU7xtcVWmZoigRlWP0S9Kp3 gA2gfjkbmssoHdFrCOP9DBNXfZ49J4l6GIdm8wzMiXSvgMrdWZZce9ApXfUW+SUE/nzm EY4A== X-Forwarded-Encrypted: i=1; AJvYcCVzBdb/ACiArECpt2zUICs91ZfOdEm6hJ+hXf1xdPbup6JbvMZyLMwP5lcjLsRaXn33xcgUs5ux339GsWs=@vger.kernel.org X-Gm-Message-State: AOJu0YyIvImRUUj+B53aL0kJ3qU65/MPrVSvcari5rCsmZnYHW3O1Yma /KN/DD1NaWQ1iBOtMbnP8stTBJ8j7CoKaP3IkgaN5s2xJZ+uaExURTQF X-Gm-Gg: ASbGncumcEg3PxSkQBWmUBsar1oFMKD4HSO/YtNap9ZPPmwUlRz7cPdpidh8RYtLD9a xQYoLnV5cSeurFtkANJRH0OHHWtHeeAYJiQvEGMLZM8HWFWZXx+j/0s7eyHwVKHKdsrSul1R/nE 00IFXymBM9kQxoPU6VadqklwESA2ueUOh3NkhUEhxgbapmdknfKEvLiQK/I9ExsVoaNSbu3bu2J AI3noWONKUoFASv/vmHEyPAp8cgEVrVjoqF2aJt5YisTVBQKYDqqs3ZZhKs8tLM0i3cYU9hjULr erIAIkjr/RlF7ZOIHAvNjqaIilBcQgBx0xn9S2vEM1YHSs9pZkpBdJxIc1dmBGCpca5minL7Y44 TdgbnA4DcMFdc4zjT9DJKftFOswHAT/GKomOFEH+dQrpy5mE5lnTFtzdVLWDuE+38e7fAY0rEDk Ilzh0ZndcrU6LZdALOutlXGswvAT8= X-Google-Smtp-Source: AGHT+IFEQVqHItn96Kc8TDNYahdPGtpH8o28572tm7Q+v8IZnToKzjnD+Tl3S+JyYpse/uqZNmWfdQ== X-Received: by 2002:a05:6e02:1b0d:b0:424:6c8e:617f with SMTP id e9e14a558f8ab-42f87368781mr57791605ab.8.1760032735463; Thu, 09 Oct 2025 10:58:55 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 08/30] dyndbg: reduce verbose/debug clutter Date: Thu, 9 Oct 2025 11:58:12 -0600 Message-ID: <20251009175834.1024308-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 BCB2D25BF13 for ; Thu, 9 Oct 2025 17:58:57 +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=1760032739; cv=none; b=e6VuWP19EokyhPw1WBQL548ZZ3IoSbwe59KMcFsDPpf2FSs2jpU/CZN3N8kY5rb8BZ1vyXGvY5rTEWji+FVhZ4vywJhPo9xWZyXJNrXJcWclGsGWxq3VVTmJXMNBvmImaCZD+2+zvWWK+rwVskhL9Gvc//U+12GAnbRpMff3olo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032739; c=relaxed/simple; bh=9/CNm/qErK1SavMH1/i1nBZVahomfVgVs/AAjSYrEHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eXRxfSJrJpICkWm8r0ilnSGXTLi27jFdQUPi7LR3k9KCDtiUY8tt/cRvzVEGUayAm0g/jL6snkaLyTNvOZ3OqFCDCuCzHxkLHvqvHGR/cjK92+XgL5wyvbzKm/YX/wx/bMthpdZXjBKfhU8xZVpS3kHjlDro0LonF5DqCRlKmyM= 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=fJzBGMBw; 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="fJzBGMBw" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-9379a062ca8so44473139f.2 for ; Thu, 09 Oct 2025 10:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032737; x=1760637537; 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=fJzBGMBwYTDSvZC6incN908CvQXbun5TDxCCwvrpJyyzPxsQvEW2+u2zdfhmi+KQdN NHgO6H/psbKFfX+FRjGzVSk+e6nT6SrdSmqDJ0VUCICFm90e1g12DVTAN4qQbz0P/gUm elTCS+cvMQrpYPQBhDQ3aCWIRB5UvPOMClrMbopdmGgv4NBmlfcyaW9XouHrW3/XVk4F /jg8J27NYwTh6O2+vKZJp1uS+PF8U5obB9Dhg8oT7DE73KfIimCnbA2jJtSOaL9XrrEq 60CN0Fcw0QmVdyw/jMyY9oWjG+lEMlLB40MbsJHSZytVKLrg0rcfCugs/BK87IHMtNo9 SdRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032737; x=1760637537; 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=tk6dNB1x+cM7pLk2vu59X1WvGkPzxVZFWVmIhm51aL7tZappNTxh3gyDH9/rKtNL81 remGwwyhamSYM+is7/VJ+hjAVJAqDlS9j8IcI7NDMvrx0vG8Y9pw9nLOnGhOdA3dX+jt G3qgx31EUVDlYsI15TtQR+2ytWmaN0u6GfJgABP15O4MFc4AIiTkbfD+Bmkyaoh55xZP 6oWKPFya+vsl5BSOYtxwDxoZI22O6ZjPd/KWvyIb3tWAlR7DhQUYvF/O4kS/BifG13I2 Sfxk37Cc3rA8Pb0Gmq8I+smqtpPs1MfL63gcX4DT9FXk77xFaOCcV+0crkkayzEFjxJm x/8A== X-Forwarded-Encrypted: i=1; AJvYcCWEd7ce9sHwJJ9W+DDiSxK2iqBvNJsPviC3JXz0lKeqoEBf4YGTMor9wJN/vVvjdewaUbJC3RAx6bKqO9o=@vger.kernel.org X-Gm-Message-State: AOJu0Ywek6Q9OpqhbakmpaeRnWBkGpBMncxCZO9rlivJ8VmjW2lbLas0 4Q3ucwrDNn4FH/oq2uRUJXLqDAuAMmsWlMdlXfsz56GE/VNn9D/SRuBa X-Gm-Gg: ASbGncvWqf0D1ZpL2aOrRfjL+uqnyzpDHpxElc1cB1fYUj6qJqPUJIi3oD/Ff6iKfq9 mKyl1KQIRz73FrR5FanCnkZ0pyPVf3FJnCKrqoMxuCJUECuBTiqlCjnKReoTK/8j1GavZsuBCcG Lms+zP7EIgDbJewhj6OWJCzBaDxiPG/K9zcdgeS1dDXNbKJ7xrHD1DDHmK1ngWpKKzL3RDh8vAu Iq+wTcjJ9M1EV9F3g/Ftktq9q0RoxvnZtWFWcAGCHyJyZO9W7HQbNWiXIR+kA80Ry26Rw/h0Mmx MzAwQ7Nrnhx+SU8Ewy5BB+s683lIMVidxuWxvthUJWHqEUrVz6DI/LmyX4/Id2j/CY1ZoP9jzCa j5dEA8i6kzczGW0udLSsimHDDSrBz1RapRBTXs0OtERYqmxAZ1WQbn+laYLC26oUVFJHPFVpl2C 2BD/Ip6JKqVX3GOZYAOBl7FdDEEOFPp61U/fJ71g== X-Google-Smtp-Source: AGHT+IESXbFctb+o02p9qsNPIjHcqpCU8JSNw70y6it9YpjqvQ7bx7AzMZxH2aFb2k9OPvodnCQZIg== X-Received: by 2002:a05:6602:3c6:b0:901:3363:e663 with SMTP id ca18e2360f4ac-93bd197f928mr889547839f.13.1760032736623; Thu, 09 Oct 2025 10:58:56 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 09/30] dyndbg: refactor param_set_dyndbg_classes and below Date: Thu, 9 Oct 2025 11:58:13 -0600 Message-ID: <20251009175834.1024308-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (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 A954A2BD02A for ; Thu, 9 Oct 2025 17:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032740; cv=none; b=q7n4jBR2/ro/+AVAdjUA9dfcjnFc2jIQMfHVTZA33f1ck1K5/6frHlnmMnkS88ttVuAtVj5FogO61TLRmn2osELjtQBCJJzKLV0BC0+1/8hj5uqS4JHIDGxkMyyxtbF8atdIyYLxdajlIr7pjMYVWcNydQrMrsat49bGHlS71m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032740; c=relaxed/simple; bh=O+DrJ+WIzxL0KCL50VNkBHjTweV2OInEHiE37yzYWsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ERGcQPXWYH5KXL8qbkxYQX5o3hw1ypQ9nBRoBGV+tyIBbxPqfi8LTeUiD2wIOvnaHfmA0KN+J+hJBKHVbTHKt+j7kR1dQSL2PW4v0FhzrjcFLpsMhlgpBtdz3rMpyDADhEx625xhcCsej7+JeigqcWPilcVCNKKiO3C5wmdOEcA= 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=MThWKHf5; arc=none smtp.client-ip=209.85.166.175 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="MThWKHf5" Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-42f91d225c9so4294525ab.0 for ; Thu, 09 Oct 2025 10:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032738; x=1760637538; 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=MThWKHf5zunsMNTN1VZxCTcDE9aq/Ti+AZ6Bxk3hxr5CaQDWw/SD6qGb9ApPvSaiQA QKY2ehWlc/PvPl1SviOBUcsLXQ8wRUswhbRZbFgONWvWyzAUXfhJzn9BBmUgOwcQ1Vbz WmI66IHjEOt1r72f1W6lEH2YAiMz1relMr0a4r6Fl2jk3WJlZ9Qx3uQJehDwGAYM7tGO a9bYjZpEKjyyZwjKg3aUKe1ADk/skBeBOfIrtdh2gund1aM3w+NwFk/BDuPcQ2KoJXzP o/ygf/wMaNfbco+tmdXFir2ysE+nmSb5TEL5RSbj+9GeYLmLgyfSEKtFcRAzjpFywSZM qCLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032738; x=1760637538; 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=lvQ1F6grINvM/k8dM79qEZa/zScdtO3fIeGfrfIWvmxFY9DswrxqkDKaTNKKl0C+ak fckq8fnbDAalEhNmDi8jPz042xypL/h83mMK5lj7npbYmahJzBu4XpCCrQedxf6/ej7V rOmlp0uoPoH9yGdQQnJi9lhh71FLNF8NTHLqNC371HA8aKPh2iwPBVnO/dCCt8BB1OXZ s4pTXSf/sQkKAPMlvKzxFcTx4Do4h3OVe/cYKJek+EOM4RaA8wiycRGcm90nxeTynmkV 29yhH9AaFJZ+WBLsGlZ8fW+03UpuWHzbvvEajePbxQmADw/VN9RCFaexfcLOGk7xQJm6 Px1g== X-Forwarded-Encrypted: i=1; AJvYcCX763ZDnhYth31ov/iPxiqXmDN3mVUSDLuQenECKsV0dOXuiSkC49EBEstLt1HsNoAH1A5G5VJ6U7HdyvE=@vger.kernel.org X-Gm-Message-State: AOJu0YzLnTcu90sIFHyksUPCz3RiA+jHBrjb62QfvQ5dOBavwfxgurYP h1cggueCpqDmoTXppMIBat79e7ohO6o3r7W5CG4CuQHpyZocQceTWBLu X-Gm-Gg: ASbGncteJ3fOex+EJNxYhjQHyKU4VwSYhbNuFERWuIx/IVD3S6tvs0wLxPQsTEq2qVa jdKODChcW+6Nm8G1kCV2DpimQPzt9ukX7ddanNibHlH5YLMS6f/QRGTfr7yEUVKKNHpbNvZJKvy 8FKn8Pdn1/+xtsyLIcjJlFNBglC69OVucBXn0MRsDOWQ6kD/psEWwMZj/V53f0VQHvKt2bHYBfJ chrYlqd8Pc0ydW8yFZ0Ug4U6x1xITfo5VwN0VE4LKRr2CKEUifjkOULeE66aeACiWRtSDylk5/K D6OduIxSbpOhcYCMRsrl3WvqkjQUJzNbmZMxmkq+9ak1dYWxy6p2KtOW7fFef2vaydLK0/seqYO sZyvyQzurJ0VCaPh52rpbn4dvd+yudf1/CbOOEk/mqwwAZnDK7LRnIfUbu5huF0XFGWMrIxtrqj 6bw8qxq+UKgx7VNEcLa5s1uDqMPOB9Z8vbByjbHqik5pJCm1Pj X-Google-Smtp-Source: AGHT+IFuL6dXa56UawxDS7QbBZMvD0b6eokP6AmRif2uOK68pKBSgTMBBEBchUQxGhuaWuFmQYhoQA== X-Received: by 2002:a92:cdac:0:b0:405:d8c4:ab8f with SMTP id e9e14a558f8ab-42f7c3b2655mr137429405ab.14.1760032737756; Thu, 09 Oct 2025 10:58:57 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 10/30] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Thu, 9 Oct 2025 11:58:14 -0600 Message-ID: <20251009175834.1024308-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 EFFE42D7DCC for ; Thu, 9 Oct 2025 17:58:59 +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=1760032741; cv=none; b=abNVbgReigXpIw0Bng72cbm9yMWjBbXSN4om2jOdFUH8mHKQKFYFLlvpDKb9ApxZ0C0pffk6cfIcar4ZgJkZxLOBacX6ZEdL7dDUQQVhJNTuYiggJBqhH7KELTUdi530CuTYMf2tXh8SGYp900YGu01zSye2XuK9S572WKW4ZyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032741; c=relaxed/simple; bh=rK4z7rclwfK0c037dAKPfOpjg7IlFZUJaEv9EBcl1IQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CYOvMxsheFhTbl6FhoLAtHLtcdy7p88JbdK6DC2iaKO6PgwZzc1GMPuAqIVMpkXhQMv+MwoIznBYVPuhuwihPw7cQqkSNQAzGCO86iACvDXv7ZomX0eWYUSyOf1sN9nlFCY4VYK5yxKcOBGK+mINA2vs99QXV+lBDo1Ju2y4RDQ= 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=mnntBQsD; 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="mnntBQsD" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-930cfdfabb3so104062539f.1 for ; Thu, 09 Oct 2025 10:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032739; x=1760637539; 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=mnntBQsDKA47enZ9GwWPvaR53nz59MPy7W8HEhL5lIJvW8D8nQL6jD9EtiRi1vWVFG Iu+cutlVIspV9mNgjS3iO1Y2adhFEAhwKeKiRMPyt5oFH6gpgoBGDjTaxLJlRfrJ5oOF S4qieEZspZoFsbl1Di7ceEhtASNfg0V+xROFzCEwMbpDl81tDxOtRcfZtlwU8wyGRK8C MKvDSkSjPtgmW9NMqvxMrQnsZshfwsoH1qaL+M3ev63talUj3vK9IIt9Q1Sfm8xIiVtN FZ+/tGUA553gTKhh8J252Ip5cyQ9KDwOsfWngNgU3XGX1mHYpoBME1k1AaPsdRWAftSQ l5Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032739; x=1760637539; 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=oOgvREp9qtG782KhB0IK4Z80219XVq/1+RTz+8XZ41H7RmHhyf3xSArUQpqcghdaNs 6Nv/xh85MpuVZ6E7ulyeOli6/wg6BVpZtfrODdZsVv6Fw5/z3bwOCs3N/S0Q+hIAJ4So JDdDl+DXL9gvhEyL716Bbik7NAW0cwqFDJXq/k/0qgj52gyqjb19anV0vIlvSfsKbgUP dUCqxaaKUlMGlYi0fXauIzZ1YPbvVUkLPA/b4L2Hn2AddaneSL6hKUlNT+wCF6yQYUR0 Euv8hraDeZ0ZWJLybPCfdfkAB1eC/XFLGplEHQmcJ0dF1k8eadItQC73YbYnDBCXotAx jFmg== X-Forwarded-Encrypted: i=1; AJvYcCUekaSIHi2OibuoyrWwN/OqEOdDClQLKfqNcv1OneMApU+mVTOvmpOvXpoS0NSm+YEVHABIa6ARMgg9nVo=@vger.kernel.org X-Gm-Message-State: AOJu0YxWj1B3mLpZKMEJk45bZERdeXDIGpQxftTmkm8SbLX5w1k2pMjz DzmNS23s518PajhEe0S896YQUL/0hR6PFpfYVzQgPlbhXXopcKyt3b2R X-Gm-Gg: ASbGncvJRYnE+2cjQJmvYiCYok0eQ32rPHFKlw7REiuqrBjaVN6tV768/Vh/Lc1ROoB +XOaYPJ+025IJxe05aA4svbpqezcS1ljvw7QmnW2QvCYpFa1z0vF5fGEyS1set7LG3kmvVyFfuT 53gog5queqI7LHCj+TDhWsKq9l036bFNMCBRhcX9pAtzTEC2BjQ55aRCriKEyRvc7AD5sUIDGTE jabR0rnEe4PZAQOpdCh4LAQYfh7r/BpaWGY91vrkSkOHWfpRMmGz+OM3QdTz70fzlXNfsFF145L HL9hPWRbXke25yhxGEcF3lu/zGnIY+vVFSmA4l6ZtDSwGRlx4Ur3MJ7LptfaHadzrtovyv2vq3r mlGeucfe++67Y6t3rWf1SY2ghhve/dI4wXt1fHwYN0o6ZVZKzhThADvx44a7No0HTYlqHXuKFPR PilaJAZRQmpnSMmFLiZTTZJyG2ZSvi70Zb/5u65A== X-Google-Smtp-Source: AGHT+IG/cmjH+ejsk6u3zL7NqZFd6p0hdxUlyoppBv2HNZg9hLOovKTP3lD4GsgDf5vDx6aTtSU7lw== X-Received: by 2002:a05:6e02:174b:b0:42f:8c7a:8bd6 with SMTP id e9e14a558f8ab-42f8c7a8e79mr63542915ab.8.1760032738804; Thu, 09 Oct 2025 10:58:58 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 11/30] dyndbg: replace classmap list with a vector Date: Thu, 9 Oct 2025 11:58:15 -0600 Message-ID: <20251009175834.1024308-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (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 1CCC42EA173 for ; Thu, 9 Oct 2025 17:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032743; cv=none; b=ruV6BPUgNjXq9toeYB6Z8YUYxdDL0qN6FoGvWC1LHgX5k3sFu57AiGngZgXjo2TKcpY1WEaBwv2ds6bQPLV+RaxP+ZUX57I3qxuyamFGugeMgP+VoI2itDmFrfsYbv1E+nid1AXozeII59UGlUS8czAWDDY0vWJJbzNICC0iMb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032743; c=relaxed/simple; bh=mz4pmSNtikpHGQKcU360KSG8B6f7Exi+ES9uDoE62vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QkCOaHLXNYaolATI5KGZxSjEIISOPj5itRlk5VSQoWL02moj8wS3KnapM3vO9eL7UxOiJoHSp/9GHzzpMZWcQtFBDDy0sH8YxXd2yDNeVDstTYrI1CRIl6lvroJgIsA15C9a4FU0O6uT7FZRzj9u+KewNfy6vG/7zdj69sGspvQ= 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=fv1Oz1Ir; arc=none smtp.client-ip=209.85.166.177 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="fv1Oz1Ir" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-425911e5661so4815535ab.1 for ; Thu, 09 Oct 2025 10:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032740; x=1760637540; 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=fv1Oz1IrtKJz7vtV98m7X1TC6QL9pKC5xaaleiQVsTYjW3Mh2LF4oetvb5Ui64mioC pD+PjYkMjklimC+LkTropkQTWbRDoh63tKFLJ+hJ8MP2kd6uWnGY6AYuwtxfFrs9+Q/C 36ynLdyvqPtDdn+7CWb3Ji9GHw0BgGaTxK6Pgxnv7f1lBPnmWyYXF0oq+JTbc7QeSesN cA7TlKpHVdgspMo5nZ3OBp9+aZZd56OByEsJ9j2qAUw3N43AXSF3G5vDTKIWpuiFTXly kernV4UF8ElbA5s10zrDDZEm91JQzFiq6/5w6UuaKKPcNHcdwo0sNsg2xPjAn1QQ3JJ9 bvtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032740; x=1760637540; 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=O1LO5dL2ACfGzAJU4Iwm0dMQPw8NRGULTltt5yUFMyAdzYNKdyVtU4tf8F6DrnHebv ogwPxirNz7GhVjxVQEQjZSmYsHcO4DKgkRfw/7QoHLXnXz6QqOGWESjNhZHK5Z9D9qQn eAkilxtcKxdO7sAcAdyXmXBe5cGPJVbH/5Gvf2kZ+RhdQXNFUkYI97GG6dX4oCuNjJTl /VceePrk/OEk+1VO3+b1+G11iqaBaHsmaRYVKvinysG4TAIm4xnQORh5XekFiSA8ab1o IM6dlHzdHtdYufANlP9cnXkZa0GIsqGDZFl3TThk13daaEtWAixC4520/7I92mXGPtQw 9FNw== X-Forwarded-Encrypted: i=1; AJvYcCVL8NITn7o4RYJLLCM09xxT0K+lmuYn3cONC5D68X9HHMsRXo31UyidIcCsvr+wgoHkYVTgOTagpT5moOc=@vger.kernel.org X-Gm-Message-State: AOJu0YyHhhPsQm0t/ctTzpjiYGHxW+oFutjIRC2NOXo4QqdCtuW2hUVX 3afeOlnyXzMW2qMRM1Nk6U1KCgNsb0cYGtUZ3q6DqWFPbnyxFwPqDQ/9 X-Gm-Gg: ASbGncv7WnwY/xtNpPvcKD3RGl8wWUknOfQglbNXFKAy96nWnE3NMjOGo03ZCoLKWiX 6FgJG5pIyTJEfpIkn/iv3cSojm4mswTgLn0pRiFwzAJHImeoKCpqLZHjCGvZ6W7WZkJVXg+vbx3 YdpVnw0a5kPqXO4rILOTy/MOlL3dKBI458ymX7rtBnAQl8e9hWeoLDieIE3A+O3GV5TnUEfO/TX QDxgZ8wCSmUIheQfUS/VHDoAI3JaFtZ8DETt1P2rkT4agjYXZMbMdHG936N+FRJfDsBfQ+gEaZV bix9XgieS3vE4Gr8qE4tdr7+nD4/q/+qAJ5fN3RfiRxwT7USbjPflQBosZHclQrK59Vai1zDhYS 0Q6KRtxcTMfrZjdQ7RyDBZdXD5GTvUWPZ9WllXCTNaYrxdLVzujaWeS/qsill8xsuP8Ardoh+Jk 6KYy9FghtAVLZV7rGeiVPy0lx+44w= X-Google-Smtp-Source: AGHT+IHjqP+G+vhE18sYwPA5Xq+a2h4s4Xorq9ruFfYudOUTjoHfdl8X+oo47RIuEgvRTTKzlg/Fzg== X-Received: by 2002:a05:6e02:2305:b0:426:7dd6:decd with SMTP id e9e14a558f8ab-42f873f4705mr67420995ab.28.1760032739929; Thu, 09 Oct 2025 10:58:59 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:58: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 12/30] dyndbg: macrofy a 2-index for-loop pattern Date: Thu, 9 Oct 2025 11:58:16 -0600 Message-ID: <20251009175834.1024308-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 E08D72EB5B8 for ; Thu, 9 Oct 2025 17:59: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=1760032744; cv=none; b=FdWK7jHc5Lup3EaGyKY260qi9dgoJp9qPi/UzL/QxTyt8HLIcu7SM5UNXOY7cxHPEmJZ4AFXpk0IgJQc1gxmU24i1/j6helkcNZHzv7Lc/uWODDfSbNwVkQ56cWLuF39qyuC98tNlPEuDtdkTZdcIUME8n46cTZYvcyY4YFyU6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032744; c=relaxed/simple; bh=iMHKQHA3tjs9UQ7SjiSntNwXKBEfD825xQLKxsfFxt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cgYtf9gOVdy6u/df2rBNjGsLteUHm472eobUSA4g8Js5RemFthPqgQNRZxw/Za2YpfHMnhtpSaTl9HBwGKFFSdoWgFFhL3Pz/GEyvvcXESW6JVR28BYuUSuDFVG9uGX9M26Kh3QGfblAWgqe6DOmBm6tqEeZyYlXWffPW+OQlHU= 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=nN7hU8CU; 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="nN7hU8CU" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-9399ddb3ffeso117165539f.3 for ; Thu, 09 Oct 2025 10:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032741; x=1760637541; 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=nN7hU8CUxwp4vWjo0qBrJWso8u5+iN5v+9cemMKwcnJvnWz0KvMahYQ/hlgvEvxgHS FgodBTcINE5VTPlzZ6rEAJSnWvBJSsrJohG3MiP12MgTqHY3md3bzF8/fLTTx1KKYA0X t3PAdry//uK5YiKLvk1TSVvAXLc6aQ5PFS6K3P52RTCH0Y9cPszQKOVtNtR22cn3LWl4 Nm989wtXd6Z0di0z9MhyQRCo/6qy3M1eQWwEPY0sELpVLOBfZkuLQKk2Ve5LnGGXMi2Z vaDN6bCfNi6CkBrC/miJpj7Cej21INoUKMbKyl+Qw8pc62aTue9NlyTUg42kZUTwzJk3 h7xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032741; x=1760637541; 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=ShPqtOHBZCil/bBxG8BmqLtEJ2WookM9v6+vI0vZ0uIj7KUvovneQnlEq7XLRif06e Xif64U2jJQn8HXMEslw1RM2VQCqPPtgh2CjW9kuISypqK4r7JlJBVQwZUH5UqVzwmeRk AUudh2fI5N920DpndHyntrKmYBCTZlTBYVKA+ECTzzYkF9OzMERc/EFnN+zcWWLMSI0J yymotZF0fYFC/rUvvEJCw4rdm2OwNFarxH/G3S+SgGaRyBZaPdAXc36kWqsmhBn1LXVB Pp+MoIIwM+5Y2NT97q72AzRuQTC55uLlhgEGujPggAk48p1aS8ujt6Zzu7bgjLZpl31a cLkA== X-Forwarded-Encrypted: i=1; AJvYcCUyjLS4nm+Q7d6YMnl6KAzONg5RXt5wiOblKc8gSPrF1R49PHginV8jqz4DL1mbBZA5/lJWvbujrdYN+ZI=@vger.kernel.org X-Gm-Message-State: AOJu0YwUZSBS0Dfd/eVrkJocIIUdGLi0JFe0HPUoLzFoOucDK0My4iTU d4feF6hSgbQm8A7qkIqFnFMKJifB1JIiGR9tDP/Hh5JF3gUd8PjopU+j X-Gm-Gg: ASbGnctQgueAVDTSCimXwBIvgBi9i4PQwvSxdt6DiSVheo6+xr+lkbCz1i6BVEAyxZ3 ML5r+VEu1vCsCA3a4M+upHgoT8FT1SR4VHSFdd45YNMKXtXIMXiIcv84QvAA2kXLDCDwLWNYsMc Ot3r81MkMI4oYJJ4SPTPbnQ9d2o/urMTpuQw1RGbFu6pOCJwwgrKaTCENJrMn7qxuXXlH7rSpZW gWVJR0hg9lxbbi39UU7gpqEROZCvK4UEIkQgvWdsuo0IJSpmVeYHOHtcT1me7QjSED4nS1HQG0i tYo46OxZwwBEwawHMOASF+de/pEORHa0vBntCKAAgSQvg0TAtAB0qhTwex+Vaw8f+yz/zm4Zc9T ZdciBkriQCM0YB8urHvE8TVRuOZ9sXk6yn4vmzDrdPqjh8RBHou8dCnxiWAK7bDIIoG3wcCtUSU BRM6iYiC4UrVH9fIGb7agdpKDV271TpH7tY2E7hA== X-Google-Smtp-Source: AGHT+IEs4KDkEu/Tkx7PA7Q0xJUK7cMMLKchJ3R9IgY6/hfuRIJ7D8MjEdR+TiVWsfUwI1oIJ916bw== X-Received: by 2002:a05:6e02:1fc4:b0:427:d82b:1f36 with SMTP id e9e14a558f8ab-42f874010aemr82928145ab.32.1760032740923; Thu, 09 Oct 2025 10:59:00 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59:00 -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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 13/30] dyndbg: DECLARE_DYNDBG_CLASSMAP needs stub defn Date: Thu, 9 Oct 2025 11:58:17 -0600 Message-ID: <20251009175834.1024308-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 566E12EBB89 for ; Thu, 9 Oct 2025 17:59:03 +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=1760032745; cv=none; b=iMyqV4kLxpNebGxPWExntiEF14qRWmeeagNdSu9nwLcD+uA1jqk+V3XCP7HzWbrN12X085ojBmdYrcgZxiIHwtgtiEemS/TBv6xXbR5yFrA8AhMHzmmx8r5M6uoZ3gNRlUF2fsmYxifMs4wkpc6Mvz3xAh5dO0cBAoFy7UjRPpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032745; c=relaxed/simple; bh=Ug4vxDYtrMo8pcex9lXFS/+9Nq7v3FBg7yjDgFv7bLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z0c26fLhmHdCSXh1WxRLwq8sUVbU44bLLtGWjOSzmJdLFNgD7PcowNPxzrB5G0pZcQLnxvgsvFOe9zHvTYCr610yehXw2A2/U1z5lwarpY+UM4BVT+tvZVEoF010h59ne8HKDdgio16ew6UBFZG1LeO6xcf4RUyrN6SAoo0kiIQ= 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=eg63OUI8; 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="eg63OUI8" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-92b92e4b078so51770639f.0 for ; Thu, 09 Oct 2025 10:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032742; x=1760637542; 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=knNOQT2q1uEY995iQRR0Buu2V4+Ucj+HSI25l7kfsO0=; b=eg63OUI8QpyhGPTglne4l/BTP6bnVITd8J/Aa9UxOY+qd+e9LST8OqfZIKqQaHF6i8 Y/eaWQqOwpBR5EPePBnA2WciaChPFtu0PmTgaiyShZ9qzc3V1esqv9AiXPLfu75MbsCZ QfRytSw7Nd5P2e6UDZwngp0kMFMbtFSzcEPj2nIH4E+ttq371GPe/6YeF853qIX3kyFv 4A/wWKBvqpmwpOXqNbikXEp20ed7brT1DZytoTREKI6W+K9bkHDo70qDo8v5TWppzI9h KJ49/41AUTyHouxQjCYTOrP6z/75d82mRkkW3jA3B8aXUcow/JsN9Vpsl/Hkwq86fDFp WRuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032742; x=1760637542; 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=knNOQT2q1uEY995iQRR0Buu2V4+Ucj+HSI25l7kfsO0=; b=to88+34u75ffd0iLr7EHwib3m57VtqH+p8W1HVNelBz0+FC4mZsb+SIg58LLqUmNNc peOlmZC9kVVCAjJltWwuy9lwaSaFeBEJdAFZF58BWCPrEW1cUla+xTWdZHNwOkn7ZUon zFYrhcYAUIMlJ6oQ8RYG0fIUI6zdyTRR2UGsrCHM2I+djiBx5CEOUmWTjKZa1GHYbTF1 wc7IVESekxMudA8FxuSlnWMx6xso2B09Vp3b26y0hvTTJ7SuMI47uxJ4ZeOiDvAncZyC brrKACx+mRvUlyY/kAlryRlLGnGrVOntYi5nEuAyqmUQ5h6WHDdp6qcO7pjiMdlCtOup KsaA== X-Forwarded-Encrypted: i=1; AJvYcCVWzAeg8VtKtCQoHB2lpfkI+EJ7q+/m6LqqspsaWp605eJpou8lUgDFdgV9+Jy4osmwGuDD711Z9AvyXAg=@vger.kernel.org X-Gm-Message-State: AOJu0YwMfApRkySnsSUC2f4pfTX0G/JUyVDyqyAaoCPNEDdhvwajdFHA IgNT0jpuKZfBEldJLs1OefyC2xAYXNEGubM2s1EjeH4iKeoFM6CVfGLV X-Gm-Gg: ASbGncvzK688QvJ3tGt6YEhj3QvqA+lqY8s22/knQ60VaxE9QbZXKUgHj+pwCCB3LGA r+2xCDab4zj9Ls498izf5As4QAFt1q3CXStjJcH+9xXLrd67imUzDZZbF9Cs9v+7h6eICT4i76z at3TEMhd6FR3KvpzFZNC8tAyKSlRQsFgoWuzOm0vCw7jNFQLOJJztizL3OtSfyH+wF9EFIjFZSq 6FTka8dpIPMdFF+kaQ4H3Zf0ORbuZTW+eq1Yg9MaWp9hzH6rcUBO/44759TCQZHlEz+9QWEoryZ 4OTU/ISKfBWNyN80cSRJoAlMiGieYeIPsBsyMgOuy/VWUhZIFUim3SIruRQGwmNHgzelOwa8r0W IQw6rfIWZCS1N2YkeChQTmHRy3EqvwkRGoMc74jBgXIVvMvjFK3iVcAi6zmgoeYpokgBYvbmdJL 5BEr/eTA/cffVeDQpnJP2C497WjSJgmuHmRmPHLg== X-Google-Smtp-Source: AGHT+IErcnk0lzVgGg8l43CMBNWBHJ+NVRbAuiQXclmrV/z1EyXs+C8hu7ESE0Z5Q2N1ktrjDPL0JQ== X-Received: by 2002:a05:6602:27c9:b0:8e8:a857:1f89 with SMTP id ca18e2360f4ac-93bd1780c1cmr912999639f.3.1760032742024; Thu, 09 Oct 2025 10:59:02 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 14/30] dyndbg,module: make proper substructs in _ddebug_info Date: Thu, 9 Oct 2025 11:58:18 -0600 Message-ID: <20251009175834.1024308-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 --- 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 ae2d2359b79e..866c79d8b2a5 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 c66b26184936..1ccc5d4399c3 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2710,12 +2710,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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 45E402ED17C for ; Thu, 9 Oct 2025 17:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032748; cv=none; b=YLu/+O2F762O1YIvGXvY41RGxI6wz0qLAxq0Ipt7y07LUA3WWgO4UpCZJfKwrv9RaqS4pPqgXVr/B1vh3saHTEypcMGsaizEZlVd/E4qvBvJW3sbOHqXKIDQRkcBVtyRV8J7mvOevV/uXx7eHui0t9Q4HU4MN3quOm4X79sbpGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032748; c=relaxed/simple; bh=zvTNU21/57sLu7CPtDOAy5ER8/SrrXIEsXuQaR053aA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qj+4NcQLHcjsxzHbtLzd6Fe0X8dpLMw2YfYrE+NWAzWnR9Njtnnr31QDwEc5dPtgfZtSxViZu8K4FnnXIqRnNn3O4+LGefXmCT9sPSjQP/+oU2cgzqtmOpo5A2ySi/hnPRpe50B00AJ7VWWl/4F0U5FwqwgL/6MS5R/8CWe6xu0= 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=ijMVa3ef; arc=none smtp.client-ip=209.85.166.171 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="ijMVa3ef" Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-425911e5661so4815695ab.1 for ; Thu, 09 Oct 2025 10:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032743; x=1760637543; 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=ijMVa3ef0bsPyRPs2cr1A7bZGmvo2jbn5oZnGK2roqm0GrGmBbDGsZmdRaaOkxlhyD +OsF9ZmFODZbZdnLb4xYTaauwjKfXR/WD6wqFEp2CNmfx3/9MLIV2MmUjd2BF1ucwCBp QZ6EVgEyqwC9NmLH0ygjoCNWmDmD+GrOYTIU1FCu9KQkiDKQ8tW1rLYPWOgTgaE9RVN1 uNN9vVxetaJemWINNJkHSYkQMLw1R+svs097qnsIyIYIu6VYCiwaj2gjMycJHj5YWNdU udkQI2jF0g/dAxw+J0I1C2nbK7P5vsnrx5Nt8znygJZBjZE4Xza+SSZ88bBcCW3aJcPZ uGXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032743; x=1760637543; 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=daFv+scEaqGB9eYTqBJdyEFdl9acygxofHLyb/IGM359rfWXTc4MfLn+FL4IX7tFrN zKGh7ErDewZll1pqA5CuTF56NQR8SIaEry4K5eweNe7vmc1+6C63TX1cG/RMuHpSXm4K CLOq/A44WHV7/VOqPyFVru9FhLzjZsIktcu60kkdw5fJbAuHVQKgLa59cn8BEIveiB6v I5q9uFuib+/8j3ozf7OVhH7auxr+kcOnG+UYTag1i9s24YqChhkvB0Hen1FUi7YR10gs 5sM8p2LtoA+oHktn02oXF83fcgci0xbJyUqzBDZ+ZYR6SHG2tJxhKkI6EyeAntxGQoZL e84w== X-Forwarded-Encrypted: i=1; AJvYcCUqs3QvrIy/PIJ7qnOMqEr/yBi/p38CCIsEynE0DC0QiZfWQerb157Eg2SaqDj6b9XHWolNgszK+favyJI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2i2SHLQQvG60gqg2G0gYNK2zH2kN3Pr871p+SEWjkjk6khrN/ MeRBfLLGF++yOum2pKh3WmbPNEHeb3rKuCbGfgJasXPqRUhJkqDIVPev X-Gm-Gg: ASbGncuKMM8+MEZYljTdeRbZcQNL1Ef9e/JhY0Th8+L8qybuEVG++net6iGvPyJ5LaL jJmJvLyWMQePW+dqkkjoaQFaoBPhd5H8hQAJ/X7TFoY2tzuQHMGLUl16WjGJEo3hgy0Oj3qHdbA s0iO9ChMNBgQbj/Bd7RkLz8KhTx6uCWIqpFQu6/7gx6G85f96QZFhKPbY8dElMPIj5pFHYJ+TtA UZ0PWC+Tm0vjTaeOSZLL8iPnNshn2gJazde3GuLVtS/FmPUjj38l8zjn7NNYpK/diW/PJrGtxL2 vussBZei1tx/xC5pvH1YemTKGVqtfm7Z2kfas19Qp0qKT1/Rb6LYjKHj2Cx1nyY3UNlLSoTvsv7 UB/zaecXs8GUuQda6/ygkEr+FPHRwHSz6fSmg+zEvaYn/2HZnnwJh28tjko3R1ZcsbAXrgOQO7m kUZCeeODbxr/Cmp5RnXyE54o+KrLCieTNR3HwZOg== X-Google-Smtp-Source: AGHT+IEXrf0bXn6pOGAetXvcTVTItgA/41FlLlYPAXC+Ci3frkzz6F6WaNaH9mI22d7vbWJNi23HhQ== X-Received: by 2002:a05:6e02:216d:b0:42f:8eeb:499d with SMTP id e9e14a558f8ab-42f8eeb4a47mr41838465ab.8.1760032743223; Thu, 09 Oct 2025 10:59:03 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 15/30] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Thu, 9 Oct 2025 11:58:19 -0600 Message-ID: <20251009175834.1024308-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 766422ED855 for ; Thu, 9 Oct 2025 17:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032748; cv=none; b=rx4ePgTRV7kw0gnJUz5ODCMtTXmdPGi86sUinf94JoHqZWvOEuj3Wo0fW5KJkyHGqs4iI1p2UVDCs0vssDnuAVW9c+83GLMS504pwnO5bcGSb/TPwdZARrKI5iQo/nnB/jj2VG+DsP/ncWuHP0KHGGG3p4wYPJ6lj7hipzem3E0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032748; c=relaxed/simple; bh=6WeSLIcdWxH0KnY4snBRfJjiQ+Ag9hQk04tWp5V1Fhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZlyTGUBcfhmRc8N9/strdCAwwXBSroZ74HqGZ322O5KBNXv/2tlgT0kU7cG9N/+At1X9PaEaNS0+VspmbyIMVFCxUIAotA7XKl6qStpNEAA5TVRLtjZ27W7omMhPCt7EuDm/L58EZdW2DwfijeVNxnNuxASO1MaJzdZ9ULy+cVM= 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=cU78dLVB; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cU78dLVB" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-4259247208aso9027095ab.3 for ; Thu, 09 Oct 2025 10:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032744; x=1760637544; 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=cU78dLVBtTpR4k6m4lhbMNHppKFamM2My5Mf2g+ivgRwWTMtZ9lS6gX3SvmdzkIY/p F3xLvs39W/hqJ5J0ciBmL2bj/bl3xUELnwKdKZoYAGrXxLPpu4l2m7TT5HTMFDtt8SSW CpoT0Toa/lWqljq2k8nkp1Qxz2d0v1Qd/bh4JmpgHhJKpdk3/lD9TEBebwzfnNmAe6fL JSDDb2jh+uVw/e/keXzULfkiH2dbKY1AFb2P5VfB18VUxR3p8AV2KoRfJN7UHLbM7QhF sQSBFfL28HFqzXQM4wEEOuEYnCotaNJcnl7CWiBEP8dzzIoCKh3gcsYZMh8ZqpQDyGLX E5LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032744; x=1760637544; 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=M47rkpUC6JjCjktYbb45dluxVFtnZPW4IFvgNa/NSrb7ifMLbgd506uZucupflhfIJ t7xbJ4NcBuYQJMbnzCNbXBV7rhWIQISHoxovBjQvJoGlZHxR1kmdICQYhUk/ecdVWWT1 1OFXvperoPjM6olXUGV/NVyPfOerYGWPEZiEUatA4Lc7MzvpI0oSj69l3SIrvMnXRUbm 6A2Wr7j5ZPxSBJiN2gDhNKbvpoXN+NdSHbuQ/5v5b9DQ9cL+bd2Tp58xplKvOOcUgijE kGXgirAQinRjy2lkiCuWUkhJVLtqQzzHXIDZfmdpuEmZLpZPM5+AoL89f8X+kHIMPiW5 R7bw== X-Forwarded-Encrypted: i=1; AJvYcCVOuTyPP6OvSUI7NtjGeX4lmy8ReSeNoqsTK0bc8OZV7YLfWvjwahHv4H/w7MbROkCyW17ajqlnFPBkZgI=@vger.kernel.org X-Gm-Message-State: AOJu0Yyz0o3Pqg6XxtnYTBpJQCwXuJSYZPV9uPjo2w23uApPJQVVEHe7 C/vuc2arepoypPXTo8fi6G+FpU9Gtq2fQfbLaO3XHl23U0z3Ot01OD7fKH0/Og== X-Gm-Gg: ASbGncsBLJDPJHKGKMxDo7S3KbubsKj90XiSAYkG4tUIX16Om8GlOPxsxGmoThoOLm8 zFvvP11h/hbtbWI2ekz1jYU7fbQGzRGbHjdFBduZMUkeBUyC5jEEq+qln1pCH0Ew9Ed4TSleHhe rpl8tLMZ/s4rRhFEGSBUoyNHnRl/A36GaM+gkZrHKJfvBnXFATkRuHxZhUFpW7UH7wnQeC9xRZP xArb8n5gLcHHkKwR2HTH1p4Pl0cRlyMv4xrYQwP8zn76YRC16y4CxsMlPpC8huRwZ3JVpCv3+hL qrhgvvlGb9GAkiGSN3Y9Nt/eL1j7O9H7KboRLTBpu5GZRd73lX4UKmbDPmrskPPdVeVA0T31B35 LICd4NyZDG33TRxbb56b+5fdaQp6G3ISLeYfpVsq+8wW+HqwXNjCA6ekAr8jS4via2t5XDV/iXJ np8OvmfQEatEgwC7f5cPnqucy8WdRaqKzofFo/zHpemTYaVxDB X-Google-Smtp-Source: AGHT+IHC/pYrpkk1pQ98omx2cEKQCK33DHJq6/oaRwjrGFF6/pxWMHlOMffq90TfVlz60FjVdMse8A== X-Received: by 2002:a05:6e02:2783:b0:424:866:ec6d with SMTP id e9e14a558f8ab-42f8736d251mr82921515ab.12.1760032744234; Thu, 09 Oct 2025 10:59:04 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 16/30] dyndbg: move mod_name from ddebug_table down to _ddebug_info Date: Thu, 9 Oct 2025 11:58:20 -0600 Message-ID: <20251009175834.1024308-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 B13A12EDD52 for ; Thu, 9 Oct 2025 17:59:06 +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=1760032748; cv=none; b=QrS2YZ4wHIZQXQ4faQrJ7YpdKZUqxsFW4dIpsXjyLB5FIK0ZejBjvRTIHK+brX772aEUnZp+5UUMJW/fWfsO2mrvPRvJTu3JxTAhuPJpxAY/R28Qzd7pvuC8DqXeuOA+c0Q2tyBzTHJaxQyZEslmOr756HZc6ChfUkfz2AbdjwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032748; c=relaxed/simple; bh=jH+1l4qvp+4+lZDHMaIkMAYILxYBcnRulcyT51Irv+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=slcYH10Y5nPKYm7sBQT7F12K73A8dPNGdBrphscy13qQnM6L43fhkmeXnk9GDgqCBojBCR7FJfYsVtePyVMLEFFXkJ+t/m5U5gJoCEXroTzUJrVSn2aNWgMhqj5/IEw2c3kaGkN5TbnO5mCk+UVBBuC/0Saqrj5A4wCWkn3TSpI= 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=nkxmJI4e; 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="nkxmJI4e" Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-88703c873d5so41949139f.3 for ; Thu, 09 Oct 2025 10:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032746; x=1760637546; 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=nkxmJI4e4ljMbTnSxtQxmMsJCL6cDv3PlL0BGcZhLnqJ2gW4N4FZOFJwrC056XFuNI CkuLZm0WhzL7q3gOe6Pvk2GR9ki/wIYCA2/Md/dWaIUQzkM4FmTQmD9+U9FRhjE8laQV 64x2jN/2cPCkag0UJ2deI/9GZdKe7tCZ2Z6B2n0SYtHqPeh3HuNKoR4XxNUEgu+54Y4v 001gwiH1qB2M6cqAe/r91xLN0f5/Ll5INbu29OPzl8jLN+oqGbvz5orGpxN30IaN+Y2d qUbrKLSrP61Txydmlpm5A8XRPlvSrQzWiXMqWKA6hu+xf6ccqKA3/1qjzJavyc5j+byN FCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032746; x=1760637546; 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=eYi0PU/5KkjtmUzTD4TarKSz+5hvgSVT97eoJBCwRQNpqtL0YomzF/wxHSL7r9C9qk SsTDep+UPDBcF4pzjRUfQXDqE/2bM4fEGU5mSZvC/tTBF2PYKLHRVX9NHptIBbNmnNnz 1aan96SXvq0UGRB2RiLtb9EmVuPKjqntbRU3Fpl7Gme20kTBzopsCzzi5O8NyTIKZMoc vlSNl0hWV1ELwlXVUMN7SIz1rhy2kqvcnZpTbEcepjve2hf87FZunZhCLsIG22J8BTxF MuHEjxcXlPObKR5NKNGRRvV9oQZ5KNoea3eJ6WeijCnGJuBB1dADOofYmVsXmdty/NkL 4yKA== X-Forwarded-Encrypted: i=1; AJvYcCWkiTBUO6qgJ48CitW1Yps4L2XtdWWaJjXAUrM4CkrwieqD3d1iEyywde503/xv94N8LUfxj88grKSj7Mk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5oVQWkI+tdEr1HM8mz8jWUxRBIoQpegK5GIQQANkHWpuo3QgP n8+mBSt4dEDttfm08vNOLOges1fSciUlQ7Bq2HdETU+KBaqDmao7puPZ X-Gm-Gg: ASbGncuOvpb7HXiGTq/wRsJGtSRWOkj4LMKQsYd9nKsL919o2mrUNe2RwFP4roSyplW mcjhtOuX20Z+djYUleYJwv5L/OQDWobDS+phMD0rfrmwjybSDLr3IYsuarOqZieUyR9xLB+JFPG nCyP03abFpvGYamYeMd9k+SltUE7nX2952WNYLCSMVBeX3lFaJEmL21riyIDT8YVFaNQSmZCyoI fKf9Mj9LusMyFjpJoRiYcVMeUw2BX+HkppvHq3o25TVQQxBT0SUvVAkTPpX4kLkdZbBIh0XZXsb 05rxVFe4aETWnCfy1Ih34XaNnUy9D1LCEw46He8TnVNAVLaolXS+D0sUeKR0rBvrk9zJaN2GKlp sDMm1MRzVrUt70H3UAAqi/uDz1k0wMAbewSJYH0yfg20ffMGdpm7jeu0MqOLMdAVuQeB5CpfVeO WxGp/n25e9w+rVLadlNGPny5liYY8= X-Google-Smtp-Source: AGHT+IHrzE6kN0KDMKNTx83OEqpURsmIMoYpBAmvGD6LTUjCMg3O4kPzfGHaru7jIi2n8COWXpRWOw== X-Received: by 2002:a05:6e02:19ca:b0:42d:82dd:2b02 with SMTP id e9e14a558f8ab-42f874138d9mr71789165ab.31.1760032745495; Thu, 09 Oct 2025 10:59:05 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 17/30] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Date: Thu, 9 Oct 2025 11:58:21 -0600 Message-ID: <20251009175834.1024308-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 0A2472EDD7A for ; Thu, 9 Oct 2025 17:59:07 +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=1760032750; cv=none; b=VsgBwxpeaV+ktNslnI1r0YsJC18D3vUvlUQ087clFFKXt+ziFa6LrKoWfVeBSxCiFl3GCDFRLz5eby0kXOHAyrNFMgtvhbvCV2uUJEKat09jGsQulvHiqBaMeLReZdxI5XG6hGIFleuz2LzGyFTL3kMJJzbyflNIu63+dJHDk/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032750; c=relaxed/simple; bh=kL/q/66eNTgH9OYzldUVyonUElybbg5iyeqJtlF7OvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dlmwhcivHnk4KoaeHqk/ZZAL1aGxG3AJxoI+31p8QytEZjrIlwvQnA3+szHxHeCUAV+ZuvRvu1L6fYk+gZup6kyilmzm+waRqZ0pix4Chg5TqZzWgBLfGAhb3L1W7SPDwUU/bVCfZfLxxTSpJHi/ThiXaXJceH6HoEZhxHHSVMQ= 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=HOwZz3ix; 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="HOwZz3ix" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-8cf4f90b6f0so113191639f.0 for ; Thu, 09 Oct 2025 10:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032747; x=1760637547; 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=8bJf8BKViTw4/xmo503k0SakyhjsE6/pt49DGGacuYc=; b=HOwZz3ixNBxaktzf7/OWRbo81NEuLwNeO9KdcWeUY7Fdh2y5JcwT9kxkqp0BVm4XR3 C/35obj/AZ5hUsKvt7LnjnEZooJeMpFz7SFLBsT0EWmoLCSagDnebyscEND6wTUACsg8 GbwNd5wYY7DH1rLAZ2f9sklZ+DhfHz7tyJ6s8UCzz0Hn4vP2zEt3+w2tkKJf7yTKesDa SiMTu8spuDtNloXVy5+Lu29gjop6c6ye9XKPxLc1lpnHCmJeVq78AKfEvMxp8liKp6h4 XTmJ0JoUobJHVtcp0i1Rb3zPqnF+PPkUs94w+D7+Qi2qgV0UTI71g0vKQaK/biSyB0fr WQkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032747; x=1760637547; 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=8bJf8BKViTw4/xmo503k0SakyhjsE6/pt49DGGacuYc=; b=S7A2tr660NxGhkbJ6VbjWLi6dIABvK4dObTs436F5N+bTkD3RESLvWO9hokb/m/Dvl +aSiuY5tC9UACtH+LGOfOruMFNvPfHGg4kFcsNbqwZujT9EAMbKv5o62DK/2wLWAqExB 6BzAYh42t1F1isWgGdQgDU5KGRdcRLlt5KySY4L8QC0sdTBhV2pPs3VU9aFvFgz02/cr BsWeLXA/LdD4E0qojP9tHimkarYnkyiEk4p9fuC7ZjrM8NuE0EFyN/Al/TfZf0CzpCr+ L3y6eqUCgayTctMfYBPC0MC97wpX+tgHLOwZokiPkBGFUe6A7jszKLQu/qrVGuNq0nTa LrPg== X-Forwarded-Encrypted: i=1; AJvYcCVr+xaXsBxqCP02NJW95GS90yQHoHeI94ir9YSULIAWhVnbKA56Vod9vEjbyYAyxxXyW3x+88DC5lUnAZc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+T/SF9rR004m7g5+Kx7QNYJqGbxqNizK6g+BnahjaJoMf+EYI WJA0Pu3TLCwIDqoVqANs1jhKgkQz7Q4aJhgNUF7yPA1Ma+2+qKE+QJX9 X-Gm-Gg: ASbGncv2r7wu4Iq8mLHAMgLTX9E960aB6GTLCDop5pBRACm70WYsoz+VqSymbw4uxaF u6Jwqwq2HjkwSbIt96GqaRMPhzXchTRBgZ5CoPAAFB8mcYURHPkNwzpp7gc9Hlp6dP4MKB+9so3 Pjkv/b0Ds0XQE6L+Ziq7ABFp3/C36zSU/+iPqbduOXHx2g7YDggSa7+PjtJFMJjPzybOlqdZkjg A+z9H9Oqz/hMphKn2ILrQoJt/gt3VxsV7CNomMD+P7HONbGItVSTu+GaDA5wZZwb85HNaGhmprH ShbCzcfkqa1hLhSlg1z0ys+5tb/zM6dlN+KtDvXbfeCPV+4Kj46eT2jHdnlwpobJJDWZPnPi7kd ilLc1ZshTl1PxT623Z1DTu+Uj9DD4ItHG5AHlqMkIdOeoXowsSXjlAp81f45PiBkATXXPVfVKeV mh1BytqLZoCufXj+albKCiKfuzBWzH6AwI8DdQhQ== X-Google-Smtp-Source: AGHT+IEeu7glopTSSuDvCZNhLjHfm129v1CwDFtKO8S4S4IyootPDCsCBoycaw1tuebiZrGvcW8TNg== X-Received: by 2002:a05:6e02:1543:b0:42f:9410:ea96 with SMTP id e9e14a558f8ab-42f9410ec91mr30802035ab.2.1760032746684; Thu, 09 Oct 2025 10:59:06 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59:06 -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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 18/30] selftests-dyndbg: add a dynamic_debug run_tests target Date: Thu, 9 Oct 2025 11:58:22 -0600 Message-ID: <20251009175834.1024308-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 97d958c945e4..0db59cca0d4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8617,6 +8617,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 030da61dbff3..3f1a8044e1c0 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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 C4B9B2EE607 for ; Thu, 9 Oct 2025 17:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032750; cv=none; b=ttrWkk/ImAvsZWToSOY5RHbWuM9E3eLVNy6HvyhW7HWcsl9avqnNyE5+nCkCpWGUmHGq2Pj+nIZQOOgHGwYMzbWUpHACAaq7tHszQYwJaUMzrEChTzNnt54uj5u9MQ+yKlIjrNjqzS+mYvH4VIN/COOabjT/INB6Aquq3ccvQQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032750; c=relaxed/simple; bh=imH4oGjtC/DVv6V74aFKG/eXjYLLf9oli7Nh0hAHYa0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Son8FMBEQIEcU1wulhd6J/y7ktw2wsXJ1g/DHL6oPdNR/mJIpD5kXZq1kyu5iTA47jw7EHnj0sezg6dFBPTzfJDn2pBQrmU19wfdpu0l1Db3zZ069NZCg7gXyh+LzA3n2LQF4Iwq/SlnE98FY/pA4iT7NQPvHBRlh1cWOYXTMbw= 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=RW4/XVLI; arc=none smtp.client-ip=209.85.166.182 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="RW4/XVLI" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-42e758963e4so11462565ab.2 for ; Thu, 09 Oct 2025 10:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032748; x=1760637548; 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=RW4/XVLIQi49Sa3wUJD9jjj/pEd1nUIvsrvbeqC0jSM27+2VPRanlt7wf48OTtDTDo 4dr+Ahqr97K/1soTWjA6azZ2/3cnL6/b5FAxLAnxG1tZrrEGXlan3I30R9eZHOvEDjaE yBKum1pqgL3AhwCjMdD4Yfynt3+ReA79/0PGaSipcepkuFm8zHAXU775vK+iuXwso7AX OkpV82+eZ0RRQ7QnlN86jP5NDuvU8TYfN40cVTm1jOU7wjkm+8WGa7bvDwtnlSUtwggs pD+5r4kcnBEDlTM0kxF08qCHu03lCypNgyggiE21lVtefvZMaK0f+mJ47lwozwozfUv+ dGwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032748; x=1760637548; 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=la1WCKHJaCJqlVA7Z40SmDYZ5UNu4AypC6d0pAkufzuN+ekRbXx0lxoNigDJqMSuIq txlTkWQ7bw28NDqbX06V6u83K8A3dzE+lgETEt7posj4f/VMJrr8z20HBjIVlN8+4XzH 3SA6B0eW0iwhB2J0U0xNCTr/1eMvWyNq+Me6vKOsc/G5vK6a8HofWbA0Z4T3r8Ue3gVP YS/fdsL/1csa5tqh+ZC+Mzm7iPtHyOJVyM0KxhcR0kBDSnc6wAreOnTOn7U5oIBz1YVs rzdgHXYP1nZlC04qvMz1QjzvTEGN93CVu2LQnSsYToxCjDqp+XpyaSAKORBN0QCd6FgC zp+Q== X-Forwarded-Encrypted: i=1; AJvYcCXSz6+1wKmkBGwhzJXcCp9sKtcRtdo/P/YlTrkG+yFKv4OthuE3nG0MW7PUBEg9EPu70V3ehOMjF8k/jpE=@vger.kernel.org X-Gm-Message-State: AOJu0YzEtC8vAa/OIPIoyGmRMwAXvRmwurSfWukmal+n3mlUroumAy5e AAA15wsy9hTI22LBsRiClmPrmYY54MBWQRyNMJGkTq206r5WbkQRSsmk X-Gm-Gg: ASbGncv8ST7aWpuHIWz1dW++SLHEYJ8SI4093JFh8ONzq2txLhMqwolGtCSWzexvaNz HoYWAUAScnDOpDBbEhMq303Go4qt03kgUg4m5/MyI8X31vQUsUMrffJDPc0cYxot2/ZA1QYKJH2 C7rb4kcLere3BSATHejfc5JPdboNxaA6W/ydv50zn9UPwah722t8IXm5KXCzX10D2tHWAYJGgqW gm0dqP8EbEFMDsaU+QtMBGXYT1IPTpvyYKNWKtoICrLKsPfb4BQMmiZ/ETXcqKGh6z2c0dZcuu9 ijxLwOxNsvURvv6gKWCjPAOFtlhHXUUvvhlIEZYLMLW/ePQ36e9HYjb1xPLn7VyYEHIsuTBTgVZ y9BqMKQr2Zlm8UiryLH+DVbCh7QIrVykJ6FVb6az546lKFcD7gGd6od4M9Qq4U6sPzR/HhZ/GVr /lnBs7uFYbcO57hP7Mq/8cfCN3QOA= X-Google-Smtp-Source: AGHT+IGyz5PWJ72Qylu52JN98V5hPC/owd9s7jI1qO3g0mG+L/5zspcKIM0k6PzzDXXuTsCSBFWwxA== X-Received: by 2002:a05:6e02:1a88:b0:42d:86cc:1bd2 with SMTP id e9e14a558f8ab-42f87410bd5mr76537985ab.32.1760032747736; Thu, 09 Oct 2025 10:59:07 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 19/30] dyndbg: change __dynamic_func_call_cls* macros into expressions Date: Thu, 9 Oct 2025 11:58:23 -0600 Message-ID: <20251009175834.1024308-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 683B82EFDA5 for ; Thu, 9 Oct 2025 17:59:10 +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=1760032754; cv=none; b=CHpDcJAeqqlyx2VnPYrUg9wIC/E8LZJSyU3V+9kBXgA480F921Ntu6bjevpcVy7HcC5/Xt/jwa/u4v+5GYU9W9lym/UCGe4imoFOaPlWmRiPnnbZKqAtmRuiM3k2EowTFSe909gWL3BhSHCL+aTEoJXLL6CMxLMo0XThNKKJRBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032754; c=relaxed/simple; bh=YrjZk3CKaK8LUH1eEuW+bOFOJ0EW6lRjmQFpzX+Pfn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RGv15EJAA/P7GXDCotsriSUbpJw4q0g7/daNkYO3GNMQVkdte4v3b/FuCodm89bbN8GtgfpGj0vOadoclK6vWod95QPdLldx418W+ZAS4VujW+063vh9B2QWR2z4ne3udmAjYURPCfneqO4DF3nfnXxxneMD7lpS0hFBldmv+I0= 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=WzIa6tT5; 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="WzIa6tT5" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-93ba2eb817aso117374539f.2 for ; Thu, 09 Oct 2025 10:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032749; x=1760637549; 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=HaW9tAfgman0phZFD6I4AYKoZxfS1xOZW1UpmzF8ieY=; b=WzIa6tT5NlHehqlgVRVJ+buGMEm4WCe4chAo0NgBhiM+3j2Ez+zYgSGUJz+tvMkeDx 90zhOi2m3/Tn4jeq0/q6UEdCwrVnTwy87Enm/ByE2P0LhV0ctPuBkpwZlCWN4v1jivjW d9dNXDgx0begLF4mS4XYO7VnGKIO0mFpU/YybuCn56o7DYzzdhnlJSplF/D36X8uP813 tFH2738t76+FfUXNnCX9X5Fd/vrJwwxhPBnRZNbcOwU5mjNrGHf1vFVMVY4m27UfJaTb +nuy8KX2ceEIwm9w9stg6jyqb3xXgpWZUKx/SR91zxyeM2z86VQKlMM9vpa4ZooqYRu/ SVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032749; x=1760637549; 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=HaW9tAfgman0phZFD6I4AYKoZxfS1xOZW1UpmzF8ieY=; b=mHI/CslTFH8x6qoNgr0IhSIUPpGNlHM9Y6qwg4fEtWCC8o7A48OgE418kPng2LoMDU lIjMh0SmRf5fPJa8fiSFeYr94i86IW+KAObRalsX3nvUcM5BA6WOtSoX+yP79Y4FacVp 7l7WO+Eajbb890MlHhFns2PKR0+6DbVXFSBzp7kfVzwB1onGR/BjHCZbLPKbL5TpFoV4 B31lsATb4Y1DA0XTmADGf/BlmWVqgOyy21rX4gDcj84okx+N6WcIbp+KjWyF0s939Ird 3GpflYRKTVw0DxCzkMLaWEKk8Oo4WGZNtNot1Nq8CQaS2kGolGEKlZwaYngqKktzvnby Y4Qw== X-Forwarded-Encrypted: i=1; AJvYcCVfe19XXESscYQq5HTSjcnjjk83k1IVoVDP8hPi5MTn9GNnB5E9pJInOD2ZeIb7DZ3vsADRRf5Bkl4xaT8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4oTLvc2wJfIIXo1tqI79gG1WiyertK2+RxhlutwI4DYT9Sip3 TTYfixsmGViSZXTK8ZYLoA2izdXIUmVfs9CA30OvoQVM1Yie/c9EQ2c+ X-Gm-Gg: ASbGncsrdPD8NFxhzTqheDExCS7XxhDCzgE+F8lnubb0eq65wyn6b9IsrPr4l7EtQh0 CpESJrQRu+JzeNj/O+QbL3D9qJ/kZcajOKUDFbl99FcmMWpISutqXp6Ezc4KXQjdHaxmxc8E/SR yLfS1Y+of7/mGwXzwnA9N8GS/qsCj/WIP/DSIY/dLEEaVeuBgH0EfZ8lpIZGnh8T8+MOVS/27+S /od5hBCZR4Y+quLjJRgHPzghxGg1uywnqo2T1bxKJefLasS1dzZLPBTirNgW7d/fRTDVnlbk/db b9bkTUPmGrNRKctZLIrXavjVHmiVyH1wFsWkuxVqW7Ut9PYxXorHE9cN2JhkOfRUep2nV8XS7lY +SOxvi3e9HtR7KGdGzW+PesK9nV0z76wsG0eXh/N/BMoLf+1dtSfUZLLbeNfKEM4PSNSURPaMnp V25S710h89/2jJhebM+Jy86sUeHG2quZeGvROTpWPAm3ZNaVaz X-Google-Smtp-Source: AGHT+IGc4Pm8viZ7Ex/z3MDPRaEDeaDT6XBmdH/OHSJyK+kbNxuVLa2JxTKXZ/rudjf/WlKTsqzZhg== X-Received: by 2002:a05:6e02:270a:b0:425:951f:52fa with SMTP id e9e14a558f8ab-42f87376e77mr84969825ab.14.1760032749004; Thu, 09 Oct 2025 10:59:09 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v5 20/30] dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP Date: Thu, 9 Oct 2025 11:58:24 -0600 Message-ID: <20251009175834.1024308-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic K&R rule: "define once, refer many times". When 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; the new ifdef _SUBMOD block invokes DYNAMIC_DEBUG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer. These 2 modules are both tristate, allowing 3 super/sub combos: Y/Y, Y/M, M/M (not N/Y, since this is disallowed by dependence). Y/Y, Y/M testing once exposed a missing __align(8) in the _METADATA macro, which M/M didn't see, probably because the module-loader memory placement constrained it from misalignment. Fixes: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") cc: linux-doc@vger.kernel.org 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 --- 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 0db59cca0d4a..4ad12af49a35 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8616,7 +8616,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 866c79d8b2a5..7bfd23ea7620 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 1ccc5d4399c3..ee35238d2d0a 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2716,6 +2716,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 dc0e0c6ed075..4fa720b98571 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2959,12 +2959,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 392ff808c9b9..45a445a5ff96 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) @@ -207,6 +210,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 Fri Dec 19 10:25:40 2025 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B4082F0C67 for ; Thu, 9 Oct 2025 17:59:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032753; cv=none; b=TvSaSP/8/mdAF2ZiFY3nwMj5PuplnTWNyb5u1QrJJH/DcmPpq3J/Z2O3hDAiQRjEzbzz4/xo6VhR4jeWeSn/AuRrqn4KZ84tnB/pToDlpXoYH/WtvPttJeXtX9SUt97yO5naWpZF4H455lUACKNeQicBpWK3xMTmMU6NBsFkS0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032753; c=relaxed/simple; bh=pchdw9wUalctnHO9hp3VAWlykvz40o38hAkRsbvrcx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qe71eMJXiK07zuSzz1Y4x1O14bWK2REJjR0TLjzcmxD7+YarqLlJvaAbqj+IFVlDKck2z+evTorW4HA1OE7pBfJpwRCPBtRdCfJdmcAEg/j3Z6e5/7CJRwza/sKaJKVA1ikApwHs82yyIr8AOteORpZUIE7Mxy//jSQaML0yxrw= 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=C7SxxyGA; arc=none smtp.client-ip=209.85.166.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7SxxyGA" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-93607aec358so23444639f.0 for ; Thu, 09 Oct 2025 10:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032750; x=1760637550; 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=BkrhZds/ll2Xl8Nzf4vLphQpqfGvsMLkRQg1rNtfyx0=; b=C7SxxyGAQck52iMSXSU9iQ+6clofXeUbJ4cHo2JMVYz05UbNyj+VUDkWwLamnq7r+7 e04leJ5cp4MpfHKHCHHEhOEyYWcR0v43qokfFjIPVom/DXtBfx8LYs3t7VkY7nXYv3Ce gHsV7nZiq1Lj0Sa6wrdNuZegzoBKyIY+9fSJFToDb0IT4Qzr7k8Z6pzozYUHeqNJfSEj 3wnuJkBmisBhJ0nxC3DXhWSYVHJIJ4FvFvNh88uZ8tyazcpTui09+jT47OkjkxMzIhrN w3jaNDbpQ3BFrxvjD5JGmDowoRZ4vbULxKq+GwcJs7B+JPCbQ9EO1FFUdFvKewA8PGJx otKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032750; x=1760637550; 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=BkrhZds/ll2Xl8Nzf4vLphQpqfGvsMLkRQg1rNtfyx0=; b=JbRsWJ9KzWm2ytPrNjTtd01TCvunHs13rIbjs+uKNk5JU2CWTILC5AbjYZ4ujfHerh V2tjiY6vBc1vRyOM+jiHFBQ+uZ3aZJFZD1EUGCSp45hzmqQPTw8M1S38Tjbe8QuedcrH ysntRt8pwalEVcXWfGfrQO1+bhKIto3W2jK+yqXJazaDzZFtB3YE2a/zgSx3EczKk2Fg zmB3Di5OFt4b9r/4diw3FMD7jtcyy6wMc1limJIyFRVpZd5MAMOjzGv8Mi3Iow0KsZfY 38jTzp4bJxkm/a7ALJNrKSBwfxlFZphKaxoRgDNjYH5mW2MI2BLbtYRc7L0XlwFhbBZX 9oNQ== X-Forwarded-Encrypted: i=1; AJvYcCVpd2+0Gx65aP9LWX2ebnulV6qwFgKBhy++Pgtkx62Cz7rFg+jAYvnFgja6UaCU1VItGZDRdMD55OW1FA8=@vger.kernel.org X-Gm-Message-State: AOJu0YyiLsylFfV6WlQ14Uz29zuD+4mv+EaeyryYaVNthe1ZRzQfBPwm i8IS6jFcpaApSb8VUqjFhLbdPGLfjj0H/ou7HjZfO3hFdN9bXDzG24PI X-Gm-Gg: ASbGncv5llclw2yydLFeAYds8edIL/AJNwy+cbmAg/0qs3yebKP001DfNLFO1v2khcZ HqEhoBFSYNgJlo/DG/Nkm3ddBDvWPk9jZlhnUoDsrbDJvT+nLUvGyW64GM5A96yO+x034WoNtnQ 6Ryh3H7bmbQNtSWK7flN+VH+b/biduZiFdIN/zEO+p3E2K6z+W5+1hJKz7t3pmdYNbH2tFziuqN B1S8Lsdvgbr5HM5I5Q8vt6Q0oudXItWJnleMLi+5+1WYIPMUyvHYgsW/QzbqZY/yAvrb0lxU41U GVcgJ8FMcQRljCG43QHR0aheJyd78QX5svE4d1ykqHOlPsLGhAxdLA79LUY6CIYk+6KO5Hrs4OD wjQQCHDmDAdvB6Jld7e98dt/KZgEZOpe1QSoq3JoMXp0IJHbriC+7PayceDfVRB9VExlz6vFLiR h3kFvf1hZBexAm4y1fXYJrHBoKvrt9on3GIBiCJQ== X-Google-Smtp-Source: AGHT+IFUtIEt4hZGGPIJzsczKNqnueKXhXvFJxzwNM//vyW6z4t8ra586gGXxFd/BYpLugooChengg== X-Received: by 2002:a05:6602:492:b0:900:1fa2:5919 with SMTP id ca18e2360f4ac-93bd19882e8mr959644239f.9.1760032749970; Thu, 09 Oct 2025 10:59:09 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 21/30] dyndbg: detect class_id reservation conflicts Date: Thu, 9 Oct 2025 11:58:25 -0600 Message-ID: <20251009175834.1024308-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 | 40 +++++++++++++++++++++++++++++++++------- lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 54f93d1d0ff2..f94ee518ed62 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) @@ -1290,15 +1307,20 @@ static int ddebug_add_module(struct _ddebug_info *d= i) } INIT_LIST_HEAD(&dt->link); /* - * 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. + * For built-in modules, di-> referents live in .*data and are + * immortal. For loaded modules, di points at the dyndbg_info + * member of its struct module, which lives at least as + * long as this struct ddebug_table. */ dt->info =3D *di; - dd_mark_vector_subrange(i, dt, cm, di, maps); - dd_mark_vector_subrange(i, dt, cli, di, users); - /* now di may be stale */ + dd_mark_vector_subrange(i, dt, cm, &dt->info, maps); + dd_mark_vector_subrange(i, dt, cli, &dt->info, users); + /* now di is stale */ + + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, &dt->info, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1312,6 +1334,10 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE("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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (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 50FDF2F25EC for ; Thu, 9 Oct 2025 17:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032755; cv=none; b=lZcS0M6+7qH/D6zl8edc7Lc7cjdVuZtU7uzmyOQ7aNrkIJe44HRQ8h6d68WuwuD4QJ3XLzyasz3dnOjA1ktTqElbDfR54XY+RXds/nWhOh0AhTgw4L484Q7yOnhp4HCnO3xZ/GmUZGt8AP6OuZf+fQF65yJFM9i3QM+ioWjBJdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032755; c=relaxed/simple; bh=Stb9gWLH6uJuqT+1HZagkMDgNJ+3r9ifT5CAmLLMAl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KAZPwvpeDoCVOp0zQRLOblMn1U5B3iwNrnQBBOHVQ67HG7UGOQkAtjYB8Qsz9AYly91ZujunyWlKJShsbKOuuF5g440HkpWH0heR3xp5owpf5eM5jcS1x9k8FJc4a2aIQWl3WX5HHfEDC8674oyQLarZevcAoEXcT0v2nxIF6+k= 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=BlfBRDw7; arc=none smtp.client-ip=209.85.166.180 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="BlfBRDw7" Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-42f5e9e4314so12594365ab.0 for ; Thu, 09 Oct 2025 10:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032751; x=1760637551; 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=BlfBRDw77G+dxT9JEnd0lFE4OL+ZBc3/qdvMw/SwVAbOhsmTtbXFtRMxEaB5OH+k/n 27BdlJ6W4aav0KmnrpRjXyigaumeVJ0I10/4wMn4VimgFLmCdR+ZklFk1lVbCa+UOTb5 emcVGN63D0ns+MyKKr1FIH6ixSqw0LaH0jr37dIgHVLwPpayTOPZ3BsmDDLnfaH7Sm62 prPCXMzm7PtYUigfseh/MJ6NaIJNM3TFuVMR0yQ1+m4b0h59xwBWM2zYEuKjEYIRZc0x Bzn3PSWG0QlqMvSnaobILg8D396AA6ZARcxj5Rx6fDufsEu5Cj558yV3jc1LCFiSL2NK VeFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032751; x=1760637551; 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=HLnJkg575g+4jWTPDfQMltlCXvr/GPYvE8KmNaaHSLwqMiBcKFBSCvKrG/0Y79KS7+ 7jsTPL2sGhrwmcufJSBZjkb+Uc1lkgGJ5BOn2lrXpkJ6G/So0N8Quf1REb3F9NKAjXdy qCMCQB0fINOrnlCYVqoI2/KWPTZSS4qy+9qb9xMP/uy/2QpjfyUAekjJR8H7sSQtFr5O SOt2C8LFM2AfmViSLRaswkrDsEnE/kOotVSFT3t/i5Ucg9bKFdaheJ4NdO0rm+2ODAqf hIEEXEgLN5SZl+/g5assbRLB0Dxh4k+UHQEu4Ejhsj/2jXVm6aVLwoKW/rxKRqbZnnH5 WQgA== X-Forwarded-Encrypted: i=1; AJvYcCXbXrOUbXUMgxm1hwY4DovrKcgpgUF2/ATnhz56qsklT+XWCtGbLY3BAKWeFfeH/Yj+FLjeIp79TT9ng54=@vger.kernel.org X-Gm-Message-State: AOJu0Yzbem9YwNlDBCrIvCR7W+mxdcs5tP0FmNc3PvoIeKc4KvVz9tgs ST7P6G1iZIBit8QQMHbMPn1/MPtEqkdZBSI26xkByTuM3+O521f8rOD2 X-Gm-Gg: ASbGncuIJPsfggKbZt8yPhUb7sley/h+ELPK8sVi4/Vj9gsNboiNdLFHx6bWzyE8IrE RI0a/4vqLVGphumTb+/Z6bpamSUtmGnkUQjNyEDM1Cmzdyavzt1S+uaD9ol4iBEg2E/VfCYb2CM 9hqQjexubknjoj5w6MS7cLu2NvnPi6oHOeUqZuhlA7xoaPsz3WQ3xC2BvWEfbIp83QmXNUUVKT5 n1l4cItigz77Rk4Hob0jZfuXcgaN+gVclzTWDFp3dCnI6oEQghvJPeIbwa8TmKK0hvKooh/Y6AA QWWuSd261zINHD43HjMMS64bgmZotUD3LMI3ULOCLtmegVEHDrZyd3rWfyb/l6DjU72QovqPiQb LnaSA7gFiq6EHhjPh6VAiURR9HFoevGMpqJmS1i1Kp0N2GQP4twSebi6Bz2ZAXXokiE3VDohubK RDUNXSUkrwmPtZHrUE9U1jmtYzSPA= X-Google-Smtp-Source: AGHT+IEYsyaeLyf8EZpNw3F9lCq0tpNVoC1uSjvB+6nwdk9sRQjO0dbdJ/WpD+G+dOz+8SbQ7siORg== X-Received: by 2002:a05:6e02:378c:b0:42e:2c30:285d with SMTP id e9e14a558f8ab-42f8735201emr80190015ab.6.1760032751102; Thu, 09 Oct 2025 10:59:11 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 22/30] dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time Date: Thu, 9 Oct 2025 11:58:26 -0600 Message-ID: <20251009175834.1024308-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (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 6C4F42F3638 for ; Thu, 9 Oct 2025 17:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032756; cv=none; b=E5CVlnMvZRY/MyvuDNv5jjY19rjja/z2ATbkoL7oN3x1hnMn6Ah7T4KfNQtrFLAjKMrG7yZ/2ewdjqZtsMMJbnGfQ284ExO5kCHmVCm13cpDbAliLkq96/zk57x4q5nBzCyTECF5HSSTrZvL0OLRVHM8fr/0KcKTs8n3wyDoFLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032756; c=relaxed/simple; bh=jYTp9B54aHLVfgeXIg3NyIskdozVnt9ZijXB+1faPyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nb44aIuVSXCVz8R1tgbBNmosasa+oE7H8AiS7dXanJwiNZXtsdSPHcykvzWQ/3FE/3rV+5ctbnOA4PrzqeMedLJ+x8qgDxo7hwmuDRGQ1e4QqOqQxp1ZdqH+O3hnm7LVuxZgfojHYHL3A6/ADyYILruEo3DFw5dIjzLJals1OJE= 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=GYVxrxmt; arc=none smtp.client-ip=209.85.166.177 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="GYVxrxmt" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-42f5f2d238fso5468485ab.0 for ; Thu, 09 Oct 2025 10:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032752; x=1760637552; 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=GYVxrxmtfP9Oer68iYLGxPFxC7DN7Bwk+XK0nWdKqO/Uk8l3niU465PGLWtj0cgNQK V/c4EI8qlcrpiVjJOicW5YeySKeoqRXWf5/Nq/Cy2mnwNj0+0gVLbXKPWxcq67OvyqPn +2s7WudNyjl16EN+rcoOJo8YvFQ4cCkoUA2ljGjxCrSzxqwLaJS2B3bZdau9OXfc7LjF FphaAUHP+OkmMEN6nxBN6NKljd9SRZVtiJ3EtAuv9dvEZHEX3DJfUXOoNdLg3Gimr7X5 rmp8fQ2nkhjbjimk7xTZyvot5OJ0NikG++atjMfspD67k/IVbqOTfrW5HDqyriLqLBp7 I8ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032752; x=1760637552; 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=WuYKfqaw5z/w1DmCC1RSfJcECJ4Bnb+l/EkHczFwPczNt++J72oMLvjzZlV5OmO6XP wdPpol3beZF5zvattSMA4SD/a7eVx7YU8I5SSFbHv3mgfP6MwI+jsg4Vwa4/Uh78C7u+ Krp6XGS7FyfQbqgY/6Gusx5y5D2fRDS7gEDI3kR/TC6RMqR92wMCBT4uc+pIz2XZuXOM +Cf8T4cRt5jvhrztakaKe3/M0uHV90k0WmdD23dirDCbsMSZaM/jaMpLRbAZSzVig9zG JYVy82IImqk/6rSWdBk/vtD0NA3p4+0QAmTokFSK59zKfMjdKH08/a4zRc39I01qeQGO MPGA== X-Forwarded-Encrypted: i=1; AJvYcCXeyYqGCe8hk5FwKVqVIweU3NpzWWuJ40YMp1EYsTAVBK7GUvnEihTbZ6iHrUaGopmjWDSe3aJgJ1ymwWw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+jUCmFsxLZzxxI8PSpViWAFrE76OyDeUPm8NjpizafK5dJV26 N5vgoeUO+/y1ggGNHfexQY/fIOuHPD9i3DMXvFHHIFIJqpAg0gtlzD9l X-Gm-Gg: ASbGncvsYfDxtDqz7ATDSWlIm2ZaPM9sNgSufhr+ptNd23W4I2tkfPnE5BWVMiMaebT GoljOqKzTAFNc0d78CVgoPEt/Ck2Zsnv2MdpZx4+rdN8eRjk8zrV3TX1IhtBAOzYcbcDUGglblO NzjrAP83D1ATL9eGmDV1c41U0vYlTaxHIttXNYLo7Yu2X915RLQvdL3u7sQYMFXh6uulwmZEKZf GCWabKyqPR+Pi91kxuQx45dVLEJxxvW2y8844lII42czHZMWFhb2VjsHiC2lLgD+taxN/JHV1Op qsCf5kj5qAXbVH74QksvAuPEmtgVugCO2RvQLmPtFFjTYXfs+9LmLQZGlPtWYyv8dWy8INMY0iV 3xKQCZK5TNLygbS7jMmOVT0Wmm14otQyB3AU4Kf62lMJpZUn0kQGCy0CGjBa96tXjt2hysKLElr rqtkiExZbgfFWaYJioBBKc7XSU8ZW+Gmwg08dHUg== X-Google-Smtp-Source: AGHT+IHFaHIr6hhGjGpGvstoe1cPL73AxoLQd3mHJOdW06DK9B2zxkHb4Qpq4bia8u2yk9gHtlYTWg== X-Received: by 2002:a05:6e02:160d:b0:42f:991f:60a9 with SMTP id e9e14a558f8ab-42f991f6190mr5265655ab.7.1760032752391; Thu, 09 Oct 2025 10:59:12 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 23/30] dyndbg-test: change do_prints testpoint to accept a loopct Date: Thu, 9 Oct 2025 11:58:27 -0600 Message-ID: <20251009175834.1024308-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 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 C966A2F39A5 for ; Thu, 9 Oct 2025 17:59:14 +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=1760032757; cv=none; b=eEzym2Q35Vuvc1OQ4tN4YG4PStmJOP430omACa4ae50TZrIcEV2Lsoj2LmRIwCGioxh8t5PRO+BV94QOSFzQm0sXoQm7hxaYWcGeCJmtrmPupIAcCf75Bb6DL2sSeBLR9SicbcGSFmwEbCBvmK7NqNpAcct/z6Py5cKriNwvVBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032757; c=relaxed/simple; bh=bVQgQdrpEqk39Vi9DV50PJ29Zp14GsHIM9c4hakMXlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mXnWhuyTwOspdUY6xXqfNbwBLartJA1N7hF9oVLgBKmIMBy/RTcp16DBMxmJA+8FKiPUoAiOLjizIrDzAbouo9hogd3HtRTThSkBCh1RaZO8kfgBusM8H79pk4SNOUQKD3bhuI3CyFdOmpNfBuqgJeaFq1grAeiGU5mZipxxuu8= 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=mdZ/zEK0; 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="mdZ/zEK0" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-91e578e2a61so53478239f.2 for ; Thu, 09 Oct 2025 10:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032754; x=1760637554; 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=WIAFOBYRau/eOmDDE9vDfGegFI/04p6qEgZWwIhgqnc=; b=mdZ/zEK0bQUqj1deCvtEfhlBUyhAHGrjAnuG6xN2zboF+7i3aULi/x2AY2muk/Da9j GZViutv4s6uxXidtMfEOO7qVDQZbPrT+oIL4pUWjtG42PId3dHtKuoqCgA7VCR+oCzUT Yd5jKAxuo7yqEqjQDIyCK+sto20/pT9eWxvLWbBOD9mClp/Mtv5+sf+wLabO58u95gwO zrsT70Kxw4BoBKGbl7eeXR0QelqXP33xu7JyZZIDy/mHNjEsGfH9kXn2Xm8i8jdh9qJ/ bCrSiIvYdYO12TiCIZIUfKbMmcXrqY80Nw1ShloVae3VqLdMVRRWRvLj0OH/ZZ22cZrl 5Pvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032754; x=1760637554; 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=WIAFOBYRau/eOmDDE9vDfGegFI/04p6qEgZWwIhgqnc=; b=VnZO7u+9k1YDxndWRCDVy11DtBI7Fwxz3l5tCSoDCMqL/4yn0I8kot38FQpVUWs57b uWp/FIGl+JXZktb9k1mHOahN8XNKITQ8buGAJ1WvzsPMM3uvkmuAQaz8H+EVQXCa9nal URbXCJDBI++5i8SW/pacjtGqDV8kf5QVj3hCXhclvKrIgtWpVP4xT4iFkj2UH6n2kemW cvMteI/UdQYav4V7QtQ4ZJQ3VyPuTnbsr0Sg5fePLaCeDKxhW63h7L12pG/wIHFokas3 BtTT1CNScDQgoY7D0uj8bH20gaUGqJuCSVEh2+BgLov/6ywYekly0P1ZJNIVd5KN57w/ oc1w== X-Forwarded-Encrypted: i=1; AJvYcCXqjBiHUbjJ65UXYGElc6OVNspEbvdNzBM7PCC9ZGDZGxlwkOL26wNjnhVJRoH/M1s9Redg8SFr3H/6LCs=@vger.kernel.org X-Gm-Message-State: AOJu0YzT4v8tfsRXTcQXul26cWR6oGFq4vA8QCTdI2w3rRmz11kWj/lG DXVovShJXwPTy8am8Q8JAx32IZXWKhPtIQzhQCf1RYRLOkVSiQ2hbThG X-Gm-Gg: ASbGncvm/O/uM9uLVlpPQDjgBIa47Zs6kvAsWufIiLeH2yyECfYTF09Sjk2Qa6kY6De jzOw7iE5hi78Enl9nYQlGzEDQsYvc9sYyXCAWKnfUFc+9gs3NAnQFTQXtsq51ofrawG+CUzx9hC xXUX/Y0KqGn4tuOeGRxj88qZJUV4DbIeRsLkllJGfkDdqQbhZ+UQ2Wgf21zKMjjzSYHqxNGZyqk weLbBzn9GN/tMeixt2GnDnWgRFikpN/khYuOJURdzDYIxDVX3Q0e6vjcB2zCzsODO6f/hWMgiAc YZfLn2LGBCknfjxhalaa7TP3R8OO/MciELYfpGd+E1UzZot071+Bup5yOBIpbapUS/qf99kyVYe K+F/UDxsDrOVjh3nwf3ghySkZCfEnra5bsKh0T+pyLDS0TPgMlgn+Nt6h3euyjddThd2WeKwBM8 tGqqqiCyAUZyRLiGw+ddecxIZya84= X-Google-Smtp-Source: AGHT+IFHV06nXLR4X3RwmMSRSF82OlPa8irEUanwvFRR9mNbZqunLS0e2zyPyCutVNyhHcvyKkXa0w== X-Received: by 2002:a05:6e02:18c7:b0:42e:70fd:f5ab with SMTP id e9e14a558f8ab-42f8735203fmr68458065ab.1.1760032753479; Thu, 09 Oct 2025 10:59:13 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v5 24/30] dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API Date: Thu, 9 Oct 2025 11:58:28 -0600 Message-ID: <20251009175834.1024308-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 f94ee518ed62..9ae2d6458a99 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 Fri Dec 19 10:25:40 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 954802F39C5 for ; Thu, 9 Oct 2025 17:59:15 +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=1760032757; cv=none; b=jNgw61MLAORDQPj0QBFfQKOnZRIDu8cfLjQ8EDW/XY7ROlxBBpcXkNfq8NB/u5yL96ayp/TYX0bkTM3YFM/YCtyZEELdgs+GEH6c0ZKy9HkfPF6Pj1QFrqhknWOBkJXLj6mim16MU44C5qo9LgbrUlGHREfmI6PJ1KzOT1c7Oww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032757; c=relaxed/simple; bh=Mk2Kq1oV8Ntz1L8OhJe0Ppcl6bWBwPIp/SjTlJK2Gpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cw6XZBOJ5OonKC5ekurQw83/xWsTupaDMlfgH6HuvJ0FHJO9HYeLalp3m1RgTG5Ml2xCtNHXz9nRpjcdmuVClIj4Z923YR2tkgjksnO24JOzwvbE1w0Tb4cK+hdCatl7BM4F/aaefu/yBojoQxgnv8vxQrBO2tC6ZzTLACSv39M= 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=XCFAeds4; 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="XCFAeds4" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-92aee734485so49239739f.1 for ; Thu, 09 Oct 2025 10:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032754; x=1760637554; 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=Vj6+/m+YvJ4nvGYtValsKBvS5LCfNDkFuITQxB3i5qw=; b=XCFAeds4OuMYY2RhMbNMd+/CEPkCG1RGtCDR03GYiKqVJ++nGlM72qmn4TWo44oHUJ QaY5kO7QOCTdoy7Ja5VTEG4d/DdMPNXY5J5wtYfX754CLIqJuOOV7dl/dagh48kglqf4 hSkstW0LJuCmB4+FcRK2LZKaQi7QfzbHFC5oaVh1xKYegD/GC6mpYyXdjeecLPpP2F49 VUHcqqWcpuPjb5GEsyoAyPKYbogzy4u1cTEYL4VlEWDWGi+QvcDXC66NtdJRQikoZxez vcA31l1eqPvxGVaxYAtn01hAHaAZX6Wo/KJDyCf3WQ8MGgpGVxX5Wl8xNgxuxb3P2CN6 kI0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032754; x=1760637554; 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=Vj6+/m+YvJ4nvGYtValsKBvS5LCfNDkFuITQxB3i5qw=; b=BdVhNZzU8hkm5iGBzXav1C1lUFWNdqDGUYovinW+VXUvwkXyADyNicUPs3rhvD/ajS anMOONsyJ18a6hjAdkOjtIunE+xenm8QhBt0EqBBWc/JxZw9H393CwqrmNa2VKiu4Hbp BZaZ76xFdGxh+KVmvX+xvOPXiGTtbIX0JIbyMtJ0a1iEsY+0O2o+zPYCcvLjIGff7LzE IDfW7B4taLfuaPfXaxCq6Q7H17urjTmnmECzfal2hd56mBcseYvSys07evi7pEBmHCSj yQ8+V3g0coAdBDiDGuO4Q+I+KX1dpPjJ63UWIKFtMqfzrVv43D591qUQCXmXYUCKxICa QD+A== X-Forwarded-Encrypted: i=1; AJvYcCW8S46RE9USFWfOhv+NGmAfaurNKuPECo1CyARYEW2AiRWKz+zNxGSKWn/xCHPiAckeu1nWbIeseWoWV3g=@vger.kernel.org X-Gm-Message-State: AOJu0YwVrlIUDny5rSQL91Nuz3j8NvZ1yIhL+LTZd0ND3DkFDJnBK1+A lSaMV15MgLxY29vmoyCB+3bn/KDlo0FpZcmXTdLygwHT3cVguOLn7EBK X-Gm-Gg: ASbGncuSgLa+fIrfUjULap1vLww4my01II8//V3SLZ7pqATPV6Tv3Ddn74jdBr26gzk LlmthdVYbVg95Jb2WAAD+RKpop/yNWa1ZR3Y4kO7nHxMFcsgxdTOzE6zllvZNCV6rbjMKGPIQsb /+5/nik1Rcftm1ClSgY+P+1eWE26X15I71jmgbFgHOFTn2yMj+9Rgdn+gFt/uk8F7MkSpbjsID1 R9gTFuAKd7CiOmRgeWFvVhSFEuFEJLJEq3dGWbekp5wRxJ3v/Vn30JP/2j7RwsHbQKJU3FAaVtm X273SObD5gQ0fmVjAN2+XFLrru3uGK8ZY2SgqJtfzNNhx06hBBHINF2FGLnxUpiyjoK7uGo/CcU L9QslJJ2bF1mDcsB5RUTdb5HLXBWxFQMWToYC5CKeOIpxrRcwIU5bpG0eQ/AebeLz/L6XRhcJB/ Y63cJKXWsNUk3htXO9mOK54hVOChssoRSPLE6eNA== X-Google-Smtp-Source: AGHT+IF1wlfvaIMMrTodeuYFfX2PbnlKbpq3sHn29eEPjyMIjYw6+Qq5SpudC+MM1kOs5ShBVQ7J2g== X-Received: by 2002:a05:6602:2b0e:b0:912:5455:f0b0 with SMTP id ca18e2360f4ac-93bd188eab3mr968983239f.9.1760032754468; Thu, 09 Oct 2025 10:59:14 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 25/30] dyndbg: treat comma as a token separator Date: Thu, 9 Oct 2025 11:58:29 -0600 Message-ID: <20251009175834.1024308-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 9ae2d6458a99..b05d186e78a1 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 Fri Dec 19 10:25:40 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 8EF792F3C16 for ; Thu, 9 Oct 2025 17:59:16 +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=1760032758; cv=none; b=UGdRCbd3BuBuKetrDfAFmmSx6Xm4J4vcyQIvqyi9JQYc49B/wITPvDsaXsV8jhu26vqUF27f3mBX26DBK+Li0pJfKbwSsXvHKwLNt3G3piM5s7yTN5cLx1x8DNT1jXEGx+C2350IwfR86xRRuZEvnWHjmVTgtbsD9TTQLl96vis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032758; c=relaxed/simple; bh=IT6AUxG7GcxMyUFjCJ/sU+IvzOP9x5ns5pQZqWMN9dA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rIc6O6MyqHjJGVKQFATaKlw4mIKrXDWGLtU1kdL5lEYH05vEsA0SLadcoWsaHj+Hxk+L5QwFiNMFRyLAWpHTiWUXdbKOcdmfrqUicORRc6E4gd+9yiSxmEXNfs8vzZ6YAgmb9uLAWgZKxs/g2KHXf9snecaibmfEpcdqEkurt0c= 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=a1pDQOAA; 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="a1pDQOAA" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-92790f12293so54872639f.2 for ; Thu, 09 Oct 2025 10:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032756; x=1760637556; 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=q5dZYlkWsj0ZEEitjTrF4YjoePePLbd6bheWS2OZneg=; b=a1pDQOAAGhiwCH4EVC6PyNEXpCs6CIoOx7N27DOiOei8mKfVUQoC3X6tk4msMXQ8ZL RvgXjUTBSa6o39GedFrKsBCqGAJCSxC7ClNAcKEHNNRRg5pPXsYxpbovGGRqMpJ4nVH6 xVWQjv/+owkyCastwj3jWnlHeIJ6dt9dBZM+UJDQ+uRloFPeDupNPfbR8k38AyHzXTzU 6dwth8CNhMmnr5GlfK3cH/rZYCWtPMm/uyaJENbLpOiHIISGmpZ7jjAzWl1NwOAhNiSE ym2pfMu26gISrFxu20utlMIG7smPu56cGYtqgEpRJKcoyCDaRIb3o3pc3vruJn+Q49Yf g3Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032756; x=1760637556; 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=q5dZYlkWsj0ZEEitjTrF4YjoePePLbd6bheWS2OZneg=; b=s/bx2F3K72C4seBcpWZUWBPjYIXA5LBkj/7Ui4RuxJkahmW/u+UADVJx6bzZVgL1Dl Qb2Iq04h/8AOsWMEVHjDm5lPFRIRFVKn01fw0Rh1w4F+tMsk/gWaQaN3rPtKKPJ5D1aq y44KtprMDp6GIOCpOEVCC9ftjdkhypIRR2UDuHdNiPQ8lYKTLYeQ79pDyklWvedENSv+ EGHtOOiK+96xClZxWzi5MifcwkyYX2GgJHjIqNaZaPrKKFGJXCNMsc7hgSbSwr76fOxH 7DRT/3bqgybND/c3BmHfXBsLS0WPsiEohXnSNky42vrGmBUAfyfH2Z3QGVCF/TdwIinV JSIw== X-Forwarded-Encrypted: i=1; AJvYcCXaRAixkY4k6qccg1IkqDc7BLNaiY1Dxf9OFsSeNBi6zCdfz/88NG7nrNoBXI5vFBQFXJdsc6O5fLMM8Rk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4VhcUGayKeLPfjcLeXFGnoCG1xyNrmq0cP87EcpKZ9bNLbqE0 xlrXCMaBOcosfPSxJqLuGQfyxc3s5iL9k3fBj4C5LX89tvZ3RfowZiz+ X-Gm-Gg: ASbGncvnVwBisG+LkEB+soIzvA5V1LU+YhSV7JMCrsSqewYW5OcG/69btU1zJH/Mj9n 51h7XZIYiTw73wjBx3aMudurjcvlv5o39gqXG0K8/Z8CeWvh93450B58qkYBLt6d6ZRVywIzhu+ lxhv/EBYB24ed7dUzNug4hlsp5orQ8Yl4vTJ6pOr55Rg2I5OrPTFSCjxluA7KPYqL84iOQ4uGWf vXz4jIvv2R/BBlQJZtsKa6bN2d/ANOzvTdmMqzHhCBXp15v39Yoc32eS2b5YP1hkAOa4PEnijwV YhG7gP6sxA097g2eOsyBc653nwtqBatxoNE0T5Hv0+EbjgYEZSmJhey81q60YPm6hMalnm8i/Vu lUOUQni30ks9krzdLuFUaLjMMIxlHs4/bLLboOO+PYrX2OnKADjL+76GVGJhR3VqYZHYlstAqFI 8PJitDSQ1KOcQM2fW1jEcwE50YzkHtgOD9tel7OA== X-Google-Smtp-Source: AGHT+IHEWGVhtAuxACrF15TMBTJdVDkb5oi4cU4Syu6r807ljXBmyTG7+iiL0/3UAgEv3Zk1RERmEQ== X-Received: by 2002:a05:6e02:348a:b0:42f:880a:cff7 with SMTP id e9e14a558f8ab-42f880ad12bmr87822445ab.13.1760032755551; Thu, 09 Oct 2025 10:59:15 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 26/30] dyndbg: split multi-query strings with % Date: Thu, 9 Oct 2025 11:58:30 -0600 Message-ID: <20251009175834.1024308-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 b05d186e78a1..5de74a1be4e5 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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A96692472AE for ; Thu, 9 Oct 2025 17:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032759; cv=none; b=rOMqbS7qNA0ktx7UacDT2HhYAESxYzq8Up98yO6xcouzaGuR8dxsOifo2mJU/BT1dtX38dUUUfFg7JcXTvgksLx5J3syKfdFWrZUXth6ots4C93IL4T5uzy+YBRR9A9H0yfsil42qBmH8j3xBgXTaH3JglDVsmvatJ8f61Aoawk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032759; c=relaxed/simple; bh=FtcFgwEejWjZvhm0rHNUUhymatBzn9CaDalgPyLWlVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FcyO33x8n7mEbynJPh3/Dtu6XeTZH1nzIY8JcldHqZsvbG4lyARTIKDs2sA8GYzdApbpNf2Uq7qvJDT21oZqQH8QvqrXGPLnRg42SRnexCXf320cuPW1TSvlg26NXE4iBRmw6QhadGzzV8wCbkb6QrRDUfCLQkKDEJmMjNj1O7I= 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=nLWsTra3; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nLWsTra3" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-42f67e91ae7so12346495ab.0 for ; Thu, 09 Oct 2025 10:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032757; x=1760637557; 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=nLWsTra3NwhT3uVNmT3v1sV5oiZotbe05cEmyQtX1masV+ozvFJLiDQ1MCa1inzm/t dWYrjF4oYAh3EN00mxnR72xEjpKhdhEm/eUogqOHmB/n5yJw6LX6v2lA5q2mzNdt62yR xcvMzUa+fR5K3clydxXoj63Eg0BK3odl0vlJ6ITG2LL+zEPWd9EDD69ko4zgRHjO6hlI SZYGlJpS3JhrDGGBfGkBWW8u09WXXAsFHA4G5Rehap+rONj/47yn6bTaosxgHd9p0jFv e6fP1EPc95hDJ/aCViLcjALo09CUN2CvDF3VaDaeUqHqm5xMkT3YQDDXrqyUumC4Ffk7 30Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032757; x=1760637557; 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=ul1rmQ6VN81vCW1/ITVjBcczfmSz9UzoGKEGB4yodNWCn3oOWNNNB+GDDvMioncWz8 OZiZzmjN+HYLmQN5Pqn7TYaNbaxBW0y0VP9ef/ExxAaukQOVeCQDsVVP1orYZEPCew51 /dd802Nod9HfHZHLZ0Ta0ZIJ1W8ec5l6zl4u86ScM5YeNeVb+wtCHxJ8Lkji5fV7zEPe OuAlc49lUhllS4OClQ0ITUPX8pc1EwyfV67Of+Js8ulMht2om1EMmVuJgxNmXCGekfM5 UoPkoQD9IbaJ/5WT6Wq5ofQbXIq9JqUoU35eXqBhOL+v1EFxSEHoLBPOQJIK2uHy5Gp3 U9NA== X-Forwarded-Encrypted: i=1; AJvYcCWd1XAE3gQ61lpbQJBX+Bxq0OVr+P4jbIPBQl2DmmODZ1ZjIIOJ5dOM/azWWuXR0/opekxX9yhcd1MrBdU=@vger.kernel.org X-Gm-Message-State: AOJu0YyLN/CQmhMXivFKhHfNSlqVGdH1pVSiOjrAHsNTj/0zAjLgEkMU NaAyDKuGb/8sQLcqYN/pQZJfGwtX/pLzv2fKRdit25rES4MpkqY/pNEr X-Gm-Gg: ASbGncv+Q5ofARqFX3THVnw6E8VFpAgBPScr3y9PJMcM0PjoGwlG2vsMOGxEs++4LI0 08Z7uXOlekaIKsXdxE5TQVAig9gk7d6zjzLuS+1QNaznnCd9U23/5LynX74gbYUzxl9Ofbnk9DI aWTd8ZC6QpSj2sD+3bLe7jE3ffE0TbITlNBjV71IzupK/1BpVNyS8KDSDdWhwATRKd4KFjDGep4 3GRhnw0Fezh6UKpuv5HjAFUbogO31CY9MJXsQmE/XxfMZPyT8okWvZixe5T0tJohTKDStHDdsx2 xAWL+ZTZsT4Sj4MeElxVfNUYaqT7BGEGXyUywg2ZMYrlSqCTN7A4G2ISBQsJ5Fn0XPb6fo/GYp6 ntRveccMBWmQYBGe5Jtt+Cia8HouwCGnShjEY10UFi9yZZVbzZVNfmQo0zMdc64u7wbdcIdWLAb 9gKIU7ollIXleLgC8UbZHhzoU/+yngGvvlKSU+mg== X-Google-Smtp-Source: AGHT+IHHW7XXxj0sK4ppRb/LDzTgeN6fkIFB7y2JX1QNjPDVNsmviia3UE4J533K6nBq7vvvPw5OpQ== X-Received: by 2002:a05:6e02:2501:b0:42d:80fb:7347 with SMTP id e9e14a558f8ab-42f8736998cmr88482295ab.12.1760032756630; Thu, 09 Oct 2025 10:59:16 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 27/30] selftests-dyndbg: add test_mod_submod Date: Thu, 9 Oct 2025 11:58:31 -0600 Message-ID: <20251009175834.1024308-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 B3D942F5479 for ; Thu, 9 Oct 2025 17:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032761; cv=none; b=Inze/56bhFuiqPd3w9zbGm/a6SSOdQcKXTN7TGratJYST1BjmmH8Th5ZT7LDfD+8cSty6Tu0ov8jg24vt2KP9h4w57kpOGgVVT7G7i9IOTVi/8n3M8p3IIqyFsoDOhq8dUbXTFwfRLux6iTcFtwBdiz2lEuMYzL9ON8TG/ndpCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032761; c=relaxed/simple; bh=wDR5d79lbTo9pPg4CrN3vJoWWlkH0ZdLgMcTgePsMAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VK7NfY6ZwP5W1Tp5lFp6RUNj33UcT6yrDwseLE0/1RrmrsTfv+hMOJbv5d+Qj8BT0MLyhCVcCezUvuYA8Z0D4Kf8SnskdLd9TUQr7YJ34VSzFRMdIiMqcxx73KUKjbUqNxbQBRuFrjtTYiuzTNcWPktmF/B5m8YKFBB/LI9u6e0= 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=AH7whHMo; arc=none smtp.client-ip=209.85.166.171 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="AH7whHMo" Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-42f95010871so3434045ab.2 for ; Thu, 09 Oct 2025 10:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032758; x=1760637558; 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=8VajdNQuLfTy6JC5i23P0vLrTfj2xqzSxVhIl0k/ENk=; b=AH7whHMoSN1vD1KLOhnM/0LACG7JvXmfkrDu/ZYgkmjAmA4LYf+58hatR5NbGOrO96 C0p2hI5r05MhyNF3F+9eB3SQaLr9WTlHpHPnX4p3bwjhakJvAcaiSJLMpP6aSoMs2VUa 54Y8GsbVPlZObS6CFRR0+N0PotrnDPkNzrquLNI95kxwqpQiULxge7KaIs5AtfiXki+2 wtKS+ECvIOPynnGvA9MO6uY95/tJHacfaPmYWATFgEsJuVuH7APpfxt7GT1G9rGl70WW UMzILNI8daIH1vLMlKLpTJJN53le2CNfy3QNbnFvjK6UR8sQrDwsjaAT5v8DD8G3WqZ7 jpsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032758; x=1760637558; 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=8VajdNQuLfTy6JC5i23P0vLrTfj2xqzSxVhIl0k/ENk=; b=Tb4ZE+NiM8cKPJwt3Sg/VRDnZn5GZBMx66fzmfxCDKIinsiPZouUL8b5BLYPRe1gl7 sCeLaJQUWtH8Xbnbu+nN1HGiPZRiFlzPTMm1Gpc/BcIy+tTHqJDwcL92imSLTKtelVZD LYgMfyjn4SEut+CLHaCcgpoioj+06Qlsigsaq6dG+9uwamBxDGRXWExK/y65hzwCbj+3 p7HLwPN9C4HIuW2gsSqd+6yLIJHxY29QGGiIxcMrfrxuYf5mhDXTH5PK1VZoqO1NiJmK v3aexb7vSoiQv8VMNuIiiTi6gs7sJLNjFMudzEQHOOmVTHoXJLWQY/LVwYVBjxb9P1RR mW7w== X-Forwarded-Encrypted: i=1; AJvYcCV7hA2wj0Nl0SuOQggMsrDx2vA8B6TRx58afWeAdY3sjU6IT3Em50fdLxwo7q9XrAXPZP0Ox106rt3QQNc=@vger.kernel.org X-Gm-Message-State: AOJu0YxFLDLfCyZRel9PLeFyc7Wima0153601CLHqgjuutmvPKvGBCuM eG0h7NtwHZ+eG8+Z5Zlm7ZvxKJWwqAaYK2Ttx3jNaB2U2460Dnnk1+Lw X-Gm-Gg: ASbGncs67CgXFw8a8ZhO9RCnfD4t2qbh59/3oiPfl52HdC307dsgX02FsewTZv8SZnv R9DoEn0FlXw5i12+R8p+ey4xyFgtRRYB2Uu40mw6iqdR3de5ASvsJd2lR9HKYEUlnpBgmj8DJ/B OujVf1cQRtMky2TrL37jq6iYnmXbuMaLOfMrK+nY0XNYFjfXTyT+w63l/IzvqUYwLEDUCNKuJBl I8z/Zn4ms5ptjcjgr6lm0iwh9BvZVQ+ints+aDje7WSeKSKem/KS5lqSuMvU05mKNclpTBoxiZV YqLMaM7vMsDOCrt6mKZQi55KHx/2uTrrpvvwIQwFjMyPzJzHNe0QQ0czw0YH68MDKho2koMdG4X Ibjp/WCI9BO32O6IH28kR732E9dngBhM1JgaTii5JJno81J5BAH0z10CxhD+xTi1MH96FPDPVnY l2QiQ1bv0pTIFFxpxrFqfHXcHN3gDkebBDTLGsxQ== X-Google-Smtp-Source: AGHT+IHpelhUUjBbXbV/tkucdrvQF0I4wn6cw0zbj09I+oz7mYy+7LPEtXoCeX7tvm1TS2dpSseiwg== X-Received: by 2002:a05:6e02:1847:b0:425:73c6:9042 with SMTP id e9e14a558f8ab-42f873fae8cmr70739435ab.24.1760032757618; Thu, 09 Oct 2025 10:59:17 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59: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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 28/30] dyndbg: resolve "protection" of class'd pr_debugs Date: Thu, 9 Oct 2025 11:58:32 -0600 Message-ID: <20251009175834.1024308-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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 --- 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 5de74a1be4e5..6e0c978bc7c4 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 Fri Dec 19 10:25:40 2025 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (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 C35F1253957 for ; Thu, 9 Oct 2025 17:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032761; cv=none; b=Qx5vi1RpGCbuUaQs4Ogi8ZKthQ4a1wSSCB74hUMSDh6QIYZTPoPEcmsAKQsiXzqcXe2COG0iXtqhz4Wf0IjiMcl+pYrBcRiYUPsRVad2DazDMqgOoETSxsv0I9+B8E3nLZXYXNn74sHI5V3tktizUqKjWcd1aN2t5Ar481WDDMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032761; c=relaxed/simple; bh=fzEy8dmuUHYtFgbqFz4KTxTrUz512mMe8qEdjC4atfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dclonlZYHfi+Jrjf82iLGbYPI3wrrocn/yLwrLSOSjBkO4FnFNSGvhaP1CbU1shSIsvf9RfG4xTu6Iz6E2STMTDw+Ev25np2hYSytNYaYk0uKXx8hK7oaPbQT+KPtFLLI7iUjucxNTRuWtA97QASNM2TGs0Ibv0TVT2yUWvk5sE= 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=F30PyS0b; arc=none smtp.client-ip=209.85.166.169 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="F30PyS0b" Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-42e726431bdso6886775ab.1 for ; Thu, 09 Oct 2025 10:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032759; x=1760637559; 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=wJonn1UQmdMquLncDUtZUHutcCuWRZij3zF+8bzYpyM=; b=F30PyS0blaUihB05HCGIXVWzSAGnBq7sIuIv+ogmvIq6w38EXg4UFzGLHnjjpSlMuF OrCXqG7+1JWd93+W7mt/LBQVZZdR+mF8ln+1k52BZ+qgJ7867gVUDa17cBqFP1+l6+On P1ho9aTMW4QGULBimGjyetrSLi7ciYKYXugJnjYMMyZRMl+yJaaXOCvdMT5zzhxQX8vb Bj1mAXedv2EMkfh3T/uKqG3ce5PIP8daV8GJeWU6vU6QP+GqQQBYKRABPwCeIriLI+My 1juQvkMwiOX0goJ0EFs/Y3+h1QZugKVWFTgikvr2B6BrEYT58B93UzQYV9hG/t6/lcyM 7eJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032759; x=1760637559; 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=wJonn1UQmdMquLncDUtZUHutcCuWRZij3zF+8bzYpyM=; b=dbicSwfhb6rS7nHbu9pxI0eTc8Oaa0UaCf/bcMplNYmXwOfKeoIZM4nWn7ptm3xtgW FTJCgdjs+34/mOhFw8oU1iUvAocG6rBWEAcX3CdWk75DlSvZctWY4jiWHAfnQwkWdyAh wFS/myROr7HupXX/9ctcX39Q7ml0UJZkPrEWCiUrzqwBY00BfPAlfEwiIZND65LA5hxD 743SYfBrIatuyZC4uwvY1TzqyD6UyoOjSYgIww6j5MIdaw+fQW3aSeFBQdRKE5Hz19Yn tDLQMK9u0CFknAwqK9K3Eoc8/uDCw2ozN/ojZ+G55rj4ph8jgCbeb6ikqsr1il0is80J 4dZw== X-Forwarded-Encrypted: i=1; AJvYcCXY9ytkqeJelTApjc4PmFKFkBkHwW6nixRq0+vN+T0sMACDXMLB+n7C9bLG7ynmiuEa9as9nYvNVNzVjyk=@vger.kernel.org X-Gm-Message-State: AOJu0Yzwg92h2UQuS1SEMGct6LJ16fgT5Qd7ZdVDE6QLsbKTqSGNeGhu Yk1l3zGNI0fDvWfSWvd9mFYnG5uzP83O7hIn/+S+2yvfgYLYVgGMvlhC X-Gm-Gg: ASbGnctlzwJlHhum7jsf/VLvS62DC+LKuWdMmslGpkONeRJpi31QSeGcU6E94k91ZKE m68xn2hkjP9FcwP3RjN3i+JpRlqf0u5hVCgqpRBq9ltIEQHS5jFbwcSL/nt0SiB1AFIMq2q7i7y UVFae8vt/yaf/j9KeuIofRoGYK+3VGCMtSgXK9RgOy2KiQ3cQKfZsjRhEBIeBHPg3WJomQbL078 50unU7OKjptUzqynKbHluMSJdoFmNZQTWva68DDwDEGCJSQs0WSIQFFYTrW5+456i2ghgbrhibV 30ui8sVP0WS5Df6LVn+uzuFTswXu9yJljoN4gfuP3ObMe4Zr+3fFfEjt/LBaWuONiqHxcwLcNLL ebZ9+J3m32j3NSIHxFJ9UlSxDNZ1pfjCqsh03gSLzSKAsiEp3QyaJuzO6NZk1G5wYmlslSIGoR2 f9Np4fmPjaVuQ+nQZ0vIKgLe7CUnmSNubEOVLq3Q== X-Google-Smtp-Source: AGHT+IHVKXFMusdqiPmDW/wzqUDYexOwse+E0pYDfFVpPjytm/THWwTC1XlwfHUx8Qo1uHRSZGwKQQ== X-Received: by 2002:a05:6e02:2489:b0:42f:9649:56b4 with SMTP id e9e14a558f8ab-42f96495934mr16480345ab.13.1760032758628; Thu, 09 Oct 2025 10:59:18 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59:18 -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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie Subject: [PATCH v5 29/30] dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(clname,_base) Date: Thu, 9 Oct 2025 11:58:33 -0600 Message-ID: <20251009175834.1024308-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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(). @DYNAMIC_DEBUG_CLASSMAP_USE* macro API kdoc is adjusted accordingly. TODO: This is just an api placeholder, it anticipates a possible need that may never arise. The normal way to add a new classmap to a drm driver would be to define the enum to avoid DRM_UT_CORE..RES vals. 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 6e0c978bc7c4..68bd2dbdacfb 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 Fri Dec 19 10:25:40 2025 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C17212F60B2 for ; Thu, 9 Oct 2025 17:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032764; cv=none; b=ACDeTkOmuNDXrSDSYD/vs6XI15otmIFipTJuJE6+7M+6IH7m9oFKSyxKhRNnNE8QV3ie2E9VXBxWfVkXRAfAsqrAoHWRbtK5SCtny5Gy1rHGOM1KfYgan37szKllQP6X3L6emp/ToPyf68HraTmDJjmd4mJLTyIGnZxRKuZTsnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760032764; c=relaxed/simple; bh=SAMH6bX/vL3va8sFv4toy+dDvica3sbvYihqhhgIHr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AyIcjQsAq7Rx7UrG5oXPin0acTj/48x79RClEJTOHvFaWSrThewkOhEN5cKdj9DugrWG4//jFLkJ9jdneAI8PBQ7gQM7oVcAYft3bGZZGV8cprAOgYeeaTOTKESnKmdhPFHWayT+WWRvmRkNKBxKSoNs97QAiNDKt2iyorBriqA= 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=D/aecxGj; arc=none smtp.client-ip=209.85.166.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D/aecxGj" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-930cfdfabb3so104074639f.1 for ; Thu, 09 Oct 2025 10:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760032760; x=1760637560; 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=D/aecxGje3VE6vLulOW8FRoB61YSczaqiMpCQI8RiIe0h1bcAHAnFyCeO958rJt1bu lJ5FrlTNaT8HAYNXWf5QF2oUPMRJl+NdQ6anuq1nu+QgCkvGARGZd1ifAQu/SCzjOZ30 mMeADlpfFxXrAy2fi6i0rFcvjKsFHOv+ftVex8yPrzJ5USrE7s9OLyvQn9Nh1MAXo033 mwoNupIWnsFft7R/tL76iuQZLuEiTOX5mz6B1y3kR2+wJTHI8C1e9cqHGvaGMx+fSfZb XX4w2hkRTDJqcGPXFtv9K3blX0xUHmR+A42TpCGQ+6Sm6wD/g3rf1L8y+6wrR9pmfaGn hoiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760032760; x=1760637560; 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=KK0WgplRSVXflo4/GJx9mIUglulHZdbWat/CeUSVMOlN2ATQN3QiK6znBbkpIcnMUW QY2icDQV2lqTOzdshnK1Lxu2Bjt5oENfk34C6kZbonq9FbKXqhFZ88jhx642eIszocFT +IiPEh6uVAe+KFPfT8A/Ak2muoN4ec58dDbMeaOrozSxNt4raKzDxQhFUcF0xWce+e9d VM6d4B4fktrPd4jMzhm0F79KixSGVbTmYzXebcTk3eloxdxZ3QFD8MH3zbHR/jHwF9C5 rl+R+Oxj7Yd5RhKBTI+VuMvDUdItRs9DqbwfTXOG96F2aibF0bNpakv0qlqffDCfgf/N +zlA== X-Forwarded-Encrypted: i=1; AJvYcCXYq+qifyvOreZl4HoBf6oVrKmAo5FBvSd4TsMN2fS0+/C8qn6BA7ww80i//j6Lr9axqS1BTNG4L5cu7CA=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl+ryQBvGsb7kTdfvkh+/5GfdMNUZbNg6m06QAAPLLuXDpLpve c6XVZbh5jBo9k4cMIhg/RDSWJgGCaAla9VV2yG27hB+3oQpM0acNtS/8 X-Gm-Gg: ASbGncufYqZj15X9GLU6k9zdlKqWVKNiLbv1MM1Dj8cefGex1fV+DeyogXB+FRWnXzJ XjSxOcmlyuwbAPKJpW2Nasd3/eSvD02CyOjeJ2aeRJ4eSM0XoKTlXrqXyUXoenXKdvTe7yKTwjX KsYwXDjIIgPDUnympwlm+G2h+ferxYzIrpPWYTQLmE1YuUaGAgNGh06PKAnDcC5QfEVJ2JEaIxE mbq+RyBijy5LDd6BRDYBWXlUv9JZ+LNcdGzCInmO6sv1TtxM4h3lp2pyAWjBlS6oAGYnARIgAMo EoUfg8TkQ9rK7pgbn+xUf9WTu9YqIvJj7TBtpiBFDnEDDYdR0liPP7GMS2e3txNQqW3D37QYp/u QjkUoyHpmNNLmnaQ8SJhrNQWBaKp2LjT5Gc5HCTEj8QE7VRHlHgC5ECxY3zdk90C7sqndRma4Vn IceIdSLKTBSN/3Yq2GBphvmHWPF4g= X-Google-Smtp-Source: AGHT+IFR+shW7+C0q+f1Fmrt23B3YTQHyjOfr3zpgzC23vGg6C8CMdPg7iTrZ94nDfkkiwmOyi5W4Q== X-Received: by 2002:a05:6e02:4405:20b0:42f:9888:48f1 with SMTP id e9e14a558f8ab-42f98884980mr10397445ab.1.1760032759717; Thu, 09 Oct 2025 10:59:19 -0700 (PDT) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-58f7200c4afsm30256173.35.2025.10.09.10.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 10:59:19 -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, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v5 30/30] docs/dyndbg: add classmap info to howto Date: Thu, 9 Oct 2025 11:58:34 -0600 Message-ID: <20251009175834.1024308-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009175834.1024308-1-jim.cromie@gmail.com> References: <20251009175834.1024308-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