From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1D5CA0EC3 for ; Tue, 12 Sep 2023 01:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235361AbjILBeo (ORCPT ); Mon, 11 Sep 2023 21:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbjILBe3 (ORCPT ); Mon, 11 Sep 2023 21:34:29 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFF614E70F; Mon, 11 Sep 2023 16:48:51 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so1508836b3a.3; Mon, 11 Sep 2023 16:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694476068; x=1695080868; 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=e6NIZdlLmgRQPJbwwmBZ102ypc9HsrQnlZpRMUUA7Yk=; b=WuPww4EZtLQn/iaQjipacQRqX7FORCnQv6ajdlhK97kBqqOHQSg8rt6LwxPtMh1HbB jhBzng7MYPquWuBBhd96vaHOWrENM/ziG3g0hEkNpd9Dkz5ItIlWPqiTsfn3hB1vUNUO bEhFrq9CnkvXgnIHDt2hWEanyu5IMD8AvYo2tPwzEnRldQ+Sn7XSISBWRGHmI0Z6fE93 cZwh5GmRa+E10f1kFzZP3WgdRFb4dIfkMq8M6QuIGNsqYHxGjnkCRX+74IeHfzJvPK6M zOBarIiQf73lMPpQoiUCcVflfQtk1UaHCbxvrxH/Map2zuagCDPwliKfQV3PFybmTwV0 66qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694476068; x=1695080868; 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=e6NIZdlLmgRQPJbwwmBZ102ypc9HsrQnlZpRMUUA7Yk=; b=cxQ+gZ6dP8u1WbhzgnUzwrs8f3EtylhO0VyHyJPtUStWNfbBlODNv2I80Bu8ovJ1WI nG9hKNVtUHMVh3RpHeXFcICwzpfSt3blNmwPNN8kd7cROTBZGJY21FNNzNB/rPWGzyU8 8C9d0ZnCFx5Moyx9aMOmWF+FjO+KNeBYZV+QCkpKb6fBXS4lFuQUMxg4D4PFdlUCJ7ow y8VTEKNQRm1p5HauJj5ZCV1frO+Tu+ZuZRnQgRK/6uLhF//kR6wOTV7btJUzcnzsyDa2 vSq1aw+h9rAOMpqN02nCCL60pLh2NBHqxribZZMytRHuzAKjAjc1YH69raMI/zXaieff XItw== X-Gm-Message-State: AOJu0YweQL9RP65ia/D35/gJ/KoGCcGfTuYwdy8xnZanj6Uvmk+aHOFP onNmO0CdtseRsB6GtpYtQi2lZHAYOo6Kkw== X-Google-Smtp-Source: AGHT+IFDCPReJlF/HoZtIiXFIPqYEeXcnDWZ2HXPByAzvqeS7BuEUfkb9nxR1SNOcZEto4daJII3TQ== X-Received: by 2002:a6b:fd0c:0:b0:783:6272:afbb with SMTP id c12-20020a6bfd0c000000b007836272afbbmr12043668ioi.9.1694473724899; Mon, 11 Sep 2023 16:08:44 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:44 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 01/22] test-dyndbg: fixup CLASSMAP usage error Date: Mon, 11 Sep 2023 17:08:17 -0600 Message-ID: <20230911230838.14461-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" more careful reading of test output reveals: lib/test_dynamic_debug.c:103 [test_dynamic_debug]do_cats =3Dpmf "doing cate= gories\n" 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 That last line is wrong, the HI class is declared. But the enum's 1st val (explicitly initialized) was wrong; it must be _base, not _base+1 (a DECLARE_DYNDBG_CLASSMAP[1] param). So the last enumeration exceeded the range of mapped class-id's, which triggered the "class unknown" report. I intentionally coded in an error, but forgot to verify its detection and remove it. RFC: This patch fixes a bad usage of DECLARE_DYNDBG_CLASSMAP(), showing that it is too error-prone. As noted in test-mod comments: * 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-62 class_id space !! * (build-bug-on tips welcome) Those shortcomings could largely be fixed with a __stringify_list (which doesn't exist,) used in DECLARE_DYNDBG_CLASSMAP to stringify __VA_ARGS__. Then, API would accept DRM_UT_* values literally; all the categories, in order, and not their stringifications, which created all the usage complications above. [1] name changes later to DYNDBG_CLASSMAP_DEFINE Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 8dd250ad022b..a01f0193a419 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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCC5ECA0EC3 for ; Tue, 12 Sep 2023 02:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240509AbjILCqu (ORCPT ); Mon, 11 Sep 2023 22:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232972AbjILCqi (ORCPT ); Mon, 11 Sep 2023 22:46:38 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4E5810DBE9; Mon, 11 Sep 2023 16:27:48 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-57756115f08so1535725a12.3; Mon, 11 Sep 2023 16:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474777; x=1695079577; 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=Mmy4CQw8YdfUBsoDy2sZHYo8FTokxGCRVZcEnly2Jnk=; b=lwre9pJUZcQTXRB60c0sEd2Vb0tYVOdpzPfRdUqw0I+GX0dA3rvrYXzSZBHvpiPZCA UiT4ewBCOrfd06QG0wEsrptT9XE3kPSCFfXolJYe/gIRxGucNHpFOXQMiLpB2Mj/GcT5 aAV1QvK20neqZrPrwlCmvMxIUZMXqetvcDB3DyF9m4fEEeoAxN/nkVOpk8Lf8Sa6faN+ YJ1En3kUjGuJYYLqeObDEuR7+6MoR19rF3ZToV/cNsLO5IjcJFm5n5TuACOBpw6fZgqQ 6VsJsgFovikYrUyiHPNqBlYFNbgrIz1IPtHD+ADGmiR0q+xhROKQn0Bk0RoG4bMLKWR9 1uDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474777; x=1695079577; 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=Mmy4CQw8YdfUBsoDy2sZHYo8FTokxGCRVZcEnly2Jnk=; b=Y1HQgNMbpSahLiDINmhEaPjd9SUOw2rA27GV3+0Cm0NIU6hDCU2OZqzGkByr9PiRqc VigpcI2tBSfDu2i3WH/iuab6NQHFFJDGCkKuNSL2eJy6NEr+Un8/TJvDOtqo9Nvap7w3 /re8G+UipZEKCKZxTresyj0hVuNwBUWmhray65tCq+EAeqoNBZkwHyUyzocGwbMzJyXS 1HxkBb3+Yr1KZ8ttiD4eLNXH0xDtskOC+bAhsp9a9coRJhQzfxqwaYcjjcaYGTrp+gpG YUPZs0y5FGUSc5wyTAbTsrwT844ujQB5mNqRk1JlJV3UOgNaYAomF7mScY6m4i0s3xtC Mqcw== X-Gm-Message-State: AOJu0YwdkeLUAv+bPIskUNjTDoOjL8CBRTdbPNvwl9MlUIkUyqiBR5Cs 5m4hNGrv1cKNLmKachwVaKt/Aj7Er4ZhuQ== X-Google-Smtp-Source: AGHT+IHLAdJUICDJlpY2SLsUaMJZhDgX9mAPnhl1PjVBKn7g0kArqTJLgGWW4MmaywrbY9ZEQTsn9Q== X-Received: by 2002:a05:6602:197:b0:791:1b1c:b758 with SMTP id m23-20020a056602019700b007911b1cb758mr13933894ioo.19.1694473725817; Mon, 11 Sep 2023 16:08:45 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:45 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 02/22] dyndbg: make ddebug_class_param union members same size Date: Mon, 11 Sep 2023 17:08:18 -0600 Message-ID: <20230911230838.14461-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" struct ddebug_class_param keeps a ref to the state-storage of the param, make both flavors use the same unsigned long under-type. ISTM this is simpler and safer. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- lib/dynamic_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4fcbf4d4fd0a..5231aaf361c4 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 fea732db7323..6fee76fcddd1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -796,7 +796,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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B780CA0ED3 for ; Tue, 12 Sep 2023 04:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235077AbjILEXg (ORCPT ); Tue, 12 Sep 2023 00:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234369AbjILEXU (ORCPT ); Tue, 12 Sep 2023 00:23:20 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6D98984D; Mon, 11 Sep 2023 16:10:17 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7926b7f8636so122846739f.1; Mon, 11 Sep 2023 16:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473727; x=1695078527; 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=KD6a1NkSA5INSDsMqMqwmTvtxNCeWnODIlEsdy3zKLI=; b=HcFIWWgPo8BaSMizAIetzih3Ef6Z6CF2X0uZoITBK2rYgNR7DvMSErnW/Dx8agUFQI rH4VgEBHEP5ardb9iVVqwsR64d8UjmcsTpgiv0ckvj3gxPRwHrrswPDpHiy63BXL5K76 /JVLuE+F5dmU/+p9n7iXVPOrIaJshZmiC0daFCKULvnxDn5CPUT1JveFciZXD2U8ZWaI Cc39gq5Z7d9gWNhmqCqEQMTp0qKGpxO7QvFnZ7fs0PL6p6t33YRPrdmF1MxFLNBSqF7D Nui9AIw+XnSpvxdba2mGNGxTttphcPcYFDCoqCHJ6Vie7IndTl4UFdkvm0uKskf47Xws Moag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473727; x=1695078527; 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=KD6a1NkSA5INSDsMqMqwmTvtxNCeWnODIlEsdy3zKLI=; b=mknrV4H8BJ0HKx+jlwHOc8ZAsr24N92aZHG3hhcgaNOv01d2JeaCD0Vrh2DvMosygv qsh8YoLQO6hFswq0InHwByhQ9P+XJ2QRRmx9L6H+fqb2NhMTErbWr3I427yo5zQmheA6 HTmY0Jf4wxP43diP8aztYHe9ZExAZX7qXt6hW+c1s15vCjdvah1G4GQ6TfFn0Gyk8dpc CCoA+m0a4Qk30MJRsDIuhWp1v/Fyb0wNtilRpPNoSxeeev/7yBb74PnoaVLMuiTPaJFr wSrpSCbyrZYh3R/X+yn1eLG4UfEoLPWgyUedepr2GzESBgyene91Mn/C2ijL+zblFpW1 zqsw== X-Gm-Message-State: AOJu0YwzHJz49xnPH53mbzUy5bClLRJLnHzQPtQPKzoAYMXWVZfV0jwX xJyJxVPxKpn/yz58FYI+f3vNrbHsbS4Clg== X-Google-Smtp-Source: AGHT+IGGA73qG0Y6Uf1hiy6xV0zty/FRZ0Y3ZD5c1D4e96M2er7/7eQ6p0vhoTQdRtxLs5Z+l2aVGA== X-Received: by 2002:a05:6602:2589:b0:792:6aaa:b54 with SMTP id p9-20020a056602258900b007926aaa0b54mr944372ioo.7.1694473726884; Mon, 11 Sep 2023 16:08:46 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:46 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 03/22] dyndbg: replace classmap list with a vector Date: Mon, 11 Sep 2023 17:08:19 -0600 Message-ID: <20230911230838.14461-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Classmaps are stored/linked in a section/array, but are each added to the module's ddebug_table.maps list-head. This is unnecessary; even when ddebug_attach_classmap() is handling the builtin section (with classmaps for multiple builtin modules), its contents are ordered, so a module's possibly multiple classmaps will be consecutive in the section, and could be treated as a vector/block, since both start-addy and subrange length are in the ddebug_info arg. So this changes: struct ddebug_class_map drops list-head link. struct ddebug_table drops the list-head maps, and gets: classes & num_classes for the start-addy and num_classes, placed to improve struct packing. The loading: in ddebug_attach_module_classes(), replace the for-the-modname list-add loop, with a forloop that finds the module's subrange (start,length) of matching classmaps within the possibly builtin classmaps vector, and saves those to the ddebug_table. The reading/using: change list-foreach loops in ddebug_class_name() & ddebug_find_valid_class() to walk the array from start to length. Also: Move #define __outvar up, above an added use in a fn-prototype. Simplify ddebug_attach_module_classes args, ref has both addy,len. no functional changes Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 61 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 5231aaf361c4..b53217e4b711 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 6fee76fcddd1..8b46d56f73a5 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 { @@ -147,13 +148,15 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 +#define __outvar /* filled by callee */ 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, + __outvar 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 +167,6 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return NULL; } =20 -#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -1111,9 +1113,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 @@ -1197,30 +1200,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 /* @@ -1253,10 +1257,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); @@ -1369,8 +1372,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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64029CA0ECB for ; Tue, 12 Sep 2023 02:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240211AbjILC5Y (ORCPT ); Mon, 11 Sep 2023 22:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240888AbjILC5I (ORCPT ); Mon, 11 Sep 2023 22:57:08 -0400 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82D68ED48A; Mon, 11 Sep 2023 16:20:22 -0700 (PDT) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-68fb7fb537dso1598636b3a.2; Mon, 11 Sep 2023 16:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474047; x=1695078847; 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=XG2hvXvpu+CwXLe5RvYP5VHJgs2lpeX9gvCj9Y1+mnw=; b=XsDYWwakFO+7jKSteMsIzsz3WXlZtY0GZLnhrshfKBU4uTJMDpcykziyNpmqu8ykF2 ZnHiOoNjmS0zHiMmAh8rCJqLLlMd8HBrWFb7ttRI8UOHtdeFMTabS6rZZ202wJfmRbaA zGSh+/tf8hEQWXqQKGwWtLpgqFifpLG3Ry7SX3SY8rVx8POYpaUPRePy9MULj6Kj86lW w3H1L/iRYexbRB2V/PNehEcilp5Ra1MEj0xpTTOwrfg8lfwiHeHOj97U09Nl9d/MoFqz pvdcFHA2yyhle4zfuZeH9F3XQGEkRo5bE4LW98+aWNrt/ka5RM+9Sjmhh+cjh7SO4MsP d0AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474047; x=1695078847; 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=XG2hvXvpu+CwXLe5RvYP5VHJgs2lpeX9gvCj9Y1+mnw=; b=ousK76bVr7lv4OdkhKRs6HZGEhlW/EESHdIk81G+eAdm9t7+JiIhf9ZVBaHbelhUAW 9k8eUGJ1jxNAQ8TELFmH45qwijFB4GDTyw9LUzEzxx0RFAubEUOtEr6ggIviinVvoCyD HSTbOuVUWFBVkAC07YhElhgZjgfLdBSsAp+QkmX0iuVVKQIt5caUk10gDXmCjnKzZwWA U72E48wOQ0kla816zOFD4JJIfDfae2hjlhMqLUw0jEQWJSyBYnPJjRQRmxUqQ0vNND4i 4DfsW/jlxR2V6m1Jr85M4h/XEDc+PaAHUARiv2kIcww6epnL+k1S5TvdM51k4kq7Y1GD 02MA== X-Gm-Message-State: AOJu0YwUKKmLga8m/CzDsOZdgtFnbrn+3VrMMrhQ5t1R5egxeeuvRnV7 QNkyVHbftAV8npFoX4GilnvmglVKD8WkLQ== X-Google-Smtp-Source: AGHT+IGhoZR/xi71flAbPieb3hsWi2v+VcLM/kavgf+PV8b2YYOhFDThzUzK1pVKlVI353E6TakjrQ== X-Received: by 2002:a5e:cb44:0:b0:792:4d29:ecc7 with SMTP id h4-20020a5ecb44000000b007924d29ecc7mr12515289iok.15.1694473727936; Mon, 11 Sep 2023 16:08:47 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:47 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 04/22] dyndbg: ddebug_apply_class_bitmap - add module arg, select on it Date: Mon, 11 Sep 2023 17:08:20 -0600 Message-ID: <20230911230838.14461-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add query_module param to ddebug_apply_class_bitmap(). This allows its caller to update just one module, or all (as currently). We'll use this later to propagate drm.debug to each USEr as they're modprobed. No functional change. Signed-off-by: Jim Cromie --- after `modprobe i915`, heres the module dependencies, though not all on drm.debug. bash-5.2# lsmod Module Size Used by i915 3133440 0 drm_buddy 20480 1 i915 ttm 90112 1 i915 i2c_algo_bit 16384 1 i915 video 61440 1 i915 wmi 32768 1 video drm_display_helper 200704 1 i915 drm_kms_helper 208896 2 drm_display_helper,i915 drm 606208 5 drm_kms_helper,drm_display_helper,drm_buddy= ,i915,ttm cec 57344 2 drm_display_helper,i915 --- lib/dynamic_debug.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8b46d56f73a5..592a700adcb8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -601,7 +601,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) =20 /* apply a new bitmap to the sys-knob's current bit-state */ 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]; @@ -609,7 +610,8 @@ 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); + 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)) @@ -618,12 +620,15 @@ 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); } + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bit= s, + query_modname ?: ""); + return matches; } =20 @@ -679,7 +684,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]); @@ -689,7 +694,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); @@ -752,7 +757,7 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) 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); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, NULL); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -765,7 +770,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, NULL); *dcp->lvl =3D inrep; break; default: --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 636CDCA0ECF for ; Tue, 12 Sep 2023 03:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241839AbjILDOx (ORCPT ); Mon, 11 Sep 2023 23:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241437AbjILDOj (ORCPT ); Mon, 11 Sep 2023 23:14:39 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F77B08DB; Mon, 11 Sep 2023 16:15:42 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-573e0d471ceso3311869a12.2; Mon, 11 Sep 2023 16:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474057; x=1695078857; 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=6OB8bUmBTX5kKvQ4ZxUIAC9aMicC4lfL3UKEwiwbQF4=; b=rE9iSlm2Nb9YbjQHS4uwWrj59RCV69nGqI9G6NclZ5b3Ee1rUnIwUBrI923eQZvKZW zHk+qN1C9y6eN60t5Tcyf3D1xufdV0iz2HREnC3N0GLR6io+e+/CMy+OeD536TaFnJ6f rQEPgRh4/+GoPGBuChUl23TZDISi8M6grkTzXF8RQWwn2wQb3KBsv+LmRR6DfdPhLnM1 8/08mtKWW2JHO9XzdA0Nu6cdBPoH05unlkSnFFcZOTEdYfX1+iPGQyLcXm0QFOaHEZb/ NRiPI4p+p888qX/NZvWeQjbShqUaoGZ/XNWr1SabB/kSVOmx9plLrRXXo0FIn1LM3KDm Iqxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474057; x=1695078857; 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=6OB8bUmBTX5kKvQ4ZxUIAC9aMicC4lfL3UKEwiwbQF4=; b=KrVjtIvXX9VRpNsk4Hj8KYhLVzAyVGgaitZHslJW0nELxld1MxRXc4nD7EnZ00/DDO A/mcBIeA3behx7GbseEDQwvyu4x2M55l2cCnN3joComRgBRRAO3mfRu7pUMWYL9GgsZ2 iRJ447UrQvkiMmpIxNp7LiZKc7LvKSGhwuRPmrGEi85hFsDWc71M797EdRT9DeoN0GuS HWs7k8dO0vnTHabmUSj3QntehRpoc3BRgtBBIwo5EFrSvTQC32uw8VqnGo/+9yUOSCzs LMK6VCark1TVJSuld19RMZf6TQc5uIaWtkXjM0snI621PuS5nZRu0I24VbWzd1rgHga9 IHHw== X-Gm-Message-State: AOJu0YzzF8zPviYgUFsu++LiFVWRvstfOsn+he7QwH2E8DIJA7yB3Bkf avdPodKOswIkhlbp4nVPTwja4iQYit6epQ== X-Google-Smtp-Source: AGHT+IFF0NIg0EvQsa4Dg6fo1g7OF6OwEySZ6KWY/DeO+qCaWimrRUc++BjjQsZ9sd7GXWD+9FOgYA== X-Received: by 2002:a5d:9d18:0:b0:794:eaef:f43e with SMTP id j24-20020a5d9d18000000b00794eaeff43emr13191253ioj.1.1694473728918; Mon, 11 Sep 2023 16:08:48 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 05/22] dyndbg: split param_set_dyndbg_classes to module/wrapper fns Date: Mon, 11 Sep 2023 17:08:21 -0600 Message-ID: <20230911230838.14461-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" rename param_set_dyndbg_classes: add _module_ name & arg, old name is wrapper to new. New arg allows caller to specify that only one module is affected by a prdbgs update. Outer fn preserves kernel_param interface, passing NULL to inner fn. This selectivity will be used later to narrow the scope of changes made. no functional change. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 592a700adcb8..153e02c3af45 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -708,18 +708,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 *modnm) { const struct ddebug_class_param *dcp =3D kp->arg; const struct ddebug_class_map *map =3D dcp->map; @@ -756,8 +747,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, NULL); + v2pr_info("bits:0x%lx > %s.%s\n", inrep, modnm ?: "*", KP_NAME(kp)); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, modnm); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -770,7 +761,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, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, modnm); *dcp->lvl =3D inrep; break; default: @@ -779,6 +770,22 @@ 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 - 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) +{ + return param_set_dyndbg_module_classes(instr, kp, NULL); +} EXPORT_SYMBOL(param_set_dyndbg_classes); =20 /** --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4E96CA0EC8 for ; Tue, 12 Sep 2023 02:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236803AbjILCRz (ORCPT ); Mon, 11 Sep 2023 22:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236928AbjILCRm (ORCPT ); Mon, 11 Sep 2023 22:17:42 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5008EE3C05; Mon, 11 Sep 2023 16:10:13 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-34f359949afso16193895ab.1; Mon, 11 Sep 2023 16:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473730; x=1695078530; 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=fEjUcd2gIGh+rcuXSmEeq7H3LSdL8L2dg7mL1DHpCLA=; b=ASO/gCBVMz/RJd6PZ9BAME2Fvmw5PGyUx6hD+ebsaE1A6K19Z3ZdaF2W+bB3249hEU P4M+0eSBoxQm96j8ahaiaSgxi9NOYCuMyM5WqZYexQo+/ScIbmNiHAKiSGew0dyna2iV DX92s3QBin49PWpmmkazpeqESP/Eu2Cabbd3SpWK2waIfxFwMdqvYtnfHDy3IYiA23J1 LCr73sV9dRGYPWei5flwXuLu4NIxzJNtAYkWgqd0tIHrEIww4J3nbhb8SWOMsjlgmSlZ aC7SEREOcor0Ocv1hzQBJDwnQ136aoXm+tFjnRp30ajJ0kllVFvi5aECpg5Afuv1phtd f6XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473730; x=1695078530; 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=fEjUcd2gIGh+rcuXSmEeq7H3LSdL8L2dg7mL1DHpCLA=; b=op7aET9RHuVf2xriorKjed+AfspdMY0jJy03Vsp1yvWU1PcTGKCyoI/y+BKVJoK47F w4bEXvIK/2rdjpMDvpYYbCeEz+jQOe5Zhnw5jAI73g0IeZxjZ4kp9aVrPkg7Z7yCuGfC BAD9qLil2QGkN45CIhir/haGRlrd/r/fHZ3RzBoWfcxlsUlMaH9eyTMaO7eOSUYm9TuJ D59qqBCQGcRJoGqtI4KKWCADisDgYOp/+pKtn0sggfbqBJG3Hqkr3bg33PymB9zpvdZ6 dEB85IdiGEaxvH4X5kOCknv0n4EVtaiRFkx9NvLzcpuTtPIyIs2LRIfb0Se/gOH+Tj5r iOWQ== X-Gm-Message-State: AOJu0YwWzlVWAKINUrA4kLFj5Z5am+rl26if0PNBkRqS8RC9hBWPAYaS muhpGAoldc13LOXimwUk04w= X-Google-Smtp-Source: AGHT+IGw9roeHaTtQyntmQ3xkyrxGL7naAB4H6rnS/E49+h4wJE5jfxNNoP6S5fKLhiwQwEVXDx5rg== X-Received: by 2002:a05:6e02:20cc:b0:34c:e84b:4c5c with SMTP id 12-20020a056e0220cc00b0034ce84b4c5cmr13702891ilq.27.1694473729966; Mon, 11 Sep 2023 16:08:49 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:49 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 06/22] dyndbg: drop NUM_TYPE_ARRAY Date: Mon, 11 Sep 2023 17:08:22 -0600 Message-ID: <20230911230838.14461-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ARRAY_SIZE works here, since array decl is complete. no functional change Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b53217e4b711..8116d0a0d33a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -106,11 +106,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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B79D6CA0ECB for ; Tue, 12 Sep 2023 01:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233346AbjILBrx (ORCPT ); Mon, 11 Sep 2023 21:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjILBra (ORCPT ); Mon, 11 Sep 2023 21:47:30 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE201140E8C; Mon, 11 Sep 2023 16:44:43 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-56a8794b5adso3746442a12.2; Mon, 11 Sep 2023 16:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475812; x=1695080612; 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=8XrchSCMiBfDcdDfNQlv8At+eGFJmxlivKt7lhA3WVs=; b=f2tP2fhsGNYNbFghIDn7ogQJsY+lBvUW+hhOORlpZEX1mFzAkkjV8PzKetG0eYIz4P V4iMZkmcfEBdyj/7E0kfSUdQj4g2DxIZlw9BNyqCn+9pH/X83aqozZQ0ic23bn5d1+8n 4nIkMBnsT4KFKZxZNOrOkVWq4scfWSm+8tCYMbX5Mw792SzB0POhiD+OgbGMUjcSSSON 1wS4OHo1UrmLBbIL4yJiusFtRufNN4/F8ds/dLM1hv4tiuv//Hstpk4iEhIhP9U8jGHI Y3DpoC6pZnDvYbAGTD2bkkaH8ip7UXJHbL+bHD00jv+j4Y5HanZ7wngHwAlvh+AQEnH1 /OTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475812; x=1695080612; 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=8XrchSCMiBfDcdDfNQlv8At+eGFJmxlivKt7lhA3WVs=; b=eCoH15cIZXDJcxTw6rjhNb3+s3bZlTUi6vaGrrtqNatOIaH4PcIJ4iyqZh1joIVHoy +zZ8MBFufvXQ8txJ9h5sEAlpjfza6PPZA1guba2UOezq0oUF0riymfyIV3TQspFkZIvp JVq55eut5XlKgu1wQUJG4DyhzKo8TrErRGqe/M+bpwTbWAiEgeA37+/6/u7M7ZFOCd1Z 30gHR/s1VHZxBeajd4kK3p/eVv5jyXuLTgP0NG6Ge8XSU+QUM6t1fftiSgpzPDI8bz5B unLZR3nDFuoxfRLDCJ5J81+Z8QbcVy1M365pnN3VulCjwJDicfUj4ipvSHxDg44lTfib 4Org== X-Gm-Message-State: AOJu0Yz1PlbvUKYHO7LMVJ8AjERQe3uiK7O/z34u7u3OFSuT4WLHj6bB 55lPa3YrVdnh//XTT8ALDc71ouVx5Q43Pg== X-Google-Smtp-Source: AGHT+IFKzHEYx4KAVeVJ735FfnDykwRs6Gp3mr7oskaB5XgkICwg7t63Zs9Skn6AnQv2Br6qeI2/OQ== X-Received: by 2002:a92:1e08:0:b0:34c:a532:615e with SMTP id e8-20020a921e08000000b0034ca532615emr12713121ile.17.1694473730939; Mon, 11 Sep 2023 16:08:50 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:50 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 07/22] dyndbg: reduce verbose/debug clutter Date: Mon, 11 Sep 2023 17:08:23 -0600 Message-ID: <20230911230838.14461-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 is like 1st, with result, not procedure. 2nd is just status, retold in 4th, with more info. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 153e02c3af45..f64d55d191ad 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -266,9 +266,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 @@ -497,7 +494,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--) { @@ -511,7 +507,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) { @@ -527,7 +522,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; } @@ -537,7 +532,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); @@ -555,10 +550,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 --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97DF6CA0EC3 for ; Tue, 12 Sep 2023 02:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240721AbjILCwu (ORCPT ); Mon, 11 Sep 2023 22:52:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240609AbjILCwc (ORCPT ); Mon, 11 Sep 2023 22:52:32 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6C8846A5; Mon, 11 Sep 2023 16:10:18 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-34f62d318a3so7907885ab.2; Mon, 11 Sep 2023 16:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473732; x=1695078532; 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=OT6IFguW/4DLumHawSixfP36EK45t059NQqpOGGT6yM=; b=Waa+yzyxK3QM/wgsl+0+9LT7g1lCAodN7oVr/09Fxc7j9ILshvzBchzazJ1r0R7MUb UyXJxpqlX3tHfpQVLnAOS/GMjhng2X+tDDDmOEJb/lU6OXpS3dpRMg5ybAYhnHTFc2UO +op9/wbsl1BKY/Cr0b2Hp7bIhRfF2iMo0mN5w+G257TjC1WTvw42cO4aAoX/vApwLpah 4aw88hPH6RfhfKn6pvg6NZ+jj+bHyKlEz2SUfVQzK99HGGocippH3WA4cyGvqBXBDeAR W0dRiF7pVU4356JsrfnBwo97Q3E1nbsSfpFmwcOjhXsB1EpWJfXi7AhvLlf78vcbw8YS 3PSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473732; x=1695078532; 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=OT6IFguW/4DLumHawSixfP36EK45t059NQqpOGGT6yM=; b=RIIPlP5y41kk/pWEiNbkuEmMi4RukA/oE1EaU9fL+FmIIN9QLPOKsoLfAQFYmUTym+ 3Eoc0zX0YAkx4z4AfIC7+kiiW6/+DLQrl2xUZQShnCmZugWP5UfPTsZ798H7nRLj3Qrk QJ5kMmkO09EwCYScdLnw62mOCWrF615kVr64g9siIwHLYNXAa0/fKC7L8RY8kIorhxvq nP+PWrQe0dU/IUYcyFIgHbfGomtAx7MRTi/IFin3vPpIA3lmuMLPm8rbzH5ZwoVp/DXs Bofac35NsV5fTr5G0m87tF4U58l5YvuRviTnlDp1F2wJ7GY8su2X+gEPYFk35dVc8oRt ya1Q== X-Gm-Message-State: AOJu0YziYBHFVhfdgHxeCGh5dsbofO6/8J0ZhcTO6e/B7+Cef0WrDi48 /QSWpqdND6LVjKkmzku4JE0= X-Google-Smtp-Source: AGHT+IGXcqZsyEpWo/sj2dkS8Od7PevZHZxGLE+VJj9Aw0UXdcHekh90w4d4NlXrlxpXOlQNiZOmkA== X-Received: by 2002:a05:6e02:961:b0:34c:dd54:10c5 with SMTP id q1-20020a056e02096100b0034cdd5410c5mr11705350ilt.10.1694473731983; Mon, 11 Sep 2023 16:08:51 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:51 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 08/22] dyndbg: silence debugs with no-change updates Date: Mon, 11 Sep 2023 17:08:24 -0600 Message-ID: <20230911230838.14461-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" check for actual changes before announcing them, declutter logs. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f64d55d191ad..05c777dedf27 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -591,7 +591,7 @@ 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, const char *query_modname) @@ -602,8 +602,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 bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bits, - query_modname ?: ""); + 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)) @@ -618,8 +619,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); } - v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bit= s, - query_modname ?: ""); + if (*new_bits !=3D *old_bits) + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); =20 return matches; } --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 155FFCA0EC3 for ; Mon, 11 Sep 2023 23:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjIKX4s (ORCPT ); Mon, 11 Sep 2023 19:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238267AbjIKXyP (ORCPT ); Mon, 11 Sep 2023 19:54:15 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D37E1249AD; Mon, 11 Sep 2023 16:35:31 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-58c92a2c52dso47247447b3.2; Mon, 11 Sep 2023 16:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475250; x=1695080050; 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=jIIYUwBsaiu36WnKQykm9kj4fLnG9Ddt/hz9ZLesgf0=; b=sa6qDk65HhA2zDz3TSk4R8oQvuZokDPgC/DVRWbl2pa1UFukGMk0q2V4FDJZ2UGG77 +8g8qw49P30op5bjAqpJNTFH46auCP7PJYO/xDjBWzrFl2Du/MYJR2dp1VAq3hclvR98 +kOUkaCoJguSXqGBLG9J617BOQ55Lx6zR7TmDuTeTb7zG0Z5tRvQH8xatYtlhFiQS2aa t0Q+B5ZIGbYSh7ett/iaF3KNMZ6i1oEjtEuIscIrqkvL5zyirZYKbHM1R8Cz5GNNNNmv 2stShTRX/krApSXvoAS0+uqgNc405wpa/5RGqFLaTPCKkaPeYFUR4YpNTUlmWwbHnfmp iSNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475250; x=1695080050; 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=jIIYUwBsaiu36WnKQykm9kj4fLnG9Ddt/hz9ZLesgf0=; b=OLSmb6LfI9EIFuYCnaaXdngIJswqDkLzAUj39E4s56onkiLYXKrYh3KXsUZ6LSDOT3 08alyDTJt/c5HIbTll77RKNp/KQB71eYMhToFnNXYvA7tLwDRtHnemO8QypdTlAy/wMh wLXX5zRQLNqGE6IboK1/J1V/ewkiwzmb2bAbbWMwmvMcvd31Ow4HfdqWrdynaCMxxJVo oLX4HXqti1g8h5i3hpgtO5JCaMX7AyirhwXrD3P3pyC4O+6zJ5E4pcEKhrsS/ncxdXWR fTx6e2eDXfqJNWPYS0jccZ9tNbYvArvRx75ynaXxvk04k89ZFksoPy6CwSxTYkYoCMTc SIKw== X-Gm-Message-State: AOJu0YymYh8+5tzwm50Y/Of+QuVjS8XoQuaYz7tgULHXYi3ILdyDrFYQ MRTuTzLeXz+Ql6l8WiEc+svG6TEoBjGWkw== X-Google-Smtp-Source: AGHT+IH4lvM9n3Sq9J/JyIhbgS3K6eNigqCkdj6RF5icXfyb3Ss3T/pl8jMa+w92YftWgv11YJIzZQ== X-Received: by 2002:a6b:fe07:0:b0:795:12b0:c2a1 with SMTP id x7-20020a6bfe07000000b0079512b0c2a1mr13897349ioh.10.1694473732975; Mon, 11 Sep 2023 16:08:52 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:52 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 09/22] dyndbg: tighten ddebug_class_name() 1st arg type Date: Mon, 11 Sep 2023 17:08:25 -0600 Message-ID: <20230911230838.14461-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Change function's 1st arg-type, and deref in the caller. The fn doesn't need any other fields in the struct. no functional change. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 05c777dedf27..e8bade6c6c06 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1117,12 +1117,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 =3D dt->classes; + int i; =20 - for (i =3D 0; i < nc; i++, map++) + for (i =3D 0; i < dt->num_classes; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1156,7 +1156,7 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) seq_puts(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 --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02F5BCA0EC3 for ; Tue, 12 Sep 2023 04:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232315AbjILEG3 (ORCPT ); Tue, 12 Sep 2023 00:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234013AbjILEGX (ORCPT ); Tue, 12 Sep 2023 00:06:23 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A94109E4B; Mon, 11 Sep 2023 16:26:52 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6c0f4ad9eb1so631144a34.1; Mon, 11 Sep 2023 16:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474718; x=1695079518; 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=fjU+yrhR2TAHVdG0q6RnBANC6+aiaYiRIqaMqsgmjjY=; b=kFEXeqRN5Ct0UVzT7ErHUa1i86Bt0rI5tXgXamGZWmrT5DEUcsxpNsuVjj+aTaEur6 ZlTvXo+sE3tgAY0HQ1jUMJqHqDlP0+XAE2uYAqaRwIhywqS+m1/RP/MTECqxEaJ4z3JQ aElWEUCLqqqnLyveRkaLaSXa76dTGlK53K4evD+zmf/uXviXQ7L1f+XrcKQk36IRpUuP JS0X5lXDCHFciZ2rSjPQfHnulyc2e75YONRE4OVdPQCbSHNSUs4/RUiS2FDUo8jAt+BW UXTCau+7jDhAQKmftgLLNc+aMtzw+nyAIo6Ak8MuiUGttKh1jBRXuQeKO5VoJDOMZ8uO Y/Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474718; x=1695079518; 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=fjU+yrhR2TAHVdG0q6RnBANC6+aiaYiRIqaMqsgmjjY=; b=X8LUDH0/5dHfezSLwsW8QDYyfvyLR44OEOt6ZPKp7+2fetLDvHy9Ji6RdSZ53rwuNM IFEVk4i6PaPHO8yh3I50QRxVZNDP7n6w9a5BEbkWc9nyG6yZfgdfU2CjMBseDkj+Tpiu 9zcSe45szo6UYc9iZdAf65BhXzXZsquNjK2WH51i+jO5E/GxXg493FBJwKJDR/Q3jF26 5c2tQyFm2iaSfLP6TyTmgMWfXcOxxpS6HkFsNgd/70Yz800r2/gy36lNw8f7WWKijM/X JGZTt5udx8wzaxFvLg9EWjf5jRnJw1pSa5PT06keHFPcUWx8cQ6iomXJQekA1uf2PzoY CFSw== X-Gm-Message-State: AOJu0YxTs7o/LpBOEJAelu4sgtYFJY0FJUNMrTwtnxv1yr6BlA8Trv+a o2zlqsABAi7RZJGRgj5mrwQ4cWcDUDanGQ== X-Google-Smtp-Source: AGHT+IHVMIL7oYmmkHbnwRvyhhKkW24G/hg+6cDPwpDjFBjd/UXHDYiLYSR+5YIP1tXudZg82PYFig== X-Received: by 2002:a05:6e02:2163:b0:34f:6f29:cb81 with SMTP id s3-20020a056e02216300b0034f6f29cb81mr7039060ilv.18.1694473733918; Mon, 11 Sep 2023 16:08:53 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:53 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 10/22] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Mon, 11 Sep 2023 17:08:26 -0600 Message-ID: <20230911230838.14461-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 e8bade6c6c06..13cab20029e6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -593,7 +593,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 @@ -602,12 +603,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], @@ -619,9 +620,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; } @@ -678,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, 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]); @@ -688,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, 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); @@ -742,7 +743,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, modnm ?: "*", KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, modnm); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, modnm); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -755,7 +756,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, modnm); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, modnm); *dcp->lvl =3D inrep; break; default: --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 692A0CA0EC7 for ; Tue, 12 Sep 2023 00:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232952AbjILA7S (ORCPT ); Mon, 11 Sep 2023 20:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232815AbjILA7L (ORCPT ); Mon, 11 Sep 2023 20:59:11 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A5C101104; Mon, 11 Sep 2023 16:41:01 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-76f066e4fffso309111585a.2; Mon, 11 Sep 2023 16:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475586; x=1695080386; 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=PgotoBDY+gd/GbWrUEhUI5vtR3kWxkuk+o/lROtivuw=; b=rw9G8ee+IzofAWeL+r6sKmKkVQp+hvSoCqZrs37D4hbA2DqwsxqwyZ3czNhPuld1gW dBxwN5eIqLzpFN+SrlTbzw9vG9//M1X0MTkXy9aJKKjV6Hkl5oKBhBT+B2K+U9eVtwHi eLor5SEh2PHEhGuKbdHpOxGCTIG0XwW7eQAzf8JOnWMjMqn6mk8I4BpXqpYGa663DvaA Vci0cnyRZl9phQBZ6R43y+ICfByQIWG89WoVXWUIBvoIg1xVrMrdT7+MIRtnelvxrPlF Ss36rEWQ9Gc3hgQPB4NLEpJLm6+tTgZ9l6YK2fWtykmojdrFq9I2YRbVLBuodcF0mARo 7vmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475586; x=1695080386; 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=PgotoBDY+gd/GbWrUEhUI5vtR3kWxkuk+o/lROtivuw=; b=lTPBhyJ0oFtA9lx0OXKzqiTwfU6EYyGdFbc2LKs0lq1VKO48hxnYMyXIkSfNoCuM8v kKqKIp2H6eUSM6HJBw1czjFvCzqL/rMDKNWYK1IsuEeTmjCokRxIZZpXESaovhdYDW3/ rQeWLtdQbxwTfcnfmF7tbmJF8f7AGedFjFMPnreEbu1b91WWhpSlbUbIYXQvK3GEX2m0 RHU5Hs6EzvzL+ghDsiTB4678zVM0eliqmWy0a1bOf1j6Gymb/aw9NMaH6X+7E4nYfl5G lVdb0nPrNMAVbXpgD8Wff/whFqEGStpYXgWT3Bn5Milr3LCwX5PjIMg9hgTXhMmc0k5x WtUA== X-Gm-Message-State: AOJu0Yw+3m5MNn4+0fjV1ji1wmBYY+q4Jzbk2npaS3ixPmsnSYYvzs/G 3EKL/ZIsntWlPzr2X8eqgVMKDVZFqDb1rw== X-Google-Smtp-Source: AGHT+IFO6poRENmHcVFDDs0Xr995LyLDypizHUJzt8kgjOBOx6csaPMrAKxev7j4sSo+AIRGiBxr5w== X-Received: by 2002:a6b:e014:0:b0:792:70f2:a8ed with SMTP id z20-20020a6be014000000b0079270f2a8edmr11702687iog.4.1694473734949; Mon, 11 Sep 2023 16:08:54 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 11/22] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Date: Mon, 11 Sep 2023 17:08:27 -0600 Message-ID: <20230911230838.14461-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the NAMED class types; 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 simplify things for now. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 19 ++----- lib/dynamic_debug.c | 103 +++------------------------------- lib/test_dynamic_debug.c | 12 ---- 3 files changed, 12 insertions(+), 122 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8116d0a0d33a..8eaf8eabdc8d 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -61,24 +61,13 @@ struct _ddebug { enum 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 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 13cab20029e6..6fd945e6719e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -632,77 +632,6 @@ static int ddebug_apply_class_bitmap(const struct ddeb= ug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 -/* accept comma-separated-list of [+-] classnames */ -static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) -{ - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; - unsigned long curr_bits, old_bits; - char *cl_str, *p, *tmp; - int cls_id, totct =3D 0; - bool wanted; - - cl_str =3D tmp =3D kstrdup(instr, GFP_KERNEL); - p =3D strchr(cl_str, '\n'); - if (p) - *p =3D '\0'; - - /* 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 *modnm) @@ -711,29 +640,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 */ @@ -798,12 +715,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 a01f0193a419..229eaadee838 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -102,10 +102,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 +125,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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0766CCA0ECB for ; Tue, 12 Sep 2023 02:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240626AbjILC5B (ORCPT ); Mon, 11 Sep 2023 22:57:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239889AbjILC4u (ORCPT ); Mon, 11 Sep 2023 22:56:50 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1161190C9; Mon, 11 Sep 2023 16:38:18 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6bf01bcb1aeso3661604a34.3; Mon, 11 Sep 2023 16:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475427; x=1695080227; 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=fkFQKBHB4GG8/l3RECixev8OXAqa/tD0dG3NgASD47c=; b=eyl5oH7Anil3gkv6atTgZIUtpJE4quztPRNYbU6Ot+lMHzHaTHs88UNxQI3mLBYvLw M0NLRxFXkqEzWStIXCcsneMfTqIYRVF0YlOz3IAQPazXkDich/Gd5p/WcOg+OV1AbbKl 58tEmoDjp19aIpi3j4DhFvg94vf/Cey9tmUZCertNMNa0GAx2DfBE7KvFDciPJ/PHDY5 MRABzz39nMPkJIAfgm/YK4Dqx992eYlglS0VI5FQJ1K0SR7W3IPJaVBN3CCGK02hUMKa 2Z4/jl6BPmJgvOgAy4n4EsLkxxBuKxwH5atsPvthINdo/v3Q/71dwet4cm8Hc10LQlmF 0zqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475427; x=1695080227; 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=fkFQKBHB4GG8/l3RECixev8OXAqa/tD0dG3NgASD47c=; b=l7ECdCQxC7Q38udKciHOT/UhTXbpl59NthRj/u2ggSkSBZiVfYCNSRsTVFe9YcN2WW E2GiyQ8yHR7pLntbtZ6sKQcGlj913A0Yjx9i0S712qqG0DwdsrULHMrCxxoJ0iIHxsNm dTBNAMsTf2Xqlo0PqPYPxZFkkYPLWAidP0q/RuV1ydjQqfiwAn2pOGfuEE0hk1URW5/L QzwIZfO2UgH2dngqY2o1w29IovarEZfTqJucEH8HbhzSaM1TVCWtAtjICAIyHz+xy26V LUqBUAVuU3hu3mqkCJnqFzVSlF4YwYqpcWnI47N/e+uahcmhtIFDRTypx/mAoFytrbGe pi9w== X-Gm-Message-State: AOJu0Yx9yAqyNSoDtbOQF3QIWwTR+8e43xrfW+qps+fnje7icdBY+oNU HqLZFEuIRweorune33BaYEoP9gLXSOro7A== X-Google-Smtp-Source: AGHT+IH56XG0z8gyyMNha3eeNUT3deNlrRmXu0OMEwcExOq4sOcn1DpFfvO+dr0oM8xVWEv1QCkkDg== X-Received: by 2002:a05:6602:2e82:b0:792:8230:c17f with SMTP id m2-20020a0566022e8200b007928230c17fmr18279059iow.13.1694473736222; Mon, 11 Sep 2023 16:08:56 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:55 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie , Tvrtko Ursulin Subject: [PATCH v6 12/22] dyndbg-API: fix CONFIG_DRM_USE_DYNAMIC_DEBUG regression Date: Mon, 11 Sep 2023 17:08:28 -0600 Message-ID: <20230911230838.14461-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DECLARE_DYNDBG_CLASSMAP() has a design error; it fails a basic K&R rule: "define once, refer many times". When DRM_USE_DYNAMIC_DEBUG=3Dy, DECLARE_DYNDBG_CLASSMAP() is used across DRM core & drivers; they all repeat the same classmap-defn args, which must match for the modules to respond together when DRM.debug categories are enabled. Worse, it causes the CONFIG_DRM_USE_DYNAMIC_DEBUG=3DY regression; 1st drm.ko loads, and dyndbg initializes its DRM.debug callsites, then a drm-driver loads, but too late - it missed the DRM.debug enablement. So replace it with 2 macros: DYNDBG_CLASSMAP_DEFINE - invoked once from core - drm.ko DYNDBG_CLASSMAP_USE - from all drm drivers and helpers. DYNDBG_CLASSMAP_DEFINE: based on DECLARE_DYNDBG_CLASSMAP, but now it drops the static on the constructed classmap variable, and exports it instead. DYNDBG_CLASSMAP_USE: then refers to the exported var by name: * used from drivers, helper-mods * lets us drop the repetitive "classname" args * fixes 2nd-defn problem * creates a ddebug_class_user record in new __dyndbg_class_users section this allows ddebug_add_module(etal) to handle them per-module. The distinction, and the usage record, allows dyndbg to initialize the driver's DRM.debug callsites separately after it is modprobed. Since DRM now needs updates to use the new macros, it also gets 2 wrappers: DRM_CLASSMAP_DEFINE, DRM_CLASSMAP_USE which declutter the users by hiding the ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG. To review, dyndbg's existing __dyndbg_classes[] section does: . catalogs the classmaps defined by the module (or builtin modules) . authorizes dyndbg to >control those class'd prdbgs for the module. . DYNDBG_CLASSMAP_DEFINE(and old one) creates classmaps in this section. This patch adds __dyndbg_class_users[] section: . catalogs uses/references to the classmap definitions. . authorizes dyndbg to >control those class'd prdbgs in ref'g module. . DYNDBG_CLASSMAP_USE() creates classmap-user records in this section. Now ddebug_add_module(etal) can handle classmap-uses like (and after) classmaps; when a dependent module is loaded, its parent's kernel params are scanned to find the param wired to dyndbg-param-ops, whose classmap matches the one ref'd by the client. To support this, 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 to encapsulate the new section: 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 dynamic_debug.c has 2 changes in ddebug_add_module(), ddebug_change(): ddebug_add_module() previously called ddebug_attach_module_classes() to handle classmap DEFINEd by a module, now it also calls ddebug_attach_user_module_classes() to handle USEd classmaps. ddebug_attach_user_module_classes() scans the module's class_users section, follows the refs to the parent's classmap, and calls ddebug_apply_params() on each. ddebug_apply_params(new fn): It scans module's/builtin kernel-params, calls ddebug_match_attach_kparam for each to find the 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're 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 AND used classes. test_dynamic_debug.c, test_dynamic_debug_submod.c: This (already) demonstrates the 2 types of classmaps & sysfs-params, following the 4-part recipe: 1. define an enum for the classmap: DRM.debug has DRM_UT_{CORE,KMS,...} multiple classes must share 0-62 classid space. 2. DYNDBG_CLASSMAP_DEFINE(.. DRM_UT_{CORE,KMS,...}) 3. DYNDBG_CLASSMAP_PARAM* (classmap) 4. DYNDBG_CLASSMAP_USE() by _submod only, skipping 2,3 Move all the enum declarations together, to better explain how they share the 0..62 class-id space available to a module (non-overlapping subranges). reorg macros 2,3 by name. This gives a tabular format, making it easy to see the pattern of repetition, and the points of change. And extend the test to replicate the 2-module (parent & dependent) scenario which caused the CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy regression seen in drm & drivers. The _submod.c is a 2-line file: #define _SUBMOD, #include parent. This gives identical complements of prdbgs in parent & _submod, and thus identical print behavior when all of: >control, >params, and parent->_submod propagation are working correctly. It also puts all the parent/_submod declarations together in the same source, with the new ifdef _SUBMOD block invoking DYNDBG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer. DEBUG details: ``#define DEBUG`` in src enables all pr_debugs after it, including any class'd pr_debugs; its not necessarily all-or-nothing, unless its a one-file-module with DEBUG at the top. If a CLASSMAP_PARAM is defined on a classmap, its readback value cannot describe the set of enablements. The param is basically write-only; it cannot know if `echo $cmd >control` was done since. To know the exact pr-debug state with certainty, toggle to both: echo 0x3ff > /sys/module/drm/parameters/debug echo 0 > /sys/module/drm/parameters/debug Cc: Daniel Vetter Cc: Jani Nikula Cc: Tvrtko Ursulin Cc: Rob Clark Cc: Sean Paul Cc: Luis Chamberlain Fixes: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") Fixes: f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 dr= ivers.") Ref: commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken") Signed-off-by: Jim Cromie --- MAINTAINERS | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +- drivers/gpu/drm/display/drm_dp_helper.c | 12 +- drivers/gpu/drm/drm_crtc_helper.c | 12 +- drivers/gpu/drm/drm_print.c | 25 ++-- drivers/gpu/drm/i915/i915_params.c | 12 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 12 +- include/asm-generic/vmlinux.lds.h | 1 + include/drm/drm_print.h | 10 +- include/linux/dynamic_debug.h | 54 +++++-- kernel/module/main.c | 3 + lib/Makefile | 2 +- lib/dynamic_debug.c | 178 ++++++++++++++++++++---- lib/test_dynamic_debug.c | 127 +++++++++++------ lib/test_dynamic_debug_submod.c | 10 ++ 15 files changed, 321 insertions(+), 151 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c diff --git a/MAINTAINERS b/MAINTAINERS index 4cc6bf79fdd8..774d17b2196a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7253,7 +7253,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 =20 DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index 0593ef8fe0a6..e8cb4bab4c39 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -198,17 +198,7 @@ int amdgpu_user_partt_mode =3D AMDGPU_AUTO_COMPUTE_PAR= TITION_MODE; =20 static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work= ); =20 -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +DRM_CLASSMAP_USE(drm_debug_classes); =20 struct amdgpu_mgpu_info mgpu_info =3D { .mutex =3D __MUTEX_INITIALIZER(mgpu_info.mutex), diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/disp= lay/drm_dp_helper.c index e6a78fd32380..d97de1a27939 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -41,17 +41,7 @@ =20 #include "drm_dp_helper_internal.h" =20 -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +DRM_CLASSMAP_USE(drm_debug_classes); =20 struct dp_aux_backlight { struct backlight_device *base; diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_h= elper.c index a209659a996c..fef4662d5f1f 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -50,17 +50,7 @@ =20 #include "drm_crtc_helper_internal.h" =20 -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +DRM_CLASSMAP_USE(drm_debug_classes); =20 /** * DOC: overview diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 5b93c11895bb..dabcfa0dd279 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where eac= h bit enables a debug cat #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) module_param_named(debug, __drm_debug, ulong, 0600); #else -/* classnames must match vals of enum drm_debug_category */ -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +/* classnames must match value-symbols of enum drm_debug_category */ +DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, + DRM_UT_CORE, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); =20 static struct ddebug_class_param drm_debug_bitmap =3D { .bits =3D &__drm_debug, diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915= _params.c index 0a171b57fd8f..d870e15da21c 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -29,17 +29,7 @@ #include "i915_params.h" #include "i915_drv.h" =20 -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +DRM_CLASSMAP_USE(drm_debug_classes); =20 #define i915_param_named(name, T, perm, desc) \ module_param_named(name, i915_modparams.name, T, perm); \ diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouvea= u/nouveau_drm.c index 40fb9a834918..5e8179db86f5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -69,17 +69,7 @@ #include "nouveau_svm.h" #include "nouveau_dmem.h" =20 -DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "DRM_UT_CORE", - "DRM_UT_DRIVER", - "DRM_UT_KMS", - "DRM_UT_PRIME", - "DRM_UT_ATOMIC", - "DRM_UT_VBL", - "DRM_UT_STATE", - "DRM_UT_LEASE", - "DRM_UT_DP", - "DRM_UT_DRMRES"); +DRM_CLASSMAP_USE(drm_debug_classes); =20 MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 9c59409104f6..e00b6380089c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -373,6 +373,7 @@ /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ + BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users) \ BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index a93a387f8a1a..706afc97c79c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -276,7 +276,7 @@ static inline struct drm_printer drm_err_printer(const = char *prefix) * */ enum drm_debug_category { - /* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ + /* Keep DRM_CLASSMAP_DEFINE args in sync with any changes here */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... @@ -321,6 +321,14 @@ enum drm_debug_category { DRM_UT_DRMRES }; =20 +#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG +#define DRM_CLASSMAP_DEFINE(...) DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__) +#define DRM_CLASSMAP_USE(name) DYNDBG_CLASSMAP_USE(name) +#else +#define DRM_CLASSMAP_DEFINE(...) +#define DRM_CLASSMAP_USE(name) +#endif + static inline bool drm_debug_enabled_raw(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8eaf8eabdc8d..dfd5e39ee4d0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -58,7 +58,7 @@ 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, mapped to bits[0= ..N]. @@ -72,24 +72,28 @@ enum class_map_type { }; =20 struct ddebug_class_map { - struct module *mod; - const char *mod_name; /* needed for builtins */ + const 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; + enum ddebug_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 + * DYNDBG_CLASSMAP_DEFINE - define a set of debug-classes used by a module. + * @_var: name of the classmap, exported for other modules coordinated u= se. + * @_type: enum ddebug_class_map_type, chooses bits/verbose, numeric/name= s. + * @_base: offset of 1st class-name, used to share 0..62 classid space + * @classes: vals are stringified enum-vals, like DRM_UT_* + * + * Defines and exports a struct ddebug_class_map whose @classes are + * used to validate a "class FOO .." >control command against each + * module, and to validate inputs to DD_CLASS_TYPE_*_NAMES typed params. */ -#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ - static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ - static struct ddebug_class_map __aligned(8) __used \ +#define DYNDBG_CLASSMAP_DEFINE(_var, _maptype, _base, ...) \ + const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + struct ddebug_class_map __aligned(8) __used \ __section("__dyndbg_classes") _var =3D { \ .mod =3D THIS_MODULE, \ .mod_name =3D KBUILD_MODNAME, \ @@ -97,14 +101,40 @@ struct ddebug_class_map { .map_type =3D _maptype, \ .length =3D ARRAY_SIZE(_var##_classnames), \ .class_names =3D _var##_classnames, \ + }; \ + EXPORT_SYMBOL(_var) + +struct ddebug_class_user { + char *user_mod_name; + struct ddebug_class_map *map; +}; + +/** + * DYNDBG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. + * @_var: name of the exported classmap var + * + * This registers a module's use of another module's classmap defn, so + * dyndbg can authorize "class DRM_CORE ..." >control commands upon + * this module. + */ +#define DYNDBG_CLASSMAP_USE(_var) \ + DYNDBG_CLASSMAP_USE_(_var, __UNIQUE_ID(ddebug_class_user)) +#define DYNDBG_CLASSMAP_USE_(_var, _uname) \ + extern struct ddebug_class_map _var; \ + struct ddebug_class_user __used \ + __section("__dyndbg_class_users") _uname =3D { \ + .user_mod_name =3D KBUILD_MODNAME, \ + .map =3D &_var, \ } =20 /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; struct ddebug_class_map *classes; + struct ddebug_class_user *class_users; unsigned int num_descs; unsigned int num_classes; + unsigned int num_class_users; }; =20 struct ddebug_class_param { diff --git a/kernel/module/main.c b/kernel/module/main.c index 59b1d067e528..ffcbb07e3782 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2206,6 +2206,9 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) mod->dyndbg_info.classes =3D section_objs(info, "__dyndbg_classes", sizeof(*mod->dyndbg_info.classes), &mod->dyndbg_info.num_classes); + mod->dyndbg_info.class_users =3D section_objs(info, "__dyndbg_class_users= ", + sizeof(*mod->dyndbg_info.class_users), + &mod->dyndbg_info.num_class_users); #endif =20 return 0; diff --git a/lib/Makefile b/lib/Makefile index 1ffae65bb7ee..31195c75f5a0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -79,7 +79,7 @@ obj-$(CONFIG_TEST_SORT) +=3D test_sort.o obj-$(CONFIG_TEST_USER_COPY) +=3D test_user_copy.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) +=3D test_dynamic_debug.o test_dynamic_de= bug_submod.o obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6fd945e6719e..018578923897 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -43,13 +43,16 @@ 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_class_user __start___dyndbg_class_users[]; +extern struct ddebug_class_user __stop___dyndbg_class_users[]; =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_class_user *class_users; + unsigned int num_ddebugs, num_classes, num_class_users; }; =20 struct ddebug_query { @@ -148,21 +151,39 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 +#define vpr_dt_info(dt_p, msg_p, ...) ({ \ + struct ddebug_table const *_dt =3D dt_p; \ + v2pr_info(msg_p " module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \ + _dt->mod_name, _dt->num_ddebugs, _dt->num_classes, \ + _dt->num_class_users); \ + }) + #define __outvar /* filled by callee */ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, const char *class_string, __outvar int *class_id) { struct ddebug_class_map *map; + struct ddebug_class_user *cli; int i, idx; =20 - for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { + for (i =3D 0, map =3D dt->classes; 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; + vpr_dt_info(dt, "good-class: %s.%s ", map->mod_name, class_string); return map; } } + for (i =3D 0, cli =3D dt->class_users; i < dt->num_class_users; i++, cli+= +) { + idx =3D match_string(cli->map->class_names, cli->map->length, class_stri= ng); + if (idx >=3D 0) { + *class_id =3D idx + cli->map->base; + vpr_dt_info(dt, "class-ref: %s.%s ", + cli->user_mod_name, class_string); + return cli->map; + } + } *class_id =3D -ENOENT; return NULL; } @@ -555,7 +576,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) { @@ -684,12 +705,12 @@ static int param_set_dyndbg_module_classes(const char= *instr, } =20 /** - * param_set_dyndbg_classes - class FOO >control + * param_set_dyndbg_classes - set all classes in a classmap * @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 prdbgs by their class, as given in the arguments to - * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative + * For all classes in the classmap, enable/disable them per the input + * (depending on map_type). For LEVEL map-types, enforce relative * levels by bitpos. * * Returns: 0 or <0 if error. @@ -1034,12 +1055,17 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddeb= ug *dp) { struct ddebug_class_map *map =3D dt->classes; + struct ddebug_class_user *cli =3D dt->class_users; int i; =20 for (i =3D 0; i < dt->num_classes; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 + for (i =3D 0; i < dt->num_class_users; i++, cli++) + if (class_in_range(dp->class_id, cli->map)) + return cli->map->class_names[dp->class_id - cli->map->base]; + return NULL; } =20 @@ -1120,31 +1146,129 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 +static const char * const ddebug_classmap_typenames[] =3D { + "DISJOINT_BITS", "LEVEL_NUM", "DISJOINT_NAMES", "LEVEL_NAMES" +}; + +#define vpr_cm_info(cm_p, msg_p, ...) ({ \ + struct ddebug_class_map const *_cm =3D cm_p; \ + v2pr_info(msg_p " module:%s base:%d len:%d type:%s\n", ##__VA_ARGS__, \ + _cm->mod_name, _cm->base, _cm->length, \ + ddebug_classmap_typenames[_cm->map_type]); \ + }) + +static void ddebug_sync_classbits(const struct ddebug_class_param *dcp, co= nst char *modname) +{ + /* 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 *modnm) +{ + 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("found kp:%s =3D0x%lx", kp->name, *dcp->bits); + vpr_cm_info(map, "mapped to:"); + ddebug_sync_classbits(dcp, modnm); + } +} + +static void ddebug_apply_params(const struct ddebug_class_map *cm, const c= har *modnm) +{ + const struct kernel_param *kp; +#if IS_ENABLED(CONFIG_MODULES) + int i; + + if (cm->mod) { + vpr_cm_info(cm, "loaded class:"); + for (i =3D 0, kp =3D cm->mod->kp; i < cm->mod->num_kp; i++, kp++) + ddebug_match_apply_kparam(kp, cm, modnm); + } +#endif + if (!cm->mod) { + vpr_cm_info(cm, "builtin class:"); + for (kp =3D __start___param; kp < __stop___param; kp++) + ddebug_match_apply_kparam(kp, cm, modnm); + } +} + +/* + * Find this module's classmaps in a sub/whole-range of the builtin/ + * modular classmap vector/section. Save the start and length of the + * subrange at its edges. + */ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { struct ddebug_class_map *cm; int i, nc =3D 0; =20 - /* - * Find this module's classmaps in a subrange/wholerange of - * the builtin/modular classmap vector/section. Save the start - * and length of the subrange at its edges. - */ - for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { + for (i =3D 0, cm =3D di->classes; i < di->num_classes; i++, cm++) { =20 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); + vpr_cm_info(cm, "classes[%d]:", i); + if (!nc++) dt->classes =3D cm; - } - nc++; } } - if (nc) { - dt->num_classes =3D nc; + dt->num_classes =3D nc; + if (nc) vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + + /* now iterate dt */ + for (i =3D 0, cm =3D dt->classes; i < dt->num_classes; i++, cm++) + ddebug_apply_params(cm, cm->mod_name); +} + +/* + * propagates class-params thru their classmaps to class-users. this + * means a query against the dt/module, which means it must be on the + * list to be seen by ddebug_change. + */ +static void ddebug_attach_user_module_classes(struct ddebug_table *dt, + const struct _ddebug_info *di) +{ + struct ddebug_class_user *cli; + int i, nc =3D 0; + + /* + * For builtins: scan the array, find start/length of this + * module's refs, save to dt. For loadables, this is the + * whole array. + */ + for (i =3D 0, cli =3D di->class_users; i < di->num_class_users; i++, cli+= +) { + + if (WARN_ON(!cli || !cli->map || !cli->user_mod_name)) + continue; + + if (!strcmp(cli->user_mod_name, dt->mod_name)) { + + vpr_cm_info(cli->map, "class_ref[%d] %s -> %s", i, + cli->user_mod_name, cli->map->mod_name); + if (!nc++) + dt->class_users =3D cli; + } } + dt->num_class_users =3D nc; + + /* now iterate dt */ + for (i =3D 0, cli =3D dt->class_users; i < dt->num_class_users; i++, cli+= +) + ddebug_apply_params(cli->map, cli->user_mod_name); + + vpr_dt_info(dt, "attach-client-module: "); } =20 /* @@ -1155,7 +1279,8 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) { struct ddebug_table *dt; =20 - v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + v3pr_info("add-module: %s %d sites %d.%d\n", modname, di->num_descs, + di->num_classes, di->num_class_users); if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1178,13 +1303,16 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) =20 INIT_LIST_HEAD(&dt->link); =20 - if (di->classes && di->num_classes) - ddebug_attach_module_classes(dt, di); - mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 + if (di->num_classes) + ddebug_attach_module_classes(dt, di); + + if (di->num_class_users) + ddebug_attach_user_module_classes(dt, di); + vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); return 0; } @@ -1334,8 +1462,10 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di =3D { .descs =3D __start___dyndbg, .classes =3D __start___dyndbg_classes, + .class_users =3D __start___dyndbg_class_users, .num_descs =3D __stop___dyndbg - __start___dyndbg, .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, + .num_class_users =3D __stop___dyndbg_class_users - __start___dyndbg_clas= s_users, }; =20 #ifdef CONFIG_MODULES diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 229eaadee838..23967071b60f 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -6,11 +6,15 @@ * Jim Cromie */ =20 -#define pr_fmt(fmt) "test_dd: " fmt +#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 +33,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 DYNDBG_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 DYNDBG_CLASSMAP_PARAM(_model, _flags) DYNDBG_CLASSMAP_PARAM_(_mod= el, _flags, ~0) +#else +#define DYNDBG_CLASSMAP_PARAM(_model, _flags) DYNDBG_CLASSMAP_PARAM_(_mod= el, _flags, 0) +#endif + +/* + * Demonstrate/test all 4 class-typed classmaps with a sys-param. + * + * Each is 3 part: client-enum decl, _DEFINE, _PARAM. + * Declare them in blocks to show patterns of use (repetitions and + * changes) within each. + * + * 1st, dyndbg expects a client-provided enum-type as source of + * category/classid truth. DRM has DRM_UT_. + * + * Modules with multiple CLASSMAPS must have enums with distinct + * value-ranges, arranged below with explicit enum_sym =3D X inits. + * + * Declare all 4 enums now, for different types + */ =20 /* numeric input, independent bits */ enum cat_disjoint_bits { @@ -60,40 +79,57 @@ 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); - -/* 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); =20 /* 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); =20 -/* symbolic verbosity */ +/* named-symbolic input, independent bits */ +enum cat_disjoint_names { LOW =3D 10, MID, HI }; + +/* named-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); + +/* recapitulate DRM's parent(drm.ko) <-- _submod(drivers,helpers) */ +#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. + */ +DYNDBG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, + D2_CORE, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); + +DYNDBG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, + V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); + +/* + * now add the sysfs-params + */ + +DYNDBG_CLASSMAP_PARAM(disjoint_bits, p); +DYNDBG_CLASSMAP_PARAM(level_num, p); + +#else /* TEST_DYNAMIC_DEBUG_SUBMOD */ + +/* + * in submod/drm-drivers, use the classmaps defined in top/parent + * module above. + */ + +DYNDBG_CLASSMAP_USE(map_disjoint_bits); +DYNDBG_CLASSMAP_USE(map_level_num); + +#endif =20 /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") @@ -129,6 +165,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..9a893402ce1a --- /dev/null +++ b/lib/test_dynamic_debug_submod.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +#define TEST_DYNAMIC_DEBUG_SUBMOD +#include "test_dynamic_debug.c" --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E48FCCA0EC8 for ; Tue, 12 Sep 2023 02:12:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236136AbjILCMW (ORCPT ); Mon, 11 Sep 2023 22:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbjILCMD (ORCPT ); Mon, 11 Sep 2023 22:12:03 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088BAE931A; Mon, 11 Sep 2023 16:19:06 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-76dc7b0da9fso266740285a.1; Mon, 11 Sep 2023 16:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474234; x=1695079034; 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=pRKwABwSVQ1OTkJFIkg8SfKEtpKioqDF4/CYpQb4P2w=; b=rPmx/yw+z3Wt61pNz3DrzOGFnTSOwPqxeEbE4T01P9dKyLxYYzsq3TmONHmv/GwSrF VAMq2f1kyk3zXpRoSUhrS/6Tq8WardHGPYJjYV701+2tOe3op1si3N+sr6PRnJ00nrdb XpBgx/kOugQvYDfCptiv3OtGDCTzHVpBfGilCpkNalTYL8tcadSpxFZGIxSN1Qd8Jgto nGX78HKhM+jTY8N5HY9HBjfFvMUto37zC6wuP0HK5W7n/POKJL64ajpjMSC9WEn5Xww9 fALQ+kIo3H6SIIxj6Dp6tbi2IpTDl20f0wdf3LHdrIIzkkF2/GCjr6VKcQCuwBwzMTAu UCaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474234; x=1695079034; 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=pRKwABwSVQ1OTkJFIkg8SfKEtpKioqDF4/CYpQb4P2w=; b=MjjIjDef8Ys2aQzy+7GvpJRsx2fkb1JKWGrNPqjL/7ZWD5SzCuNcEURW6TYrHhvyNW Mxv6POKrD0N++/Hem8qaCUJ7I5DB3LhoKfbz7d3uBzpFGfHhXHSP0tGh06Wf01cS6Xwi j25yDauKaT91xyTCDDzkN1zqDIC/68viFg5+f6WHegvY/4Luhd6Q0GYkt0DGI0Aq4CQN gVG8RTjR273hzT+kXwTNQQ8GipKHsDNMS9WLiLoUqDdmnn/bhPdRp3rVh61I4FYaRHQP kief0xo1Wfk5h06qTwzzq7IiRIyqQiF7/ygg896kZ9NkOe4rwGduTwh9A5DVKYFYbXmx Y2mA== X-Gm-Message-State: AOJu0YwK+Mn8fm1OImORwPwsn8XIXk9Eey2gfnS5xaJkU4NhcFAnA/EE F5Bs2aDncZiwFwBaNMn4JYB3MmorUS4vwQ== X-Google-Smtp-Source: AGHT+IGnBiv6UbJsu+sBM5Hhx9sTk4Vk8peUvrBdp3UqCNKfl/LsZspNoj46K2gBb3H7JdLQgmF4mw== X-Received: by 2002:a5e:8912:0:b0:792:9a3e:2dd with SMTP id k18-20020a5e8912000000b007929a3e02ddmr13540344ioj.3.1694473737580; Mon, 11 Sep 2023 16:08:57 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:57 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 13/22] dyndbg: add for_each_boxed_vector Date: Mon, 11 Sep 2023 17:08:29 -0600 Message-ID: <20230911230838.14461-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a for_each iterator to walk a counted vector member in a struct (ie the box), and use it to replace 8 open-coded loops. Signed-off-by: Jim Cromie --- v5- parens-on-box-force-precedence --- lib/dynamic_debug.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 018578923897..851e7f9de085 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -158,6 +158,9 @@ static void vpr_info_dq(const struct ddebug_query *quer= y, const char *msg) _dt->num_class_users); \ }) =20 +#define for_each_boxed_vector(_box, _vec, _len, _ct, _curs) \ + for (_ct =3D 0, _curs =3D (_box)->_vec; _ct < (_box)->_len; _ct++, _curs+= +) + #define __outvar /* filled by callee */ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, const char *class_string, @@ -167,7 +170,7 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons struct ddebug_class_user *cli; int i, idx; =20 - for (i =3D 0, map =3D dt->classes; i < dt->num_classes; i++, map++) { + for_each_boxed_vector(dt, classes, 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; @@ -175,7 +178,7 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return map; } } - for (i =3D 0, cli =3D dt->class_users; i < dt->num_class_users; i++, cli+= +) { + for_each_boxed_vector(dt, class_users, num_class_users, i, cli) { idx =3D match_string(cli->map->class_names, cli->map->length, class_stri= ng); if (idx >=3D 0) { *class_id =3D idx + cli->map->base; @@ -1058,11 +1061,11 @@ static const char *ddebug_class_name(struct ddebug_= table *dt, struct _ddebug *dp struct ddebug_class_user *cli =3D dt->class_users; int i; =20 - for (i =3D 0; i < dt->num_classes; i++, map++) + for_each_boxed_vector(dt, classes, num_classes, i, map) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 - for (i =3D 0; i < dt->num_class_users; i++, cli++) + for_each_boxed_vector(dt, class_users, num_class_users, i, cli) if (class_in_range(dp->class_id, cli->map)) return cli->map->class_names[dp->class_id - cli->map->base]; =20 @@ -1216,7 +1219,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug struct ddebug_class_map *cm; int i, nc =3D 0; =20 - for (i =3D 0, cm =3D di->classes; i < di->num_classes; i++, cm++) { + for_each_boxed_vector(di, classes, num_classes, i, cm) { =20 if (!strcmp(cm->mod_name, dt->mod_name)) { vpr_cm_info(cm, "classes[%d]:", i); @@ -1229,7 +1232,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); =20 /* now iterate dt */ - for (i =3D 0, cm =3D dt->classes; i < dt->num_classes; i++, cm++) + for_each_boxed_vector(di, classes, num_classes, i, cm) ddebug_apply_params(cm, cm->mod_name); } =20 @@ -1249,7 +1252,7 @@ static void ddebug_attach_user_module_classes(struct = ddebug_table *dt, * module's refs, save to dt. For loadables, this is the * whole array. */ - for (i =3D 0, cli =3D di->class_users; i < di->num_class_users; i++, cli+= +) { + for_each_boxed_vector(di, class_users, num_class_users, i, cli) { =20 if (WARN_ON(!cli || !cli->map || !cli->user_mod_name)) continue; @@ -1264,8 +1267,7 @@ static void ddebug_attach_user_module_classes(struct = ddebug_table *dt, } dt->num_class_users =3D nc; =20 - /* now iterate dt */ - for (i =3D 0, cli =3D dt->class_users; i < dt->num_class_users; i++, cli+= +) + for_each_boxed_vector(di, class_users, num_class_users, i, cli) ddebug_apply_params(cli->map, cli->user_mod_name); =20 vpr_dt_info(dt, "attach-client-module: "); --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D30A6CA0EC8 for ; Tue, 12 Sep 2023 01:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235038AbjILBqf (ORCPT ); Mon, 11 Sep 2023 21:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235415AbjILBqR (ORCPT ); Mon, 11 Sep 2023 21:46:17 -0400 Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A81613AF32; Mon, 11 Sep 2023 16:43:26 -0700 (PDT) Received: by mail-ua1-x92f.google.com with SMTP id a1e0cc1a2514c-7a52a1e2a59so2013163241.0; Mon, 11 Sep 2023 16:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475748; x=1695080548; 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=OSfRKZal5I08Kg2LNxyAmDMoxHoLrERFX8CpvZDeNLU=; b=XgQUY/RNWE49Z60zqq3GAPCesZYDluxwFb94RLvtFS1iVkLteMtHBjqhkPJ4bceDGW FCJqUnWXAbmM7upMTRIL/V6xvc3fcpSTn6pbP3E3Ja5e4O6y7GL5Ssril+Fo7ghw53eM lwkQLIa+1cwQWqLKicc96o6eIB4uqIFi0Tm07Hf7nUlOvVAvq9bkyRxmu3t6FzV2K+sG 6MNpaYknP/qtpNIai104FB58/n3MOQ5kp+jSqkde19iRQzmNAT13yjcLyeqmbThC137A sgefFwpNJWzA0TWkZjqHAuIOVI/eXuOFb7MlXc2XSyrtM6HTgY8OO7qctiyMbjJOx82a zDLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475748; x=1695080548; 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=OSfRKZal5I08Kg2LNxyAmDMoxHoLrERFX8CpvZDeNLU=; b=ueOkPwOabGuN1kqXAZDYkZIoxFtKfpC1ZGUsMDk4ag00l9hLWryzqw94AeaYkvQCyN vVJNN0J5O4sgoJZFz4hJQdGuMKr6hYZaf1jAkThB8Usxw26MRBjjzEuaJo71zuGsGbCn 80seOdeeDTHWcWays6WIhBq//IDLn6xr/7wVzEg7k6zFaoZVW2OOgdXbI7XDqKSVTpwC +JsQ35jJz4uFerLfTdBWrD3ZzQtx5OxTpSmEwajA6Ulo8YQfLd+DjruDfI4TTg5pHaEN TG/VjPrRh8EtGGcwAOrL2pLVF+hLYZKzwjOg/eo/qnTzQiDEmmPxjMgdF6Rkm/aDgFBv Hrpg== X-Gm-Message-State: AOJu0Yw7vpXeA2KJSTD/E18AHTk9SlJIx0K6sufIeU4kDFQYU8D7AQsU qZGeGImlwMXxg70Bwd7g52kKmzYd19lTSA== X-Google-Smtp-Source: AGHT+IFcDet/yMw0w72Vp9INEsacivj8gjJhEwzdN7FdFH2NxXvnk+9hlDDkDfO5YLzJ/X6RaRGOww== X-Received: by 2002:a05:6602:2be1:b0:795:196c:a074 with SMTP id d1-20020a0566022be100b00795196ca074mr12359921ioy.3.1694473738930; Mon, 11 Sep 2023 16:08:58 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:58 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 14/22] dyndbg: refactor ddebug_classparam_clamp_input Date: Mon, 11 Sep 2023 17:08:30 -0600 Message-ID: <20230911230838.14461-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Extract input validation code, from param_set_dyndbg_module_classes() (the sys-node >handler) to new: ddebug_classparam_clamp_input(kp), call it from former. It takes kernel-param arg, so it can complain about "foo: bad input". Reuse ddparam_clamp_input(kp) in ddebug_sync_classbits(), to validate inputs from parent's params, just like our own. To support that reuse, alter ddebug_sync_classbits() and caller to pass kp instead of kp->arg. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 66 ++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 851e7f9de085..90e36fea5635 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -656,6 +656,30 @@ static int ddebug_apply_class_bitmap(const struct ddeb= ug_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 *modnm) @@ -674,26 +698,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, modnm ?: "*", KP_NAME(kp)); totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, modnm); *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)); @@ -1160,16 +1173,27 @@ static const char * const ddebug_classmap_typenames= [] =3D { ddebug_classmap_typenames[_cm->map_type]); \ }) =20 -static void ddebug_sync_classbits(const struct ddebug_class_param *dcp, co= nst char *modname) +static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { - /* 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); + struct ddebug_class_param *dcp =3D kp->arg; + unsigned long new_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, @@ -1186,7 +1210,7 @@ static void ddebug_match_apply_kparam(const struct ke= rnel_param *kp, if (map =3D=3D dcp->map) { v2pr_info("found kp:%s =3D0x%lx", kp->name, *dcp->bits); vpr_cm_info(map, "mapped to:"); - ddebug_sync_classbits(dcp, modnm); + ddebug_sync_classbits(kp, modnm); } } =20 --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D23ECA0EC3 for ; Mon, 11 Sep 2023 23:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjIKX46 (ORCPT ); Mon, 11 Sep 2023 19:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235599AbjIKXwe (ORCPT ); Mon, 11 Sep 2023 19:52:34 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19A9A3B9FF; Mon, 11 Sep 2023 16:15:39 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6c0f3f24c27so644643a34.2; Mon, 11 Sep 2023 16:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474046; x=1695078846; 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=PB3LiUhIzXuAa4xXViPHoKYMaiRTHzf1WidpgS8wmiM=; b=WH4KmwtRiR72WLZGz6sucMuruqNJI7YzmVPY923ct/x+d1uNTBAsiVM1AAblW0DEkf 9gVaSfsl/ZdZCvrcMnQRLI29TOj8RSVrlhCemZC4+xZEyiOXe74rcKj/vC6WPBRw3QHu EiZnlIwEbFhS8GnkWjUhNTJuwOuRtlf8Ht+9QEq7Fw8Cq2ZkH3pM7/GHY+v/Urep6Hip rY/QGEJcmhH+J8ZujTtCr7NG0curlkRPzDOY6B9oExlhlrlxh+ZJLwadoq91LMdtMJRU HQVfHHddlXE1+WunMTwB/00RKGbx3iw2ycpSVAua4OITFKdyCJdFOV55rlnZebE9KPwZ tDVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474046; x=1695078846; 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=PB3LiUhIzXuAa4xXViPHoKYMaiRTHzf1WidpgS8wmiM=; b=cdLGthSHu7RnHWhT6rznXLTPkRkXBZqAwYz+xL3oeYXSVLITfZozC08zsiyeaBS9oW GaTGA/sQps1Dh0epuVuejzCxNc6iOJYiiR6XBSCBd8vK8K+4/SvJSdoc2AWmAR34E6w9 VReRV7BacHjux+Xb8oLRRUWMGg/rueEQOqD6mXj5Bldkrx8sjn838bTcTK3GNzuJ8+Pm knMGFfqbao/9VQLuluYnlnW+ct1PkX1MfCn7MgzJLFSRKD/U5Cvmzr8c/dv3qQ9odiTZ FE485SUXdDAc3pDWM7AnBiQ26ILHxCX6oFUA/Dh4AXIOYhr2T/CII7QTpDZFuxjH4cyW sj7Q== X-Gm-Message-State: AOJu0Yx1l3jbpq+WKCseDfDoeI0N3xdeMZlL1viOBAWj+ssyv0pwmZul pIDgeDBB1kl9jaR2Ox0zeDvqEpqlqk9V/g== X-Google-Smtp-Source: AGHT+IFZlzJvcL7t8HpK3t1MGGrcXjBoJCFaW7ILAZbaIKK8PyB9W0txXEF0mcChge9f5bUy9KPu9w== X-Received: by 2002:a5e:c80a:0:b0:795:c6f:59ff with SMTP id y10-20020a5ec80a000000b007950c6f59ffmr13164380iol.17.1694473740585; Mon, 11 Sep 2023 16:09:00 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:00 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 15/22] dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API Date: Mon, 11 Sep 2023 17:08:31 -0600 Message-ID: <20230911230838.14461-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" move macro from test-dynamic-debug.c into header, and refine it. Distinguish the 2 use cases of DYNDBG_CLASSMAP_PARAM* 1.DYNDBG_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.DYNDBG_CLASSMAP_PARAM new user (test_dynamic_debug) doesn't need to share state, decls a static long unsigned int to store the bitvec. __DYNDBG_CLASSMAP_PARAM bottom layer - allocate,init a ddebug-class-param, module-param-cb. Also clean up and improve comments in test-code, and add MODULE_DESCRIPTIONs. Signed-off-by: Jim Cromie --- v5b - parens-on-PARAM --- drivers/gpu/drm/drm_print.c | 8 ++--- include/drm/drm_print.h | 6 ++-- include/linux/dynamic_debug.h | 39 ++++++++++++++++++++-- lib/test_dynamic_debug.c | 58 +++++++++++++-------------------- lib/test_dynamic_debug_submod.c | 9 ++++- 5 files changed, 74 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index dabcfa0dd279..8f4b609353a5 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -69,12 +69,8 @@ DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DIS= JOINT_BITS, "DRM_UT_DP", "DRM_UT_DRMRES"); =20 -static struct ddebug_class_param drm_debug_bitmap =3D { - .bits =3D &__drm_debug, - .flags =3D "p", - .map =3D &drm_debug_classes, -}; -module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); +DRM_CLASSMAP_PARAM_REF(debug, __drm_debug, drm_debug_classes, p); + #endif =20 void __drm_puts_coredump(struct drm_printer *p, const char *str) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 706afc97c79c..94d4f5500030 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -322,11 +322,13 @@ enum drm_debug_category { }; =20 #ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG -#define DRM_CLASSMAP_DEFINE(...) DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__) -#define DRM_CLASSMAP_USE(name) DYNDBG_CLASSMAP_USE(name) +#define DRM_CLASSMAP_DEFINE(...) DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__) +#define DRM_CLASSMAP_USE(name) DYNDBG_CLASSMAP_USE(name) +#define DRM_CLASSMAP_PARAM_REF(...) DYNDBG_CLASSMAP_PARAM_REF(__VA_ARGS__) #else #define DRM_CLASSMAP_DEFINE(...) #define DRM_CLASSMAP_USE(name) +#define DRM_CLASSMAP_PARAM_REF(...) #endif =20 static inline bool drm_debug_enabled_raw(enum drm_debug_category category) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dfd5e39ee4d0..15edac27cb56 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -92,7 +92,7 @@ struct ddebug_class_map { * module, and to validate inputs to DD_CLASS_TYPE_*_NAMES typed params. */ #define DYNDBG_CLASSMAP_DEFINE(_var, _maptype, _base, ...) \ - const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ struct ddebug_class_map __aligned(8) __used \ __section("__dyndbg_classes") _var =3D { \ .mod =3D THIS_MODULE, \ @@ -121,7 +121,7 @@ struct ddebug_class_user { DYNDBG_CLASSMAP_USE_(_var, __UNIQUE_ID(ddebug_class_user)) #define DYNDBG_CLASSMAP_USE_(_var, _uname) \ extern struct ddebug_class_map _var; \ - struct ddebug_class_user __used \ + static struct ddebug_class_user __used \ __section("__dyndbg_class_users") _uname =3D { \ .user_mod_name =3D KBUILD_MODNAME, \ .map =3D &_var, \ @@ -146,6 +146,41 @@ struct ddebug_class_param { const struct ddebug_class_map *map; }; =20 +/** + * DYNDBG_CLASSMAP_PARAM - wrap a dyndbg-classmap with a controlling sys-p= aram + * @_name sysfs node name + * @_var name of the struct classmap var defining the controlled classes + * @_flags flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * classmap. Keeps bits in a private/static + */ +#define DYNDBG_CLASSMAP_PARAM(_name, _var, _flags) \ + static unsigned long _name##_bvec; \ + __DYNDBG_CLASSMAP_PARAM(_name, _name##_bvec, _var, _flags) + +/** + * DYNDBG_CLASSMAP_PARAM_REF - wrap a dyndbg-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 struct classmap var defining the controlled classes + * @_flags flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classmap, keeping bitvec in user @= _bits. + * This lets drm use __drm_debug elsewhere too. + */ +#define DYNDBG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ + __DYNDBG_CLASSMAP_PARAM(_name, _bits, _var, _flags) + +#define __DYNDBG_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) + /* * pr_debug() and friends are globally enabled or modules have selectively * enabled them. diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 23967071b60f..84e049c07e77 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 @@ -35,24 +36,8 @@ 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 DYNDBG_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 DYNDBG_CLASSMAP_PARAM(_model, _flags) DYNDBG_CLASSMAP_PARAM_(_mod= el, _flags, ~0) -#else -#define DYNDBG_CLASSMAP_PARAM(_model, _flags) DYNDBG_CLASSMAP_PARAM_(_mod= el, _flags, 0) -#endif - /* - * Demonstrate/test all 4 class-typed classmaps with a sys-param. + * Demonstrate/test both types of classmaps, each with a sys-param. * * Each is 3 part: client-enum decl, _DEFINE, _PARAM. * Declare them in blocks to show patterns of use (repetitions and @@ -64,7 +49,7 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 06= 00); * Modules with multiple CLASSMAPS must have enums with distinct * value-ranges, arranged below with explicit enum_sym =3D X inits. * - * Declare all 4 enums now, for different types + * Declare all enums now, for different types */ =20 /* numeric input, independent bits */ @@ -83,18 +68,21 @@ enum cat_disjoint_bits { /* numeric verbosity, V2 > V1 related */ enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; =20 -/* named-symbolic input, independent bits */ +/* + and possibly later, params accepting named-value inputs +*/ enum cat_disjoint_names { LOW =3D 10, MID, HI }; +enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; =20 -/* named-symbolic verbosity */ -enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; - -/* recapitulate DRM's parent(drm.ko) <-- _submod(drivers,helpers) */ +/* + * 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. */ DYNDBG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, D2_CORE, @@ -113,19 +101,18 @@ DYNDBG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_L= EVEL_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. */ - -DYNDBG_CLASSMAP_PARAM(disjoint_bits, p); -DYNDBG_CLASSMAP_PARAM(level_num, p); +DYNDBG_CLASSMAP_PARAM(p_disjoint_bits, map_disjoint_bits, p); +DYNDBG_CLASSMAP_PARAM(p_level_num, map_level_num, p); =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. */ - DYNDBG_CLASSMAP_USE(map_disjoint_bits); DYNDBG_CLASSMAP_USE(map_level_num); =20 @@ -186,5 +173,6 @@ 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_LICENSE("GPL"); diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c index 9a893402ce1a..0d15f3ffe466 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 @@ -8,3 +11,7 @@ =20 #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.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFAEFCA0EC3 for ; Tue, 12 Sep 2023 01:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235642AbjILBhH (ORCPT ); Mon, 11 Sep 2023 21:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235577AbjILBgx (ORCPT ); Mon, 11 Sep 2023 21:36:53 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988AC150D07; Mon, 11 Sep 2023 16:49:24 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-58fb8963617so49917987b3.3; Mon, 11 Sep 2023 16:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694476099; x=1695080899; 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=BXZWG/nA8iNczDldd6SjpWfFw/ABPHN8JU5LNr6qz3s=; b=kLJ2MN9OpGb/NemUrNokXi/UxN2oQKQ+opDVjm/kssPMm7ZpqATbViieq1uAajoJPN O6/VQh9ifUYwBokFoM9QdlCy57iyKYTksmcIcnWVDFj6gwVhVhES49DYKHF+7GSKPHIR IOHqbrLFi0gCwqg17dh8fHx6cc0M/mFBTgmexnjlSg28LnC4nXeVKkJsxy5bry0AlUCf 1qxF6eNYKGerPLDqAjhettKP6fOmLwB8flV+BcHyaII6iT5Ky/bSa+/hZKxe0YcnYu97 R6k2aS4p3tX3MYYIDMp379SPIz4bg5E8fawCChRZTzZw/JsoDt2O9if1qD2ZfQyENWJd 4ZYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694476099; x=1695080899; 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=BXZWG/nA8iNczDldd6SjpWfFw/ABPHN8JU5LNr6qz3s=; b=dNXWjWB1P+XIK29BAReB3b203XrOeMXkDgrIB7qeg+NZQiI1EPpmZ/kEepOFdTZze5 cbwus1+/0xlUu0AgJh/oCC7eAVARNoIGcnwUiSu2cmA4zObmoYA4S67KzO/W5IFRpZSr P7arin9eJq5yBNw8M4FmaV3sPkNaDdo389mot6JhfclwYsvj66RRv/B2d0uSR9UkWoNs Hkw7yD00Lp+RkxJ/zuI4vGZzpbuAhagiGFgH/T6FIZ6zeKxE4iI8/hL0mpqxwqh8UNzq 5a/FjU/wW3Q7vkdTO9NqdO5dX3zTRUAK2I5sL7QvyuvNw1n3HIJYrEBelOMhUISEaPCV twBg== X-Gm-Message-State: AOJu0YzC6dxTU/Uk4LRlHUOJ5QKBL206itNh8wfKSMJiw/WjHFYpldob Zld48v2fiH9PJFnswx6YcBEgmbpOI3+tiA== X-Google-Smtp-Source: AGHT+IGY+Y9DO+vyrjnMRL7HVOugzwFjUd7HmRNBSMbrU8a8Upu6hXUK9+5a2CqGJ5tFV3wuipMVBQ== X-Received: by 2002:a05:6602:388c:b0:798:2665:8939 with SMTP id br12-20020a056602388c00b0079826658939mr5726278iob.20.1694473741943; Mon, 11 Sep 2023 16:09:01 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:01 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 16/22] dyndbg-test: build it with just CONFIG_DYNAMIC_DEBUG_CORE Date: Mon, 11 Sep 2023 17:08:32 -0600 Message-ID: <20230911230838.14461-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Make the test-module buildable with just CONFIG_DYNAMIC_DEBUG_CORE; add CFLAGS_$ofile defns to supply -DDYNAMIC_DEBUG_MODULE to cc. Change the Kconfig entry to allow building with just _CORE, and fix the help text. Signed-off-by: Jim Cromie --- lib/Kconfig.debug | 10 +++++----- lib/Makefile | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d6798513a8c2..a40bc9ab689a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2794,12 +2794,12 @@ 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 works/demo's the dyndbg's classmap API, by + creating 2 classes: a DISJOINT classmap (like DRM.debug) + and a LEVELS/VERBOSE classmap (like verbose2 > verbose1). =20 If unsure, say N. =20 diff --git a/lib/Makefile b/lib/Makefile index 31195c75f5a0..943492d94771 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -239,6 +239,8 @@ obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) +=3D syscall.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 --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73150CA0EC3 for ; Tue, 12 Sep 2023 02:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235461AbjILCA0 (ORCPT ); Mon, 11 Sep 2023 22:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236125AbjILCAN (ORCPT ); Mon, 11 Sep 2023 22:00:13 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA051018BE; Mon, 11 Sep 2023 16:37:59 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-59205f26e47so47963397b3.2; Mon, 11 Sep 2023 16:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475414; x=1695080214; 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=vxV5EwVeeWXpJX0Hrevj96jd4dTd0GlqOcLeKugsmAo=; b=d7JHKPl3cpptRvP4X2nMFPNsAE0q85jy8pDy0/BQvofrlf8jbt4mlxqCdN+5qa3FFj oF9MDflDb8lYrelq+mMcGCmP5Lto0h9NPEIsPcOQIFSJUEPEiYjLBDD3TchlqYISwRIc skMiQc1k9zzXVwdzTCzwdPz069Y5dkes9nn5t6hANFrnsDfWpFYLb3mE93F1d1a9BjE0 UcfKIZnLDmqsMHuDFGYyNWjxV2G3vDVpFokrLfLki2tun8HgNwIHPiJXDImAtlnonIy5 t7uN8uqw9GDZkaLIUlVYHHlyPjy2JceQ56/F4zOvGrsrBlxTUqSDPvoR3SBLSIGF9a2B c2Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475414; x=1695080214; 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=vxV5EwVeeWXpJX0Hrevj96jd4dTd0GlqOcLeKugsmAo=; b=EdEJUj3c/bp5VB8nAfbuDqJwF9AOuboIVPYrbaJ9YCP3R7mtcaTDZCGWGsYle5nfBy lDB79X5hiKiZ1e0ZtmVNOmlirKotnIKPU0e1WcEmtz0QRs95ZKK2Zhp6/iIqV6H3zUkd eKS9XT4hjoSzp1dwhqfsKdkBqCO66uHis1wvUoQ6QPTTeYKDKpn5HF86YTCs2tI3wcLP 7FQYfnzTdFRmnydMCcsSjM1ROnKqCcgWKSvSE3iihBIv18vj3ns/nXsTMLP9RzEeAgGT nZjq26fxaP1qJCqHluAvgJ9MAsU6W1pTgzO/DJWcuA7lSLfi9u9Z2ABIW//6WSHYEEbi JlYw== X-Gm-Message-State: AOJu0YyeobI1X2jDxAlw1jw8dtUHXJk+SV6p62bx8MnmwiDZxu514B/E oLpumsR5LxdEcja8wu5la8yIpBO3Ntjffw== X-Google-Smtp-Source: AGHT+IGToB+JhZTwISt0CgVORoAeQuEFbPe5m0BPaNkuKCYxWUyirqBpKKg2RS9ogJTYNrxKH1TaXw== X-Received: by 2002:a05:6602:3352:b0:787:8fc:75d8 with SMTP id c18-20020a056602335200b0078708fc75d8mr13398981ioz.9.1694473743182; Mon, 11 Sep 2023 16:09:03 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:02 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 17/22] dyndbg-doc: add classmap info to howto Date: Mon, 11 Sep 2023 17:08:33 -0600 Message-ID: <20230911230838.14461-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add some basic info on classmap usage and api Signed-off-by: Jim Cromie --- v5- adjustments per Randy Dunlap, me --- .../admin-guide/dynamic-debug-howto.rst | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 0b3d39c610d9..4ad7d184ed9f 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -225,7 +225,6 @@ the ``p`` flag has meaning, other flags are ignored. Note the regexp ``^[-+=3D][fslmpt_]+$`` matches a flags specification. To clear all flags at once, use ``=3D_`` or ``-fslmpt``. =20 - Debug messages during Boot Process =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=3D=3D=3D=3D=3D=3D=3D=3D =20 @@ -375,3 +374,62 @@ 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 + +Dyndbg allows selection/grouping of *prdbg* callsites using structural +info: module, file, function, line. Classes allow authors to add +their own domain-oriented groupings using class-names. Classes span +the kernel, so DRM can define DRM_UT_<*> classes, and helpers & +drivers can use those definitions. + + # enable classes individually + :#> ddcmd class DRM_UT_CORE +p + :#> ddcmd class DRM_UT_KMS +p + # or more selectively + :#> ddcmd class DRM_UT_CORE module drm +p + +The "class FOO" syntax protects class'd prdbgs from generic overwrite:: + + # IOW this doesn't wipe any DRM.debug settings + :#> ddcmd -p + +To support the DRM.debug parameter, DYNDBG_CLASSMAP_PARAM* updates all +classes in a classmap, mapping param-bits 0..N onto the classes: +DRM_UT_<*> for the DRM use-case. + +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 + +DYNDBG_CLASSMAP_DEFINE - modules use this to create classmaps, naming +each of the classes (stringified enum-symbols: "DRM_UT_<*>"), and +type, and mapping the class-names to consecutive _class_ids. + +By doing so, modules tell dyndbg that they are have prdbgs with those +class_ids, and they authorize dyndbg to accept "class FOO" for modules +which declare that classname with the DEFINE macro. + +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) + +DYNDBG_CLASSMAP_PARAM - refers to a DEFINEd classmap, exposing the set +of defined classes to manipulation as a group. This interface +enforces the relatedness of classes of DD_CLASS_TYPE_LEVEL_NUM typed +classmaps; all classes are independent in the >control parser itself. + +DYNDBG_CLASSMAP_USE - drm drivers use the CLASSMAP that drm DEFINEs. +This shares the classmap definition, authorizes coordinated changes +amongst the CLASSMAP DEFINEr and multiple USErs, and tells dyndbg +how to initialize the user's prdbgs at modprobe. + +Modules or module-groups (drm & drivers) can define multiple +classmaps, as long as they share the limited 0..62 per-module-group +_class_id range, without overlap. + +``#define DEBUG`` will enable all pr_debugs in scope, including any +class'd ones (__pr_debug_cls(id,fmt..)). This won't be reflected in +the PARAM readback value, but the pr_debug callsites can be toggled +into agreement with the param. --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C0ECCA0ED3 for ; Tue, 12 Sep 2023 04:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233915AbjILEVg (ORCPT ); Tue, 12 Sep 2023 00:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230270AbjILEV1 (ORCPT ); Tue, 12 Sep 2023 00:21:27 -0400 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483A8F90D2; Mon, 11 Sep 2023 16:23:27 -0700 (PDT) Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6c0f4ad9eb1so629500a34.1; Mon, 11 Sep 2023 16:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474467; x=1695079267; 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=zeh7PAP1bDfU/ByWs4XqsTralpUOih5UTW3jDedZc7E=; b=aWk6fP5B+l6NF8pnFBNWJhgtm5EXC/EQdepQUjZlgCTJxlX8y2+9R1c7JvDsmljY3x slSGvgrBGDk5MRfCNBUvF6xyaagvjHaqEI/zoFUuD7nrQ0u2coHoO77XeU/KAADDtnKQ EWYcRbzbNP22BJUJYw8UlPrZYJaea57l5cT2eHc6lt/JdUlr0A8rEZqekiVd78+S/Nwd 7kDKRqSTYVqPNFlyGm8YO1lq3UvtfP4sZ8HUF7C4L4ae/ifLaddLLOE6bkzy0TLJaRnT UOqHDHNccBLnq7ZyhRBdT57sf1Ak9SsY+dUBHT+oPf3fbfVkXCDjxSjafRj4JYmLsSHf gLAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474467; x=1695079267; 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=zeh7PAP1bDfU/ByWs4XqsTralpUOih5UTW3jDedZc7E=; b=kkWrNKy7HtZuajMmNEHRVfWyVjmPhNlxTXZDjuZRzKza9JSm9QHqlMAsbJojeFdMud yTtKsybUOQ6JHYg2BXQdvpPtaeetnT2ZlNkEvJ6BwhJW0Kx88bJFRxaf0OQWjcX3ZtSy 1exzrgpmbzHA+rO3tcly4663vn+b3iRJkS0f9vw3HXz7ygXHm9VnQpEUDrPqDtRrHzms B7RmTZX/ZOzS4yPKuAVZz0LxfKWeiBRYC5ZqgDw00kSN0KL7TpCQiznuSfU8xrS1gYDi Bx0TRSaNIHuYu2xFh+SitKhRSl4M73KnPaVoFR7G+fWh9vLFqeCjVIS7SzKArLNDCsJa l9rQ== X-Gm-Message-State: AOJu0YxoAzAAeDcy9dXWYowboUkTcIcLOIjQuvlWBm3wLKLBosc2ABO9 Ce8Hb1A49rJ0pMFvkSJfn/18q7p5yWjfbg== X-Google-Smtp-Source: AGHT+IFOVUo/VwcxfVY8ZADs8CkL6phLCtLh6KlZ/IQ/cX8VOt/0wmLERhDHtLnKqrozckRxSOEdzw== X-Received: by 2002:a05:6e02:1053:b0:34c:f665:861e with SMTP id p19-20020a056e02105300b0034cf665861emr12027086ilj.21.1694473745039; Mon, 11 Sep 2023 16:09:05 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:04 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 18/22] dyndbg: reserve flag bit _DPRINTK_FLAGS_PREFIX_CACHED Date: Mon, 11 Sep 2023 17:08:34 -0600 Message-ID: <20230911230838.14461-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Reserve bit 7 to remember that a pr-debug callsite is/was: - enabled, with +p - wants a dynamic-prefix, with one+ of module:function:sourcfile - was previously called - was thus saved in the cache. NOT YET. Its unclear whether any cache fetch would be faster than 2-3 field fetches, but theres another factor; the 3 columns in the __dyndbg section are highly redundant and compressible, but to get the compression, we need field accessors, which will rebalance the tradeoff. So, for now, its just the bit reservation. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 15edac27cb56..bdb0d12b13ec 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -38,6 +38,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) #define _DPRINTK_FLAGS_INCL_SOURCENAME (1<<5) +#define _DPRINTK_FLAGS_PREFIX_CACHED (1<<7) =20 #define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E4BCCA0EC3 for ; Tue, 12 Sep 2023 02:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239274AbjILCeU (ORCPT ); Mon, 11 Sep 2023 22:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239323AbjILCeG (ORCPT ); Mon, 11 Sep 2023 22:34:06 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506C989A96; Mon, 11 Sep 2023 16:10:44 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-79536bc6697so181327839f.1; Mon, 11 Sep 2023 16:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473746; x=1695078546; 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=ESkE1bZNfU1HWAKelmlyxfVO/PhQytfAXhWjbkh3sXk=; b=Lcjj5t0jnyL1eJYPppc/vIAmycCSJaxf2llQpcpyHfWJ94OcmpNlA6vCAdW3rWj4za H6ql6yiPFYV0tF+aKqeJCuJaynXZs7Uca+2Hy5rbiW/t5s3ECXygnkiRKEFurUtXYJ+H 3ltRwRTp/ZBHYbsd2wG5OxmJvxOUz850ef7Vj9Zm54Nk1ybtgaecHGb/ERr76Ai8HZfe 3BntSBWn7IugX8H6yvMttDV9Qy+kCe8+0Rj2NhpxS5kJr3bsp+MOsvc5mzWSM0QzijT5 oy3bQGrnq4AcdOb+3XXBGKBpEc4Jh61YP4idJkNEIKbCqV4vxU94UCELLKOxnrzm0IuT AlcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473746; x=1695078546; 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=ESkE1bZNfU1HWAKelmlyxfVO/PhQytfAXhWjbkh3sXk=; b=gdrR4WU/24L3gJ94tQOEV3tSX8rKFNxRhIPnHt8o7JmoXITY5kWba5v5opz4ixTyxJ 5PUu5W9fdjrXP3mEmdEQJg9xz8VBzyi5K7lxnkqygoGuGDhTyGL8HW6tJZ08QvpkhmN0 AF6zGfdSBWBBZRo3e+c/V150Q4XtorlC2suL59FVZWZ1hJ8cb7Nv31ZCDtpMoiDkN00i 2w9gAOJwmIuM0CaFOvtq0qAWVoqZCPJ0z7KGOnDcWRioY8a3JyIaxMb2auSKwjDxKuYG ZJTOCarwMVZGKENojw5MsD6F2bS8ZzSwRjQuB6jG54R24SgnzXM+kLB2gVf8cyGg2HID Nq+Q== X-Gm-Message-State: AOJu0Yzmp6yna0yNr6gf2iH/foCer524FjFBzwouOxzJ0sMY7E4W3VDj uCe4PiB6D3zzkCe+9i7DTPw= X-Google-Smtp-Source: AGHT+IHNuCLf8PX+N8HFzY2KIxhpLtrrXX7XbHvVmw+f5uCzl6ZDWoiAWyY7Py4er03hU5zXqdzM6g== X-Received: by 2002:a05:6e02:1bae:b0:34c:c8e8:ca87 with SMTP id n14-20020a056e021bae00b0034cc8e8ca87mr14120307ili.20.1694473746384; Mon, 11 Sep 2023 16:09:06 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:06 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 19/22] dyndbg: add _DPRINTK_FLAGS_INCL_LOOKUP Date: Mon, 11 Sep 2023 17:08:35 -0600 Message-ID: <20230911230838.14461-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" dyndbg's dynamic prefixing (by +tmfsl flags) is needlessly expensive. When an enabled (with +p) pr_debug is called, _DPRINTK_FLAGS_INCL_ANY prefix decorations are sprintf'd into stack-mem for every call. This string (or part of it) could be cached once its 1st generated, and retreived thereafter, as long as its deleted any time the callsite's flags are changed afterwards. So consider the prefix/decoration flags: 'tmfsl', and what should be in the cache: -t thread-id. not part of the "callsite" info, derived from current. doesnt belong in the cache. it would be wrong. can be done in outer: dynamic_emit_prefix() -l line number this could be part of the prefix, but would bloat the cache can also be done in outer: dynamic_emit_prefix() -mfs module, function, source-file we cache these, composed into a sub-string. they are "lookups", currently to descriptor fields, could be accessor macros to "compressed" tables. cache saves more access work. All enabled together, they compose a prefix string like: # outer -----inner---------- outer "[tid] module:function:sourcfile:line: " So this patch extracts _DPRINTK_FLAGS_INCL_LOOKUP macro out of _DPRINTK_FLAGS_INCL_ANY macro, then redefs latter. Next re-refactor dynamic_emit_prefix inner/outer fns accordingly. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index bdb0d12b13ec..c5609560ca1b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -40,10 +40,12 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_SOURCENAME (1<<5) #define _DPRINTK_FLAGS_PREFIX_CACHED (1<<7) =20 -#define _DPRINTK_FLAGS_INCL_ANY \ - (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ - _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID |\ +#define _DPRINTK_FLAGS_INCL_LOOKUP \ + (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME | \ _DPRINTK_FLAGS_INCL_SOURCENAME) +#define _DPRINTK_FLAGS_INCL_ANY \ + (_DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID | \ + _DPRINTK_FLAGS_INCL_LOOKUP) =20 #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2571CA0EC8 for ; Tue, 12 Sep 2023 02:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240282AbjILCms (ORCPT ); Mon, 11 Sep 2023 22:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239726AbjILCmF (ORCPT ); Mon, 11 Sep 2023 22:42:05 -0400 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1F01E5B15; Mon, 11 Sep 2023 16:11:17 -0700 (PDT) Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-34e202a9cc9so16177705ab.2; Mon, 11 Sep 2023 16:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473747; x=1695078547; 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=fcAgeVHnxNNRvfl+2uM1osGvKKovW40vicb6K15Ndz8=; b=b7rVmnS9T2aQg3o2AMKyW8JM0sAfC7g3uZR+9zk+WYr+FmzAR1qZHWThmg1cJGEN7I MoRELaXROKoZKKXMIei0VQ1XVB1i51m3iLSQp7hs4vfYZ0JD2z8yT5OEhooFVLKzLNdp 9J2wQUfGv3mZKgCf1ST3EC93stRjqwBN9kBQ6c4aVxs5f8gndoLNxzLM5+5wrP+Baj/f OXEawUVMX8Nfzo/83S/AaRGB9aTnweFyK1Cst6MkrPcNlTVv2m+KPWPumIheQv1b7R0X J/t3r4CWBQTtPWqGOztAghW011W6vhTAcMgyaWaNHB+wdBAalaJgQ1XrBxmV89L1IIn1 K0CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473747; x=1695078547; 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=fcAgeVHnxNNRvfl+2uM1osGvKKovW40vicb6K15Ndz8=; b=Os1ooQGMtjx0G8t19xaarmAbi1Npkk7HtGf9w9wNvA6w6snMgJJZCaK2X1eY0Y5jnJ c8ezqJlQQXJLrxjK1iCtNs3hqzRCrwMg9ckjq7iahi6wJ3uOSDyodP/dnK12qulAIGY+ Go+oK95FRrQ26lYC7ARpFuzuxgnm1dHJ2wgF+Ad7+fqlXl2AaCNtOhnI1y49aO9i54Eq J96GFLLvLtHQ9xQI9iCpv7pUZDoYP4smWl6ckJwQltzKm0/5ojoi2fQbLa3g9alcg7lf am+zdkNneuurL3zSn7zbrOqtSgyGQU4Z/3WgQVydbqYKLuQOLu6vVAMIg8gY7+p2jOxP rBRw== X-Gm-Message-State: AOJu0YxbZlsvX9xK0AZDVxrQg7Q0ftHK5NTrGNVbZpQLlDpyNXyXKJgo agF/go/aZ5MOHwYFh7s4bPU= X-Google-Smtp-Source: AGHT+IGm8XJJjgEBdcXS6iFzgL2wU9gzTG524paxkBRkx7pWMbgnsFowJbau/w+sUivI5RVDg02BfA== X-Received: by 2002:a05:6e02:1a85:b0:34f:49cb:40a9 with SMTP id k5-20020a056e021a8500b0034f49cb40a9mr12781961ilv.4.1694473747663; Mon, 11 Sep 2023 16:09:07 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:07 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 20/22] drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN Date: Mon, 11 Sep 2023 17:08:36 -0600 Message-ID: <20230911230838.14461-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Lots of burn-in testing needed before signing, upstreaming. NOTE: I set default Y to maximize testing by default. Is there a better way to do this ? Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index afb3b2f5f425..27bbb03e84dd 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -52,8 +52,7 @@ config DRM_DEBUG_MM =20 config DRM_USE_DYNAMIC_DEBUG bool "use dynamic debug to implement drm.debug" - default n - depends on BROKEN + default y depends on DRM depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE depends on JUMP_LABEL --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CF5ECA0EC8 for ; Tue, 12 Sep 2023 02:12:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235645AbjILCMc (ORCPT ); Mon, 11 Sep 2023 22:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235775AbjILCMM (ORCPT ); Mon, 11 Sep 2023 22:12:12 -0400 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E9CDE9D8D; Mon, 11 Sep 2023 16:19:37 -0700 (PDT) Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-d7cbcfdf137so4361902276.2; Mon, 11 Sep 2023 16:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694474244; x=1695079044; 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=dPgMplOaghCKoaw6KVIn3I1GwgTSwBS4ON0Ej0Rg2ww=; b=jc7BIF6NZU8mIj2C313YafIAlP1V7KMkKA671ff3rlJy/gC6vfzRfXeiPyKFuEUb5j lx1Y1xJntmBmyoV41xefDnuBWSWYiSlWdrY9I8J02ZRby4cNxELseEaNpTok8ejPMlTX LrE0jTANl2Jmu+iUW/B0JF2E/nHGifwf6eHZ/nZ441/8WT5d7vdZX+pf4r3YwK+HQCwM bQSGjYSxpv15M3166EtLbr84J691yw6nbYFPnN6JN2YYXK77jmDGuji4XUYn6x5RvyhC qGbCK1zvsbMGi3WGdrvnx7pdRl0UgnzaiQTR/zNT8HYxDsaw+EgqI4kA0LNV0mgASuN4 aejA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694474244; x=1695079044; 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=dPgMplOaghCKoaw6KVIn3I1GwgTSwBS4ON0Ej0Rg2ww=; b=ewmGvTXJJt1aQHE0JhAMqKH2i6iU11RL6sJc0fggrpBfXTwGa2mU6y12SS/UF4Ojtp h2JPdPFEJ2SGwPebKoxQXNb6ZcPPZ9ZntTLoGOpPxZm/ibsFiw6K0pubVQlsW9SVHtDN KYMXmfT9bDj6FCfEcwiyCAxcgoi9lrg7z3w3tZDgKll1cqiVzpFPpPzBR3DJV7BgHtls GaCdAw4o0X78D9yodNH4vDh5xAGDl9rHih2yy4egNO1cvtwE2gayIaOEDizaksZxsrqG /MjAr+VD9W5V++Hz0V9AqyvrBHAfFAVwiN2BR1fVAfj+mmlDfSRDRTQ2mVsq5ad5jjoU WQuw== X-Gm-Message-State: AOJu0YzWzCwj4kmEjQyKh1AYClVrrwcguV7WH241ysQ8lWDDsvRmyxw3 GFAroiiD1pf50BUtWIOkBgryz4Fjv9UKig== X-Google-Smtp-Source: AGHT+IHX0TSt+caD80mtO3zdFhx13hIWLdOMsQp29S6Hbbwm3vaZvIW2jLmwTNt0GjAv/TclECpUsQ== X-Received: by 2002:a05:6602:2776:b0:790:9f0c:3069 with SMTP id l22-20020a056602277600b007909f0c3069mr13263726ioe.9.1694473749038; Mon, 11 Sep 2023 16:09:09 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:08 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 21/22] drm: use correct ccflags-y spelling Date: Mon, 11 Sep 2023 17:08:37 -0600 Message-ID: <20230911230838.14461-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Incorrectly spelled CFLAGS- failed to add -DDYNAMIC_DEBUG_MODULE, which broke builds with: CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy CONFIG_DYNAMIC_DEBUG_CORE=3Dy CONFIG_DYNAMIC_DEBUG=3Dn Also add subdir-ccflags so that all drivers pick up the addition. Fixes: 84ec67288c10 ("drm_print: wrap drm_*_dbg in dyndbg descriptor factor= y macro") Signed-off-by: Jim Cromie --- drivers/gpu/drm/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 7a09a89b493b..013cde886326 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -3,7 +3,8 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. =20 -CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) +=3D -DDYNAMIC_DEBUG_MODULE +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) +=3D -DDYNAMIC_DEBUG_MODULE +subdir-ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) +=3D -DDYNAMIC_DEBUG_MODULE =20 drm-y :=3D \ drm_aperture.o \ --=20 2.41.0 From nobody Sun Sep 14 06:35:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E192CA0EC3 for ; Tue, 12 Sep 2023 01:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233272AbjILBsU (ORCPT ); Mon, 11 Sep 2023 21:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbjILBsK (ORCPT ); Mon, 11 Sep 2023 21:48:10 -0400 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09C313CC1C; Mon, 11 Sep 2023 16:43:48 -0700 (PDT) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-59b9b47e35dso10281477b3.0; Mon, 11 Sep 2023 16:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694475697; x=1695080497; 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=sg6cE/x2UUPlr07T7fY2WapJd57AiLvtF5oOk9nL6T4=; b=SXmW67e9cMPdC2V8L5WjgsumE1phAVoof/0bWoQfpQmDJl2iVex6gOlFoNdwVZHXhb M+3+BBULcVwzkNEeD0epU6jz7wmfsNLFoVR1QV/voKLjIuWDtUPha5HUqeyEJto8s5nK 1lMUEyK0N2LGS2NGhh/dcjURInvnRQ5BwdORzKfXLyhS+KBQWIIN7tx0qhhICvVoYshy w3Awmw25zOPH+QKi+aq8gmu0nX4iGJ5M+ppDUQunN2UBcut3Vf8XRizxKwE6eiXjV1qN Qzb6rv8jMQvxikJ7KWeSuDpMUBOfq72+mpMAfEk0t01RBlgOuU/DEWlIxI859BNYc8VT K07w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694475697; x=1695080497; 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=sg6cE/x2UUPlr07T7fY2WapJd57AiLvtF5oOk9nL6T4=; b=pPcw3JGxV7EvcXxSbJcns6/opOC/acbjIERAPclHMvraGRfhbggpmv0ALvW82Dgn2C PMxa21NYb/OTYUo1xIYCA+4erD5dsXoVZ5yPwIQItn+J/28rXes1xOuzNdCDD+vsAg2h kj9pRzWfWgA3PkwdgEPV+pNM/gznTrD6+3DA+L4lZqEZXvzquciiCBsaO/vhfoBMF84G PusjWQCJ1WwCkINKu1Wzo1/y185WfjTu9fblsMWXErhFnCnvq5Q04QwUGq20RPg+bADS GdkeVzIKeEI2mTdK5uKllC4vuJMJgScnEqK/oFEhlfK7Mj9lbpPYZxBQCNlk/qfD7fgj V9NA== X-Gm-Message-State: AOJu0YwRycRGRO+I0iplhsCmGAgtq/jYKWJzR/yPGUD2Z4BA+IIAgawU gXZXP97IkFfbTPgoiS29o1esokzJWsyT7A== X-Google-Smtp-Source: AGHT+IGZBso+YJhrY7t/VYPk/2yLAsPpkHexYrSGfYFJHFWMcssIeOmFtlcZJ94GnWtgRM+asWeoAw== X-Received: by 2002:a6b:5c18:0:b0:785:5917:a35f with SMTP id z24-20020a6b5c18000000b007855917a35fmr13374513ioh.8.1694473750661; Mon, 11 Sep 2023 16:09:10 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:09:10 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: 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, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 22/22] drm-drivers: DRM_CLASSMAP_USE in 2nd batch of drivers, helpers Date: Mon, 11 Sep 2023 17:08:38 -0600 Message-ID: <20230911230838.14461-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a DRM_CLASSMAP_USE declaration to 2nd batch of helpers and *_drv.c files. For drivers, add the decl just above the module's PARAMs, since it identifies the "inherited" drm.debug param. Note: with CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, a module not also declaring DRM_CLASSMAP_USE will have its class'd prdbgs stuck in the initial (disabled, but for DEBUG) state. The stuck sites are evident in /proc/dynamic_debug/control as: class unknown, _id:N # control's last column rather than a proper "enumeration": class:DRM_UT_CORE This set of updates was found by choosing M for all DRM-config items I found (not allmodconfig), building & modprobing them, and grepping "class unknown," control. There may yet be others. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++ drivers/gpu/drm/gud/gud_drv.c | 2 ++ drivers/gpu/drm/mgag200/mgag200_drv.c | 2 ++ drivers/gpu/drm/qxl/qxl_drv.c | 2 ++ drivers/gpu/drm/radeon/radeon_drv.c | 2 ++ drivers/gpu/drm/udl/udl_main.c | 2 ++ drivers/gpu/drm/vkms/vkms_drv.c | 2 ++ drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 ++ 8 files changed, 16 insertions(+) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_g= em_shmem_helper.c index baaf0e0feb06..097d87f1ad74 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -23,6 +23,8 @@ #include #include =20 +DRM_CLASSMAP_USE(drm_debug_classes); + MODULE_IMPORT_NS(DMA_BUF); =20 /** diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c index 9d7bf8ee45f1..5b555045fce4 100644 --- a/drivers/gpu/drm/gud/gud_drv.c +++ b/drivers/gpu/drm/gud/gud_drv.c @@ -31,6 +31,8 @@ =20 #include "gud_internal.h" =20 +DRM_CLASSMAP_USE(drm_debug_classes); + /* Only used internally */ static const struct drm_format_info gud_drm_format_r1 =3D { .format =3D GUD_DRM_FORMAT_R1, diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag20= 0/mgag200_drv.c index 976f0ab2006b..a1b2be1c27f6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -24,6 +24,8 @@ int mgag200_modeset =3D -1; MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); module_param_named(modeset, mgag200_modeset, int, 0400); =20 +DRM_CLASSMAP_USE(drm_debug_classes); + int mgag200_init_pci_options(struct pci_dev *pdev, u32 option, u32 option2) { struct device *dev =3D &pdev->dev; diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index a3b83f89e061..12600f557c23 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c @@ -65,6 +65,8 @@ module_param_named(modeset, qxl_modeset, int, 0400); MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)= "); module_param_named(num_heads, qxl_num_crtc, int, 0400); =20 +DRM_CLASSMAP_USE(drm_debug_classes); + static struct drm_driver qxl_driver; static struct pci_driver qxl_pci_driver; =20 diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/r= adeon_drv.c index e4374814f0ef..4219276ade6a 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -274,6 +274,8 @@ int radeon_cik_support =3D 1; MODULE_PARM_DESC(cik_support, "CIK support (1 =3D enabled (default), 0 =3D= disabled)"); module_param_named(cik_support, radeon_cik_support, int, 0444); =20 +DRM_CLASSMAP_USE(drm_debug_classes); + static struct pci_device_id pciidlist[] =3D { radeon_PCI_IDS }; diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c index 3ebe2ce55dfd..ba57c14454e5 100644 --- a/drivers/gpu/drm/udl/udl_main.c +++ b/drivers/gpu/drm/udl/udl_main.c @@ -19,6 +19,8 @@ =20 #define NR_USB_REQUEST_CHANNEL 0x12 =20 +DRM_CLASSMAP_USE(drm_debug_classes); + #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE) #define WRITES_IN_FLIGHT (20) #define MAX_VENDOR_DESCRIPTOR_SIZE 256 diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_dr= v.c index e3c9c9571c8d..38252f29f983 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -39,6 +39,8 @@ =20 static struct vkms_config *default_config; =20 +DRM_CLASSMAP_USE(drm_debug_classes); + static bool enable_cursor =3D true; module_param_named(enable_cursor, enable_cursor, bool, 0444); MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/v= mwgfx_drv.c index 8b24ecf60e3e..9cb6be422621 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -275,6 +275,8 @@ static int vmw_probe(struct pci_dev *, const struct pci= _device_id *); static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, void *ptr); =20 +DRM_CLASSMAP_USE(drm_debug_classes); + MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages"); module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600); MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages"); --=20 2.41.0