From nobody Sat Apr 11 12:31:06 2026 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 9DD01ECAAD5 for ; Sun, 4 Sep 2022 21:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234742AbiIDVmR (ORCPT ); Sun, 4 Sep 2022 17:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234698AbiIDVmI (ORCPT ); Sun, 4 Sep 2022 17:42:08 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6012C648 for ; Sun, 4 Sep 2022 14:42:07 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5652534iod.8 for ; Sun, 04 Sep 2022 14:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wU3a+NtnQXjoNN7rXOqrGTxjDahMgVmGQsWn0PV1P8M=; b=oqkgy1Lfx8/69RwJIe3zmzWJ5fKHCCfMExZbNN1eCUrtrvQvfE+1n1ok/9I/8qxcYJ V2Y5ovP3OXd3K2CAgS1BbVBtTfJUEdG+6tO5gfR37M2/5p6wJ7VN6X0nrZdJxzrfPg/O GkZXIIfX5vDFQr6/LJp0ofI0n6FCf/1AN3tsFeNZ25fi7xHd9VYOST2OyHqYWaGYzSlw QAv9HoibN19LRrRCQG9pGNe24p8W2DNmEf8nLDndfGLmEJnHDeMsDoQW6Zdu2pC0wkcY XlK7itax1DrgPu8UOaURRS4O0KdAKHHKQZ5pij8wgvGjblMAY0dpNFeQ9Bgy/4Pt7tCN CpYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=wU3a+NtnQXjoNN7rXOqrGTxjDahMgVmGQsWn0PV1P8M=; b=HXci5Uj1eQui56bOj8lp+JfYxuaEF404XKpPfxq62XwDFSBfkLfLoopxz8EGMWKZJA QxXWXBy9RkOkpy+u3YOB5eKm3E8EKvg2YI8rUgYK7UDP2pr+06y7YIQlJrLAoYPbuI0/ hsYp7uRjy7yS6sGmMzXqafPjwXsam0eH18hnkyF70qNIbM0VGh0/eNjLmHZfbjfBaZeI uOqT5KbamoVXFrsI9wN3xgwbzuja+LVxBATwxVmzwMm9dEJxYmCxGHwlapKDcdPCU5gt Isnka0uP/KNPgijrW4Dw/uWsEVUdIiijXMJ4pYsjmp6LV6+630yywfAaIKRJbVS4H1nJ hOyQ== X-Gm-Message-State: ACgBeo3bjNgSLLQ9XJmt23GO2L7HCm73X7mNB4MmH1p6qC3NyQDQGXnp vpoXprICewYmCVi2JFUw4cStzLv54zk= X-Google-Smtp-Source: AA6agR6woh73WD6o0519OJbQFrJQIwWPKVm7AZf+Fo8tuX8h74mdDupZVosU1fX68Rvv18her7b2lQ== X-Received: by 2002:a05:6638:25ca:b0:351:1a2a:763d with SMTP id u10-20020a05663825ca00b003511a2a763dmr3305728jat.251.1662327726407; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:06 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH v6 01/57] dyndbg: fix static_branch manipulation Date: Sun, 4 Sep 2022 15:40:38 -0600 Message-Id: <20220904214134.408619-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" In https://lore.kernel.org/lkml/20211209150910.GA23668@axis.com/ Vincent's patch commented on, and worked around, a bug toggling static_branch's, when a 2nd PRINTK-ish flag was added. The bug results in a premature static_branch_disable when the 1st of 2 flags was disabled. The cited commit computed newflags, but then in the JUMP_LABEL block, failed to use that result, instead using just one of the terms in it. Using newflags instead made the code work properly. This is Vincents test-case, reduced. It needs the 2nd flag to demonstrate the bug, but it's explanatory here. pt_test() { echo 5 > /sys/module/dynamic_debug/verbose site=3D"module tcp" # just one callsite echo " $site =3D_ " > /proc/dynamic_debug/control # clear it # A B ~A ~B for flg in +T +p "-T #broke here" -p; do echo " $site $flg " > /proc/dynamic_debug/control done; # A B ~B ~A for flg in +T +p "-p #broke here" -T; do echo " $site $flg " > /proc/dynamic_debug/control done } pt_test Fixes: 84da83a6ffc0 dyndbg: combine flags & mask into a struct, simplify wi= th it CC: vincent.whitchurch@axis.com Acked-by: Jason Baron Signed-off-by: Jim Cromie --- .drop @stable, no exposed bug. .add jbaron ack --- lib/dynamic_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dd7f56af9aed..a56c1286ffa4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -211,10 +211,11 @@ static int ddebug_change(const struct ddebug_query *q= uery, continue; #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + if (!(newflags & _DPRINTK_FLAGS_PRINT)) static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + } else if (newflags & _DPRINTK_FLAGS_PRINT) { static_branch_enable(&dp->key.dd_key_true); + } #endif dp->flags =3D newflags; v4pr_info("changed %s:%d [%s]%s =3D%s\n", --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 313A6C6FA86 for ; Sun, 4 Sep 2022 21:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234698AbiIDVmU (ORCPT ); Sun, 4 Sep 2022 17:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbiIDVmP (ORCPT ); Sun, 4 Sep 2022 17:42:15 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19D152EF2B for ; Sun, 4 Sep 2022 14:42:12 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id q81so5653536iod.9 for ; Sun, 04 Sep 2022 14:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uH+4PavI6tAvpP/bjllSxBrsqqx6lF8VrU02FESH7jw=; b=KSguwditGP/8FfWJ8QbYlUiwq8c5izqFVOSRXyhmdm05P40z31yyLERnx/4KMPZ18U yGQR/CcjnDmULO16vw9EZu863miip8Q4Ywm4OktFjjZNUdUqH0muQK6Hts5AQIQFY6EB Gnd8tvXDTP4gJcju+NDHoa6XhCzxcDglfVGpQH0OUqyXe+AwXj6MR3J0j7QIftZAI5mj aaAjnkm2GGxbLWKdhe9FWSpkC220hHqlwQNKss4GdfYbEiEqODGTAqXksS6qf8YV6XOx K+5l+OjHWI7q3CG8hiEA7+JF714yQmdURuxM/WmEm8lMmPJufYDfmHmioTV5V0ZMKzak OMig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=uH+4PavI6tAvpP/bjllSxBrsqqx6lF8VrU02FESH7jw=; b=qd9qyxCNiglQ5IFMvi8xYPTJNx/3RHtz3TqoVttf979PuDX/uyNF5YxGEripLH1Q5Y mTHtjKF4PPMJuh+xmjnDl/1YgyR6ls7yAbz3huqa6pyPFAhAg4JLdpJenH0gjp8vDrZB 6x5wwB7bhJrb4D5QE+u4ohV+mwMoTpBVK7/MrQ1JsuVYRVEWlO47DxX7qSnJWViabXAm ijWK4bmBRFNoT9WQXW4Cya9HgTsyq3EL5gGEmjaFtcKMTGURUFoNMjJU8qFNHdJ1Bdra YIj6HcF2fGnbbDOX8+txTQ+rGdYlL5n41m2AkzlED12hts4I40qxXQjuV509mvJv2K5c kPkA== X-Gm-Message-State: ACgBeo0QuTbE4dJAlDCIN8FdyqMihrc2L1puY5T7WoJyldTFn0CiMUjh c0Dsw9pu+MSC6JZXyLW5WMboWHVqYdY= X-Google-Smtp-Source: AA6agR47srkJpi3DXb58PnE0nCQCRP4+fmezLwneAZEvxkrMVJGtdvwOuDoiXOHxF1d7qDgzdSj+Lg== X-Received: by 2002:a05:6602:140d:b0:68b:1bd1:1c54 with SMTP id t13-20020a056602140d00b0068b1bd11c54mr18562369iov.9.1662327731887; Sun, 04 Sep 2022 14:42:11 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:11 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 02/57] dyndbg: fix module.dyndbg handling Date: Sun, 4 Sep 2022 15:40:39 -0600 Message-Id: <20220904214134.408619-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" For CONFIG_DYNAMIC_DEBUG=3DN, the ddebug_dyndbg_module_param_cb() stub-fn is too permissive: bash-5.1# modprobe drm JUNKdyndbg bash-5.1# modprobe drm dyndbgJUNK [ 42.933220] dyndbg param is supported only in CONFIG_DYNAMIC_DEBUG builds [ 42.937484] ACPI: bus type drm_connector registered This caused no ill effects, because unknown parameters are either ignored by default with an "unknown parameter" warning, or ignored because dyndbg allows its no-effect use on non-dyndbg builds. But since the code has an explicit feedback message, it should be issued accurately. Fix with strcmp for exact param-name match. Reported-by: Rasmus Villemoes Fixes: b48420c1d301 dynamic_debug: make dynamic-debug work for module initi= alization Acked-by: Jason Baron Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..f30b01aa9fa4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -201,7 +201,7 @@ static inline int ddebug_remove_module(const char *mod) static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *modname) { - if (strstr(param, "dyndbg")) { + if (!strcmp(param, "dyndbg")) { /* avoid pr_warn(), which wants pr_fmt() fully defined */ printk(KERN_WARNING "dyndbg param is supported only in " "CONFIG_DYNAMIC_DEBUG builds\n"); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 B16FEECAAD5 for ; Sun, 4 Sep 2022 21:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234971AbiIDVmY (ORCPT ); Sun, 4 Sep 2022 17:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234794AbiIDVmQ (ORCPT ); Sun, 4 Sep 2022 17:42:16 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33882F002 for ; Sun, 4 Sep 2022 14:42:13 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id q81so5653543iod.9 for ; Sun, 04 Sep 2022 14:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=PbqFdyxSi0Pp6DU3HKsSvwhQJYj8Q2VNhxZwCrpnF6M=; b=VsDvR0vs9q2FKCQfOJtjIj8FHz9/Z3bqLVP6coIdC18//1aR2LaIbaZwWf9Z6tEGfl 5LATbVVqKiBlBcSVvzROupFX7UszhsGWDUy+bmPT1qGZcI1Zqa5qU39Qb2kqg4sRO0kw fgQxDQpiLWZ85LuT4smVr3O+O5zuSTuXZnwG3Rv/A16MfL6bVIcM4HNldOSP2KESU/gT V20+cxV8kGInvZOnWna6gEYV1K+GBUIItJpcmPhCpXQ4cyszHg26A0WRN3M3WtAN/wBm medsQTQakd/d2p87LqtCTlPg3npIOQkOQZQTqCeT1ibwK4SGN1YC/clvc4rCKuFX7YAD 0pxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=PbqFdyxSi0Pp6DU3HKsSvwhQJYj8Q2VNhxZwCrpnF6M=; b=hGtoXlK7pMgn1l40fY8Yx5LCFrSwS16fCSY8hi2WvUPX6ZUNRpXwlxTnfAJiFMo+mH efGgEIc8wN5AJqTV0Xx4IWU97ogF/5t/EvGyVHXjhxMz5Yvw7NM5xqQb727K4n6IeMWJ /6NNLs8zV9YyAHQV3ona5NaI2VhYuekz1DpX00AQoriK8ZKkHMaRHw2ncRxbO1A7dKH5 ag8GxNnwqgRpDhMxdHlXxZjeAENCLZP5DuxCTPR8tpGqu7u7QFOdjHU6czFpsQzQtdM9 BinbVdWEWni26MNdsRqPkQRH8Td7jCVRMRH4V3qGdEseKvx2+BBt//IBUYPWeLYtwEeE 5qUQ== X-Gm-Message-State: ACgBeo1c8OZalrl0RuEoC+Q63vuIqKaNARZcToVrV9Lvhs2/6wTmdYgm jsud9GlDGeFopMDm5NJdISg= X-Google-Smtp-Source: AA6agR7fSTOVCWKQ249DqThxtdMK6mWi8uoaxMmg3jSWwtFYYJA/nulJNENKG3FHhy/TNLExju0ubQ== X-Received: by 2002:a05:6638:3385:b0:339:ea59:a31f with SMTP id h5-20020a056638338500b00339ea59a31fmr23089435jav.55.1662327732789; Sun, 04 Sep 2022 14:42:12 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:12 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 03/57] dyndbg: show both old and new in change-info Date: Sun, 4 Sep 2022 15:40:40 -0600 Message-Id: <20220904214134.408619-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" print "old =3D> new" flag values to the info("change") message. no functional change. Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a56c1286ffa4..8faf584f2f4b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -156,7 +156,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, struct ddebug_table *dt; unsigned int newflags; unsigned int nfound =3D 0; - struct flagsbuf fbuf; + struct flagsbuf fbuf, nbuf; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -217,11 +217,12 @@ static int ddebug_change(const struct ddebug_query *q= uery, static_branch_enable(&dp->key.dd_key_true); } #endif + v4pr_info("changed %s:%d [%s]%s %s =3D> %s\n", + trim_prefix(dp->filename), dp->lineno, + dt->mod_name, dp->function, + ddebug_describe_flags(dp->flags, &fbuf), + ddebug_describe_flags(newflags, &nbuf)); dp->flags =3D newflags; - v4pr_info("changed %s:%d [%s]%s =3D%s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &fbuf)); } } mutex_unlock(&ddebug_lock); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 373E8C6FA86 for ; Sun, 4 Sep 2022 21:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235023AbiIDVm2 (ORCPT ); Sun, 4 Sep 2022 17:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234778AbiIDVmQ (ORCPT ); Sun, 4 Sep 2022 17:42:16 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EFA82C643 for ; Sun, 4 Sep 2022 14:42:14 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5652637iod.8 for ; Sun, 04 Sep 2022 14:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lfSfy0OiU9ae6zZc6r/YuzMWOjdJ0UjQGjJ43pXzmPk=; b=KcesxilWXRdWpOhaJNS8hSdNzO2vJhvPIX8XFE/aZuuFFV/+3fkufo6o6ElznrbWN1 hoQZPHbfdOcz8L6sXkvFrKKZliazt6a4HKb0p79Fa2Zhrdr6HDCcI0KK/H9P9yVDZ0Y1 XOoaExBg1xHhuXs3yHeI8R5l5GWskuW3Z+FVRjyUb653F8P0zqYTLWJiVIDzJ2NhKKTd sAM2TckvvjW2cAHdzhkzl7UYgmcQlxp7qgTNOjT2XZzRsRWDv8h0wvTVgRljyvneh0q1 9N5+8G6XjIRe/5YLV+HiKEXVas9ltjJefKy4f23RAvj1+gQWPwzMCaVO52+Z4MXYdv5k T+pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=lfSfy0OiU9ae6zZc6r/YuzMWOjdJ0UjQGjJ43pXzmPk=; b=Qf1DmaPsWRVIHAUqsdVJqOB6XO0h1ccmRM7dzeJh3MbFFfUUfugvPXr/P6AZISDDBP pb5fxXiyNHuekY4Bhgr6V44jeT0LMvpIScMgKV3K1NMccCjeGbsayBX6bUVw0kiuHnyu AynaBSEX7QBcDnMS++zX5SEEFQSTr1KnZIjDztFHw2p1W5/r04I7SOq6//X5myZpm3+s SzY6C2b2kcVYikiZso3EmYHBceiNRKNCjTYTzEb0wC2NElDnraLtFyIVSCM6/ln4CvQv 3+qYGxu1Nzb17PMEmsYiJ1nzqeIkKa1X+3+oiKcGbH2CfqO7lGcGKSODoArzQebTDP86 NcZw== X-Gm-Message-State: ACgBeo2Vh574bwyNEoyIw6mJfTs6O4eMLj9jCQF+ERHxHZRnniW+ThGZ 9cifGXrVFWp5qaFUN1lyF44= X-Google-Smtp-Source: AA6agR52gEm4o8C36a4sLU4vrMjIM3u6oGZjtYr9bqiC4iAeliEnkHdid9H5R34pPZS4s09WvEyVEg== X-Received: by 2002:a5e:a70f:0:b0:684:d596:b7e7 with SMTP id b15-20020a5ea70f000000b00684d596b7e7mr20134222iod.84.1662327733775; Sun, 04 Sep 2022 14:42:13 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:13 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 04/57] dyndbg: reverse module walk in cat control Date: Sun, 4 Sep 2022 15:40:41 -0600 Message-Id: <20220904214134.408619-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" /proc/dynamic_debug/control walks the prdbg catalog in "reverse", fix this by adding new ddebug_tables to tail of list. This puts init/main.c entries 1st, which looks more than coincidental. no functional changes. Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8faf584f2f4b..7fb99492c16f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -970,7 +970,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int= n, dt->ddebugs =3D tab; =20 mutex_lock(&ddebug_lock); - list_add(&dt->link, &ddebug_tables); + list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 15812C6FA82 for ; Sun, 4 Sep 2022 21:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbiIDVm3 (ORCPT ); Sun, 4 Sep 2022 17:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234761AbiIDVmT (ORCPT ); Sun, 4 Sep 2022 17:42:19 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9959E2DA8E for ; Sun, 4 Sep 2022 14:42:15 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id d68so5628781iof.11 for ; Sun, 04 Sep 2022 14:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=86ewCwjQW9i1kYjMVzcHXeBvyH4rTaXf6X7Uwlu5n+M=; b=GXl1s6xju+1eOoRqJRl5q8cmU4AqdZG79xuy+4LJGCEiw/Hpm6hcED/kqRFHo3q+gu qamuPL9FDFXp54vbLn1D/b404KlO7XolhPIJPAhLWpnmuPX+sSGTlZLE8h+zZqYnQIrO WQv5lca1ZofQjJIzLmrQTtiUPEYKCY216cU1ZnpHg+6ZUjNnIOjcVxlqwiL58RevVO8D pGUHsa6tvLQW+hC5jGjp1KE581rAtx4OqvJE4X3qwKJoz1fNkj+HyJpZ/66sdZUCD24D Mz7y6TAL9Xr3pr/ZW5qptrtm61mPi57w9KyBOC6mMX4UYP+bimaAR2CSopw3oHJTZyoA VPjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=86ewCwjQW9i1kYjMVzcHXeBvyH4rTaXf6X7Uwlu5n+M=; b=XQTvhvS7H9ws2H9jYj98Jno0xHiuk4sqZ9B4h4wLgZ6jwkyCRepktvE2XIZyJ3pSCW PSIBIyLdBpls0RvohvHPoPs9MBivOWG0yLBpyN2ZNfNq+ihIcaK6P4KzkGci9xei00iX hXCLA3doOsxPaa31cPjjKDOjilDzTG/xdZww8L1+6TRb0OgI54KHsFaEgG0ORgGgK2mP Eku9YN00LpACi+5sxT/zcx3sIU373gwdk3C7+kAuhk3mX4r/x7XWQ7VnLoz6bvBjha+N C3U0TlGFf8QDr3AHw4j+nVLWp61TTwNAno62nQefhtm2arBIobnwICQuQbVQCRmrvCOt 0CcQ== X-Gm-Message-State: ACgBeo3B8WNoC5QSMbflp+laoDMrDN9B/FnFS9iE2+E+cRzAI0QbN4H2 5EuSZgfMYJsBLSgwEgJcvww= X-Google-Smtp-Source: AA6agR6667/lK+w05CI7BYagBtCSm/gCmvjQy5HHxRwHWCtcxf7YniB8McshMO9sqao4Jd/ymXysNA== X-Received: by 2002:a05:6638:1607:b0:34a:105c:7204 with SMTP id x7-20020a056638160700b0034a105c7204mr24730394jas.216.1662327734786; Sun, 04 Sep 2022 14:42:14 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:14 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 05/57] dyndbg: reverse module.callsite walk in cat control Date: Sun, 4 Sep 2022 15:40:42 -0600 Message-Id: <20220904214134.408619-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Walk the module's vector of callsites backwards; ie N..0. This "corrects" the backwards appearance of a module's prdbg vector when walked 0..N. I think this is due to linker mechanics, which I'm inclined to treat as immutable, and the order is fixable in display. No functional changes. Combined with previous commit, which reversed tables-list, we get: :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s\= 012" init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blacklisted= \012" init/main.c:1424 [main]run_init_process =3D_ " with arguments:\012" init/main.c:1426 [main]run_init_process =3D_ " %s\012" init/main.c:1427 [main]run_init_process =3D_ " with environment:\012" init/main.c:1429 [main]run_init_process =3D_ " %s\012" Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 7fb99492c16f..8ff11977b8bd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -59,7 +59,7 @@ struct ddebug_query { =20 struct ddebug_iter { struct ddebug_table *table; - unsigned int idx; + int idx; }; =20 struct flag_settings { @@ -805,13 +805,12 @@ static struct _ddebug *ddebug_iter_first(struct ddebu= g_iter *iter) { if (list_empty(&ddebug_tables)) { iter->table =3D NULL; - iter->idx =3D 0; return NULL; } iter->table =3D list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx =3D 0; - return &iter->table->ddebugs[iter->idx]; + iter->idx =3D iter->table->num_ddebugs; + return &iter->table->ddebugs[--iter->idx]; } =20 /* @@ -824,15 +823,16 @@ static struct _ddebug *ddebug_iter_next(struct ddebug= _iter *iter) { if (iter->table =3D=3D NULL) return NULL; - if (++iter->idx =3D=3D iter->table->num_ddebugs) { + if (--iter->idx < 0) { /* iterate to next table */ - iter->idx =3D 0; if (list_is_last(&iter->table->link, &ddebug_tables)) { iter->table =3D NULL; return NULL; } iter->table =3D list_entry(iter->table->link.next, struct ddebug_table, link); + iter->idx =3D iter->table->num_ddebugs; + --iter->idx; } return &iter->table->ddebugs[iter->idx]; } --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 3A3D0C6FA82 for ; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235288AbiIDVme (ORCPT ); Sun, 4 Sep 2022 17:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234871AbiIDVmT (ORCPT ); Sun, 4 Sep 2022 17:42:19 -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 7D07F2E69B for ; Sun, 4 Sep 2022 14:42:16 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id y187so5723630iof.0 for ; Sun, 04 Sep 2022 14:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ysIiIQDuG3NPX9ftczW4ZGg58gUBI4jeSANScS140gM=; b=APgxhuRWpHrA5EiAcM6bPTAJX5sVjnKO8ZXN2+OQbTnNZthJ6+91rd6qMlpfQu96tK kU7buxw62MArc4SqmHlqi7ZnRepiJzi2ZjfY0l2reZS4c+bENNXL+q4MBcG6kmRIBJDg zjOTRGcunIJUea9k7GCkxnFakIoXTx5p4Q3YZsvD2JZKGgVLIqCxlvTVr6lLWopOQ5jg tM6aObbyHfQt4hKC15wVu4dtKTl7xSjSAHhGJrPEG7cERNokHi0L0ifYgGVAskmds7W2 JuY57ATFtM+4aknCtkIxF/AXoHBg+QwEAv3LIU8kjqNqvJGhCXZbCxBDuxpyjqad4Plp 4+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ysIiIQDuG3NPX9ftczW4ZGg58gUBI4jeSANScS140gM=; b=hesK1dUJzB5BEZDHhZG19+uKmpGEpdLG7h0Y0dE0a9am84X40l6rTgBjtduI6rLTfq 3kXCVCxH+RYghbZA6Ynp+sifnpw4Z+Y5fc+tmYydz5/P/nJR+w93CMFPXLP6IMnygV/T /fhxBrFC/qfHfE14U3qjvyw46wB5ebACcxmG9djGbHPRih0FMko5X151lsv8YKWhNFZY j5R1yWzTz/YdcLVCbI4htG3Eq7SMk6yesfLBb0OWYhkuaO6Kvys+EkQCI8FD2AugmkUO LQi2cBd3udM9pl3EAQkmZJSb0x/57quel6+/BQ+KNZPVm0/QGxK10N7hkba19xUJ4OW6 qe9Q== X-Gm-Message-State: ACgBeo3q8rkucjymCRmB2q2+SteYPKFc/eGB3y6jFf8LerMANgHzIvfr zA0a6Bn/lrZpd/wVrcijbgY= X-Google-Smtp-Source: AA6agR6afjzcErCVofVv8IgSNBB83b3vDq9Bdzagkl5cWOw7B+80htmvEYKRocJbPU12He1vQEZnCg== X-Received: by 2002:a05:6602:2b81:b0:688:b897:13b8 with SMTP id r1-20020a0566022b8100b00688b89713b8mr21276933iov.43.1662327735766; Sun, 04 Sep 2022 14:42:15 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:15 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 06/57] dyndbg: use ESCAPE_SPACE for cat control Date: Sun, 4 Sep 2022 15:40:43 -0600 Message-Id: <20220904214134.408619-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" `cat control` currently does octal escape, so '\n' becomes "\012". Change this to display as "\n" instead, which reads much cleaner. :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \n" init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\n" init/main.c:1424 [main]run_init_process =3D_ " with arguments:\n" init/main.c:1426 [main]run_init_process =3D_ " %s\n" init/main.c:1427 [main]run_init_process =3D_ " with environment:\n" init/main.c:1429 [main]run_init_process =3D_ " %s\n" Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8ff11977b8bd..e5cbe603000c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -900,7 +900,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) trim_prefix(dp->filename), dp->lineno, iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); - seq_escape(m, dp->format, "\t\r\n\""); + seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\"\n"); =20 return 0; --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 EFBECECAAD5 for ; Sun, 4 Sep 2022 21:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235343AbiIDVmj (ORCPT ); Sun, 4 Sep 2022 17:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234798AbiIDVmU (ORCPT ); Sun, 4 Sep 2022 17:42:20 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEF72F012 for ; Sun, 4 Sep 2022 14:42:17 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5652675iod.8 for ; Sun, 04 Sep 2022 14:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nL64tgfR3yuX9RW4VuAbZjo3bVMvuFZk7zY8MVD5bOI=; b=MCERlmgtJae24BInitcbNWrvVsK4E28qygPVO0EI6bkancXMheS04Tjo59+IeITlng jf5a49doi5XUUhgQrgt0RmWEG3xEjEu3z6ICYcIoTvGgQxKN8UUHK2ER+0LYVRq3FV20 WucDDDHNaHkRRVFc33rm6kG1+UsezVvy9A3pW29Mq1niKl9lIkT8agZdaeX87NAWjUS1 MYunE/FL5qWQueHrE71Nebq3OiS0fnNs9Cl3zzOr1/GBkEIemuvUKXl1uWUTCi/CRp7Y yFRVweG/UcdYXA9YY+/xnyx11VcNoG2ZRCFkTug07yb1tarb7cX3rZ4pliWCDznewiHQ YFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=nL64tgfR3yuX9RW4VuAbZjo3bVMvuFZk7zY8MVD5bOI=; b=HTA2w/Yseax5bS9E7NFcXkDEG+QH2OFpMjQukl2iA9elE5NgarPJrDj0fBFnKyt6bu F9rDq6JoDTAb3jVsgN1R637kc50DRQcilrSOcEo7ZZ6MJd4uoln3vf7bIu813CpGqRAJ BRzMuyZvcHMXcEhNuHezoRAP3fyIbXLqIsDpxGmf3H1sPwKRM2xPjSp0AtG2iv97GI9z GUsYnSxQmAR+T1+i3jGDfr1wzWf1N5m1lhZV/pJJ+hpmK8ja5djmsz1lmV9ORP0+t9WO AXUM4Q/CHXg+ueFpGrwpsiHmoWvAt/D7JVl77kl230XKBy2s1BJFxDFueAkDphonbX0L zVVg== X-Gm-Message-State: ACgBeo3G6xAQZhJD4lWGOZ4+BowLlIlRbaWX0N8CeOUgQLjLgQ5Gu2SF HboJShNc0Yg/lSCONOKGBTs= X-Google-Smtp-Source: AA6agR6mvknJtV6TiNBzpnOFVHbpLslD1LC4cvqoUjepqIcY8t7Gx+7cGEaleIov3kTIKLX0n/BTLQ== X-Received: by 2002:a05:6602:13c8:b0:68a:db5d:269d with SMTP id o8-20020a05660213c800b0068adb5d269dmr20950589iov.209.1662327736752; Sun, 04 Sep 2022 14:42:16 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:16 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 07/57] dyndbg: let query-modname override actual module name Date: Sun, 4 Sep 2022 15:40:44 -0600 Message-Id: <20220904214134.408619-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 control-parser: ddebug_parse_query(), requires that search terms: module, func, file, lineno, are used only once in a query; a thing cannot be named both foo and bar. The cited commit added an overriding module modname, taken from the module loader, which is authoritative. So it set query.module 1st, which disallowed its use in the query-string. But now, its useful to allow a module-load to enable classes across a whole (or part of) a subsystem at once. # enable (dynamic-debug in) drm only modprobe drm dyndbg=3D"class DRM_UT_CORE +p" # get drm_helper too modprobe drm dyndbg=3D"class DRM_UT_CORE module drm* +p" # get everything that knows DRM_UT_CORE modprobe drm dyndbg=3D"class DRM_UT_CORE module * +p" # also for boot-args: drm.dyndbg=3D"class DRM_UT_CORE module * +p" So convert the override into a default, by filling it only when/after the query-string omitted the module. NB: the query class FOO handling is forthcoming. Fixes: 8e59b5cfb9a6 dynamic_debug: add modname arg to exec_query callchain Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e5cbe603000c..5a849716220a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -385,10 +385,6 @@ static int ddebug_parse_query(char *words[], int nword= s, return -EINVAL; } =20 - if (modname) - /* support $modname.dyndbg=3D */ - query->module =3D modname; - for (i =3D 0; i < nwords; i +=3D 2) { char *keyword =3D words[i]; char *arg =3D words[i+1]; @@ -429,6 +425,13 @@ static int ddebug_parse_query(char *words[], int nword= s, if (rc) return rc; } + if (!query->module && modname) + /* + * support $modname.dyndbg=3D, when + * not given in the query itself + */ + query->module =3D modname; + vpr_info_dq(query, "parsed"); return 0; } --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 0D5B0ECAAD5 for ; Sun, 4 Sep 2022 21:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235380AbiIDVmm (ORCPT ); Sun, 4 Sep 2022 17:42:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234888AbiIDVmV (ORCPT ); Sun, 4 Sep 2022 17:42:21 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673892C65C for ; Sun, 4 Sep 2022 14:42:18 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id a9so3885262ilh.1 for ; Sun, 04 Sep 2022 14:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=a7DZCtJXdhSHu/g5l+Gfz3Grwf1u1lU78G+9NH5FV+4=; b=Jkkv7Uh7bMpbU+r6NlVBVYvbcfasFu4S18WrtPiOTovRP/fBU0eokGYClnWQb7wddC DJ2DbVzsV7l0UCuqjr+/R6KQlSzLD5J92WNj7XSoVVY8gqVI9s5+LywRHe/BNZ0ZDJCc DBl/2kKsA3D/oCquCqonuGQe5CgfatnSAtbCiKvVrFPbB6oGvCcBuFm2/uYygIQIwATx /9hnZoDjFPUZ988quw0t0Q6f4uHxj8Y7bfuMSk0/m2vgl7WvaETEtWFom2mBW8A8JJcp dzHb6d84REzzsRPCW3uadJ6MxO4TQxHz/Xw5lgx7Ma3qC+o1NzDn+smeH30H24e+PkJ2 LgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=a7DZCtJXdhSHu/g5l+Gfz3Grwf1u1lU78G+9NH5FV+4=; b=tBth5ul36jYskDfM2HIfCC2pu67MUnlqzLZ9E3xM3UwaDFG4pqlPCfTFkdZRve3trX kkbZ8pMmMxjHuaRv5q2Bvx8luhmbF1yXUmvNtV8ukK+jIvjij5oTqIBIp8Lmv4nSQUY5 GFrI69v3dcg46VNCxfNKXJb5iqo2NY1XKpWEQHX51ozaz2KuFAKPDdJhf44/r+C/jnTE jA+0YHqBDqcwqpMDNAp/XZ+VejoZR52nWj4rPFxaPccNABRv0Tj8RmAGa9dLsWwOJ1gc W444idQmP7x1iAzE3NTxUdMa6o3AKXyimbSWhK55+m07LdX+0Se7OFTlkStjLaP6QFas kg6A== X-Gm-Message-State: ACgBeo13+7wkuKx2vT/1mzC/XCnpQHYKi3/glAYMom6YSDt/z1zIJ9m7 USHjjgaBT1Dx/nHu5hJIKH8= X-Google-Smtp-Source: AA6agR7hw62bgxem2HOBZn5lz7k1Ka/rS42TkERRx352o8pyZNwU2vSuXFqs3ENfjD7w6M0xKnvuiQ== X-Received: by 2002:a92:cdae:0:b0:2f1:8d4e:403e with SMTP id g14-20020a92cdae000000b002f18d4e403emr4891ild.129.1662327737641; Sun, 04 Sep 2022 14:42:17 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:17 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 08/57] dyndbg: add test_dynamic_debug module Date: Sun, 4 Sep 2022 15:40:45 -0600 Message-Id: <20220904214134.408619-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Provide a simple module to allow testing DYNAMIC_DEBUG behavior. It calls do_prints() from module-init, and with a sysfs-node. dmesg -C dmesg -w & modprobe test_dynamic_debug dyndbg=3D+p echo 1 > /sys/module/dynamic_debug/parameters/verbose cat /sys/module/test_dynamic_debug/parameters/do_prints echo module test_dynamic_debug +mftl > /proc/dynamic_debug/control echo junk > /sys/module/test_dynamic_debug/parameters/do_prints Acked-by: Jason Baron Signed-off-by: Jim Cromie --- MAINTAINERS | 2 ++ lib/Kconfig.debug | 10 ++++++ lib/Makefile | 1 + lib/test_dynamic_debug.c | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lib/test_dynamic_debug.c diff --git a/MAINTAINERS b/MAINTAINERS index 41762df1be0c..c4465981df31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7222,6 +7222,8 @@ M: Jason Baron S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +M: Jim Cromie +F: lib/test_dynamic_debug.c =20 DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 183c37502119..5bf7897d9095 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2587,6 +2587,16 @@ config TEST_STATIC_KEYS =20 If unsure, say N. =20 +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on DYNAMIC_DEBUG + 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. + + If unsure, say N. + config TEST_KMOD tristate "kmod stress tester" depends on m diff --git a/lib/Makefile b/lib/Makefile index f0a855eed891..c893114029b8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -83,6 +83,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_PRINTF) +=3D test_printf.o obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o obj-$(CONFIG_TEST_BITMAP) +=3D test_bitmap.o diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c new file mode 100644 index 000000000000..ba3882ca3e48 --- /dev/null +++ b/lib/test_dynamic_debug.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +#define pr_fmt(fmt) "test_dd: " fmt + +#include + +static void do_prints(void); /* device under test */ + +/* run tests by reading or writing sysfs node */ + +static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) +{ + do_prints(); + return 0; +} + +static int param_get_do_prints(char *buffer, const struct kernel_param *kp) +{ + do_prints(); + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); +} + +static const struct kernel_param_ops param_ops_do_prints =3D { + .set =3D param_set_do_prints, + .get =3D param_get_do_prints, +}; + +module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); + +static void do_alpha(void) +{ + pr_debug("do alpha\n"); +} +static void do_beta(void) +{ + pr_debug("do beta\n"); +} + +static void do_prints(void) +{ + do_alpha(); + do_beta(); +} + +static int __init test_dynamic_debug_init(void) +{ + pr_debug("init start\n"); + + do_prints(); + + pr_debug("init done\n"); + return 0; +} + +static void __exit test_dynamic_debug_exit(void) +{ + pr_debug("exiting\n"); +} + +module_init(test_dynamic_debug_init); +module_exit(test_dynamic_debug_exit); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 92128ECAAD5 for ; Sun, 4 Sep 2022 21:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235407AbiIDVms (ORCPT ); Sun, 4 Sep 2022 17:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbiIDVmV (ORCPT ); Sun, 4 Sep 2022 17:42:21 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFF32C109 for ; Sun, 4 Sep 2022 14:42:19 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e7so3873045ilc.5 for ; Sun, 04 Sep 2022 14:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=774vPkNjj+tHobVK7wxTpiFngzuHiOZuQGU68liCSfs=; b=C7K+Yu8rS5CfqjlNHPHnOaD4zxwfuunfcvyOT5g9f9rMen9a6bVHcvqbwXA2+Y+9Kz RKQbD2pNaDWCYN70iNH05lkOWO4RBz/bQ8/cRwN6WEZcEvurKwq1+mOrxYFqPOqFAgqc jTojshygRsAzBiQhplkoP1HY15Ecq9/KjZAyKP3dmiszNKFO5leOY1ZvfEMxlgqXIOZd dYRX5/7LlkpgOOE5bEoz36HFy0JsAvZ+ng4hTn9uDioPYMM7Bu0T/tVRPEgpDqQID6iV nipB6JonPPNto+aq00YwjoQiAFGv/V/8G9n0DURSqGi4XiyI78KNHcGZM6RuJDkxs46Z 26bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=774vPkNjj+tHobVK7wxTpiFngzuHiOZuQGU68liCSfs=; b=p5+W/5ggSREFgjvIoZp9LHMvLvrR4jL2ns3cmiggd7Q4fMIF7MMglilO1D+yRsrobn 1J7/CY6pYgSB6yvir+34Dt+2A/FYLu9H+z5m2keyepxNmlutBcT68WGyPg0g60RY+aDc C/q7g4DK3WKH7HyntC2gKqpAxYFsDc9RApOTjALG/6q+u8XrX4Lgn+XjaL83ZHVszmMo 8+8sOiCIfR+ko+e/uDu6qSTVHpA5ATljmoN6cRuGf+dBe7mcHp0Z3n5L4JlV9EkQuqy4 PhhA+QWnDCTYvQUiH33hdNZ8+qyrYRXE3JqE9jamJdoTCrw7PLhiaA945ImeV6q6DXgY G1vw== X-Gm-Message-State: ACgBeo1TgK1WIs2wnG+KVKzWS1BcktAYXdTIaI0wCvRO/pK07n0+JRkr cauXzndJ25NOVejvnLZlzXA= X-Google-Smtp-Source: AA6agR5dk7sIC47F0zJwtTKZLwCG1OGpPQGC5vGCcEQBykOFT3Gx9Uw/vzxF/89YxMKOB4dB9YkQUQ== X-Received: by 2002:a05:6e02:148d:b0:2ee:82e:63fc with SMTP id n13-20020a056e02148d00b002ee082e63fcmr7362054ilk.289.1662327738560; Sun, 04 Sep 2022 14:42:18 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:18 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 09/57] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Sun, 4 Sep 2022 15:40:46 -0600 Message-Id: <20220904214134.408619-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" This exported fn is unused, and will not be needed. Lets dump it. The export was added to let drm control pr_debugs, as part of using them to avoid drm_debug_enabled overheads. But its better to just implement the drm.debug bitmap interface, then its available for everyone. Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_q= ueries()") Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") Acked-by: Jason Baron Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 9 --------- lib/dynamic_debug.c | 29 ----------------------------- 2 files changed, 38 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f30b01aa9fa4..8d9eec5f6d8b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -55,9 +55,6 @@ struct _ddebug { =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 -/* exported for module authors to exercise >control */ -int dynamic_debug_exec_queries(const char *query, const char *modname); - int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); extern int ddebug_remove_module(const char *mod_name); @@ -221,12 +218,6 @@ static inline int ddebug_dyndbg_module_param_cb(char *= param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) =20 -static inline int dynamic_debug_exec_queries(const char *query, const char= *modname) -{ - pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); - return 0; -} - #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a849716220a..e96dc216463b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -558,35 +558,6 @@ static int ddebug_exec_queries(char *query, const char= *modname) return nfound; } =20 -/** - * dynamic_debug_exec_queries - select and change dynamic-debug prints - * @query: query-string described in admin-guide/dynamic-debug-howto - * @modname: string containing module name, usually &module.mod_name - * - * This uses the >/proc/dynamic_debug/control reader, allowing module - * authors to modify their dynamic-debug callsites. The modname is - * canonically struct module.mod_name, but can also be null or a - * module-wildcard, for example: "drm*". - */ -int dynamic_debug_exec_queries(const char *query, const char *modname) -{ - int rc; - char *qry; /* writable copy of query */ - - if (!query) { - pr_err("non-null query/command string expected\n"); - return -EINVAL; - } - qry =3D kstrndup(query, PAGE_SIZE, GFP_KERNEL); - if (!qry) - return -ENOMEM; - - rc =3D ddebug_exec_queries(qry, modname); - kfree(qry); - return rc; -} -EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); - #define PREFIX_SIZE 64 =20 static int remaining(int wrote) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 84CF5C6FA82 for ; Sun, 4 Sep 2022 21:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235429AbiIDVmw (ORCPT ); Sun, 4 Sep 2022 17:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234928AbiIDVmV (ORCPT ); Sun, 4 Sep 2022 17:42:21 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 496ED2C661 for ; Sun, 4 Sep 2022 14:42:20 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id 62so5673882iov.5 for ; Sun, 04 Sep 2022 14:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=JzdXJQgZbXW3FjxRfc8LeNnI2jIQsEPwZbCx/pElNeM=; b=FUv8NBMgLulwhhEoMyLnxfYB3+uPNeLFEo5/TLMiSZjR94roddKbiqTTG31unDiBV2 koej5AIOTpgc4Fj75xhV1jWGKl/5CM8q7EieivOlV5/b+BYdXa9pALtMLQe6QZEuohs8 uc4jHbPW01pKLaccj4L/SBD9SF3hrWMDpeLoGgRrvCEUQKX8JmTlITp0J8QvdPavHfqS KpCN89/psw628tV7ylJY71laqV2x/K4y1PPoettY5lY6Kg7pmI05/DzTkiDbBqcz1dnc NsgFPB4IEgajS8Toc7/PVXqE2pPIC6p3Ibe6XKVfl3deYBS708mMbxWmh4z8Z7N8CYIi UccQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=JzdXJQgZbXW3FjxRfc8LeNnI2jIQsEPwZbCx/pElNeM=; b=C8P8iZWZk81ggH+/BxLOLwSrHcaRIip+CUrdb3URVAi/1dHW8/2gBZ9erUMuRQWsWm vGeI60tGw9eegoPVOgIYXNbqo5S5GofQTR9Z1rf5MnH/VxkYa/NoTvlYl5Vcbc0BwjqB 4Gzf8kTf1u2FoOPaoDZdzJeLTjp5gCWD39Yr+JgdoCyTygHAMZJIZtidaxs2Us0ouoCF Ia9LJJj3L6u0gSuuhq2823zYeQ0OKS4Ojs0j3mAUpeo3VPg1YupwDFsy/BBCY/+fIFz/ X5BlEzmp7HYQFWbHnFoKaUibKg/zo8/4Mf1zFwVSX2ioSWVg27IOsMm88SruC5fDn9Od Cz+g== X-Gm-Message-State: ACgBeo0FP7CzRsPccR2OPeYIRKgRa0NJZlOCU1Aadf4Notf32Qajbjve ZhL7ilCIrYbjl+gDByyCnfM= X-Google-Smtp-Source: AA6agR69LwdoHmp66Z3rxXxBJJ0Vec0ZLNH/n+zC6VNVydFgIRnTRHkjqAX0L8kf28KEk70mHqw2jw== X-Received: by 2002:a5e:8414:0:b0:689:e3c:308a with SMTP id h20-20020a5e8414000000b006890e3c308amr21338651ioj.29.1662327739611; Sun, 04 Sep 2022 14:42:19 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:19 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 10/57] dyndbg: cleanup auto vars in dynamic_debug_init Date: Sun, 4 Sep 2022 15:40:47 -0600 Message-Id: <20220904214134.408619-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" rework var-names for clarity, regularity rename variables - n to mod_sites - it counts sites-per-module - entries to i - display only - iter_start to iter_mod_start - marks start of each module's subrange - modct to mod_ct - stylistic new iterator var: - site - cursor parallel to iter 1st step towards 'demotion' of iter->site, for removal later treat vars as iters: - drop init at top init just above for-loop, in a textual block Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e96dc216463b..2e8ebef3bd0d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1059,11 +1059,10 @@ static int __init dynamic_debug_init_control(void) =20 static int __init dynamic_debug_init(void) { - struct _ddebug *iter, *iter_start; - const char *modname =3D NULL; + struct _ddebug *iter, *iter_mod_start; + int ret, i, mod_sites, mod_ct; + const char *modname; char *cmdline; - int ret =3D 0; - int n =3D 0, entries =3D 0, modct =3D 0; =20 if (&__start___dyndbg =3D=3D &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1074,30 +1073,32 @@ static int __init dynamic_debug_init(void) ddebug_init_success =3D 1; return 0; } - iter =3D __start___dyndbg; + + iter =3D iter_mod_start =3D __start___dyndbg; modname =3D iter->modname; - iter_start =3D iter; - for (; iter < __stop___dyndbg; iter++) { - entries++; + i =3D mod_sites =3D mod_ct =3D 0; + + for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + if (strcmp(modname, iter->modname)) { - modct++; - ret =3D ddebug_add_module(iter_start, n, modname); + mod_ct++; + ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; - n =3D 0; + + mod_sites =3D 0; modname =3D iter->modname; - iter_start =3D iter; + iter_mod_start =3D iter; } - n++; } - ret =3D ddebug_add_module(iter_start, n, modname); + ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; =20 ddebug_init_success =3D 1; vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in _= _dyndbg section\n", - entries, modct, (int)((modct * sizeof(struct ddebug_table)) >> 10), - (int)((entries * sizeof(struct _ddebug)) >> 10)); + i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), + (int)((i * sizeof(struct _ddebug)) >> 10)); =20 /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 8F307ECAAD5 for ; Sun, 4 Sep 2022 21:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235230AbiIDVm5 (ORCPT ); Sun, 4 Sep 2022 17:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234794AbiIDVmZ (ORCPT ); Sun, 4 Sep 2022 17:42:25 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF3A2F000 for ; Sun, 4 Sep 2022 14:42:21 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id a9so3885307ilh.1 for ; Sun, 04 Sep 2022 14:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=UryXZ8MRQvm9M8ywPbYKJOd9IzaI7xdASsleEmdDI64=; b=muSWjLs7x00fb34NXmJsZan+xUhIQRfkeBRQvGNO6EFtSqDV4gjF1KMkI8Bqak2VBg M+SglSeYYC0OIZzXmOEj02FMTLSgdMYfMKEdDLaaJuUeMzg1y8KursXgroBhEJhRXtPE ES3Dwgi1AQvCREt4K2pjDPVYOugleYpu5qaUw9tS2HWryERwvYXOQYwsEa82WRrrUjO/ yp7b0DPlePFOgcmNGO1FDSg1nPI3ICuWkKnZ9YbEBpQ3YvU6cljVk8CuOS4yIAP4Zg5S dnOYXunWEY24yxfgLxp+iCfDjBKFKOLqcksfSprGowZrq59RNyZHdmnZQ7ThwtBHf/Qg N9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=UryXZ8MRQvm9M8ywPbYKJOd9IzaI7xdASsleEmdDI64=; b=tXhDYGDP55SN9Od+/MzWscWb3TvnMqTqlzwa7+/6LhAFXzHD7f0vMzY7dh7VC1LTpF wdo/+Xo0PcYFSGKd+6OaD4qHOx6YuQKp+wrl5xj9KqHzLoHM4CE0HVOCpss54EYntoHz vV3h1yOvf//e93N0OLp7pt5zTL0cWdIMhk8ws82JOkE1P+sfglSNfXGrFEJAXCTs1nP5 eSm9i7WyRFQExA0Qntepy2cUBC7dHEmoXJpkOHM8Ftql4iVQGzPij5maMndRASntVlgl FMRBvhHeY9qTKdHslBs/atWm+rVWZoO/aU2u0Ib6+KONnRBCCnzDCLa1YBlPyiHmtl9u 9dyQ== X-Gm-Message-State: ACgBeo0Yj1XGtKTeSf8ggw2oYD4pvw4Z/GPj3ul35eTk9wEiAUmv/OeL 2SuAX4yKe1usoOvzn5OLJUw= X-Google-Smtp-Source: AA6agR4xCBLCNJuB54OnGN7VtAxvyEt+vNDQxb7qX+QcTnPDx6k921Txd/smbqxpe7ugLH91cljdjg== X-Received: by 2002:a05:6e02:15c4:b0:2e1:986c:91a1 with SMTP id q4-20020a056e0215c400b002e1986c91a1mr24412890ilu.22.1662327740646; Sun, 04 Sep 2022 14:42:20 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:20 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , Luis Chamberlain Subject: [PATCH v6 11/57] dyndbg: gather __dyndbg[] state into struct _ddebug_info Date: Sun, 4 Sep 2022 15:40:48 -0600 Message-Id: <20220904214134.408619-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" This new struct composes the linker provided (vector,len) section, and provides a place to add other __dyndbg[] state-data later: descs - the vector of descriptors in __dyndbg section. num_descs - length of the data/section. Use it, in several different ways, as follows: In lib/dynamic_debug.c: ddebug_add_module(): Alter params-list, replacing 2 args (array,index) with a struct _ddebug_info * containing them both, with room for expansion. This helps future-proof the function prototype against the looming addition of class-map info into the dyndbg-state, by providing a place to add more member fields later. NB: later add static struct _ddebug_info builtins_state declaration, not needed yet. ddebug_add_module() is called in 2 contexts: In dynamic_debug_init(), declare, init a struct _ddebug_info di auto-var to use as a cursor. Then iterate over the prdbg blocks of the builtin modules, and update the di cursor before calling _add_module for each. Its called from kernel/module/main.c:load_info() for each loaded module: In internal.h, alter struct load_info, replacing the dyndbg array,len fields with an embedded _ddebug_info containing them both; and populate its members in find_module_sections(). The 2 calling contexts differ in that _init deals with contiguous subranges of __dyndbgs[] section, packed together, while loadable modules are added one at a time. So rename ddebug_add_module() into outer/__inner fns, call __inner from _init, and provide the offset into the builtin __dyndbgs[] where the module's prdbgs reside. The cursor provides start, len of the subrange for each. The offset will be used later to pack the results of builtin __dyndbg_sites[] de-duplication, and is 0 and unneeded for loadable modules, Note: kernel/module/main.c includes for struct _ddeubg_info. This might be prone to include loops, since its also included by printk.h. Nothing has broken in robot-land on this. cc: Luis Chamberlain Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 13 +++++++----- kernel/module/internal.h | 4 ++-- kernel/module/main.c | 18 ++++++++-------- lib/dynamic_debug.c | 40 +++++++++++++++++++++++++++-------- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8d9eec5f6d8b..6a2001250da1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -51,12 +51,16 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 - +/* encapsulate linker provided built-in (or module) dyndbg data */ +struct _ddebug_info { + struct _ddebug *descs; + unsigned int num_descs; +}; =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname); +int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); + extern int ddebug_remove_module(const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -184,8 +188,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include =20 -static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname) +static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char= *modname) { return 0; } diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 680d980a4fb2..2e2bf236f558 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -53,6 +53,7 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const s32 __start___kcrctab[]; extern const s32 __start___kcrctab_gpl[]; =20 +#include struct load_info { const char *name; /* pointer to module in temporary copy, freed at end of load_module() */ @@ -62,8 +63,7 @@ struct load_info { Elf_Shdr *sechdrs; char *secstrings, *strtab; unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; - struct _ddebug *debug; - unsigned int num_debug; + struct _ddebug_info dyndbg; bool sig_ok; #ifdef CONFIG_KALLSYMS unsigned long mod_kallsyms_init_off; diff --git a/kernel/module/main.c b/kernel/module/main.c index a4e4d84b6f4e..4c20bc3ff203 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1598,16 +1598,16 @@ static void free_modinfo(struct module *mod) } } =20 -static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug,= unsigned int num) +static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *d= yndbg) { - if (!debug) + if (!dyndbg->num_descs) return; - ddebug_add_module(debug, num, mod->name); + ddebug_add_module(dyndbg, mod->name); } =20 -static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) +static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *= dyndbg) { - if (debug) + if (dyndbg->num_descs) ddebug_remove_module(mod->name); } =20 @@ -2111,8 +2111,8 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) if (section_addr(info, "__obsparm")) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); =20 - info->debug =3D section_objs(info, "__dyndbg", - sizeof(*info->debug), &info->num_debug); + info->dyndbg.descs =3D section_objs(info, "__dyndbg", + sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); =20 return 0; } @@ -2807,7 +2807,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, } =20 init_build_id(mod, info); - dynamic_debug_setup(mod, info->debug, info->num_debug); + dynamic_debug_setup(mod, &info->dyndbg); =20 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init(mod); @@ -2871,7 +2871,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, =20 ddebug_cleanup: ftrace_release_mod(mod); - dynamic_debug_remove(mod, info->debug); + dynamic_debug_remove(mod, &info->dyndbg); synchronize_rcu(); kfree(mod->args); free_arch_cleanup: diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2e8ebef3bd0d..c358ccdf4a39 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -923,14 +923,20 @@ static const struct proc_ops proc_fops =3D { * Allocate a new ddebug_table for the given module * and add it to the global list. */ -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *name) +static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, + const char *modname) { struct ddebug_table *dt; =20 + v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + if (!di->num_descs) { + v3pr_info(" skip %s\n", modname); + return 0; + } + dt =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { - pr_err("error adding module: %s\n", name); + pr_err("error adding module: %s\n", modname); return -ENOMEM; } /* @@ -939,18 +945,25 @@ int ddebug_add_module(struct _ddebug *tab, unsigned i= nt n, * member of struct module, which lives at least as long as * this struct ddebug_table. */ - dt->mod_name =3D name; - dt->num_ddebugs =3D n; - dt->ddebugs =3D tab; + dt->mod_name =3D modname; + dt->ddebugs =3D di->descs; + dt->num_ddebugs =3D di->num_descs; + + INIT_LIST_HEAD(&dt->link); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); + vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); return 0; } =20 +int ddebug_add_module(struct _ddebug_info *di, const char *modname) +{ + return __ddebug_add_module(di, 0, modname); +} + /* helper for ddebug_dyndbg_(boot|module)_param_cb */ static int ddebug_dyndbg_param_cb(char *param, char *val, const char *modname, int on_err) @@ -1064,6 +1077,11 @@ static int __init dynamic_debug_init(void) const char *modname; char *cmdline; =20 + struct _ddebug_info di =3D { + .descs =3D __start___dyndbg, + .num_descs =3D __stop___dyndbg - __start___dyndbg, + }; + if (&__start___dyndbg =3D=3D &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); @@ -1082,7 +1100,9 @@ static int __init dynamic_debug_init(void) =20 if (strcmp(modname, iter->modname)) { mod_ct++; - ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs =3D mod_sites; + di.descs =3D iter_mod_start; + ret =3D __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; =20 @@ -1091,7 +1111,9 @@ static int __init dynamic_debug_init(void) iter_mod_start =3D iter; } } - ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs =3D mod_sites; + di.descs =3D iter_mod_start; + ret =3D __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 62EBAECAAD5 for ; Sun, 4 Sep 2022 21:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235494AbiIDVm7 (ORCPT ); Sun, 4 Sep 2022 17:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234761AbiIDVma (ORCPT ); Sun, 4 Sep 2022 17:42:30 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2902EF2B for ; Sun, 4 Sep 2022 14:42:22 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id r7so3867178ile.11 for ; Sun, 04 Sep 2022 14:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xIjcpB1yObanMGjMFeMKYjIQWCM49hxUe0Q+YC489GU=; b=MLaOUG1eQyDNFysR3kFQ1CuvqHjhT0aQXApMqF4gTtmKSNtSjX/I5UlLfKj7GXM5dJ ERh08+wfPW/pY1uDfq/mQRn9W4pI+ZknWQk0O9BgR5Mk9AjPJWG5zDfHLcpmenzVQTzo 579HyQFoNP2ls47VGJ5G3weYDitOixMG/+//9S/xiAYoLVVWBuJc+DV/rYYNjDLyRLfb HNDjMkbf5rFexzATxXpZ556L2eM2E51BpzYlMdQx5ufJQGJ8cauf0lUEASuflYmkRnFq wm3CJLRAjYbtQSKbcHHo9KjCQC9bF3ISuBv6sJ+vPDbFd2H4Yl4b8qIqAqmbssefUuAQ LhwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=xIjcpB1yObanMGjMFeMKYjIQWCM49hxUe0Q+YC489GU=; b=eJ7nxhKwJU1ffZ8WHDiYj3AVNIqQ8mu7b7oRlKMqwB+uR8+2Qn2bLYSzAhamFB+QAd 3rZSC13/Rq692PvbPis7RXTDn1Rjzjbtt58p8YTANZN1wsf10JJ/lJ3ZvxVeFC25sWKX lzP3yXneFs8xbWNvwR3oOo6JXjMZDcCHVbLKB2k4JZCrgAceEepI/WnqFXjmW/Kc2xH6 9lJUzIYivARP7Gb2Ur4tIx+zfcLoTlv6Yw5wlqa1okxWPeMAWfiqZipX1pLc67EWMmQz aVwtVNaAfYJRwVQt9jdd4E23qsAGZE7gJ8h+g1jY/Z8wE1atFpFuQyObGWdRRGox7PIP duKA== X-Gm-Message-State: ACgBeo2kcpMBl8+iSBPU6kb7PCfdI3KXGc1JgCCj7DT4MER8kqJcM+V9 ZJxq89bTiWi8Cm1oLLGkcZA= X-Google-Smtp-Source: AA6agR67iR6BYXhMU24o7aSNMqzyMctDSZZTQcZ/yxizOCzV0f4LJSYbYSri4MSdNRuTGB/KPRJVfw== X-Received: by 2002:a05:6e02:15c9:b0:2e1:a5b6:7e25 with SMTP id q9-20020a056e0215c900b002e1a5b67e25mr23241731ilu.185.1662327741691; Sun, 04 Sep 2022 14:42:21 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:21 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , Rasmus Villemoes Subject: [PATCH v6 12/57] dyndbg: add class_id to pr_debug callsites Date: Sun, 4 Sep 2022 15:40:49 -0600 Message-Id: <20220904214134.408619-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" DRM issues ~10 exclusive categories of debug messages; to represent this directly in dyndbg, add a new 6-bit field: struct _ddebug.class_id. This gives us 64 classes, which should be more than enough. #> echo 0x012345678 > /sys/module/drm/parameters/debug All existing callsites are initialized with _DPRINTK_CLASS_DFLT, which is 2^6-1. This reserves 0-62 for use in new categorized/class'd pr_debugs, which fits perfectly with natural enums (ints: 0..N). Thats done by extending the init macro: DEFINE_DYNAMIC_DEBUG_METADATA() with _CLS(cls, ...) suffix, and redefing old name using extended name. Then extend the factory macro callchain with _cls() versions to provide the callsite.class_id, with old-names passing _DPRINTK_CLASS_DFLT. This sets us up to create class'd prdebug callsites (class'd callsites are those with .class_id !=3D _DPRINTK_CLASS_DFLT). No behavior change. cc: Rasmus Villemoes Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 71 +++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 6a2001250da1..633f4e463766 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -6,6 +6,8 @@ #include #endif =20 +#include + /* * An instance of this structure is created in a special * ELF section at every dynamic debug callsite. At runtime, @@ -21,6 +23,9 @@ struct _ddebug { const char *filename; const char *format; unsigned int lineno:18; +#define CLS_BITS 6 + unsigned int class_id:CLS_BITS; +#define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -88,7 +93,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); =20 -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name =3D { \ .modname =3D KBUILD_MODNAME, \ @@ -97,8 +102,14 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ + .class_id =3D cls, \ _DPRINTK_KEY_INIT \ - } + }; \ + BUILD_BUG_ON_MSG(cls > _DPRINTK_CLASS_DFLT, \ + "classid value overflow") + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) =20 #ifdef CONFIG_JUMP_LABEL =20 @@ -129,17 +140,34 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #endif /* CONFIG_JUMP_LABEL */ =20 -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ -} while (0) - -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ +/* + * Factory macros: ($prefix)dynamic_func_call($suffix) + * + * Lower layer (with __ prefix) gets the callsite metadata, and wraps + * the func inside a debug-branch/static-key construct. Upper layer + * (with _ prefix) does the UNIQUE_ID once, so that lower can ref the + * name/label multiple times, and tie the elements together. + * Multiple flavors: + * (|_cls): adds in _DPRINT_CLASS_DFLT as needed + * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) + */ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ + func(&id, ##__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ +} while (0) +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) =20 /* * "Factory macro" for generating a call to func, guarded by a @@ -149,22 +177,33 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS_= _) #define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) + _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) + /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ + func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define dynamic_pr_debug_cls(cls, fmt, ...) \ + _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \ + pr_fmt(fmt), ##__VA_ARGS__) =20 #define dynamic_pr_debug(fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_pr_debug, \ + _dynamic_func_call(fmt, __dynamic_pr_debug, \ pr_fmt(fmt), ##__VA_ARGS__) =20 #define dynamic_dev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ + _dynamic_func_call(fmt, __dynamic_dev_dbg, \ dev, fmt, ##__VA_ARGS__) =20 #define dynamic_netdev_dbg(dev, fmt, ...) \ --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 32CA4C6FA82 for ; Sun, 4 Sep 2022 21:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235509AbiIDVnE (ORCPT ); Sun, 4 Sep 2022 17:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235104AbiIDVmb (ORCPT ); Sun, 4 Sep 2022 17:42:31 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0048E2F007 for ; Sun, 4 Sep 2022 14:42:22 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id d68so5628878iof.11 for ; Sun, 04 Sep 2022 14:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9SzKct1HE2F9SFFHU0qV3d4yTS+Vy3tZKPhpRiWkMoE=; b=keVbDAqmRl0RyYCgYBZ9vpqCQmkMyk7el0JhW316fk9lzXS1Qp8s1NvY5dl+0KhmSp ibqXTnOnHqVsgbVNxEqbtv43vgYRsJvWCMIHnYD2MdOnweaxtJ/6lJmRUKioxtauNnK3 MAOa5YY5NhAaVnZUHf9WjVTMmFZFR8zfXvqsn6ug0qyuxgGFFgrtJhQLojNKtMyGeGVu +yc9Lpue47auQ2O1yq9JKZ+AL+lsysQCM4CP52NRtG4YNpaMNSOR2BmwDKNu/vEgwcNy CzChZLaOzOawknlDJ4jxM+ihj0KwR+efhIg2T10h1eobX6skVdqLap7sQsWzIfHZi9ST UvOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=9SzKct1HE2F9SFFHU0qV3d4yTS+Vy3tZKPhpRiWkMoE=; b=mLoPzAT0tPQupExuRDKWzYWQzNaZ4pujoLH6pVtLffbC4w3/0hLg7Uv40LS56WeKVC GjEe0Ai5MWzbHj+WQPriEXpoIcH/1e7b7lsXMWepMUAtRyJAcq1bwj9xH0kwCOv0r9t0 UVOD7+60wOdxexNHti9XjKBj1TEj4yYvnrrWgwhneXB4H2pMLYtksIhChmgmqzYZrMLR ciJzF8ISAO1zpX/14fnOhuWhshz2ufqGQjeQ/ftxki5HfLR4Aon2DDeTAE4E1oW5txpn 3vHgvevcObRrw0O0tA63WfNJhBl9jGzU5bU/cehBQGaj7YVQf3Pil6A1llQMMyyjv2+a uulQ== X-Gm-Message-State: ACgBeo1tFrLkaHbmR7MTjoeBK1zbtA28knuLirFM8azroP9Dh8K6NrNo gltpuuc0XbEYSA5wBxywFgM= X-Google-Smtp-Source: AA6agR6jMolGXndfzGgA0ZvJd/LMfHAfLgpxQDVqtziCymaTm3c0Mj4mJvOTk/aEeCbTagH4y5NkEA== X-Received: by 2002:a5e:8407:0:b0:689:ff32:84d3 with SMTP id h7-20020a5e8407000000b00689ff3284d3mr21836771ioj.180.1662327742655; Sun, 04 Sep 2022 14:42:22 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:22 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 13/57] dyndbg: add __pr_debug_cls for testing Date: Sun, 4 Sep 2022 15:40:50 -0600 Message-Id: <20220904214134.408619-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" For selftest purposes, add __pr_debug_cls(class, fmt, ...) I didn't think we'd need to define this, since DRM effectively has it already in drm_dbg, drm_devdbg. But test_dynamic_debug needs it in order to demonstrate all the moving parts. Note the __ prefix; its not intended for general use, at least until a need emerges. ISTM the drm.debug model (macro wrappers inserting enum const 1st arg) is the baseline approach. That said, nouveau might want it for easy use in its debug macros. TBD. NB: it does require a builtin-constant class, __pr_debug_cls(i++, ...) is disallowed by compiler. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 633f4e463766..3c9690da44d9 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -221,6 +221,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 +/* for test only, generally expect drm.debug style macro wrappers */ +#define __pr_debug_cls(cls, fmt, ...) do { \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ + "expecting constant class int/enum"); \ + dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ + } while (0) + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 #include --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 E68CCECAAD5 for ; Sun, 4 Sep 2022 21:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235534AbiIDVnH (ORCPT ); Sun, 4 Sep 2022 17:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235113AbiIDVmb (ORCPT ); Sun, 4 Sep 2022 17:42:31 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EACE2C64E for ; Sun, 4 Sep 2022 14:42:24 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id h78so5628223iof.13 for ; Sun, 04 Sep 2022 14:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5Pcy7SEXmziNMuvuaPrrGzNbNpmap+iXZUcd2i8OvCY=; b=GB9PW2F6Q86MU59eDr4MyMDq35GvNA/Jg6eGCzAQ+7KsoRzAAGQZzPwH/dw5FsI2O2 3lRJv+1hZh1L7J0X5r+/gJmZ/p+S01FMLMk12jtIdbQdXgJQ5HUhVxyOwaVdwGYVI3Oz yjqdX503u6uH34EL0ic6GiF8HRbIhCOXLCJO9nVVYQl1dCp+lnEx6muhaf01/usDbzPU ZZzM26A2bAzM2xcI/xnYhnCbRLdj88A3HAOOSNyOx2yCAv4FEaJnA3vSTNlpS3Zj1ziY Be6DgpqOnB5C2e1LiZ39wPFC92RfVb0RqUf1pyPHHTI99OqApEkJoA3tEi/tTJOeGG06 rZsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5Pcy7SEXmziNMuvuaPrrGzNbNpmap+iXZUcd2i8OvCY=; b=lXb8GqsS1TfS19kA+HDv/IIEePK+R9WBQFopgNgvR6iVcv2mFmYSNyOWH4TCFEC+HI OYr7yyc+6I1OfIpZOgUjl0AMQv+ryGuDqtYaXMELzo7Vu9tOpPNbKhILstlB2KyZrGdK 5GCr/C/cDDdDc2MXLlaDE/79EUTWG8SnvAPa7aZLEoCetZP3vLmZT+AHHzinvi73hdCj pwBNzs2Agp1UBpqxs4+/fO9MolCJUzp/QlIabgbdBP8S7xqtsqsmO95YMgeTNhWW/yJ1 li/PYU6HkreGIVzjgwAUoUWtwhaAVJIsPJZ9I34t9YQeKO31ERy+RhIlhEatpp9Q+upk xRUw== X-Gm-Message-State: ACgBeo34gtRrIHo6qM8uDLUYZ406dUI1K/8QR7/QWldY/cwMwYSB/K+q zRUy2SSVmrgwcY2OrmwGblM= X-Google-Smtp-Source: AA6agR6EECGaIhMrD6/ftIKIMo5ApfTHYgvzkKs19vbQldr38XY5/ivWSJIIjhhS6BH5Fg18Gldhsw== X-Received: by 2002:a6b:e816:0:b0:688:c999:d08c with SMTP id f22-20020a6be816000000b00688c999d08cmr22221392ioh.100.1662327743569; Sun, 04 Sep 2022 14:42:23 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:23 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 14/57] dyndbg: add DECLARE_DYNDBG_CLASSMAP macro Date: Sun, 4 Sep 2022 15:40:51 -0600 Message-Id: <20220904214134.408619-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Using DECLARE_DYNDBG_CLASSMAP, modules can declare up to 31 classnames. By doing so, they authorize dyndbg to manipulate class'd prdbgs (ie: __pr_debug_cls, and soon drm_*dbg), ala:: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control The macro declares and initializes a static struct ddebug_class_map:: - maps approved class-names to class_ids used in module, by array order. forex: DRM_UT_* - class-name vals allow validation of "class FOO" queries using macro is opt-in - enum class_map_type - determines interface, behavior Each module has its own class-type and class_id space, and only known class-names will be authorized for a manipulation. Only DRM modules should know and respont to this: :#> echo class DRM_UT_CORE +p > control # across all modules pr_debugs (with default class_id) are still controllable as before. DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, classes...) is:: _var: name of the static struct var. user passes to module_param_cb() if they want a sysfs node. _maptype: this is hard-coded to DD_CLASS_TYPE_DISJOINT_BITS for now. _base: usually 0, it allows splitting 31 classes into subranges, so that multiple classes / sysfs-nodes can share the module's class-id space. classes: list of class_name strings, these are mapped to class-ids starting at _base. This class-names list must have a corresponding ENUM, with SYMBOLS that match the literals, and 1st enum val =3D _base. enum class_map_type has 4 values, on 2 factors:: - classes are disjoint/independent vs relative/xcontrol interface doesn't enforce the LEVELS relationship, so you could confusingly have V3 enabled, but V1 disabled. OTOH, the control iface already allows infinite tweaking of the underlying callsites; sysfs node readback can only tell the user what they previously wrote. 2. All dyndbg >control reduces to a query/command, includes +/-, which is at-root a kernel patching operation with +/- semantics. And the _NAMES handling exposes it to the user, making it API-adjacent. And its not just >control where +/- gets used (which is settled), the new place is with sysfs-nodes exposing _*_NAMES classes, and here its subtly different. _DISJOINT_NAMES: is simple, independent _LEVEL_NAMES: masks-on bits 0 .. N-1, N..max off # turn on L3,L2,L1 others off echo +L3 > /sys/module/test_dynamic_debug/parameters/p_level_names # turn on L2,L1 others off echo -L3 > /sys/module/test_dynamic_debug/parameters/p_level_names IOW, the - changes the threshold-on bitpos by 1. Alternatively, we could treat the +/- as half-duplex, where -L3 turns off L>2 (and ignores L1), and +L2 would turn on L<=3D2 (and ignore others). Signed-off-by: Jim Cromie --- . revised DD_CLASS_TYPE_{DISJOINT,LEVEL}_* names . reorder-enum - _NAMES feature is extra. --- include/linux/dynamic_debug.h | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 3c9690da44d9..98dbf1d49984 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -56,6 +56,61 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 +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_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 + */ +}; + +struct ddebug_class_map { + struct list_head link; + struct module *mod; + const char *mod_name; /* needed for builtins */ + const char **class_names; + const int length; + const int base; /* index of 1st .class_id, allows split/shared space */ + enum class_map_type map_type; +}; + +/** + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module + * @_var: a struct ddebug_class_map, passed to module_param_cb + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names used to control class'd prdbgs + */ +#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + static struct ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_classes") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D _base, \ + .map_type =3D _maptype, \ + .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .class_names =3D _var##_classnames, \ + } +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) + /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 C52DAC6FA82 for ; Sun, 4 Sep 2022 21:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235560AbiIDVnL (ORCPT ); Sun, 4 Sep 2022 17:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234721AbiIDVmb (ORCPT ); Sun, 4 Sep 2022 17:42:31 -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 373592F008 for ; Sun, 4 Sep 2022 14:42:25 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id e195so5690483iof.1 for ; Sun, 04 Sep 2022 14:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ygTuajbmVKRymZcTR8l4AYG1vTV31KkFalfQRqvEO70=; b=qb+eXUS2FeGvpVtJ7v+DpOZwxGybLXxNLvokvSQTdNFeUtdY8CsheY5eB/SHmPx4O9 huSEsSDTQKrSj+0Puiw+lGBf49Y4J1xWJgf6Ap2MJoyUCbw2fAY5nQAAJERXo7vJ7beG uEy7TG4owjT8onLbXW0wMRyVFiQeDhNfDDdJsyJhbLqVj3VikXMuVtM2AfKuFTkruuIT ZEtn5PQ+tih96gGXNgsH2cVDPtvjPYgq/XfBF5eBzbkWlcn29wqz/HPJB8mdX0xxRHTF eqZ20NxASPafvwnESXcu++44WdfCGPEIGsJqdmjGZ4Ebkk3JbphMGW8Ilt+BN7LlYeLQ RQIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ygTuajbmVKRymZcTR8l4AYG1vTV31KkFalfQRqvEO70=; b=v67MR2cLj+bZNLnZfdyhRe0FOso0QQlLE7VuB8SQnT+X7+zg3y/tUvl0tynz8rPLWQ maoqIIrvx/oQxRWkRNmXyqPz957kvuPYQ5gVTqg1Uq2m/OKbKQttQODLgN9emVJLkj8s bNHpxjZm2JdNxvSJ3A8XL3pX0Dn/AGwvLh8lIz7fteiTwEZDTfuJ8/OBY7P6xuOM8Ybe Tm/8TuVHWuyyBMeJD1SHswhOoTiUcfG446IIrpUDbzzKcDemp6i4jgwfCFwFRRzn/Nge k0EB9v68UxhIPAVztUNkEEw/N97gN5GRMI984pzCDntpOk8hXXq74PZQg92g3t2FX8Vs IS0A== X-Gm-Message-State: ACgBeo14hpD8SsmitrE3GoCQEmsnXF5rCwy6rTWU3AFVYfvgH1H5Qvkm gHbWNEe6Wpv8Y2xcrW/mlUw= X-Google-Smtp-Source: AA6agR6i2bEKl1Cs2088Bgc9CVI77OTinqvJI0IWGolf9NIA7tDBAIrKIIWBixVDBMgcEhK2nR9WNg== X-Received: by 2002:a05:6638:4091:b0:342:e406:45d8 with SMTP id m17-20020a056638409100b00342e40645d8mr25310655jam.130.1662327744496; Sun, 04 Sep 2022 14:42:24 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:24 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 15/57] kernel/module: add __dyndbg_classes section Date: Sun, 4 Sep 2022 15:40:52 -0600 Message-Id: <20220904214134.408619-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 __dyndbg_classes section, using __dyndbg as a model. Use it: vmlinux.lds.h: KEEP the new section, which also silences orphan section warning on loadable modules. Add (__start_/__stop_)__dyndbg_classes linker symbols for the c externs (below). kernel/module/main.c: - fill new fields in find_module_sections(), using section_objs() - extend callchain prototypes to pass classes, length load_module(): pass new info to dynamic_debug_setup() dynamic_debug_setup(): new params, pass through to ddebug_add_module() dynamic_debug.c: - add externs to the linker symbols. ddebug_add_module(): - It currently builds a debug_table, and *will* find and attach classes. dynamic_debug_init(): - add class fields to the _ddebug_info cursor var: di. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 2 ++ kernel/module/main.c | 2 ++ lib/dynamic_debug.c | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 7515a465ec03..9b8bd5504ad9 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -345,6 +345,9 @@ *(__tracepoints) \ /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ + __start___dyndbg_classes =3D .; \ + KEEP(*(__dyndbg_classes)) \ + __stop___dyndbg_classes =3D .; \ __start___dyndbg =3D .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg =3D .; \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 98dbf1d49984..9073a43a2039 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -114,7 +114,9 @@ struct ddebug_class_map { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct ddebug_class_map *classes; unsigned int num_descs; + unsigned int num_classes; }; =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) diff --git a/kernel/module/main.c b/kernel/module/main.c index 4c20bc3ff203..6aa6153aa6e0 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2113,6 +2113,8 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) =20 info->dyndbg.descs =3D section_objs(info, "__dyndbg", sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); + info->dyndbg.classes =3D section_objs(info, "__dyndbg_classes", + sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); =20 return 0; } diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c358ccdf4a39..fb31a1a2fc3f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -41,6 +41,8 @@ =20 extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct ddebug_class_map __start___dyndbg_classes[]; +extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 struct ddebug_table { struct list_head link; @@ -1079,7 +1081,9 @@ static int __init dynamic_debug_init(void) =20 struct _ddebug_info di =3D { .descs =3D __start___dyndbg, + .classes =3D __start___dyndbg_classes, .num_descs =3D __stop___dyndbg - __start___dyndbg, + .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, }; =20 if (&__start___dyndbg =3D=3D &__stop___dyndbg) { @@ -1122,6 +1126,9 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); =20 + if (di.num_classes) + v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. * While this has already been done for known boot params, it --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 154AEC6FA82 for ; Sun, 4 Sep 2022 21:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235577AbiIDVnO (ORCPT ); Sun, 4 Sep 2022 17:43:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235191AbiIDVmc (ORCPT ); Sun, 4 Sep 2022 17:42:32 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B035F2EF1B for ; Sun, 4 Sep 2022 14:42:25 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id 62so5673946iov.5 for ; Sun, 04 Sep 2022 14:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bV2pbi1NEnXBIYceq2iCnojYvMw47Sm5P0bDatZE/qY=; b=DRCAFhL8qizXn9QBOsMZO6CWk737/iorbRJ4AxHGEgMlW1XjBcP+vkmFKNoyTUK0Mj RgDgR2Ync4KORGyKwN45XuxZ3LCgDHh7aM7gIcdOLcttBFR6Un79bJyvT2V/T+t1uwET tHeAl0kEFnMLN5umqFTSN7rOVhAj0XWVzl/y6lz8DsbMtgZKngpwCHlWQPaVdjC6LyHL qSLUkoUXTZ6m9J5MpZDXz12M3aHFBVeTnL/qP7lUD45vpjehf2aOfxyxGF8UMp8S8D8U hKvmKb7U5FALDSB3abvwTeqDsOg4bgbNnzuU9E1pJLb4XrIdrdIzUyRn++u3pSGOKqBq 6ETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=bV2pbi1NEnXBIYceq2iCnojYvMw47Sm5P0bDatZE/qY=; b=occVs2iPNgKpwi+93QaEZ22NN2UXfda/NFNHfwdb5tPENYVLAq+A1Kx2H4loBCguhd X4RNcCkIaA2+q1t9G0Nr+FuAAw9Fy4s++d0fqbdlVpuHb5XQfRAsmDjBNFucE/gHwHAt 2vxsdky8bFzW9hOAZffpqA+XHX6TST3qK4SPePX3b7oiZquPmEAXP1TszMpbKWiGEDtu vtnxOqiy4gVRm253zLgEM5x6qakqj4adqeZitOLJ9yykRXdOT/oWkoJG9tIWs2eQ7x4k B8hyXNDgHp3edycrsqk2xG4/6MSJk4DHawV19GmFT1Evr3Y5ATqERO7DweWOOYBgrMDv XoHg== X-Gm-Message-State: ACgBeo2nBSo2sXAa9dqUa+I/SuMRqtSiSit2Gjn2sv68/zkNJaWv8i1y muCARip2Y46SonVLfWx/6Bg= X-Google-Smtp-Source: AA6agR4Eiudl3FZhHqIH1u+1kjDcwObHAsibzo+7iq3K3aAIOXK9LPSM3GGiI3JaBRbAwyq3KZU0rA== X-Received: by 2002:a6b:3e06:0:b0:68b:7524:f342 with SMTP id l6-20020a6b3e06000000b0068b7524f342mr15398868ioa.149.1662327745421; Sun, 04 Sep 2022 14:42:25 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:25 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 16/57] dyndbg: add ddebug_attach_module_classes Date: Sun, 4 Sep 2022 15:40:53 -0600 Message-Id: <20220904214134.408619-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 ddebug_attach_module_classes(), call it from ddebug_add_module(). It scans the classes/section its given, finds records where the module-name matches the module being added, and adds them to the module's maps list. No locking here, since the record isn't yet linked into the ddebug_tables list. It is called indirectly from 2 sources: - from load_module(), where it scans the module's __dyndbg_classes section, which contains DYNAMIC_DEBUG_CLASSES definitions from just the module. - from dynamic_debug_init(), where all DYNAMIC_DEBUG_CLASSES definitions of each builtin module have been packed together. This is why ddebug_attach_module_classes() checks module-name. NOTES Its (highly) likely that builtin classes will be ordered by module name (just like prdbg descriptors are in the __dyndbg section). So the list can be replaced by a vector (ptr + length), which will work for loaded modules too. This would imitate whats currently done for the _ddebug descriptors. That said, converting to vector,len is close to pointless; a small minority of modules will ever define a class-map, and almost all of them will have only 1 or 2 class-maps, so theres only a couple dozen pointers to save. TODO: re-evaluate for lines removable. Signed-off-by: Jim Cromie --- v6 . fix compile err due to reorderd commits, and missed lkp report. . init dt->maps in ddebug_add_module, prior to ddebug_attach_module_classes --- lib/dynamic_debug.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fb31a1a2fc3f..b71efd0b491d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,7 +45,7 @@ extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 struct ddebug_table { - struct list_head link; + struct list_head link, maps; const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; @@ -921,6 +921,32 @@ 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) +{ + struct ddebug_class_map *cm; + int i, j, ct =3D 0; + + for (cm =3D classes, i =3D 0; i < num_classes; i++, cm++) { + + 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 (ct) + vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -952,6 +978,10 @@ static int __ddebug_add_module(struct _ddebug_info *di= , unsigned int base, dt->num_ddebugs =3D di->num_descs; =20 INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->maps); + + if (di->classes && di->num_classes) + ddebug_attach_module_classes(dt, di->classes, di->num_classes); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 5188FECAAD5 for ; Sun, 4 Sep 2022 21:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235584AbiIDVnR (ORCPT ); Sun, 4 Sep 2022 17:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235207AbiIDVmc (ORCPT ); Sun, 4 Sep 2022 17:42:32 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F562C648 for ; Sun, 4 Sep 2022 14:42:26 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id q81so5653723iod.9 for ; Sun, 04 Sep 2022 14:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VxE+CjvPcbwZBKtBtewU/pc49ydYdwD1bemh/z2C+cc=; b=h1uXArjcpOcsplR1a7ck5hMfB0jipK7wuQb7G44QWNwGjgEBu1Xr0G94cXBoKzCxfl 1vjqE5xplO6F9Ls21RTEGvLbk74OohelrHNWo/7jTzO5+gDicgi/Bhw7sy4kErWVx22u 02PfdOEn6NyoxKvro1zgilAxVQfYygibBFevXKY43frFl8LZo4SEX9VknH94NYm2QeTv ntOmxRNJPekmmY2SfXOh/Mtv93hcpIqsrWvRjureF0LbQUIqNg5XmgRMuOe2/qExVrJY FsBtgrOyxi+4w3laqUtR4Qlj95NLv5TTt4NuboZT5tsRTKmXXBS6ekBqAFZ/3n+DSo0a el+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=VxE+CjvPcbwZBKtBtewU/pc49ydYdwD1bemh/z2C+cc=; b=Ta+Mx37K1QeHqPAKPFTyunHh9M6QypN/YwxmaOkkJY33Pp9BcIY7H7uEgqVxaJHVKD GI6mmFJC8q3JMpT8SpRiw68l4TXpAB4WzzB7ISGbL52u/sV6hAoRSrJtWQYBIGXJWtMC 5GqGcvTQ5qgt1C1AfvoWevNfQt5BXoRpme8ex3dColOG9P52oqQWU/Cmd+qhJDj0Hsex 6hxfmTumsbfMMxdk0Z+ruTpPjoeYEdXh9oD1qhxhJTQmLDNPIvI+b+jfbYO6TspW01Qs /J5axobpIx9mrftUxUDGSxbj7kTaIrEJQGvqMVE187FSLMeO6/SOH+82/EaVc3NrVsTG TiyA== X-Gm-Message-State: ACgBeo2tgi/riQEJMs+1pSNS6Ivm4+TqeHXHyn5JnaaoYGvB0FnqK6dA QMYHd+UY5ztDl46hpXsaugM= X-Google-Smtp-Source: AA6agR4/STeszDaNnHQOAo3k0NzkOuMgD+5y52Td5RoIs4nkonSkpoIupcmrwQAe7iVGrvlZT5LJ6A== X-Received: by 2002:a02:c487:0:b0:34f:3b8b:6ba1 with SMTP id t7-20020a02c487000000b0034f3b8b6ba1mr6323054jam.291.1662327746302; Sun, 04 Sep 2022 14:42:26 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:26 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 17/57] dyndbg: validate class FOO by checking with module Date: Sun, 4 Sep 2022 15:40:54 -0600 Message-Id: <20220904214134.408619-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 module-to-class validation: #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control If a query has "class FOO", then ddebug_find_valid_class(), called from ddebug_change(), requires that FOO is known to module X, otherwize the query is skipped entirely for X. This protects each module's class-space, other than the default:31. The authors' choice of FOO is highly selective, giving isolation and/or coordinated sharing of FOOs. For example, only DRM modules should know and respond to DRM_UT_KMS. So this, combined with module's opt-in declaration of known classes, effectively privatizes the .class_id space for each module (or coordinated set of modules). Notes: For all "class FOO" queries, ddebug_find_valid_class() is called, it returns the map matching the query, and sets valid_class via an *outvar). If no "class FOO" is supplied, valid_class =3D _CLASS_DFLT. This insures that legacy queries do not trample on new class'd callsites, as they get added. Also add a new column to control-file output, displaying non-default class-name (when found) or the "unknown _id:", if it has not been (correctly) declared with one of the declarator macros. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 76 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b71efd0b491d..db96ded78c3f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -56,6 +56,7 @@ struct ddebug_query { const char *module; const char *function; const char *format; + const char *class_string; unsigned int first_lineno, last_lineno; }; =20 @@ -136,15 +137,33 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) fmtlen--; } =20 - v3pr_info("%s: func=3D\"%s\" file=3D\"%s\" module=3D\"%s\" format=3D\"%.*= s\" lineno=3D%u-%u\n", - msg, - query->function ?: "", - query->filename ?: "", - query->module ?: "", - fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno); + v3pr_info("%s: func=3D\"%s\" file=3D\"%s\" module=3D\"%s\" format=3D\"%.*= s\" lineno=3D%u-%u class=3D%s\n", + msg, + query->function ?: "", + query->filename ?: "", + query->module ?: "", + fmtlen, query->format ?: "", + query->first_lineno, query->last_lineno, query->class_string); } =20 +static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, + const char *class_string, int *class_id) +{ + struct ddebug_class_map *map; + int idx; + + list_for_each_entry(map, &dt->maps, link) { + idx =3D match_string(map->class_names, map->length, class_string); + if (idx >=3D 0) { + *class_id =3D idx + map->base; + return map; + } + } + *class_id =3D -ENOENT; + return NULL; +} + +#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 @@ -159,6 +178,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; + struct ddebug_class_map *map =3D NULL; + int __outvar valid_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -169,9 +190,22 @@ static int ddebug_change(const struct ddebug_query *qu= ery, !match_wildcard(query->module, dt->mod_name)) continue; =20 + if (query->class_string) { + map =3D ddebug_find_valid_class(dt, query->class_string, &valid_class); + if (!map) + continue; + } else { + /* constrain query, do not touch class'd callsites */ + valid_class =3D _DPRINTK_CLASS_DFLT; + } + for (i =3D 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp =3D &dt->ddebugs[i]; =20 + /* match site against query-class */ + if (dp->class_id !=3D valid_class) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -420,6 +454,8 @@ static int ddebug_parse_query(char *words[], int nwords, } else if (!strcmp(keyword, "line")) { if (parse_linerange(query, arg)) return -EINVAL; + } else if (!strcmp(keyword, "class")) { + rc =3D check_set(&query->class_string, arg, "class"); } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -854,6 +890,20 @@ static void *ddebug_proc_next(struct seq_file *m, void= *p, loff_t *pos) return dp; } =20 +#define class_in_range(class_id, map) \ + (class_id >=3D map->base && class_id < map->base + map->length) + +static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) +{ + struct ddebug_class_map *map; + + list_for_each_entry(map, &iter->table->maps, link) + if (class_in_range(dp->class_id, map)) + return map->class_names[dp->class_id - map->base]; + + return NULL; +} + /* * Seq_ops show method. Called several times within a read() * call from userspace, with ddebug_lock held. Formats the @@ -865,6 +915,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) struct ddebug_iter *iter =3D m->private; struct _ddebug *dp =3D p; struct flagsbuf flags; + char const *class; =20 if (p =3D=3D SEQ_START_TOKEN) { seq_puts(m, @@ -877,7 +928,16 @@ static int ddebug_proc_show(struct seq_file *m, void *= p) iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id !=3D _DPRINTK_CLASS_DFLT) { + class =3D ddebug_class_name(iter, dp); + if (class) + seq_printf(m, " class:%s", class); + else + seq_printf(m, " class unknown, _id:%d", dp->class_id); + } + seq_puts(m, "\n"); =20 return 0; } --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 F137EECAAD5 for ; Sun, 4 Sep 2022 21:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235596AbiIDVnX (ORCPT ); Sun, 4 Sep 2022 17:43:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235217AbiIDVmc (ORCPT ); Sun, 4 Sep 2022 17:42:32 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03882F025 for ; Sun, 4 Sep 2022 14:42:27 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id d68so5628957iof.11 for ; Sun, 04 Sep 2022 14:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ka8KRcp96RIs3WOVwaYMps+w4bs0E4mB3tU6nT4x+Cw=; b=GxYiBhtnCCLvIcjhtx8t6SNtIL7IN9FTRLpFWPEgQwmEChr7Li1YPuQJ9uzL52Yj6A cgqwOnKPTkhyNLE0ZRZ71TysRmVMnqOnOuIZy+W7qyW1e5LLWRS5QYdy3aifvqzwysH4 6lBOaERL6zccFDJfBmPhlj41W7qOzgatR/sLszHd+5qrcHenG/kiPqGelWghMXTumLSf wFRbcjMRbogjvc9bqHIzD2/qSvsiQjcw0SYznzSLJ7jTTu+kn1HauuURN6n5y/Y3xzEP XBYr4ufLmOy1cM38/VKtTZMrK2mJrrVShrlX+MdWlctqxmtxNnUASO0irSsXn081Wpp/ hmlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ka8KRcp96RIs3WOVwaYMps+w4bs0E4mB3tU6nT4x+Cw=; b=UeA7n6oMrXjKpLpfDTWkCIakbpC353awoupEMh4bkcSFhyeJDz/65PAUoo458mkyCq hBsH1iJr6jXMMNV/ppFsCNurIG0nhKpRsLNTyqJkcZHmkoNd3UHu+kVlEpAhp9GsRLQm XulrDm+ERVMSxIO7bEV89vdNDxeRNzaDa7v6Eo5YgBfWSTOWNmzr5xmMQbQO9DBoOi6N 9DSYqMeYOsO6RdJjKdrUJ4fcpSpXtzqYhwvqWdzQD24aGxg6Y/kAuPxKxNkBK7IallZJ /+XO1J7h39n78XknKq3a7lQCg2w7GXACEcepNhjAHDAqK9X56q7IlxtaEd+7GMmEyqo8 IZPA== X-Gm-Message-State: ACgBeo11jSOKQN3yqQZtoGSJTSZinMiMWuGKHu87kiYvS6cuOMu1jI9t +8OKk9wyv921nomI7g6qnXPKcyBuLrU= X-Google-Smtp-Source: AA6agR5AUEVpUfSPOxmk4wGZ/zK2tirYmhJ7zb9Jqld8zfrr8gDhVIB8ywXi+kyB8PgF4y+5mK88yQ== X-Received: by 2002:a6b:5f19:0:b0:688:2173:1ae3 with SMTP id t25-20020a6b5f19000000b0068821731ae3mr21256805iob.12.1662327747322; Sun, 04 Sep 2022 14:42:27 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:27 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 18/57] doc-dyndbg: describe "class CLASS_NAME" query support Date: Sun, 4 Sep 2022 15:40:55 -0600 Message-Id: <20220904214134.408619-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 an explanation of the new "class CLASS_NAME" syntax and meaning, noting that the module determines if CLASS_NAME applies to it. Signed-off-by: Jim Cromie --- Documentation/admin-guide/dynamic-debug-howto.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index a89cfa083155..d8954ab05c7b 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -35,6 +35,7 @@ Dynamic debug has even more useful features: - line number (including ranges of line numbers) - module name - format string + - class name (as known/declared by each module) =20 * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -142,6 +143,7 @@ against. Possible keywords are::: 'file' string | 'module' string | 'format' string | + 'class' string | 'line' line-range =20 line-range ::=3D lineno | @@ -203,6 +205,15 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitesp= ace =20 +class + The given class_name is validated against each module, which may + have declared a list of known class_names. If the class_name is + found for a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a DRM.debug category + class JUNK # silent non-match + line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 5A4E5C6FA82 for ; Sun, 4 Sep 2022 21:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235634AbiIDVn2 (ORCPT ); Sun, 4 Sep 2022 17:43:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235254AbiIDVmd (ORCPT ); Sun, 4 Sep 2022 17:42:33 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC77E2F032; Sun, 4 Sep 2022 14:42:28 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id h78so5628274iof.13; Sun, 04 Sep 2022 14:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=CX6qv1cFIAak2H7Dm87W0kPuSMznCRZBjCF+tQ4X600=; b=Q3cfmH2LyzD2M1ZLD1pNAYsFedbjIhzATxm909rJnzqncgvkGEna14g3zmelu6oNst yGRhbYN/jRA+ojsvvywLPGWaCcX47VMRUnKRP92jnlsGfo1gGsS/0pX+v8XIDy5+K1wv hcfhFf3zOBj2FBQR39ZiBbHIk3gixOCnKUR2CMrawaeq1wqnvitFf/VGPNqkBkPIpnls 56wnzrcfUPLjZXmU8QQUnd4C5IE+42uE+JPwWFrONI+gkyiM0SOy/zS4gmQQTKnJrSEh AmFmI41xFzMh/EU0bL2Kwgx3PqC/fsLN3iAS+RAov2KWCcsxbl/Ax9pu0IhieIAi3uwK Zk8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=CX6qv1cFIAak2H7Dm87W0kPuSMznCRZBjCF+tQ4X600=; b=zXN5unkb0NJ85+m2+ZCfoMgniuEIPu6GXpxsnsj4Yv/mlLwQ6VHrzfrUX2mQ6AlNFL khAgpOsaTs/77oV9Cx9JGQVa8MYlYkXNMy+Oy6XUhiB5we9Wkj6cYOdxewV8cnGt9pTu yAoEgjk7NnrfuClt5mhYWtTIFrHPrv7IueTRFj8JQfDrrrmvV993vrCHK8I09bNBGYrV +CLRtd9iTJqZi+K7O830Zjzk63I7Est3KEZFGnb/+K7WZaxhr6xyEMaCANrC1uyDWKy9 CoNrSFyhdiNDKyAnF05u6BY8iA37ftS9nj6nzdIpQGnx158Nmkt7bQH7s2xRJmw64ccJ racQ== X-Gm-Message-State: ACgBeo1zznizIVqfefi2+JBqX5Ot+4V4ec4laj/FeSUfg9elC0DJIriT rExddWAlHqKO1FSl2+pTY+M= X-Google-Smtp-Source: AA6agR6FDmbgVlOi+VH2xD/wJEH/An47KuIR8rJmhUndQnxcZqdaaNF4vm3Z/VHoIzRdq/aFbHaolw== X-Received: by 2002:a02:cb57:0:b0:34c:b847:d5fb with SMTP id k23-20020a02cb57000000b0034cb847d5fbmr9181329jap.32.1662327748378; Sun, 04 Sep 2022 14:42:28 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:27 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v6 19/57] doc-dyndbg: edit dynamic-debug-howto for brevity, audience Date: Sun, 4 Sep 2022 15:40:56 -0600 Message-Id: <20220904214134.408619-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Rework/modernize docs: - use /proc/dynamic_debug/control in examples its *always* there (when dyndbg is config'd), even when is not. drop talk, its a distraction here. - alias ddcmd=3D'echo $* > /proc/dynamic_debug/control focus on args: declutter, hide boilerplate, make pwd independent. - swap sections: Viewing before Controlling. control file as Catalog. - focus on use by a system administrator add an alias to make examples more readable drop grep-101 lessons, admins know this. - use init/main.c as 1st example, thread it thru doc where useful. everybodys kernel boots, runs these. - add *prdbg* api section to the bottom of the file, its for developers more than admins. move list of api functions there. - simplify - drop extra words, phrases, sentences. - add "decorator" flags line to unify "prefix", trim fmlt descriptions CC: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- fixup-doc: trailing colons for block headers, trim fedora numbers. Bagas --- .../admin-guide/dynamic-debug-howto.rst | 235 +++++++++--------- 1 file changed, 117 insertions(+), 118 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index d8954ab05c7b..faa22f77847a 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -5,30 +5,19 @@ Dynamic debug Introduction =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -This document describes how to use the dynamic debug (dyndbg) feature. +Dynamic debug allows you to dynamically enable/disable kernel +debug-print code to obtain additional kernel information. =20 -Dynamic debug is designed to allow you to dynamically enable/disable -kernel code to obtain additional kernel information. Currently, if -``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and -``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamic= ally -enabled per-callsite. +If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic +debug. You'll need root access (sudo su) to use this. =20 -If you do not want to enable dynamic debug globally (i.e. in some embedded -system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dyn= amic -debug and add ``ccflags :=3D -DDYNAMIC_DEBUG_MODULE`` into the Makefile of= any -modules which you'd like to dynamically debug later. +Dynamic debug provides: =20 -If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just -shortcut for ``print_hex_dump(KERN_DEBUG)``. + * a Catalog of all *prdbgs* in your kernel. + ``cat /proc/dynamic_debug/control`` to see them. =20 -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 has even more useful features: - - * Simple query language allows turning on and off debugging - statements by matching any combination of 0 or 1 of: + * a Simple query/command language to alter *prdbgs* by selecting on + any combination of 0 or 1 of: =20 - source filename - function name @@ -37,107 +26,88 @@ Dynamic debug has even more useful features: - format string - class name (as known/declared by each module) =20 - * Provides a debugfs control file: ``/dynamic_debug/control`` - which can be read to display the complete list of known debug - statements, to help guide you - -Controlling dynamic debug Behaviour -=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=3D - -The behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing t= o a -control file in the 'debugfs' filesystem. Thus, you must first mount -the debugfs filesystem, in order to make use of this feature. -Subsequently, we refer to the control file as: -``/dynamic_debug/control``. For example, if you want to enable -printing from source file ``svcsock.c``, line 1603 you simply do:: - - nullarbor:~ # echo 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - -If you make a mistake with the syntax, the write will fail thus:: - - nullarbor:~ # echo 'file svcsock.c wtf 1 +p' > - /dynamic_debug/control - -bash: echo: write error: Invalid argument - -Note, for systems without 'debugfs' enabled, the control file can be -found in ``/proc/dynamic_debug/control``. - Viewing Dynamic Debug Behaviour =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 -You can view the currently configured behaviour of all the debug -statements via:: +You can view the currently configured behaviour in the *prdbg* catalog:: =20 - nullarbor:~ # cat /dynamic_debug/control + :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format - net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =3D_ "SVCRDMA M= odule Removed, deregister RPC RDMA transport\012" - net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =3D_ "\011max_inli= ne : %d\012" - net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =3D_ "\011sq_depth= : %d\012" - net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =3D_ "\011max_requ= ests : %d\012" - ... + init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \012 + init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\012" + init/main.c:1424 [main]run_init_process =3D_ " with arguments:\012" + init/main.c:1426 [main]run_init_process =3D_ " %s\012" + init/main.c:1427 [main]run_init_process =3D_ " with environment:\012" + init/main.c:1429 [main]run_init_process =3D_ " %s\012" =20 +The 3rd space-delimited column shows the current flags, preceded by +a ``=3D`` for easy use with grep/cut. ``=3Dp`` shows enabled callsites. =20 -You can also apply standard Unix text manipulation filters to this -data, e.g.:: +Controlling dynamic debug Behaviour +=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=3D =20 - nullarbor:~ # grep -i rdma /dynamic_debug/control | wc -l - 62 +The behaviour of *prdbg* sites are controlled by writing +query/commands to the control file. Example:: =20 - nullarbor:~ # grep -i tcp /dynamic_debug/control | wc -l - 42 + # grease the interface + :#> alias ddcmd=3D'echo $* > /proc/dynamic_debug/control' =20 -The third column shows the currently enabled flags for each debug -statement callsite (see below for definitions of the flags). The -default value, with no flags enabled, is ``=3D_``. So you can view all -the debug statement callsites with any non-default flags:: + :#> ddcmd '-p; module main func run* +p' + :#> grep =3Dp /proc/dynamic_debug/control + init/main.c:1424 [main]run_init_process =3Dp " with arguments:\012" + init/main.c:1426 [main]run_init_process =3Dp " %s\012" + init/main.c:1427 [main]run_init_process =3Dp " with environment:\012" + init/main.c:1429 [main]run_init_process =3Dp " %s\012" =20 - nullarbor:~ # awk '$3 !=3D "=3D_"' /dynamic_debug/control - # filename:lineno [module]function flags format - net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto ret= urned %d\012" +Error messages go to console/syslog:: + + :#> ddcmd mode foo +p + dyndbg: unknown keyword "mode" + dyndbg: query parse failed + bash: echo: write error: Invalid argument + +If debugfs is also enabled and mounted, ``dynamic_debug/control`` is +also under the mount-dir, typically ``/sys/kernel/debug/``. =20 Command Language Reference =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 -At the lexical level, a command comprises a sequence of words separated +At the basic lexical level, a command is a sequence of words separated by spaces or tabs. So these are all equivalent:: =20 - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' > - /dynamic_debug/control - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd file svcsock.c line 1603 +p + :#> ddcmd "file svcsock.c line 1603 +p" + :#> ddcmd ' file svcsock.c line 1603 +p ' =20 Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: =20 - ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \ - > /dynamic_debug/control - -If your query set is big, you can batch them too:: - - ~# cat query-batch-file > /dynamic_debug/control + :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd <<"EOC" + func pnpacpi_get_resources +p + func pnp_assign_mem +p + EOC + :#> cat query-batch-file > /proc/dynamic_debug/control =20 -Another way is to use wildcards. The match rule supports ``*`` (matches -zero or more characters) and ``?`` (matches exactly one character). For -example, you can match all usb drivers:: +You can also use wildcards in each query term. The match rule supports +``*`` (matches zero or more characters) and ``?`` (matches exactly one +character). For example, you can match all usb drivers:: =20 - ~# echo "file drivers/usb/* +p" > /dynamic_debug/control + :#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion =20 -At the syntactical level, a command comprises a sequence of match -specifications, followed by a flags change specification:: +Syntactically, a command is pairs of keyword values, followed by a +flags change or setting:: =20 command ::=3D match-spec* flags-spec =20 -The match-spec's are used to choose a subset of the known pr_debug() -callsites to which to apply the flags-spec. Think of them as a query -with implicit ANDs between each pair. Note that an empty list of -match-specs will select all debug statement callsites. +The match-spec's select *prdbgs* from the catalog, upon which to apply +the flags-spec, all constraints are ANDed together. An absent keyword +is the same as keyword "*". =20 -A match specification comprises a keyword, which controls the -attribute of the callsite to be compared, and a value to compare -against. Possible keywords are::: + +A match specification is a keyword, which selects the attribute of +the callsite to be compared, and a value to compare against. Possible +keywords are::: =20 match-spec ::=3D 'func' string | 'file' string | @@ -213,6 +183,7 @@ class =20 class DRM_UT_KMS # a DRM.debug category class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names =20 line The given line number or range of line numbers is compared @@ -239,17 +210,16 @@ of the characters:: The flags are:: =20 p enables the pr_debug() callsite. - f Include the function name in the printed message - l Include line number in the printed message - m Include module name in the printed message - t Include thread ID in messages not generated from interrupt context - _ No flags are set. (Or'd with others on input) + _ enables no flags. =20 -For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` = flag -have meaning, other flags ignored. + Decorator flags add to the message-prefix, in order: + t Include thread ID, or + m Include module name + f Include the function name + l Include line number =20 -For display, the flags are preceded by ``=3D`` -(mnemonic: what the flags are currently equal to). +For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only +the ``p`` flag has meaning, other flags are ignored. =20 Note the regexp ``^[-+=3D][flmpt_]+$`` matches a flags specification. To clear all flags at once, use ``=3D_`` or ``-flmpt``. @@ -324,7 +294,7 @@ For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings give= n at boot-time (or enabled by ``-DDEBUG`` flag during compilation) can be disabled later via the debugfs interface if the debug messages are no longer needed:: =20 - echo "module module_name -p" > /dynamic_debug/control + echo "module module_name -p" > /proc/dynamic_debug/control =20 Examples =3D=3D=3D=3D=3D=3D=3D=3D @@ -332,37 +302,31 @@ Examples :: =20 // enable the message at line 1603 of file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c line 1603 +p' =20 // enable all the messages in file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c +p' =20 // enable all the messages in the NFS server module - nullarbor:~ # echo -n 'module nfsd +p' > - /dynamic_debug/control + :#> ddcmd 'module nfsd +p' =20 // enable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process +p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process +p' =20 // disable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process -p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process -p' =20 // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. - nullarbor:~ # echo -n 'format "nfsd: READ" +p' > - /dynamic_debug/control + :#> ddcmd 'format "nfsd: READ" +p' =20 // enable messages in files of which the paths include string "usb" - nullarbor:~ # echo -n 'file *usb* +p' > /dynamic_debug/control + :#> ddcmd 'file *usb* +p' > /proc/dynamic_debug/control =20 // enable all messages - nullarbor:~ # echo -n '+p' > /dynamic_debug/control + :#> ddcmd '+p' > /proc/dynamic_debug/control =20 // add module, function to all enabled messages - nullarbor:~ # echo -n '+mf' > /dynamic_debug/control + :#> ddcmd '+mf' > /proc/dynamic_debug/control =20 // boot-args example, with newlines and comments for readability Kernel command line: ... @@ -375,3 +339,38 @@ Examples dyndbg=3D"file init/* +p #cmt ; func parse_one +p" // enable pr_debugs in 2 functions in a module loaded later pc87360.dyndbg=3D"func pc87360_init_device +p; func pc87360_find +p" + +Kernel Configuration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Dynamic Debug is enabled via kernel config items:: + + CONFIG_DYNAMIC_DEBUG=3Dy # build catalog, enables CORE + CONFIG_DYNAMIC_DEBUG_CORE=3Dy # enable mechanics only, skip catalog + +If you do not want to enable dynamic debug globally (i.e. in some embedded +system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dyn= amic +debug and add ``ccflags :=3D -DDYNAMIC_DEBUG_MODULE`` into the Makefile of= any +modules which you'd like to dynamically debug later. + + +Kernel *prdbg* API +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The following functions are cataloged and controllable when dynamic +debug is enabled:: + + pr_debug() + dev_dbg() + print_hex_dump_debug() + print_hex_dump_bytes() + +Otherwise, they are off by default; ``ccflags +=3D -DDEBUG`` or +``#define DEBUG`` in a source file will enable them appropriately. + +If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is +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. --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 691C3ECAAD5 for ; Sun, 4 Sep 2022 21:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235313AbiIDVnd (ORCPT ); Sun, 4 Sep 2022 17:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234871AbiIDVmf (ORCPT ); Sun, 4 Sep 2022 17:42:35 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37E52F03B for ; Sun, 4 Sep 2022 14:42:29 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id a9so3885390ilh.1 for ; Sun, 04 Sep 2022 14:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ER34tpiRxpxrqbyeNfK9kTxedh1cey5Wd7+bTMMeAt0=; b=gUiSZYP/k1pFS83DqE+EmB82be55p+NVZac494a9x4xvG65y6FIZ6bn2Dug8vAHY9q qzJdTJ0xaj0Tydn2YUrikCBWFQcFjSz5g9K7vIAtbjGAnIZi4K/jJs2sHNZBJ+baoA8l URtbxytNiVq1d9Gu6B/r7QOd6vTqF0GZqhWye1MbM7fFBWlQFQAJXor/wBXat4Nk7Et/ pEIU7EQnt5M5neYGmrgk6SH/GT1IUmqsTEaBMUPKKfJBHtQW3Zxu7sdHRGllR577eVYj MSfDzcicu+qbF1uZp/QhiDLJS0y/yQR5YspuuKz5kZ2xpPb3n6kFqaSM4iSEEbLHVncg ltBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ER34tpiRxpxrqbyeNfK9kTxedh1cey5Wd7+bTMMeAt0=; b=KrAv05t6EJ6ceYvOcm41mi7YrBcDp8itVWKkg+4mcx14kncJtw8PMt8LLTmo0Ur7Gq LQrq4XWV0iBqAwGIoNoF6DJQN3CcBvIMxcy27ZKCPNgjaANEkN6nEKwui5FVyfBh98XC ndxmsPRMczie3m4+QOcrYD40xnKLz6OrFo7298e4BxcuWcvFU/VWJsD0CztOGSiqzDrt 7HS4Bu7jixPykn/rsQRf8TkoOejkkadlbX2VZX8IiEeZ2suDu3zNbS41e25zRtV7Uwt6 ph8+GOethmnsMHzPtqu5Ptz+8cCtGJR4DC/CcTE8LDwflOpfZrMqlwFf2NZ92Ypx8htd 65lw== X-Gm-Message-State: ACgBeo1dtqGqp1lf2gcQD1mJNws98ZgbZ5vCgAbJdB6HeydVPPVm8l5K OFbZCD2a1jZXNagT5Mfj1E0= X-Google-Smtp-Source: AA6agR58q6IyXd9WZ12hKcbIiqtMN6VqpqX1EWImJSjgdussO16aRw1Y1NKPghl79c/vNyaNEGfwGw== X-Received: by 2002:a92:2c0e:0:b0:2ea:c3b8:433c with SMTP id t14-20020a922c0e000000b002eac3b8433cmr19399396ile.107.1662327749404; Sun, 04 Sep 2022 14:42:29 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:29 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 20/57] dyndbg: add drm.debug style (drm/parameters/debug) bitmap support Date: Sun, 4 Sep 2022 15:40:57 -0600 Message-Id: <20220904214134.408619-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 kernel_param_ops and callbacks to use a class-map to validate and apply input to a sysfs-node, which allows users to control classes defined in that class-map. This supports uses like: echo 0x3 > /sys/module/drm/parameters/debug IE add these: - int param_set_dyndbg_classes() - int param_get_dyndbg_classes() - struct kernel_param_ops param_ops_dyndbg_classes Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. This might be unnecessary here. get/set use an augmented kernel_param; the arg refs a new struct ddebug_class_param, which contains: - A ptr to user's state-store; a union of &ulong for drm.debug, &int for nouveau level debug. By ref'g the client's bit-state _var, code coordinates with existing code (like drm_debug_enabled) which uses it, so existing/remaining calls can work unchanged. Changing drm.debug to a ulong allows use of BIT() etc. - FLAGS: dyndbg.flags toggled by changes to bitmap. Usually just "p". - MAP: a pointer to struct ddebug_classes_map, which maps those class-names to .class_ids 0..N that the module is using. This class-map is declared & initialized by DECLARE_DYNDBG_CLASSMAP. - map-type: 4 enums DD_CLASS_TYPE_* select 2 input forms and 2 meanings. numeric input: DD_CLASS_TYPE_DISJOINT_BITS integer input, independent bits. ie: drm.debug DD_CLASS_TYPE_LEVEL_NUM integer input, 0..N levels classnames-list (comma separated) input: DD_CLASS_TYPE_DISJOINT_NAMES each name affects a bit, others preserved DD_CLASS_TYPE_LEVEL_NAMES names have level meanings, like kern_levels.h _NAMES - comma-separated classnames (with optional +-) _NUM - numeric input, 0-N expected _BITS - numeric input, 0x1F bitmap form expected _DISJOINT - bits are independent _LEVEL - (x /sys/module/drm/parameters/debug_catnames A naive _LEVEL_NAMES use, with one class, that sets all in the class-map according to (x /sys/module/test_dynamic_debug/parameters/p_level_names : problem solved echo -L1 > /sys/module/test_dynamic_debug/parameters/p_level_names Note this artifact: : this is same as prev cmd (due to +/-) echo L0 > /sys/module/test_dynamic_debug/parameters/p_level_names : this is "even-more" off, but same wo __pr_debug_class(L0, ".."). echo -L0 > /sys/module/test_dynamic_debug/parameters/p_level_names A stress-test/make-work usage (kid toggling a light switch): echo +L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7 \ > /sys/module/test_dynamic_debug/parameters/p_level_names ddebug_apply_class_bitmap(): inside-fn, works on bitmaps, receives new-bits, finds diffs vs client-bitvector holding "current" state, and issues exec_query to commit the adjustment. param_set_dyndbg_classes(): interface fn, sends _NAMES to param_set_dyndbg_classnames() and returns, falls thru to handle _BITS, _NUM internally, and calls ddebug_apply_class_bitmap(). Finishes by updating state. param_set_dyndbg_classnames(): handles classnames-list in loop, calls ddebug_apply_class_bitmap for each, then updates state. NOTES: _LEVEL_ is overlay on _DISJOINT_; inputs are converted to a bitmask, by the callbacks. IOW this is possible, and possibly confusing: echo class V3 +p > control echo class V1 -p > control IMO thats ok, relative verbosity is an interface property. _LEVEL_NUM maps still need class-names, even though the names are not usable at the sysfs interface (unlike with _NAMES style). The names are the only way to >control the classes. - It must have a "V0" name, something below "V1" to turn "V1" off. __pr_debug_cls(V0,..) is printk, don't do that. - "class names" is required at the >control interface. - relative levels are not enforced at >control _LEVEL_NAMES bear +/- signs, which alters the on-bit-pos by 1. IOW, +L2 means L0,L1,L2, and -L2 means just L0,L1. This kinda spoils the readback fidelity, since the L0 bit gets turned on by any use of any L*, except "-L0". All the interface uncertainty here pertains to the _NAMES features. Nobody has actually asked for this, so its practical (if a little tedious) to split it out. Signed-off-by: Jim Cromie --- . drop kp->mod->name as unneeded (build-dependent) . param_set_dyndbg_classnames, not _class_strings . DD_CLASS_TYPE_* name changes, per Jason . callbacks: extend comments on DD_CLASS_TYPE_* handling, flow notes varname changes . kdoc tweaks . add stub macro: #define KP_NAME(kp) kp->name later, add "$module." prefix when config doesn't do it . s/struct ddebug_classes_bitmap_param/struct ddebug_class_param/ . fix levels state handling v4 had trouble where level-type's state was fouled by conversion to bitmap form given to apply-bitmap. fix by: (simplify/clarify) add old-bits, new-bits to sysfs-iface&support use CLASSMAP_BITMASK more in param_set_dyndbg_class{es,names}(): move state-saving inside switches, and tailor it to type. this preserves lvl-state, vs -v4 which didnt. I could "hack" in an offset, but the problem feels deeper. The root-problem may be the ambiguity wrt 0x0 > knob; per a input-is-assert-bitpos interpretation, it turns on bit 0. Thus far, code has avoided this ambiguity, by recommending against coding pr_dbg_cls(V0|L0, ""), which makes "+L0" & "-L0" equivalent, and "0" silent. That might be "too clever by 1/2"; accepting an int, so -1 means all-bits-off as well as verbosity-off, might be the better way. fix-lvl-sz --- include/linux/dynamic_debug.h | 21 ++++ lib/dynamic_debug.c | 212 ++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 9073a43a2039..41682278d2e8 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -119,6 +119,15 @@ struct _ddebug_info { unsigned int num_classes; }; =20 +struct ddebug_class_param { + union { + unsigned long *bits; + unsigned int *lvl; + }; + char flags[8]; + const struct ddebug_class_map *map; +}; + #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); @@ -278,6 +287,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 +struct kernel_param; +int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp); +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp); + /* for test only, generally expect drm.debug style macro wrappers */ #define __pr_debug_cls(cls, fmt, ...) do { \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ @@ -324,6 +337,14 @@ static inline int ddebug_dyndbg_module_param_cb(char *= param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) =20 +struct kernel_param; +static inline int param_set_dyndbg_classes(const char *instr, const struct= kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classes(char *buffer, const struct kern= el_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 +extern const struct kernel_param_ops param_ops_dyndbg_classes; + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index db96ded78c3f..009f2ead09c1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -596,6 +596,218 @@ static int ddebug_exec_queries(char *query, const cha= r *modname) return nfound; } =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) +{ +#define QUERY_SIZE 128 + char query[QUERY_SIZE]; + const struct ddebug_class_map *map =3D dcp->map; + int matches =3D 0; + int bi, ct; + + v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + + for (bi =3D 0; bi < map->length; bi++) { + if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) + continue; + + snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], + test_bit(bi, new_bits) ? '+' : '-', dcp->flags); + + ct =3D ddebug_exec_queries(query, NULL); + matches +=3D ct; + + v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, + ct, map->class_names[bi], *new_bits); + } + return matches; +} + +/* stub to later conditionally add "$module." prefix where not already don= e */ +#define KP_NAME(kp) kp->name + +#define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) + +/* 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); + *dcp->bits =3D curr_bits; + v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, + map->class_names[cls_id]); + break; + case DD_CLASS_TYPE_LEVEL_NAMES: + /* cls_id =3D N in 0..max. wanted +/- determines N or N-1 */ + old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); + curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); + + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); + v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, + map->class_names[cls_id], old_bits, curr_bits); + break; + default: + pr_err("illegal map-type value %d\n", map->map_type); + } + } + kfree(tmp); + vpr_info("total matches: %d\n", totct); + return 0; +} + +/** + * param_set_dyndbg_classes - class FOO >control + * @instr: string echo>d to sysfs, input depends on map_type + * @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) +{ + const struct ddebug_class_param *dcp =3D kp->arg; + const struct ddebug_class_map *map =3D dcp->map; + unsigned long inrep, new_bits, old_bits; + int rc, totct =3D 0; + + 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); + return -EINVAL; + } + + /* 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 */ + 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:%lx > %s\n", inrep, KP_NAME(kp)); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + *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)); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + *dcp->lvl =3D inrep; + break; + default: + pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + } + vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg_classes); + +/** + * param_get_dyndbg_classes - classes reader + * @buffer: string description of controlled bits -> classes + * @kp: kp->arg has state: bits, map + * + * Reads last written state, underlying prdbg state may have been + * altered by direct >control. Displays 0x for DISJOINT, 0-N for + * LEVEL Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp =3D kp->arg; + const struct ddebug_class_map *map =3D dcp->map; + + switch (map->map_type) { + + case DD_CLASS_TYPE_DISJOINT_NAMES: + case DD_CLASS_TYPE_DISJOINT_BITS: + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); + + case DD_CLASS_TYPE_LEVEL_NAMES: + case DD_CLASS_TYPE_LEVEL_NUM: + return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + default: + return -1; + } +} +EXPORT_SYMBOL(param_get_dyndbg_classes); + +const struct kernel_param_ops param_ops_dyndbg_classes =3D { + .set =3D param_set_dyndbg_classes, + .get =3D param_get_dyndbg_classes, +}; +EXPORT_SYMBOL(param_ops_dyndbg_classes); + #define PREFIX_SIZE 64 =20 static int remaining(int wrote) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 1123CC6FA82 for ; Sun, 4 Sep 2022 21:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235768AbiIDVnp (ORCPT ); Sun, 4 Sep 2022 17:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235312AbiIDVmh (ORCPT ); Sun, 4 Sep 2022 17:42:37 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E866E2E69B for ; Sun, 4 Sep 2022 14:42:30 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id c4so5673295iof.3 for ; Sun, 04 Sep 2022 14:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=SWtn3j+X9Qv4/8jm3akSHIAKz6ptgqW0K3O3Ay77qY0=; b=kdD+2APgzWur66T/Yw0JAUha2OIBdQGSWr5pcgqmIKcw9t0P0ExtxJ+wCGmYlifBWY jx4J02H6x5y7Jghzq1hjlLd3x+JlLb3u/xHIEvdFLXebvyF7FseT8Um/rfOTT8sRqkHS Kwn5kYLnvRsaaJvK8r60GbVBm4z23vlSxPpIWmtoTyoxwEUVg3LWqMUsG2Yi6iDLoOmG BEzbio/nlWqLK6FIxJogNbut2lE5Za4JjbwBPh5poTqO7XvQoIMgS1PV8gDVCvH69rhU ccmuPpHwqKxPNGqKrdl4oLgloCvbIqvr5bIuq/7NKCEFQ+QaUBDxXUj6ZrVzTpP227xS 4kDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=SWtn3j+X9Qv4/8jm3akSHIAKz6ptgqW0K3O3Ay77qY0=; b=eNnQ7Q45vMkKNtqlUNu0zj5Ht+EpAYFzB1p8Vz66h+aTPIWyRZJAJalKW2Z+DjNqpX q7MAoCsyuRHp39iXIB/5WKnpE3WjQArtsDUFcLNaCxDapq/6J8Dcp9c0ZtDaJCniEbLA jphyfpmbhEJ+VOUsTJi4/TkOapzT99LwiSnHNQjT1IYeu7x2yLXPs9bnxy4f9G8I1giK cAkGAuuFf4OyK7o1lh64iZmodfQKhSYuEpqROUoXJoXoBGznjM7mlym3UaXSLw7A1diJ QfdEawUVI6aadSwLQUCb9fhxDnXNANxHYjYBs8/FpAT7s4eLTwQsum3GOHaMU4UtYnJi /1Qw== X-Gm-Message-State: ACgBeo0gmYumVD0LKrh5TcbxMGfCawQnMa47R8NsXNet+qdVn6ecT9fT CDBao28OLG3H/a5W+uL5pQs= X-Google-Smtp-Source: AA6agR41XH/DfG2wtMg0P4XixHVW9m5d5cJuou6QXxyrDYjIbsET4TcIXXSM7OxtuZdeXgbZ6EA6Xg== X-Received: by 2002:a6b:610c:0:b0:688:820d:bd14 with SMTP id v12-20020a6b610c000000b00688820dbd14mr20274946iob.205.1662327750268; Sun, 04 Sep 2022 14:42:30 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:29 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 21/57] dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes Date: Sun, 4 Sep 2022 15:40:58 -0600 Message-Id: <20220904214134.408619-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Demonstrate use of DECLARE_DYNDBG_CLASSMAP macro, and expose them as sysfs-nodes for testing. For each of the 4 class-map-types: - declare a class-map of that type, - declare the enum corresponding to those class-names - share _base across 0..30 range - add a __pr_debug_cls() call for each class-name - declare 2 sysnodes for each class-map for 'p' flag, and future 'T' flag These declarations create the following sysfs parameter interface: :#> pwd /sys/module/test_dynamic_debug/parameters :#> ls T_disjoint_bits T_disjoint_names T_level_names T_level_num do_prints p_disjoint_bits p_disjoint_names p_level_names p_level_num NOTES: The local wrapper macro is an api candidate, but there are already too many parameters. OTOH, maybe related enum should be in there too, since it has _base inter-dependencies. The T_* params control the (future) T flag on the same class'd pr_debug callsites as their p* counterparts. Using them will fail, until the dyndbg-trace patches are added in. :#> echo 1 > T_disjoint [ 28.792489] dyndbg: disjoint: 0x1 > test_dynamic_debug.T_D2 [ 28.793848] dyndbg: query 0: "class D2_CORE +T" mod:* [ 28.795086] dyndbg: split into words: "class" "D2_CORE" "+T" [ 28.796467] dyndbg: op=3D'+' [ 28.797148] dyndbg: unknown flag 'T' [ 28.798021] dyndbg: flags parse failed [ 28.798947] dyndbg: processed 1 queries, with 0 matches, 1 errs [ 28.800378] dyndbg: bit_0: -22 matches on class: D2_CORE -> 0x1 [ 28.801959] dyndbg: test_dynamic_debug.T_D2: updated 0x0 -> 0x1 [ 28.803974] dyndbg: total matches: -22 Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 125 ++++++++++++++++++++++++++++++++++----- 1 file changed, 110 insertions(+), 15 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index ba3882ca3e48..8dd250ad022b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -10,57 +10,152 @@ =20 #include =20 -static void do_prints(void); /* device under test */ - -/* run tests by reading or writing sysfs node */ +/* run tests 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) { do_prints(); return 0; } - static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { do_prints(); return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); } - static const struct kernel_param_ops param_ops_do_prints =3D { .set =3D param_set_do_prints, .get =3D param_get_do_prints, }; - module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); =20 -static void do_alpha(void) +/* + * 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 { \ + .bits =3D &bits_##_model, \ + .flags =3D #_flags, \ + .map =3D &map_##_model, \ + }; \ + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_m= odel, 0600) + +/* numeric input, independent bits */ +enum cat_disjoint_bits { + D2_CORE =3D 0, + D2_DRIVER, + D2_KMS, + D2_PRIME, + D2_ATOMIC, + D2_VBL, + D2_STATE, + 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 11, MID, HI }; +DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, + "LOW", "MID", "HI"); +DD_SYS_WRAP(disjoint_names, p); +DD_SYS_WRAP(disjoint_names, T); + +/* numeric verbosity, V2 > V1 related */ +enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, + "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); +DD_SYS_WRAP(level_num, p); +DD_SYS_WRAP(level_num, T); + +/* symbolic verbosity */ +enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, + "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); +DD_SYS_WRAP(level_names, p); +DD_SYS_WRAP(level_names, T); + +/* stand-in for all pr_debug etc */ +#define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") + +static void do_cats(void) { - pr_debug("do alpha\n"); + pr_debug("doing categories\n"); + + prdbg(LOW); + prdbg(MID); + prdbg(HI); + + prdbg(D2_CORE); + prdbg(D2_DRIVER); + prdbg(D2_KMS); + prdbg(D2_PRIME); + prdbg(D2_ATOMIC); + prdbg(D2_VBL); + prdbg(D2_STATE); + prdbg(D2_LEASE); + prdbg(D2_DP); + prdbg(D2_DRMRES); } -static void do_beta(void) + +static void do_levels(void) { - pr_debug("do beta\n"); + pr_debug("doing levels\n"); + + prdbg(V1); + prdbg(V2); + prdbg(V3); + prdbg(V4); + 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) { - do_alpha(); - do_beta(); + do_cats(); + do_levels(); } =20 static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); - pr_debug("init done\n"); return 0; } =20 static void __exit test_dynamic_debug_exit(void) { - pr_debug("exiting\n"); + pr_debug("exited\n"); } =20 module_init(test_dynamic_debug_init); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 C184DECAAD5 for ; Sun, 4 Sep 2022 21:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235779AbiIDVnt (ORCPT ); Sun, 4 Sep 2022 17:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234977AbiIDVmh (ORCPT ); Sun, 4 Sep 2022 17:42:37 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D5B2F037 for ; Sun, 4 Sep 2022 14:42:31 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id d68so5629002iof.11 for ; Sun, 04 Sep 2022 14:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4JXdBl/0qOwV/A52QqNijcawUGjQl7evE5vQaPe8I/Q=; b=Q6wDNH7ni+pezhZQtqZpJ97lJZANkr1r1w8Q0HIYBSFAhwljRqOGh9Iv19Gf64+llB frZm5l9a2D6+RrKMDxtJrGMvuFtfct+nV7wpbjJBApGvgbR/UCdA+edFFEWQV3yW5xZt Abl341qIlvY+ti5hONgL6a+0BiJXwAUlG16pl8y98ByU4SwhFvt6k2mPawMY8CGIW+5o XyF4e1Ssr9Pgjhu7rCIp5wA50OjjlhqxJNYWrilP5bH59brlOnduXsjVgJiJlrcuk94w aC5b1ZZDeZyRlOAFIdmJz1af5ykZ0tqCvavdXbRILxmEHXgITfMxjOp5/9nTnIUykGr1 jaiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=4JXdBl/0qOwV/A52QqNijcawUGjQl7evE5vQaPe8I/Q=; b=JKLl1Ttk93FmbBC5wViZamc4njy6xzYC0tXdhJgtkeOfr3PX116dh7gkW5pZ8XNULg KjroQWX/4n81viFAx5vTOWlECbMsKSe6ImPKHC2PqEXihe7UVQJeUGISgvYp7EKfzqOr dKGf6M4MT2IoJKeYQd8yAiQ5T8+3uGxfNMTAm6IQgtcaAKVK6yUG3z/eehVypBzg6TnU aVioFvgGvbsnB2JvImRo5mQwUxHZv1OtWHZPb6BpVPK8epHco+4q3kB1y/lWFRCAHXHY USIQTHcALULUmaDhAMcX5RruohIw7elpfT8Vco9EIzFUQZY2iqKvGoRHKJLOsOyl3Qu2 mLgQ== X-Gm-Message-State: ACgBeo2dXiVgLkMUIazxzbZ2KicDLVSPov37XhYVlSLhSXJmm6DJ5xdH rh+EIA8rqs+wk6smLhVsRX84z4+kx1M= X-Google-Smtp-Source: AA6agR4RtFxm49IqbK2hc+ajeSg5bxr0q7Z7xZNKzxnPnzjA/QHoeK8+UuSlF8s2NBv4jPh+uCHATQ== X-Received: by 2002:a02:9a16:0:b0:350:636f:af9a with SMTP id b22-20020a029a16000000b00350636faf9amr4392137jal.191.1662327751171; Sun, 04 Sep 2022 14:42:31 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:30 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 22/57] drm_print: condense enum drm_debug_category Date: Sun, 4 Sep 2022 15:40:59 -0600 Message-Id: <20220904214134.408619-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" enum drm_debug_category has 10 categories, but is initialized with bitmasks which require 10 bits of underlying storage. By using natural enumeration, and moving the BIT(cat) into drm_debug_enabled(), the enum fits in 4 bits, allowing the category to be represented directly in pr_debug callsites, via the ddebug.class_id field. While this slightly pessimizes the bit-test in drm_debug_enabled(), using dyndbg with JUMP_LABEL will avoid the function entirely. NOTE: this change forecloses the possibility of doing: drm_dbg(DRM_UT_CORE|DRM_UT_KMS, "weird 2-cat experiment") but thats already strongly implied by the use of the enum itself; its not a normal enum if it can be 2 values simultaneously. Signed-off-by: Jim Cromie Reviewed-by: Daniel Vetter --- include/drm/drm_print.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..b3b470440e46 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -279,49 +279,49 @@ enum drm_debug_category { * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... */ - DRM_UT_CORE =3D 0x01, + DRM_UT_CORE, /** * @DRM_UT_DRIVER: Used in the vendor specific part of the driver: i915, * radeon, ... macro. */ - DRM_UT_DRIVER =3D 0x02, + DRM_UT_DRIVER, /** * @DRM_UT_KMS: Used in the modesetting code. */ - DRM_UT_KMS =3D 0x04, + DRM_UT_KMS, /** * @DRM_UT_PRIME: Used in the prime code. */ - DRM_UT_PRIME =3D 0x08, + DRM_UT_PRIME, /** * @DRM_UT_ATOMIC: Used in the atomic code. */ - DRM_UT_ATOMIC =3D 0x10, + DRM_UT_ATOMIC, /** * @DRM_UT_VBL: Used for verbose debug message in the vblank code. */ - DRM_UT_VBL =3D 0x20, + DRM_UT_VBL, /** * @DRM_UT_STATE: Used for verbose atomic state debugging. */ - DRM_UT_STATE =3D 0x40, + DRM_UT_STATE, /** * @DRM_UT_LEASE: Used in the lease code. */ - DRM_UT_LEASE =3D 0x80, + DRM_UT_LEASE, /** * @DRM_UT_DP: Used in the DP code. */ - DRM_UT_DP =3D 0x100, + DRM_UT_DP, /** * @DRM_UT_DRMRES: Used in the drm managed resources code. */ - DRM_UT_DRMRES =3D 0x200, + DRM_UT_DRMRES }; =20 static inline bool drm_debug_enabled(enum drm_debug_category category) { - return unlikely(__drm_debug & category); + return unlikely(__drm_debug & BIT(category)); } =20 /* --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 AFB0BC6FA82 for ; Sun, 4 Sep 2022 21:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235829AbiIDVoA (ORCPT ); Sun, 4 Sep 2022 17:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235160AbiIDVmm (ORCPT ); Sun, 4 Sep 2022 17:42:42 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784DA2C64D for ; Sun, 4 Sep 2022 14:42:33 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k9so701142ils.12 for ; Sun, 04 Sep 2022 14:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yb6CWV+TDDmM9onUuCxvFgBnmtmfnm46mq8t0HXB9jg=; b=lHCcfKuE75YvbApb3Q3ZrFKS/VLaGwoG8AzIOt7lRvkN6SBFDFxisWcCRiGMiVWTmH Kt63m7En4yLxNz7W7gTVWvhHgavhPV4rIN/E8gjWDoz36fXVQ8TufnV5YiPONZdg0wA9 PSC+3lVcstXByssTzg5qYKmlsp30bseonqBYHx7jAS4+G7wvrNp/c/1zAFFPf+Zb+I+C bM52a0v8IgrcQsDr4+T74tV0XI154yB2HOw02ZrUn321+0Geo88H4CTT7pj1lgDKjIx/ lz/D5+FWjXkDEy4M7lN8ydHYZ3SpeaGHxvF6OeZEhZdGSQrj5iVYVDwQgerulqIfnVFo NX1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Yb6CWV+TDDmM9onUuCxvFgBnmtmfnm46mq8t0HXB9jg=; b=bvO9hXo32eRk72xuUsux6jTJYNMsUJAJetkKBIHV91Ns5kU018zKkig/p03Pzew8oN MXUbh1IzITY/T2jRl12Jp/3N6zIbNbCshekUN4L0IRNU82Ko21DcRbfSZpr6hIifHhcx W9wUprLlZOv4xaODV+9qxYRqYsQUhTJeulPU/siNplYSfuKVKehTSN6Bmz0d4fmvGZz0 BOiHwmNSmoFM5QTj7VF7Vhg23ouEWOS1qI8pXhXRKr4Zr+vHDJgxs7edctu1L7/rKzX+ O4/H164V3OqJhy7qkWrFERo4U+HgcRx3dDj1VYhBQ00nMxLXfMpWPmN7hjH8vYYuuNL8 nRLQ== X-Gm-Message-State: ACgBeo0JEzuXbH0l/RmTAFuW2LHEZ5wwDIritTeyJWc0m5Axv5K4vj9R TpaF4CttN+vMiT2Qwr8mH+w= X-Google-Smtp-Source: AA6agR5Cx+ajN8UUSivj7N6vamViDhkJkE8U1oCqTJYgtKCcaD95EUgEYEoUpvP503z2jlMiKd37Xg== X-Received: by 2002:a92:6a0d:0:b0:2e5:afe7:8d95 with SMTP id f13-20020a926a0d000000b002e5afe78d95mr24687711ilc.262.1662327752155; Sun, 04 Sep 2022 14:42:32 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:31 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 23/57] drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers. Date: Sun, 4 Sep 2022 15:41:00 -0600 Message-Id: <20220904214134.408619-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Use DECLARE_DYNDBG_CLASSMAP across DRM: - in .c files, since macro defines/initializes a record - in drivers, $mod_{drv,drm,param}.c ie where param setup is done, since a classmap is param related - in drm/drm_print.c since existing __drm_debug param is defined there, and we ifdef it, and provide an elaborated alternative. - in drm_*_helper modules: dp/drm_dp - 1st item in makefile target drivers/gpu/drm/drm_crtc_helper.c - random pick iirc. Since these modules all use identical CLASSMAP declarations (ie: names and .class_id's) they will all respond together to "class DRM_UT_*" query-commands: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: This changes __drm_debug from int to ulong, so BIT() is usable on it. DRM's enum drm_debug_category values need to sync with the index of their respective class-names here. Then .class_id =3D=3D category, and dyndbg's class FOO mechanisms will enable drm_dbg(DRM_UT_KMS, ...). Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie a different NAME =3D> class_id mapping), changes are made according to each module's private class-map. No callsites are actually selected by this patch, since none are class'd yet. Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++ drivers/gpu/drm/display/drm_dp_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_crtc_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_print.c | 27 +++++++++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 12 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 13 ++++++++++++ include/drm/drm_print.h | 3 ++- 7 files changed, 92 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index de7144b06e93..97e184f44a52 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include =20 #include "amdgpu.h" #include "amdgpu_irq.h" @@ -185,6 +187,18 @@ int amdgpu_vcnfw_log; =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"); + struct amdgpu_mgpu_info mgpu_info =3D { .mutex =3D __MUTEX_INITIALIZER(mgpu_info.mutex), .delayed_reset_work =3D __DELAYED_WORK_INITIALIZER( diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/disp= lay/drm_dp_helper.c index 92990a3d577a..cbb9c4d6d8f2 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #include #include @@ -40,6 +41,18 @@ =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"); + struct dp_aux_backlight { struct backlight_device *base; struct drm_dp_aux *aux; diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_h= elper.c index 457448cc60f7..7d86020b5244 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -32,6 +32,7 @@ #include #include #include +#include =20 #include #include @@ -50,6 +51,18 @@ =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"); + /** * DOC: overview * diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..ec32df35a3e3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -40,7 +40,7 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned int __drm_debug; +unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); =20 MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a deb= ug category.\n" @@ -52,7 +52,30 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each= bit enables a debug cat "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -module_param_named(debug, __drm_debug, int, 0600); + +#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"); + +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); +#endif =20 void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915= _params.c index 6fc475a5db61..d1e4d528cb17 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -29,6 +29,18 @@ #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"); + #define i915_param_named(name, T, perm, desc) \ module_param_named(name, i915_modparams.name, T, perm); \ MODULE_PARM_DESC(name, desc) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouvea= u/nouveau_drm.c index 561309d447e0..fd99ec0f4257 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 #include #include @@ -70,6 +71,18 @@ #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"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b3b470440e46..668273e36c2c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -35,7 +35,7 @@ #include =20 /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; =20 /** * DOC: print @@ -275,6 +275,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 */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 8047CECAAD5 for ; Sun, 4 Sep 2022 21:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235434AbiIDVnx (ORCPT ); Sun, 4 Sep 2022 17:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235369AbiIDVmm (ORCPT ); Sun, 4 Sep 2022 17:42:42 -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 781B92C109 for ; Sun, 4 Sep 2022 14:42:33 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id y187so5723838iof.0 for ; Sun, 04 Sep 2022 14:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=AsutXgMDAJiXYIziQgoUHz04vuwS74Ufjn18RboeZlU=; b=Qw5u5kHlAuCdVRdp5boFr8w9l56DpQmLytG5X7x/gapi8SNDYyfHxGQ865EixG1rDF w+qm25s4Qx7V+r1LIT4Yojr69wswh53LgdFjuv5u8ss4N7Y3M6OvvXRH+gSQtLhrl51K 8MA7vqh1hp2ucRb7mbZmSegCHdgHh45ZtNYeJv2RuaJEfVrE7xjijSClBWTNNcJBAAfv QJ9VxUtPDKNoU59NHhpkj4z/UKL9NQ5pTTXZdMEXqLoRbGLT/+iXx3JIGAlyabOc3HOS z4XZEA/jjk7trB7VNHK/xQkhJcQcINVffpR5ej+XDbn5uk/XFMlCTA04L/CLoqDiCira /Okw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=AsutXgMDAJiXYIziQgoUHz04vuwS74Ufjn18RboeZlU=; b=wDJF0ECzoiTuIoeB+9r/Y+u7/aotJIkpBdxxbuEnjnxgmI9s4294lcHlMU68S2YlZC z2CAy86TS4sjEG4jMKxwI3qMlJR/BhCCgwA5I50pUVqmCmi4G6ZG/OJp5kIkyN3OTrt8 qW1wVDAN3FowBWIaYMQH0mzJXHnZD4u1zOQMky0CO7ZyXBvpcOXm12J+GTWu5HvimQHR 1FNilPjpqn9voSZbaLsowwn/CebuCrGd3j8jgSJ9Ft26Jj2oAQMKktMYwCMkvLc/y3N8 x9hVZ12FYLuAv97b/ptEgXf5/+dzcA5lGSsmbQU1rl/h8w06fG5Py1RG5UyFx0hzcCLh voFg== X-Gm-Message-State: ACgBeo0a0pvodLa1jUURPGps80tpprO8zsjF2GCGe4jSxloN7s6/Wg8Y Vp7W23wW7muP0Zunvq0ZjbY= X-Google-Smtp-Source: AA6agR4XUVL8R/sQ1zC2uzGX3CzIouq5JH8v/iId7txQSE5EgJyUlziUe0GD5gnf+dO0fl8HHWQm8g== X-Received: by 2002:a02:740b:0:b0:349:bcdd:ca20 with SMTP id o11-20020a02740b000000b00349bcddca20mr25953249jac.110.1662327753065; Sun, 04 Sep 2022 14:42:33 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:32 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 24/57] drm_print: interpose drm_*dbg with forwarding macros Date: Sun, 4 Sep 2022 15:41:01 -0600 Message-Id: <20220904214134.408619-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 drm_dev_dbg & drm_dbg to macros, which forward to the renamed functions (with __ prefix added). Those functions sit below the categorized layer of macros implementing the DRM debug.category API, and implement most of it. These are good places to insert dynamic-debug jump-label mechanics, which will allow DRM to avoid the runtime cost of drm_debug_enabled(). no functional changes. memory cost baseline: (unchanged) bash-5.1# drms_load [ 9.220389] dyndbg: 1 debug prints in module drm [ 9.224426] ACPI: bus type drm_connector registered [ 9.302192] dyndbg: 2 debug prints in module ttm [ 9.305033] dyndbg: 8 debug prints in module video [ 9.627563] dyndbg: 127 debug prints in module i915 [ 9.721505] AMD-Vi: AMD IOMMUv2 functionality not available on this syst= em - This is not a bug. [ 10.091345] dyndbg: 2196 debug prints in module amdgpu [ 10.106589] [drm] amdgpu kernel modesetting enabled. [ 10.107270] amdgpu: CRAT table not found [ 10.107926] amdgpu: Virtual CRAT table created for CPU [ 10.108398] amdgpu: Topology: Add CPU node [ 10.168507] dyndbg: 3 debug prints in module wmi [ 10.329587] dyndbg: 3 debug prints in module nouveau Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 10 +++++----- include/drm/drm_print.h | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec32df35a3e3..29a29949ad0b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -279,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const cha= r *level, } EXPORT_SYMBOL(drm_dev_printk); =20 -void drm_dev_dbg(const struct device *dev, enum drm_debug_category categor= y, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, + const char *format, ...) { struct va_format vaf; va_list args; @@ -301,9 +301,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_deb= ug_category category, =20 va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); =20 -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -320,7 +320,7 @@ void __drm_dbg(enum drm_debug_category category, const = char *format, ...) =20 va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); =20 void __drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 668273e36c2c..c429c258c957 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -335,7 +335,7 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category categor= y, +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, const char *format, ...); =20 /** @@ -384,6 +384,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_deb= ug_category category, } \ }) =20 +#define drm_dev_dbg(dev, cat, fmt, ...) \ + __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -485,10 +488,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, */ =20 __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 +#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) + /* Macros to make printk easier */ =20 #define _DRM_PRINTK(once, level, fmt, ...) \ --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 51765C6FA82 for ; Sun, 4 Sep 2022 21:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235455AbiIDVoG (ORCPT ); Sun, 4 Sep 2022 17:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235391AbiIDVmm (ORCPT ); Sun, 4 Sep 2022 17:42:42 -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 AA53E2EF3D for ; Sun, 4 Sep 2022 14:42:34 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id h14so3863798ilh.10 for ; Sun, 04 Sep 2022 14:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=U1e/PDiTaqhNlqhWklmksFO85pXyEBvT7LYXXx9lRsc=; b=Dx9MBKpykNOjC760F4pFLwFUkOoBmF/4z7wBX2mc5AIweU/3t3yi4wF+532OcszVdM fJS+kbBgoRInPWQA6RJ24UEiO6RyYqvxzwnizY/OXlGjDTiAte5Jy7Wgkyh+ej2dw7mp 8ah+0F5F3ut30swO8Jl6e2dH2RtgR7VodKDNux7pE967WR0SeE/u428cUqvwN8xe2OmV ay3wjVmLVzY5WIqtJ/VBzchbZ+9NV5ny/h5+U6aR4pyOmNjuCxZNrwhA78HFQY997wef fNMxXUBdIylIsoA4g3Yk7C70N55L4Qb/lJbN8V6hoNbx4nWhOh8w8GsOeIFiw0QPvj7b zvqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=U1e/PDiTaqhNlqhWklmksFO85pXyEBvT7LYXXx9lRsc=; b=jH9+mCTUGsMZfAUxjRm/YJjf7bc0Y/Wx4+wrfUXkIY5c/y13RiidDuXGqIGZ0eFiny YrR/B9o8EJkbSWtM9QqqpEwcQMNrtktPvKzXyk35BifAS2W7J46ZCBW4g73uCCa7ts1F Ax63L+cjZ8gQxoeLamuAdju8fS4r24yOC7UOsluJv2VNUKp7FgxCNLHQ0InNTtVTNAfU k9amANyTCslHBZaRnHS2cpj4WfkzOJ3xQLBpwhPaWyJwjaFgiSuwPKDjZVkzHO66o7XO /iHToZcv0if8svYMKJkMBw5mKska2oEuhUNFPKDB7ykKWF2QK+YItvUrBODi3uJ6jg5I Q+SQ== X-Gm-Message-State: ACgBeo2bde3ttm1ngRnGURmnkg/4HzQJE2WpzMwSXsCpQKt+AIkQA10x pdV7Bci7m9M89kKVtkqD2tE= X-Google-Smtp-Source: AA6agR4QIlOxxpmNgt7Mmv0IK9vaV2J3UNUt+wMqkJN9PXiw35wmcxQf7MVn0gpUR78DsbgyvTivGg== X-Received: by 2002:a05:6e02:1d07:b0:2eb:1792:5468 with SMTP id i7-20020a056e021d0700b002eb17925468mr15883450ila.60.1662327753969; Sun, 04 Sep 2022 14:42:33 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:33 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 25/57] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Date: Sun, 4 Sep 2022 15:41:02 -0600 Message-Id: <20220904214134.408619-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" For CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, wrap __drm_dbg() & __drm_dev_dbg() in one of dyndbg's Factory macros: _dynamic_func_call_no_desc(). This adds the callsite descriptor into the code, and an entry for each into /proc/dynamic_debug/control. #> echo class DRM_UT_ATOMIC +p > /proc/dynamic_debug/control CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy/n is configurable because of the .data footprint cost of per-callsite control; 56 bytes/site * ~2k for i915, ~4k callsites for amdgpu. This is large enough that a kernel builder might not want it. Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 12 ++++++++++++ drivers/gpu/drm/Makefile | 2 ++ include/drm/drm_print.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 2f52e8941074..3b75c286f14f 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -51,6 +51,18 @@ config DRM_DEBUG_MM =20 If in doubt, say "N". =20 +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default y + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + Use dynamic-debug to avoid drm_debug_enabled() runtime overheads. + Due to callsite counts in DRM drivers (~4k in amdgpu) and 56 + bytes per callsite, the .data costs can be substantial, and + are therefore configurable. + config DRM_KUNIT_TEST tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS depends on DRM && KUNIT diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 25d0ba310509..0b283e46f28b 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -3,6 +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 + drm-y :=3D drm_aperture.o drm_auth.o drm_cache.o \ drm_file.o drm_gem.o drm_ioctl.o \ drm_drv.o \ diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index c429c258c957..2d2cef76b5c1 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -384,8 +384,14 @@ void __drm_dev_dbg(const struct device *dev, enum drm_= debug_category category, } \ }) =20 +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, cat, fmt, ...) \ __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) +#else +#define drm_dev_dbg(dev, cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) +#endif =20 /** * DRM_DEV_DEBUG() - Debug output for generic drm code @@ -492,7 +498,13 @@ void ___drm_dbg(enum drm_debug_category category, cons= t char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#else +#define __drm_dbg(cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) +#endif =20 /* Macros to make printk easier */ =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 79598ECAAD5 for ; Sun, 4 Sep 2022 21:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235473AbiIDVoK (ORCPT ); Sun, 4 Sep 2022 17:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234928AbiIDVmx (ORCPT ); Sun, 4 Sep 2022 17:42:53 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A8842F390 for ; Sun, 4 Sep 2022 14:42:35 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id 62so5674077iov.5 for ; Sun, 04 Sep 2022 14:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6ZAp0SLSNepdkM6caeO4skWDicbHMA8OFY8bo87a1Nc=; b=DfX4/ghpRrLMvEAxpwWwPbtD5a1dkzxKOUPp2TD6F2q29vGGj/18IHkmJJpqNGED84 ReA0JJE5AA9AlXq8pGzPQjVUBQcsMR8EpnSbOuKD6tojGRRoX3dI2Ud0v22DsMUX8opI d3JQlwkymuNoAqrccLE9gDUMCmRsZkunqKR2XFWr2KptUsf2TiLlIieQnWztzPo6ZUgh MiQCOt2dHNm9l4z5HrlM5ImqTPv0SubrVLnrEYTh/r1aKOa0fhVY5VE/iog4DwbkB60l BBQjI90yzoxv+hYSTdUZRg31WO5JZtO0Ko4fDN3r4WVdZF42swnnS3An562cNwwtMv5i lx7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=6ZAp0SLSNepdkM6caeO4skWDicbHMA8OFY8bo87a1Nc=; b=yHLlq2bJlJRT4/6dCCrLLNJxJmasdwZqMO8j4KeawthUcZx2TMQLZ6yA2p/KAuDyQq +L3UpR+sIjgMbaVRqIkCj0b6Q7ze70qsuaO8FdUYGiwx+gDUr6qw3LGVuiBFAR9aSgyJ suEH+D4Vg5XzKjYNok+EBKhp77R6Bd91RvFvdZeY7WJ91K5AaBXLMFErhR/05+yGpv2P 9qKy+iKG80dN81T3/IAsGybVz5I8oY7JPvYz1LYXmBjeKchwiZ+0Nx+rZa9guCrHYK9+ G/5c2wBwi6hO5lUKSXSGpmIkMRr3sHriIjX5QvSnW2DbQVwEdHaE6IYm5n6oakgH0Myl gWOA== X-Gm-Message-State: ACgBeo2PJQuN1kNCWoAiMfKOlwTrcd9C3aExbVOBuKizDEMNElbFhuIJ ac1xDPRU1x1+FFjOtJEJBSA= X-Google-Smtp-Source: AA6agR7xT5UcbaaPMupHq74aD54OF9ftmAPlIhpkXGE6kw4lTSCQlvdL0+PZQyRTjzyip0WI8xfCIg== X-Received: by 2002:a02:3f20:0:b0:342:c96d:2f8 with SMTP id d32-20020a023f20000000b00342c96d02f8mr25501456jaa.74.1662327754895; Sun, 04 Sep 2022 14:42:34 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:34 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 26/57] drm-print.h: include dyndbg header Date: Sun, 4 Sep 2022 15:41:03 -0600 Message-Id: <20220904214134.408619-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" lkp robot told me: >> drivers/gpu/drm/drm_ioc32.c:989:2: error: call to undeclared function '_dynamic_func_call_cls'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] DRM_DEBUG("comm=3D\"%s\", pid=3D%d, dev=3D0x%lx, auth=3D%d, %s\n= ", Since that macro is defined in drm_print.h, and under DRM_USE_DYN*=3Dy configs, invokes dyndbg-factory macros, include dynamic_debug.h from there too, so that those configs have the definitions of all the macros in the callchain. This is done as a separate patch mostly to see how lkp sorts it. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 2d2cef76b5c1..f8bb3e7158c6 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include =20 #include =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 CFD74C6FA82 for ; Sun, 4 Sep 2022 21:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235884AbiIDVoO (ORCPT ); Sun, 4 Sep 2022 17:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235468AbiIDVmy (ORCPT ); Sun, 4 Sep 2022 17:42:54 -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 C73712F39F for ; Sun, 4 Sep 2022 14:42:36 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id 10so5685341iou.2 for ; Sun, 04 Sep 2022 14:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=JJmkd9QkaZyaFdemWU+lkrR5661ckSN9S5LOBM0abWI=; b=Ekp5LSqCs4NIcDItFljM2WjOwt/efnWVaMW3yCqrqsUihOs5E0jY1gRnas7XeEnwXQ mJczoHE301+UhR2sdrk2Z8XMrus7OmPoIHzPLx9pOfthkP14wtWEMeSmcVDFGWB/CtdJ QoGwdbXBIatuJbFnjhsoLD7HBBwTwthzbbd/ephKZj4F869SAIYstaCw9X5XldSmfsj5 425BY3FM/yceTIl0QRHpBbqSrZ3pLSgxz0QvSfOSxR2x3onovMe0LjQXpUS5rZwJQTDD f0EEtc2lmFOrlMPRrbL5XtYdvoUv6FfCFWPMR8AZBn6i4YQ82dbzn0YVDauHfrda6dbp qmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=JJmkd9QkaZyaFdemWU+lkrR5661ckSN9S5LOBM0abWI=; b=J2/J1OOgY9+exRKjbn14/m23WCAjYtMr6FhYtcoIEcjdeSXrHSM6lW5qENVDHruufp 9MrriCCiNrRJYBKiUjeN5maRavpHRN5MIGgLO6XYOgMHYmEXOgd1qpxSEhyqn1iKXpcK r7JOwj6Y5A8+hNFjfeiTOWkAkv5pUSVbjt781g5eQLfPPAFnXBhy+LGf6vsHhg5227ul 9RAGpmyFokn7fD6Sv+cdamdMuf8xSEkuyqdpCHD0zeu+fgtLzv3vN++os18eOp6B0ocd Ia4E5i4TP7j6l9lGF/efr4RAIQNJtjlZx44ssGipmywvwKF5/fuNjAfV2fYJj2rUF+Sy qDxw== X-Gm-Message-State: ACgBeo1bvhg5bR27zoirYiJETgL7G8juFd2F9y975knMJgR4Xeppn11T +A6by7TQEG02U+x20wjUd54= X-Google-Smtp-Source: AA6agR6Y58eeN88K8D4OKhkCxT/e0VQuWiJ6m00+40bBTPAFdN9SV1gHrr39O9uhC7t16UdJ5cZYpQ== X-Received: by 2002:a05:6638:224:b0:350:6e7b:8e59 with SMTP id f4-20020a056638022400b003506e7b8e59mr4269174jaq.237.1662327755824; Sun, 04 Sep 2022 14:42:35 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:35 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 27/57] drm-print: add drm_dbg_driver to improve namespace symmetry Date: Sun, 4 Sep 2022 15:41:04 -0600 Message-Id: <20220904214134.408619-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" drm_print defines all of these: drm_dbg_{core,kms,prime,atomic,vbl,lease,_dp,_drmres} but not drm_dbg_driver itself, since it was the original drm_dbg. To improve namespace symmetry, change the drm_dbg defn to drm_dbg_driver, and redef grandfathered name to symmetric one. This will help with nouveau, which uses its own stack of macros to construct calls to dev_info, dev_dbg, etc, for which adaptation means drm_dbg_##driver constructs. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index f8bb3e7158c6..dfdd81c3287c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -468,7 +468,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, =20 #define drm_dbg_core(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) -#define drm_dbg(drm, fmt, ...) \ +#define drm_dbg_driver(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) @@ -487,6 +487,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) =20 +#define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__) =20 /* * printk based logging --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 9071EECAAD5 for ; Sun, 4 Sep 2022 21:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbiIDVoX (ORCPT ); Sun, 4 Sep 2022 17:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbiIDVnY (ORCPT ); Sun, 4 Sep 2022 17:43:24 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B382F3B8 for ; Sun, 4 Sep 2022 14:42:38 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k2so3867811ilu.9 for ; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=wrWdD5DCeuwxIKmi8edwooIcWywqt3OjpL8zqDahPx8JbsVW9NE6o54pZNBz375bvW UOeQ9pMC3GvOkyXHSHc6XnrhcPD1AqXd+eONzfXyPH3oluJItvjBh5PoBXTHV3slO8O0 nWUQW3w/nx+pF7dhWWr7nHhpaOc3Tc5luANf8KAq3jLnMr5rO3FrR/tE0k0gT+GphOHI NiONNrfcvo0RcNqdk/UL/+RGPnqqG+N4Xy3SOAZ/7rCXTOc3WxJK3kMesv31u1KTMsUG qSaVOj0DePbh/B6f7o2V76koDWvI0CoI9lPABCtfbDShGwR2LOfDEWkTrtEd5vIZs530 Fdwg== X-Gm-Message-State: ACgBeo0f7DPyUuXftzdLJXOms4AwPerT2SWMn1DxGIW0XX7etICLcSbM t4ydKY3LtGQxh+lW0YhEVrQ= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, struct va_format vaf; va_list args; =20 - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; =20 va_start(args, format); @@ -308,7 +308,7 @@ void ___drm_dbg(enum drm_debug_category category, const= char *format, ...) struct va_format vaf; va_list args; =20 - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; =20 va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; =20 +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-ci= rcuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } =20 +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 7D353C6FA82 for ; Sun, 4 Sep 2022 21:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235703AbiIDVod (ORCPT ); Sun, 4 Sep 2022 17:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbiIDVnY (ORCPT ); Sun, 4 Sep 2022 17:43:24 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 340032F001 for ; Sun, 4 Sep 2022 14:42:39 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id b142so5642337iof.10 for ; Sun, 04 Sep 2022 14:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0Id8r2vYLmajWhF+0Lsomg5sSzhIk/Fv798x/2NCQJ8=; b=nMgcsqv10t0jNSou/ChM9aj4Oe2Z78Qyt3lMIFBuZ+lquITOKuL5RF792lnxd7UxJ8 qpp+DhMKR6rD8Oc8zSCbZeoe0h9QjbpOO0YVftf9vHqXoRe8XPNetD5weW3YMiDh/hpz X9RMWx9bzPZKcOgMLConc2T+c/6pPJAtaa/JQl2Ee4JRD9rij46vnjQIlGRlSmKUKYKq Bepfrnuvr4KbA0CMM4R2ttIK4x2CvNrggANC7Rg2YtNXHsSx94pjtZ8bFBhm7X0MlxoT SxodpVFGmtdB1b6dU/Q2eNKDiZA6RGYLKeiZvHON/fhARPCby/xRuXS2G7hj7UBtB+21 GNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=0Id8r2vYLmajWhF+0Lsomg5sSzhIk/Fv798x/2NCQJ8=; b=kfRBwJz69bXA752Qnbe+2pygErWyZPTC43NfnHWyRVf/X0xLVeftWnNBftg0MTsM24 HD3pZc/kOlyHkUGPwt/IMFnUN/HrnTvJyLnM3grruMlqP6BwjAx5MEf1UYNpR/hEKsCv EtcnWeFKwBXYfA1MTwHP+hgrbtdBXuFyrqwFRDEvnhftOtKNW5+hnUbbewnlNDUAZTel e/goO//sTFz1z3Ix28ddsEYXabj10hQg3DkPcpD97Zum1cyckg3n+6lrZgpVcqgqPx6d AlmLnJYn0SZ9uMJp8YlF9sR1OMdK6Yu/Qd1TQPnnfvmKbnyf1Q5RZYN/dbreKZ0ZSa+7 v0fw== X-Gm-Message-State: ACgBeo1TkrEZhjnHo1HoGmTsSZsA90PHNsBoVSxI5IEbVF/vGBeXQkF3 RNess6sds3k3AzQoJAP3+0o= X-Google-Smtp-Source: AA6agR6b4AaEEfOSIKL24Lu0tIv0q3qOCsBl00MyhLWPv9u8tITL7jjngdAbr9/9HEHOPy1kJLcPuw== X-Received: by 2002:a02:cc76:0:b0:34c:13cf:efc9 with SMTP id j22-20020a02cc76000000b0034c13cfefc9mr10073340jaq.152.1662327757907; Sun, 04 Sep 2022 14:42:37 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:37 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 29/57] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Sun, 4 Sep 2022 15:41:06 -0600 Message-Id: <20220904214134.408619-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" drm_print.c calls pr_debug() just once, from __drm_printfn_debug(), which is a generic/service fn. The callsite is compile-time enabled by DEBUG in both DYNAMIC_DEBUG=3Dy/n builds. For dyndbg builds, reverting this callsite back to bare printk is correcting a few anti-features: 1- callsite is generic, serves multiple drm users. it is soft-wired on currently by #define DEBUG could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading here, they describe only the generic site, not end users IOW, 1,2 are unhelpful at best, and possibly confusing. reverting yields a nominal data and text shrink: text data bss dec hex filename 462583 36604 54592 553779 87333 /kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 -dirty/kernel/drivers/gpu/drm/drm.ko Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cb203d63b286..ec477c44a784 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -23,8 +23,6 @@ * Rob Clark */ =20 -#define DEBUG /* for pr_debug() */ - #include =20 #include @@ -185,7 +183,8 @@ EXPORT_SYMBOL(__drm_printfn_info); =20 void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) { - pr_debug("%s %pV", p->prefix, vaf); + /* pr_debug callsite decorations are unhelpful here */ + printk(KERN_DEBUG "%s %pV", p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_debug); =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 81830ECAAD5 for ; Sun, 4 Sep 2022 21:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbiIDVoi (ORCPT ); Sun, 4 Sep 2022 17:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235658AbiIDVnc (ORCPT ); Sun, 4 Sep 2022 17:43:32 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD302F64D for ; Sun, 4 Sep 2022 14:42:40 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id r141so5678569iod.4 for ; Sun, 04 Sep 2022 14:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tmR8ChrylisxKKWzjN/Li/odfvtNSLNzyjwd4uQokF0=; b=YA6JGiqu4qnXHVqjxeqktp9+r4L0ElOdnkT68N+xlzo9ovLmKCzEp0/6pi8K8SxiDU KwjNYzCmK6I94RrfiBdEEofeg4VWstkfQy+pNcJcE38TAL+pwdl46PNNCBJq9ZaPrn+M 33ZbFTernPGN1s7PslLH1V5BQcLd2PMYBAL+EoFjllsHeR8xFZK5WLR46dTOAwP0TnT8 bt/FsSKVUbEDbMrLCkfwGdCNAWH8Ln1DNUBpcBawBvltIsAyilsUMDBqwiHRMVwbxjna NuT9XG9QpeIHCXfM3q7C9UUlbZKFIiyTINWnv7+ybnDtbVtD6WNa+Zzsrjxap3WT1/h0 5ZDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=tmR8ChrylisxKKWzjN/Li/odfvtNSLNzyjwd4uQokF0=; b=r0TlPGCJC68KQHIsrf2h+6MkEfkmOfvXQDF21/1Gqufv6G4w1vHE9yOozEawagWheK /R3vNbeigdncD+jp0ZD0N1jnBb8gj2GvNda9POwnnRzajYTDBAdbuJNL4mNLVzlkkT26 eec8LDMnRVGcrG/yuDsqkZS3u2c7i8OAjm3bm85fovmdpRG1Y8+b2M2inLx2g8t9s6MZ R2nybLU7QZXHKLFGe7tD7+WEjWe4n0kjuYY9Uwf82q3C+JdpGncax5pZFOi/nAWbOnVC tib21jgGDrpkjkOKQ0YIaUkkyWrgUhzRY7EhFeD+gBf9oRG9W+BIj6W5+3C9lhQYNBsr mV1w== X-Gm-Message-State: ACgBeo0fG4rY/71j+tMdjJOr9+KhMXg5tj9ZTbsggwmlPiulEuoRTFX5 bj7QCh84X4LZoKkJNzbwL6I= X-Google-Smtp-Source: AA6agR67W0JwMKVjGZ0XAZCtblPF2QCqY+yVd4ipB10+ywZ/x6+YYkZcz6CmYFni52Q8uttRgXx7og== X-Received: by 2002:a05:6638:488a:b0:342:6d75:dfa6 with SMTP id ct10-20020a056638488a00b003426d75dfa6mr23007148jab.319.1662327758805; Sun, 04 Sep 2022 14:42:38 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:38 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 30/57] drm_print: add _ddebug descriptor to drm_*dbg prototypes Date: Sun, 4 Sep 2022 15:41:07 -0600 Message-Id: <20220904214134.408619-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" upgrade the callchain to drm_dbg() and drm_dev_dbg(); add a struct _ddebug ptr parameter to them, and supply that additional param by replacing the '_no_desc' flavor of dyndbg Factory macro currently used with the flavor that supplies the descriptor. NOTES: The descriptor gives these fns access to the decorator flags, but does none of the dynamic-prefixing done by __dynamic_emit_prefix(). DRM already has conventions for logging/messaging; just tossing optional decorations on top may not help. Instead, existing flags (or new ones) can be used to make current conventions optional. For CONFIG_DRM_USE_DYNAMIC_DEBUG=3DN, just pass null. Note: desc->class_id is redundant with category parameter, but its availability is dependent on desc. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 8 +++++--- include/drm/drm_print.h | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec477c44a784..5b93c11895bb 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include #include @@ -278,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const cha= r *level, } EXPORT_SYMBOL(drm_dev_printk); =20 -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, - const char *format, ...) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -287,6 +288,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, if (!__drm_debug_enabled(category)) return; =20 + /* we know we are printing for either syslog, tracefs, or both */ va_start(args, format); vaf.fmt =3D format; vaf.va =3D &args; @@ -302,7 +304,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, } EXPORT_SYMBOL(__drm_dev_dbg); =20 -void ___drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, co= nst char *format, ...) { struct va_format vaf; va_list args; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 7631b5fb669e..46f14cfb401e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -363,9 +363,10 @@ static inline bool drm_debug_enabled(enum drm_debug_ca= tegory category) __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); -__printf(3, 4) -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, - const char *format, ...); +struct _ddebug; +__printf(4, 5) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...); =20 /** * DRM_DEV_ERROR() - Error output. @@ -415,11 +416,11 @@ void __drm_dev_dbg(const struct device *dev, enum drm= _debug_category category, =20 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, cat, fmt, ...) \ - __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__) #else #define drm_dev_dbg(dev, cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ - dev, cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) #endif =20 /** @@ -523,17 +524,17 @@ void __drm_dev_dbg(const struct device *dev, enum drm= _debug_category category, * Prefer drm_device based logging over device or prink based logging. */ =20 -__printf(2, 3) -void ___drm_dbg(enum drm_debug_category category, const char *format, ...); +__printf(3, 4) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, co= nst char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) #else #define __drm_dbg(cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ - cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) #endif =20 /* Macros to make printk easier */ --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 E37C3C6FA89 for ; Sun, 4 Sep 2022 21:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235964AbiIDVot (ORCPT ); Sun, 4 Sep 2022 17:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235680AbiIDVnc (ORCPT ); Sun, 4 Sep 2022 17:43:32 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F271E2F657 for ; Sun, 4 Sep 2022 14:42:40 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id m16so861459ilg.3 for ; Sun, 04 Sep 2022 14:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LAElKATTm6r2TIe9HchZuJ0iTvp0tkidaAAlkqZf57g=; b=ioFXEtAboLLUIN/kNyc61L0HOu8/6UCEVPrRpVK/iZqDkjSxhy1lokEax7skm4mwOF mCdRRCoU7224D2s+eeI9bmOsLLpeqbAXpSoc5ewN3Vnu4++5Y8MjvC45CARQ2eSUmtPM vq67RMmjwELCYQ5rsDgJHAwkUX47ytKixYLVLxiRln+UZzGGvAk+2JB+Sw0belDPO48F qDmzIHF6L9eAsm4bEnMCzLrXaEJmVUloL5mpLRJ14V94PQCg5aoimHZKHASnmIAq31fh i6l/G06rgbvOyZ/eJK8nqcrZ4A1qC4+YiBem4FdzmsbXjDz5e2YWLpntsHdBPAZvrPbS m72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=LAElKATTm6r2TIe9HchZuJ0iTvp0tkidaAAlkqZf57g=; b=P67HNdUyjaExBdl5MMlXDQHlR+pscy+wDpQ1XINCVFWHnD2ddLyzxe3gy+7aIem8kN BrHmaYicd3KCWyhfUWZoHHdpHVX2FsxgU6EMm1hjhkUBfsDTlhgMj9P71HqF2jQ8xuAX RXHeIknFDxErJodXde5D/1NuISCtyOawD9jlH7iK7lFvvTZCTmymVV3CaICXlUrzlRWP mUygIK9bruChj4OIeZ32jMX/KMY3rgTCnVdkt+3S9ukVEQje8fD4YPLkJOWjSsXlfPev myz//cBUXUFmOlm3JMn7R24uLkg+ZAGV8r0W+tAkKzrcpAI/0tc/Bz65cRCjpihap7EV IyRg== X-Gm-Message-State: ACgBeo28teYZ9mF7d85s+/KOmkwfDZ3hJ9o0cbosxxlYhGPOs0xbtNEe F+QR78igXYKf09/hXZLkLNc= X-Google-Smtp-Source: AA6agR4JZnvP+IfSOvpE/ZnPHvuTyE3m/D+cXn8a4t+7sZ/c+tnbIR9Wi8DqdENHAxq6VZVKf3h3Ew== X-Received: by 2002:a05:6e02:20c1:b0:2e9:f747:ad54 with SMTP id 1-20020a056e0220c100b002e9f747ad54mr25614470ilq.144.1662327759838; Sun, 04 Sep 2022 14:42:39 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:39 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 31/57] nouveau: change nvkm_debug/trace to use dev_dbg POC Date: Sun, 4 Sep 2022 15:41:08 -0600 Message-Id: <20220904214134.408619-32-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" These 2 macros formerly used dev_info, and they still check subdev->debug to gate the printing. So dyndbg control is redundant ATM (and possibly confusing, since its off by default). prdbg count is up from 3, or from 65 (with VMM_DEBUG here) [ 7.765379] dyndbg: 516 debug prints in module nouveau Its possible to control error, warn, info callsites too, but they're usually on, and the .data overheads on ~450 more callsites (56 bytes each) would just be wasted. $ for l in fatal error warn info debug trace spam; do echo $l; ack nvkm_$l drivers/gpu |wc; done fatal 3 19 335 error 289 1956 30651 warn 84 513 8860 info 14 88 1502 debug 387 2339 40844 trace 31 219 3368 spam 1 7 123 bash-5.1# echo $(( 516-65-387-31-1 )) 32 Thats approximate; not accounting #defines and doc/comment mentions. NOTE: this patch changes the log-level of the macro-issued messages from KERN_INFO to KERN_DEBUG. Adding a .kern_lvl field to struct _ddebug could fix that. RFC: dyndbg & subdev->debug Separate class-maps for each subdev are possible; except for the coordinated use of _base, each is independent, including choice of DISJOINT or LEVELS, as long as class-names don't conflict. So theres some flexibility. Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/g= pu/drm/nouveau/include/nvkm/core/subdev.h index 96113c8bee8c..065d07ccea87 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -59,8 +59,8 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a) +#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) #define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) =20 #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratel= imited, f, ##a) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 F165EECAAD5 for ; Sun, 4 Sep 2022 21:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235728AbiIDVoo (ORCPT ); Sun, 4 Sep 2022 17:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235679AbiIDVnc (ORCPT ); Sun, 4 Sep 2022 17:43:32 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 607BC2F3A7 for ; Sun, 4 Sep 2022 14:42:41 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id c4so5673419iof.3 for ; Sun, 04 Sep 2022 14:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8gwyhoydIHSfwTTFYi0xd/UEVRo5zT1WMZJS4KZ9ukE=; b=Oj7Ixl6oj9kg3JhT5hX2YNpqFWBWrRAemLR9ZyRiH8YKxlEL1JbyYUePKaIrZAL5jf 1WolreEcW4UQ85oE8rIFcQKM9Y8DgXov3VdkOuxIChkt3b8QQ86vavL7yfZdfnG1GXrG DieSrzFFZkksP5SG7xHoU2NUtwtLwxXiHtZdjYdGp0A0SfFIYvtv5K3SHQproh7ZaK9g fFJF5WVYv4z4A9NBf1N+h/WwX6chGYIEj2Ni0q0zS2lPBsAWNrYRKNiDRgERv8ZCLA+5 CocXeZEZ1Rn3EM+S6VnFtLemc62uByDMdXXT71Ilig4RAz83otTF0UG6qgEF5wkzDQpI 548g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=8gwyhoydIHSfwTTFYi0xd/UEVRo5zT1WMZJS4KZ9ukE=; b=5AKnx3tJwf+5Cr/5s8yg1wyq4FoZEqblv1raDWhp5S0i+mW1/KMzUAmq14xFclkbzr 956d5G/EJer3cKssjy6Cen32ePDr5DjzWQP+bygvCcqorjj+uMUzqfO0ZJ2G+CdHf0o/ llX5DRj+4EmyCKlKI+xM8EPHYCPdlheoZRtRoGvPh6N8fkrE4tnKkNXSTLzc4xqc9hkE MhniZYgz9v4V15ovrcNlLw5MIkDrr3pKM3BKqPc2Xcgl1pL5KPhEmYDfiD9v+BtysL1v XupMHEPO4vo7qFXciXoSS3+jcqeTwA6imd+IK1cmXvpPqPIUGTyoo7RbOndV1YiXptFA qG+Q== X-Gm-Message-State: ACgBeo0DngHIfu5/4E/2nsx1nw6mu2cQezj3W1XkPdZa/6bt3bNk3uqd /UujTYmImLSFaaGOr5dA0dU= X-Google-Smtp-Source: AA6agR7YcRBN9eLsdX3bzp79/kQqCn5Cue7Lw5y+W0FC6PDyqlsmvwF4ziOCRLDCU+BO8di3xE1W6A== X-Received: by 2002:a05:6638:d06:b0:350:a613:f7ec with SMTP id q6-20020a0566380d0600b00350a613f7ecmr3859829jaj.169.1662327760724; Sun, 04 Sep 2022 14:42:40 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:40 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug Date: Sun, 4 Sep 2022 15:41:09 -0600 Message-Id: <20220904214134.408619-33-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC} respectively, replace those with drm_dbg_##cat invocations. this results in new class'd prdbg callsites: :#> grep nouveau /proc/dynamic_debug/control | grep class | wc 116 1130 15584 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc 74 704 9709 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc 31 307 4237 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc 11 119 1638 the KMS entries are due to existing uses of drm_dbg_kms(). Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/nouveau_drv.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouvea= u/nouveau_drv.h index 84df5ddae4d0..3b8a76004b57 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -39,6 +39,7 @@ */ =20 #include +#include =20 #include #include @@ -263,13 +264,16 @@ void nouveau_drm_device_remove(struct drm_device *dev= ); #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a) #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a) =20 -#define NV_DEBUG(drm,f,a...) do { = \ - if (drm_debug_enabled(DRM_UT_DRIVER)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ +#define NV_DRMDBG(cat,c,f,a...) do { \ + struct nouveau_cli *_cli =3D (c); \ + drm_dbg_##cat(_cli->drm->dev, "%s: "f, _cli->name, ##a); \ } while(0) -#define NV_ATOMIC(drm,f,a...) do { = \ - if (drm_debug_enabled(DRM_UT_ATOMIC)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ + +#define NV_DEBUG(drm,f,a...) do { \ + NV_DRMDBG(driver, &(drm)->client, f, ##a); \ +} while(0) +#define NV_ATOMIC(drm,f,a...) do { \ + NV_DRMDBG(atomic, &(drm)->client, f, ##a); \ } while(0) =20 #define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 07CC6C6FA82 for ; Sun, 4 Sep 2022 21:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236000AbiIDVpA (ORCPT ); Sun, 4 Sep 2022 17:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235751AbiIDVni (ORCPT ); Sun, 4 Sep 2022 17:43:38 -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 283242C643 for ; Sun, 4 Sep 2022 14:42:42 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id h14so3863870ilh.10 for ; Sun, 04 Sep 2022 14:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jC4v9G/jhIkV0IQnbp5Uklfh57U7QHhGGd6NNp2oJCQ=; b=JArjEmrzGNVVldZMbJ5jrf44JYpBIstZSf/RikgwsjBwJH+il6AO3P1IV8DJwWsj01 wjyu3J9Voml6ApRZ9BbFJ9M9k7fiqw10KqjikCPJe1ZZgvidWnhx5sJWFvV6+ACmKVLG 04lpCLgNFAvsSYE1SjofxinrRx7C40uUtSYlD0/U1rAvxGK3g49Gp7iVxPuuo1UN1koT pE+CL1wi/k0+XzIAs5uudPeEblnnR/mJkz43hOcjYDEU+8Vb57yY9NqVAbA3oEUNEnUK b8swAPOctxMUkIWBM3RbRCtpkGuO1hVdC7f8myhppY8uQYK3DxWRAN3ZApquu4AfNZfN 3Law== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=jC4v9G/jhIkV0IQnbp5Uklfh57U7QHhGGd6NNp2oJCQ=; b=K9uSqBDmRV83LjWv873xqEjCeIHVVWo4ZTDvcGKIvaZxY/meMD1ZcCPtgG7Y2ed2uP pxmDBuPLYnfqkCX6vPfZugkjDpeKrUBO76HNEK+qIdgHPxZbtm5dvb0j5STFjyyCm1Cu IXlp08GH10wmYXyUQJrHbrnQkUMWZsY5Uquzl6tj1cxWwPWXtW2abJq8MRHbOIKScN6r 1UZR5wP5T/FIFh8WCx/+N3ei2b9w8PM0RlVA66U9wMjQexiQaMsD2mkbKWomLRbDjo2J q9wmWhLOWp4z4WSwORF4Q/Q89ARYsGuwZhtHYXcAxgUywrQJNAXcemjJFgVVwdrcP/IA awEw== X-Gm-Message-State: ACgBeo070MOdH8e3IQcnQ3NU5hHtihRzlngK8Yt4Ar2NJo6MtfWqCWDH ICCdWtKHIpcJjBzIWixD3uA= X-Google-Smtp-Source: AA6agR5aUJRUan3rD6naJWTJ2nKGrD7fI4wCyu4cKP7ShkwvcE9ugvvmti6Sq7eCe3uNSIs9c/N8tg== X-Received: by 2002:a05:6e02:dc3:b0:2ea:d7a4:a5f with SMTP id l3-20020a056e020dc300b002ead7a40a5fmr18266464ilj.308.1662327761570; Sun, 04 Sep 2022 14:42:41 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:41 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 33/57] nouveau: WIP add 2 LEVEL_NUM classmaps for CLI, SUBDEV Date: Sun, 4 Sep 2022 15:41:10 -0600 Message-Id: <20220904214134.408619-34-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" clone the nvkm_printk,_,__ macro ladder into nvkm_drmdbg,_,__. And alter the debug, trace, spam macros to use the renamed ladder. This *sets-up* (not done yet) to remove the _subdev->debug >=3D (l) condition, once the bitmap-param is wired up correctly, and figured into dyndbg's jump-label enablement. WIP. Then undo the 1-line change that reduced count of prdbgs from 632 to 119. ie: s/NV_SUBDEV_DBG_##l/NV_DBG_##l/ So heres what happened: new symbol is 15 (or 10), and fails this macro test, so gets compiled out, and the dev_dbg is excluded. if (CONFIG_NOUVEAU_DEBUG >=3D (l) && _subdev->debug >=3D (l)) = \ dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a);= \ I could hack this, by doing (l + base), but base is pretty distant. OTOH, the whole CONFIG_NOUVEAU_DEBUG check could be reworked; given that trace is minumum recommended, theres not that many callsites elided (SPAM only iirc) at compile-time, and dyndbg means keeping them has "zero" run-cost (and 56 bytes per callsite). So this config item doesnt do much when DRM_USE_DYNAMIC_DEBUG=3Dy. So this is a useful place to stop and look around, try to guess which trail to take.. nouveau has additional debug variables to consider: drivers/gpu/drm/nouveau/include/nvkm/core/device.h 131: if (_device->debug >=3D (l)) = \ drivers/gpu/drm/nouveau/include/nvkm/core/client.h 39: if (_client->debug >=3D NV_DBG_##l) = \ drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h 54: if (CONFIG_NOUVEAU_DEBUG >=3D (l) && _subdev->debug >=3D (l)) = \ This is another baby-step, that seems not to break, so lets get a snapshot. whats done here: In nouveau_drm.c, do DECLARE_DYNDBG_CLASSMAP(LEVEL_NUM type) 2x more, for cli and subdev, right after the drm DECLARE. Adjust base for each, to share the 0..30 classid-space. These declare class-names: NV_CLI_DBG_* NV_SUBDEV_DBG_* accordingly. Note: class-name-space is flat and wide, so super-generic names like INFO should be prefixed; who could predict what a generic V3 does across all modules. s should be included adjusting the base to avoid each other, and the 0-10 already mapped to drm-debug-categorys (just above this addition). In nvkm/core/debug.h, add enums to match the names, with initial values to match the bases. In nvkm/core/subdev.h, alter (recently added) nvkm_drmdbg_() to use NV_SUBDEV_DBG_* instead of NV_DBG_*. NB: in both classmaps, Ive left FATAL..WARN out, they're not really optional the way INFO..SPAM are; dyndbg shouldn't be able to turn them off. bash-5.1# modprobe nouveau [ 966.107833] dyndbg: 3 debug prints in module wmi [ 966.342188] dyndbg: class[0]: module:nouveau base:15 len:5 ty:1 [ 966.342873] dyndbg: 15: 0 NV_SUBDEV_DBG_OFF [ 966.343352] dyndbg: 16: 1 NV_SUBDEV_DBG_INFO [ 966.343912] dyndbg: 17: 2 NV_SUBDEV_DBG_DEBUG [ 966.344443] dyndbg: 18: 3 NV_SUBDEV_DBG_TRACE [ 966.344938] dyndbg: 19: 4 NV_SUBDEV_DBG_SPAM [ 966.345402] dyndbg: class[1]: module:nouveau base:10 len:5 ty:1 [ 966.346011] dyndbg: 10: 0 NV_CLI_DBG_OFF [ 966.346477] dyndbg: 11: 1 NV_CLI_DBG_INFO [ 966.346989] dyndbg: 12: 2 NV_CLI_DBG_DEBUG [ 966.347442] dyndbg: 13: 3 NV_CLI_DBG_TRACE [ 966.347875] dyndbg: 14: 4 NV_CLI_DBG_SPAM [ 966.348284] dyndbg: class[2]: module:nouveau base:0 len:10 ty:0 [ 966.348888] dyndbg: 0: 0 DRM_UT_CORE [ 966.349310] dyndbg: 1: 1 DRM_UT_DRIVER [ 966.349694] dyndbg: 2: 2 DRM_UT_KMS [ 966.350083] dyndbg: 3: 3 DRM_UT_PRIME [ 966.350482] dyndbg: 4: 4 DRM_UT_ATOMIC [ 966.351016] dyndbg: 5: 5 DRM_UT_VBL [ 966.351475] dyndbg: 6: 6 DRM_UT_STATE [ 966.351899] dyndbg: 7: 7 DRM_UT_LEASE [ 966.352309] dyndbg: 8: 8 DRM_UT_DP [ 966.352678] dyndbg: 9: 9 DRM_UT_DRMRES [ 966.353104] dyndbg: module:nouveau attached 3 classes [ 966.353759] dyndbg: 119 debug prints in module nouveau NOTE: it was 632 with previous commit, switching NV_DEBUG to use NV_SUBDEV_DBG_DEBUG instead of NV_DBG_DEBUG may be the cause. Signed-off-by: Jim Cromie --- .../gpu/drm/nouveau/include/nvkm/core/debug.h | 16 +++++++++++++ .../drm/nouveau/include/nvkm/core/subdev.h | 17 ++++++++++---- drivers/gpu/drm/nouveau/nouveau_drm.c | 7 ++++++ drivers/gpu/drm/nouveau/nvkm/core/subdev.c | 23 +++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h b/drivers/gp= u/drm/nouveau/include/nvkm/core/debug.h index b4a9c7d991ca..6a155a23a3d1 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h @@ -9,4 +9,20 @@ #define NV_DBG_TRACE 5 #define NV_DBG_PARANOIA 6 #define NV_DBG_SPAM 7 + +enum nv_cli_dbg_verbose { + NV_CLI_DBG_OFF =3D 10, + NV_CLI_DBG_INFO, + NV_CLI_DBG_DEBUG, + NV_CLI_DBG_TRACE, + NV_CLI_DBG_SPAM +}; +enum nv_subdev_dbg_verbose { + NV_SUBDEV_DBG_OFF =3D 15, + NV_SUBDEV_DBG_INFO, + NV_SUBDEV_DBG_DEBUG, + NV_SUBDEV_DBG_TRACE, + NV_SUBDEV_DBG_SPAM +}; + #endif diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/g= pu/drm/nouveau/include/nvkm/core/subdev.h index 065d07ccea87..ce33c82e5c75 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -2,6 +2,7 @@ #ifndef __NVKM_SUBDEV_H__ #define __NVKM_SUBDEV_H__ #include +#include =20 enum nvkm_subdev_type { #define NVKM_LAYOUT_ONCE(t,s,p,...) t, @@ -18,7 +19,7 @@ struct nvkm_subdev { enum nvkm_subdev_type type; int inst; char name[16]; - u32 debug; + unsigned long debug; struct list_head head; =20 void **pself; @@ -59,9 +60,17 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) -#define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) + +#define nvkm_drmdbg__(s,l,p,f,a...) do { \ + const struct nvkm_subdev *_subdev =3D (s); \ + if (CONFIG_NOUVEAU_DEBUG >=3D (l) && _subdev->debug >=3D (l)) \ + dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \ +} while(0) +#define nvkm_drmdbg_(s,l,f,a...) nvkm_drmdbg__((s), NV_SUBDEV_DBG_##l, dbg= , f, ##a) +#define nvkm_debug(s,f,a...) nvkm_drmdbg_((s), DEBUG, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_drmdbg_((s), TRACE, f, ##a) +#define nvkm_spam(s,f,a...) nvkm_drmdbg_((s), SPAM, f, ##a) =20 #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratel= imited, f, ##a) + #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouvea= u/nouveau_drm.c index fd99ec0f4257..864750451dc8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -83,6 +83,13 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE= _DISJOINT_BITS, 0, "DRM_UT_DP", "DRM_UT_DRMRES"); =20 +DECLARE_DYNDBG_CLASSMAP(nv_cli_debug_verbose, DD_CLASS_TYPE_LEVEL_NUM, 10, + "NV_CLI_DBG_OFF", + "NV_CLI_DBG_INFO", + "NV_CLI_DBG_DEBUG", + "NV_CLI_DBG_TRACE", + "NV_CLI_DBG_SPAM"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/n= ouveau/nvkm/core/subdev.c index a74b7acb6832..20cd99cce2a4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c @@ -26,6 +26,27 @@ #include #include =20 +#include +#include + +#define DEBUG + +DECLARE_DYNDBG_CLASSMAP(nv_subdev_debug_verbose, DD_CLASS_TYPE_LEVEL_NAMES= , 15, + "NV_SUBDEV_DBG_OFF", + "NV_SUBDEV_DBG_INFO", + "NV_SUBDEV_DBG_DEBUG", + "NV_SUBDEV_DBG_TRACE", + "NV_SUBDEV_DBG_SPAM"); + +static struct ddebug_class_param nv_subdev_verbose =3D { + .bits =3D NULL, // wants &_subdev->debug + .flags =3D "p", + .map =3D &nv_subdev_debug_verbose, +}; +module_param_cb(debug_subdev, ¶m_ops_dyndbg_classes, &nv_subdev_verbos= e, 0600); + + + const char * nvkm_subdev_type[NVKM_SUBDEV_NR] =3D { #define NVKM_LAYOUT_ONCE(type,data,ptr,...) [type] =3D #ptr, @@ -180,6 +201,8 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func, s= truct nvkm_device *device else strscpy(subdev->name, nvkm_subdev_type[type], sizeof(subdev->name)); subdev->debug =3D nvkm_dbgopt(device->dbgopt, subdev->name); + nv_subdev_verbose.bits =3D &subdev->debug; + pr_debug("updated bitmap: %px\n", &nv_subdev_verbose.bits); list_add_tail(&subdev->head, &device->subdev); } =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 F2197C6FA86 for ; Sun, 4 Sep 2022 21:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235983AbiIDVo4 (ORCPT ); Sun, 4 Sep 2022 17:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235748AbiIDVni (ORCPT ); Sun, 4 Sep 2022 17:43:38 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC352F67D for ; Sun, 4 Sep 2022 14:42:43 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5652980iod.8 for ; Sun, 04 Sep 2022 14:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=yB0p6m1pbFn82PaaCe9bX0Com85Je0ESfO84kw+YqGQ=; b=UQ8KTpkUZuUjPBlMxj/1xzitRYQINMPQpY3Hd7AH9zV7Ub4knjfNFZVsDZcPlumg6D RVvYcS9KlYeVAl2ypb4nyaXZuZp4hKLEPCUJULeth+dw9XjB7AZUphJjVMw77uQvbwIP F74jHiu1hanUG/lW7nkcHVm36JEUcgagI5taL7R0dabNs3eanVGIGy30Bz+y4yv7YaJg uJQDYEHEOVxa0h3AynNMElY1UV5uwXtZvaejV0B8nW90gt5D3JzxCo087m/HxCJPbM3P OmgAgxgRkcofaDF0Os9F+y60Rz4cN4ndRv4xMNT9b4kOQ3TXaSKJIqrX2mX1Xky6pPdt OYJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=yB0p6m1pbFn82PaaCe9bX0Com85Je0ESfO84kw+YqGQ=; b=4IncOqkA3RGHkppARhWKnD53bTmP32fYhNBuNuGViqu3gsCJNWZ1d8wn0jM4Avuje+ t1hryk5hIqfnqGQfeaGNE4sFMA9lGKh+jT+/TuQiinwqvADF2C6rtANOKpGGTZG4XTYY 7ISdQ5HM+e3pSJN4wy8SzoFoDpxCt+TNf087M645qWyCDR5kRQYtUdZcbdFQoZYUI/lg Ku7DwObNrD9LjGF/MjbwyfMl3vbpy0WSdk33+d5kIwL4oTGTwx1L9Ad+LUpCHS1LKf1r NjDtH1BTQY+fyuh35hrYx+fn2k89nBcjbGWNkncwddLYVTT62B/jX0cYj7u/r8MF5dVM S4UA== X-Gm-Message-State: ACgBeo3PbFTiLF1qrdmVGMBBA3Q8WAn80d0sZmNc8LYmMEJxrck3kuiu 3uUD6kjZZdqU7ZjhgRKyqUE= X-Google-Smtp-Source: AA6agR5hyoFODwyMk2f+k/6+4G4cl6nFZCnCNI0y+wxYxmE+qgJlFbiwfQMvoxjNj4fTWX0cU6fXrg== X-Received: by 2002:a05:6638:3712:b0:34a:31f:b80 with SMTP id k18-20020a056638371200b0034a031f0b80mr24360396jav.84.1662327762569; Sun, 04 Sep 2022 14:42:42 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:42 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH v6 34/57] dyndbg: add _DPRINTK_FLAGS_ENABLED Date: Sun, 4 Sep 2022 15:41:11 -0600 Message-Id: <20220904214134.408619-35-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Distinguish the condition: _DPRINTK_FLAGS_ENABLED from the bit: _DPRINTK_FLAGS_PRINT, and re-define former in terms of latter, in preparation to add a 2nd bit: _DPRINTK_FLAGS_TRACE Update JUMP_LABEL code block to check _DPRINTK_FLAGS_ENABLED symbol. Also add a 'K' to get new symbol _DPRINTK_FLAGS_PRINTK, in order to break any stale uses. CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 10 ++++++---- lib/dynamic_debug.c | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 41682278d2e8..ecd3379090c4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,7 +32,7 @@ struct _ddebug { * writes commands to /dynamic_debug/control */ #define _DPRINTK_FLAGS_NONE 0 -#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format= */ +#define _DPRINTK_FLAGS_PRINTK (1 << 0) /* printk() a message using the for= mat */ #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1) #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) @@ -42,8 +42,10 @@ struct _ddebug { (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) =20 +#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK + #if defined DEBUG -#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT +#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif @@ -198,10 +200,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #ifdef DEBUG #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - likely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + likely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #else #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + unlikely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #endif =20 #endif /* CONFIG_JUMP_LABEL */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 009f2ead09c1..1e9d0124a0e9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -89,7 +89,7 @@ static inline const char *trim_prefix(const char *path) } =20 static struct { unsigned flag:8; char opt_char; } opt_array[] =3D { - { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_PRINTK, 'p' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, @@ -246,10 +246,10 @@ static int ddebug_change(const struct ddebug_query *q= uery, if (newflags =3D=3D dp->flags) continue; #ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(newflags & _DPRINTK_FLAGS_PRINT)) + if (dp->flags & _DPRINTK_FLAGS_ENABLED) { + if (!(newflags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (newflags & _DPRINTK_FLAGS_PRINT) { + } else if (newflags & _DPRINTK_FLAGS_ENABLED) { static_branch_enable(&dp->key.dd_key_true); } #endif --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 7E645C6FA89 for ; Sun, 4 Sep 2022 21:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235784AbiIDVpD (ORCPT ); Sun, 4 Sep 2022 17:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235754AbiIDVni (ORCPT ); Sun, 4 Sep 2022 17:43:38 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB88D2FFCA for ; Sun, 4 Sep 2022 14:42:43 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e7so3873263ilc.5 for ; Sun, 04 Sep 2022 14:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TAwV35ZWZLIKqOElwfkhFfIbRXseVOLIKBiUUUQjUVQ=; b=YQSF24Us+VgO6MmkwBVVohgShZMcax7Tlk2S3GvdeKpX8+kDOiSv3UtwHdryBa/MfZ MVJvIEFu2ceZYdrJvC7LCgaG6cEGWWOo9rPDcMnnD+bMW23GiPRN5wZw8EBRiwT0rE4D tyIORau8tjxdkTvurYsJa1KKbPC7Xw24bYyvtnAHFUTaVJyVUi4XMOenzHqGO8vAeZLz IykguT8g4g+lANiwbVQH2BC/Z9FWb7/vEYDvWbQ9K6c9NLNB3P6ZPkHEEo1aJnLu/3DP so/ytamyrgwlaVUiFuKwgSUCvGgReaF3szmlQpVggMMm6ySVIhuDBYvRb9VRu2wy021f mxrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=TAwV35ZWZLIKqOElwfkhFfIbRXseVOLIKBiUUUQjUVQ=; b=LLoLBCZYSXj7jmUM8N0TfwgUEECHRE5mCehEL4q7xaONnziZnReAyFWv5Ie3Mh3kz3 dliB7NjSLFPXGvaPsJMdQ+yXlWAXEYYpDXOpCc+uWnXYFVbp5lAEmS6eleKZDe1fW7gq yWOYzjZ8naLyTOWIltsb62o7azz/uPVSNGTh9sEiVgQqva37/O2HOGtDk/IHIE5SMqsR 1oUy8aUTgtNRY4JlkUjRpwOkrBPMZEeHGZz3yxodwe8MP/pd7AIkZChsZmcM8WRVBQ0c pWbXogc81bu4YFuc4KCBRS6rzzjwWkPM6oyQ0bM1WOUSMmMN3fDcHe3pCZyqFWi8PhDy ZHhQ== X-Gm-Message-State: ACgBeo39gCeZaXcI3uuH6P33FY7TvK59rUpkGVQSoxrkAiz0VYhUDvev FQL24vT8JQV+aFG8FDOxa00= X-Google-Smtp-Source: AA6agR5dlZ+2mbjYaiVo07B1ri+ETbudxxDzknKKyObWsKY9ZVDTd1RmO8d48xns2r12tpVnSs9bbw== X-Received: by 2002:a05:6e02:12ed:b0:2eb:753e:cfb with SMTP id l13-20020a056e0212ed00b002eb753e0cfbmr12322927iln.14.1662327763512; Sun, 04 Sep 2022 14:42:43 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:43 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH v6 35/57] dyndbg: add _DPRINTK_FLAGS_TRACE Date: Sun, 4 Sep 2022 15:41:12 -0600 Message-Id: <20220904214134.408619-36-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 new flag, and OR it into _DPRINTK_FLAGS_ENABLED definition CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index ecd3379090c4..04f49df308a7 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -42,7 +42,9 @@ struct _ddebug { (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) =20 -#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK +#define _DPRINTK_FLAGS_TRACE (1 << 5) +#define _DPRINTK_FLAGS_ENABLED (_DPRINTK_FLAGS_PRINTK | \ + _DPRINTK_FLAGS_TRACE) =20 #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 C24DBC6FA82 for ; Sun, 4 Sep 2022 21:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235754AbiIDVpL (ORCPT ); Sun, 4 Sep 2022 17:45:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbiIDVnu (ORCPT ); Sun, 4 Sep 2022 17:43:50 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9932FFDC for ; Sun, 4 Sep 2022 14:42:44 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id m16so861502ilg.3 for ; Sun, 04 Sep 2022 14:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hLX0vmxfE2cNoXxW+pxt5dZIDGNJfmOeoJDSMO1hano=; b=ZpQL1fgEKB26ROGXg3bIaSFjutqwzthCJGLTsOMm82G/WKNEV7RaSc1HgHH+4EYBBS I4kKHN3sYKUpq6oxtDqQ1rCKWqBdgYhjSyRVZjcy2kkCKt36zUM2J/ACsEbogd/hT1/4 424RgMlqSajD+0g+5qs3goYOHny/cd7TJJkRA/BMgzHJmFhr2Q29luzQuKVFVIgObj69 m8/YXI9TBy0MBh8wQ/bAntqEfcQ5RhKh7RL9djNRQrRx1PcKpAkktrHMphwSX2m7oEaQ uSJsFu2GqUMeiXnT8ItzwB1PI1sTsJRhpbzjAcUWmn/b2uQrxhPmWUibRuhMD2GPNPqm PVKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=hLX0vmxfE2cNoXxW+pxt5dZIDGNJfmOeoJDSMO1hano=; b=tovUZ9wzCW5tXdeKIOlPQ5jy+EKz2vN5l1dkswCi+A6p0ma+JCh8LdlU/A6ZmbpgcU mXx9qQ1H8nUlOp665a7mY2lgtlD4KwXZgFegBSuRBlJpUPVZEuDzsRJ6kzzbSl8QqoSI 1DgpxL6t+n1wuU/NFSLuA3N0iiI7i66SdqeetdiHOsanIvc4axuT7HUCkPO0jN7Nxusu YKWSB0ie4oGvPqy2SQVU2cGzlHnJyYMoZfFJo0mAxNpJN5cGlgXeiylSvC8QiFTQTxq9 gv4unJ/1bejhhJ1H1kzCPw5/YTqv7251uVfV8WiVQdtehQv7tzA00JX+FT6NGToP4VWM ICoQ== X-Gm-Message-State: ACgBeo0PGLUHNh3lnGU8wRGnRg306LsGzE6ajmjXyAOWB2+ZSj8dQePM VuhJj2PyeXwgX8uRtWKZE8XuJP3DrUw= X-Google-Smtp-Source: AA6agR6D4aeYAw5/pzfOTRxYtiGWHhCcgKpGfv2afQnTmQdaB6TE6PRIg59M3lVF8/S7qM7IzEmgCg== X-Received: by 2002:a05:6e02:1a6c:b0:2f1:5a6e:93c6 with SMTP id w12-20020a056e021a6c00b002f15a6e93c6mr1815104ilv.175.1662327764441; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:44 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH v6 36/57] dyndbg: add write-events-to-tracefs code Date: Sun, 4 Sep 2022 15:41:13 -0600 Message-Id: <20220904214134.408619-37-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" adds: ddebug_trace() uses trace_console() temporarily to issue printk:console event uses internal-ish __ftrace_trace_stack code: 4-context buffer stack, barriers per Steve Rostedt call it from new funcs: ddebug_printk() - print to both syslog/tracefs ddebug_dev_printk() - dev-print to both syslog/tracefs These handle both _DPRINTK_FLAGS_PRINTK and _DPRINTK_FLAGS_TRACE cases, allowing to vsnprintf the message once and use it for both, skipping past the KERN_DEBUG character for tracing. Finally, adjust the callers: __ddebug_{pr_debug,{,net,ib}dev_dbg}, replacing printk and dev_printk with the new funcs above. The _DPRINTK_FLAGS_TRACE flag character is 'T', so the following finds all callsites enabled for tracing: grep -P =3Dp?T /proc/dynamic_debug/control This patch,~1,~2 are basically copies of: https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@ax= is.com/ with a few differences: - s/dynamic_/ddebug_/ on Vincent's additions - __printf attrs on the _printk funcs - reuses trace_console() event, not adding a new "printk:dyndbg" event. next patch replaces this with 2 new events CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 5 +- lib/dynamic_debug.c | 156 +++++++++++++++--- 2 files changed, 133 insertions(+), 28 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index faa22f77847a..45b6e5697c89 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -209,8 +209,9 @@ of the characters:: =20 The flags are:: =20 - p enables the pr_debug() callsite. - _ enables no flags. + p callsite prints to syslog + T callsite issues a dyndbg:* trace-event + _ enables no flags =20 Decorator flags add to the message-prefix, in order: t Include thread ID, or diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1e9d0124a0e9..3c6c18f13889 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include =20 #include =20 @@ -90,6 +91,7 @@ static inline const char *trim_prefix(const char *path) =20 static struct { unsigned flag:8; char opt_char; } opt_array[] =3D { { _DPRINTK_FLAGS_PRINTK, 'p' }, + { _DPRINTK_FLAGS_TRACE, 'T' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, @@ -854,6 +856,98 @@ static inline char *dynamic_emit_prefix(struct _ddebug= *desc, char *buf) return buf; } =20 +/* + * This code is heavily based on __ftrace_trace_stack(). + * + * Allow 4 levels of nesting: normal, softirq, irq, NMI. + */ +#define DYNAMIC_TRACE_NESTING 4 + +struct ddebug_trace_buf { + char buf[256]; +}; + +struct ddebug_trace_bufs { + struct ddebug_trace_buf bufs[DYNAMIC_TRACE_NESTING]; +}; + +static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); +static DEFINE_PER_CPU(int, ddebug_trace_reserve); + +static void ddebug_trace(const char *fmt, va_list args) +{ + struct ddebug_trace_buf *buf; + int bufidx; + int len; + + preempt_disable_notrace(); + + bufidx =3D __this_cpu_inc_return(ddebug_trace_reserve) - 1; + + if (WARN_ON_ONCE(bufidx > DYNAMIC_TRACE_NESTING)) + goto out; + + /* For the same reasons as in __ftrace_trace_stack(). */ + barrier(); + + buf =3D this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; + + len =3D vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); + trace_console(buf->buf, len); + +out: + /* As above. */ + barrier(); + __this_cpu_dec(ddebug_trace_reserve); + preempt_enable_notrace(); +} + +__printf(2, 3) +static void ddebug_printk(unsigned int flags, const char *fmt, ...) +{ + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + /* + * All callers include the KERN_DEBUG prefix to keep the + * vprintk case simple; strip it out for tracing. + */ + ddebug_trace(fmt + strlen(KERN_DEBUG), args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } +} + +__printf(3, 4) +static void ddebug_dev_printk(unsigned int flags, const struct device *dev, + const char *fmt, ...) +{ + + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + ddebug_trace(fmt, args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + dev_vprintk_emit(LOGLEVEL_DEBUG, dev, fmt, args); + va_end(args); + } +} + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; @@ -868,16 +962,18 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, c= onst char *fmt, ...) vaf.fmt =3D fmt; vaf.va =3D &args; =20 - printk(KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + dynamic_emit_prefix(descriptor, buf), &vaf); =20 va_end(args); } EXPORT_SYMBOL(__dynamic_pr_debug); =20 void __dynamic_dev_dbg(struct _ddebug *descriptor, - const struct device *dev, const char *fmt, ...) + const struct device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; =20 BUG_ON(!descriptor); @@ -887,16 +983,18 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, =20 vaf.fmt =3D fmt; vaf.va =3D &args; + flags =3D descriptor->flags; =20 if (!dev) { - printk(KERN_DEBUG "(NULL device *): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL device *): %pV", + &vaf); } else { char buf[PREFIX_SIZE] =3D ""; =20 - dev_printk_emit(LOGLEVEL_DEBUG, dev, "%s%s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev), dev_name(dev), - &vaf); + ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev), dev_name(dev), + &vaf); } =20 va_end(args); @@ -909,6 +1007,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; =20 BUG_ON(!descriptor); @@ -918,22 +1017,24 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, =20 vaf.fmt =3D fmt; vaf.va =3D &args; + flags =3D descriptor->flags; =20 if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] =3D ""; =20 - dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev->dev.parent), - dev_name(dev->dev.parent), - netdev_name(dev), netdev_reg_state(dev), - &vaf); + ddebug_dev_printk(flags, dev->dev.parent, + "%s%s %s %s%s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + &vaf); } else if (dev) { - printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev), - netdev_reg_state(dev), &vaf); + ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", + &vaf); } =20 va_end(args); @@ -949,26 +1050,29 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + unsigned int flags; =20 va_start(args, fmt); =20 vaf.fmt =3D fmt; vaf.va =3D &args; + flags =3D descriptor->flags; =20 if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] =3D ""; =20 - dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, - "%s%s %s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(ibdev->dev.parent), - dev_name(ibdev->dev.parent), - dev_name(&ibdev->dev), - &vaf); + ddebug_dev_printk(flags, ibdev->dev.parent, + "%s%s %s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(ibdev->dev.parent), + dev_name(ibdev->dev.parent), + dev_name(&ibdev->dev), + &vaf); } else if (ibdev) { - printk(KERN_DEBUG "%s: %pV", dev_name(&ibdev->dev), &vaf); + ddebug_printk(flags, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } =20 va_end(args); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 66556C6FA82 for ; Sun, 4 Sep 2022 21:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236045AbiIDVpP (ORCPT ); Sun, 4 Sep 2022 17:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235805AbiIDVnv (ORCPT ); Sun, 4 Sep 2022 17:43:51 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E282FFE9 for ; Sun, 4 Sep 2022 14:42:46 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id d68so5629192iof.11 for ; Sun, 04 Sep 2022 14:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=A2zndOeDRPgGOvwAIBa0JaD1rifqqeyYUM4/f4LglP8=; b=Dx7ob9YDExsS8kTSLfJMyPG66UA0U31lxKW3FyZ0OB7RnX+eTy24lpN15BN0uRCHgK iYRtls7LairgGBqQuWjOWGt5yV/5sReWPL8tJcxGLve+LNOB7TeMPm6iwWvkuf+Gq8oK Jg00USMN4Sx6FBVhr4RDt6XK444pORZc4ArmQjXr5Hi+BWDooYO/+r75wEMcyKAvmeXv ITokxmZrLFKj9FfRabOmhj5kw4y0bEhW59aTj3Y2WyYkmh3QI84/qPuQpnu2EEilo0M9 03YBBWYjSQ9xaDCSkgVNC8OmCZZsemz9X0cEsj/0x82tX7xElqTn8iPg31QwPj3XtjyW ewQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=A2zndOeDRPgGOvwAIBa0JaD1rifqqeyYUM4/f4LglP8=; b=DTl2D4aYw4gjKPnK1B0zZL7+uVj0pKNoh3oFzV0+Pz1SGdSM+pBPxgkt9NDgXQ6BG2 UAdFpeB2WHC5d7dX0F+mR8LFGkTlISlIjV4cn9O0sYcuXfZ3QbeT7gi1pOEugI33i38Q keCMJbYHqNGhk+Q4kK5KogapcYFwhb5wtx9TLmaXF0LM038zUbuW5UaIgeS5hgkbpY8q NrTzaOfuEpuWdwXjtLoCxYwQ/3wzMkusU1Ke2OU5+EpFqAF0Ew1UyMJ3IGFBtey3+gPh qTvz3MM7t9zRJeacLfODvlLK9UQSv+61KoI6Sx2TK/gsiLTnPNN0N/R0gZup3amTytMq M7YA== X-Gm-Message-State: ACgBeo16990pVFXA1TDB0W3T64SyE9/K4QdDK3K4wife+fXhOQhmUDrV OyFZi4WlI+W9mMJKlYdRqsuAHSzstFg= X-Google-Smtp-Source: AA6agR5zZ3MpxOCe1Gv6PL9bbcItO9JKVZB4ZP+mJzEw4KEVnlCu6qXDvhLhCGEBE1WfgmU3fBenrw== X-Received: by 2002:a05:6638:d10:b0:34c:10d8:4f7 with SMTP id q16-20020a0566380d1000b0034c10d804f7mr10894388jaj.246.1662327765640; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:45 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 37/57] dyndbg: add 2 trace-events: drm_debug, drm_devdbg Date: Sun, 4 Sep 2022 15:41:14 -0600 Message-Id: <20220904214134.408619-38-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Recently added ddebug_trace() issues a single printk:console event. Replace that event with 2 new ones, defined in a new header: include/trace/events/dyndbg.h - dyndbg:prdbg - from trace_prdbg() - if !dev - dyndbg:devdbg - from trace_devdbg() - if !!dev This links the legacy pr_debug API to tracefs, so pr_debug() and dev_dbg() calls can add more debug context into the trace-logs, and then at users option, less into syslog. The new events allow enabling by event-type in tracefs, and dyndbg allows individual enablement of prdbg callsites (via +T flag). Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 25 ++++++++++++----- include/trace/events/drm.h | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 include/trace/events/drm.h diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 5b93c11895bb..c50edbf443d3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -35,6 +35,9 @@ #include #include =20 +#define CREATE_TRACE_POINTS +#include + /* * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. @@ -293,13 +296,19 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct= device *dev, vaf.fmt =3D format; vaf.va =3D &args; =20 - if (dev) - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - else - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - + if (dev) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) + dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + if (desc->flags & _DPRINTK_FLAGS_TRACE) + trace_drm_devdbg(dev, category, &vaf); + } else { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) + printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + if (desc->flags & _DPRINTK_FLAGS_TRACE) + trace_drm_debug(category, &vaf); + } va_end(args); } EXPORT_SYMBOL(__drm_dev_dbg); @@ -319,6 +328,8 @@ void ___drm_dbg(struct _ddebug *desc, enum drm_debug_ca= tegory category, const ch printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); =20 + trace_drm_debug(category, &vaf); + va_end(args); } EXPORT_SYMBOL(___drm_dbg); diff --git a/include/trace/events/drm.h b/include/trace/events/drm.h new file mode 100644 index 000000000000..589fa1e1f2c2 --- /dev/null +++ b/include/trace/events/drm.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM drm + +#if !defined(_TRACE_DRM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DRM_H + +#include + +/* drm_debug() was called, pass its args */ +TRACE_EVENT(drm_debug, + TP_PROTO(int drm_debug_category, struct va_format *vaf), + + TP_ARGS(drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(int, drm_debug_category) + __vstring(msg, vaf->fmt, vaf->va) + ), + + TP_fast_assign( + __entry->drm_debug_category =3D drm_debug_category; + __assign_vstr(msg, vaf->fmt, vaf->va); + ), + + TP_printk("%s", __get_str(msg)) +); + +/* drm_devdbg() was called, pass its args, preserving order */ +TRACE_EVENT(drm_devdbg, + TP_PROTO(const struct device *dev, int drm_debug_category, struct va_= format *vaf), + + TP_ARGS(dev, drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(const struct device*, dev) + __field(int, drm_debug_category) + __vstring(msg, vaf->fmt, vaf->va) + ), + + TP_fast_assign( + __entry->drm_debug_category =3D drm_debug_category; + __entry->dev =3D dev; + __assign_vstr(msg, vaf->fmt, vaf->va); + ), + + TP_printk("cat:%d, %s %s", __entry->drm_debug_category, + dev_name(__entry->dev), __get_str(msg)) +); + +#endif /* _TRACE_DRM_H */ + +/* This part must be outside protection */ +#include --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 2F1A3C6FA86 for ; Sun, 4 Sep 2022 21:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235897AbiIDVp3 (ORCPT ); Sun, 4 Sep 2022 17:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235458AbiIDVoG (ORCPT ); Sun, 4 Sep 2022 17:44:06 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD41303CB for ; Sun, 4 Sep 2022 14:42:47 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id e7so3873293ilc.5 for ; Sun, 04 Sep 2022 14:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=MkO54h6RbL6AorJv6VQNVgmDkIVAXQk+J2K+rcA8Q74=; b=T3ioRoJuy8MAjM1fBChZi1K/OJxDzDdQQqCdKzjffCvU/X3SlWWIpnYLeQ03GsbxIu 5yy9VpNkonyO/kzNDY+IHHlpvMoDhr7TUxSwbaOTSQBjRTpMXELmW2qMxlS7zOBqTtAk LSywTJwn2v8eW8UIn/wC7G6bCUzFxHHA19DEPZ8Tb2eK8Ygwpx3NOvYhqhDhsSTuNblU uwascp+YyeS1UKoece2GHDMTMny2l3Gzr8HP/GirCcvXoswIOyRKsLSKaPSnP7DDTIOQ S5fNQreonTFjeF77CvhSPd4peuR9kXy9/Fs/m/E3iM7Ab+itlCiZck+Wtnigj5rqVSw+ Eh/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=MkO54h6RbL6AorJv6VQNVgmDkIVAXQk+J2K+rcA8Q74=; b=A8YKF9L4mSJCPi75xxMgLpU9CBO7vXPmVVORzSerA0Uoh9ZCLhStzt5PC4Iinpeluu v5jGKvVHpfkAJTRRX5pf2bdeLD5Y8tqqzV1tbJM3a75MJCjjejzeWkffdfwZ0W9R8Ud9 nTz8jSCxYAMzFHBpvzDY955jT5wyGtg0jVorDMOzVnGayn+sYYZ75Qln4m7EZ35YWe3i 5dlXeTrP+1MEtmzL+iKLQJw8yh3HMbRjrKw7DIqffvl0RnaOxU8Ug8N8LgQZtQF0/ZRr jDtZqzOqxlMtiMuoPfKZQryZGFR///ZAlVIeowId/cB9q8MAuPPf1VnOA3vJrHg3SPIV hs0w== X-Gm-Message-State: ACgBeo3e3zFKE4s9dmK/dCfAqUV3VdAEBM73HZBLbUA7OxJcff9H0bHb PUHq3HKHOIN6rkd7t95qd4A= X-Google-Smtp-Source: AA6agR6NnQrYXo22ArhDnzgxL+0DpouWFgKRVUKYMPOBl25l0DqdASsseYFz8k/hKpmJXQxvRG2mmg== X-Received: by 2002:a92:6903:0:b0:2e5:8f47:22e0 with SMTP id e3-20020a926903000000b002e58f4722e0mr24549638ilc.97.1662327766575; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:46 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 38/57] dyndbg: add 2 more trace-events: pr_debug, dev_dbg Date: Sun, 4 Sep 2022 15:41:15 -0600 Message-Id: <20220904214134.408619-39-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" ddebug_trace() currently issues a single printk:console event. Replace that, adding include/trace/events/dyndbg.h, which defines 2 new events: - dyndbg:prdbg - from trace_prdbg() - if !dev - dyndbg:devdbg - from trace_devdbg() - if !!dev This links the legacy pr_debug API to tracefs, via dyndbg, allowing pr_debug()s etc to add just a little more user-context to the trace-logs, and then at users option, less syslog. The 2 new trace_*() calls accept their caller's args respectively, keeping the available info w/o alteration; we can't improve on transparency. The args: 1- struct _ddebug *descriptor, giving tracefs all of dyndbg's info. 2- struct device *dev, used by trace_devdbg(), if !!dev The trace_*() calls need the descriptor arg, the callchain prototypes above them are extended to provide it. The existing category param in this callchain is partially redundant; when descriptor is available, it has the class_id. dev_dbg(desc, dev...), if dev is true, issues a trace_devdbg(), otherwise trace_prdbg(). This way we dont consume buffer space storing nulls. Otherwise the events are equivalent. Also add include/trace/events/drm.h, to create 2 events for use in drm_dbg() and drm_devdbg(), and call them. This recapitulates the changes described above, connecting 3-10K drm.debug callsites to tracefs. Signed-off-by: Jim Cromie --- include/trace/events/dyndbg.h | 74 +++++++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 73 +++++++++++++++++----------------- 2 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 include/trace/events/dyndbg.h diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h new file mode 100644 index 000000000000..e19fcb56566c --- /dev/null +++ b/include/trace/events/dyndbg.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dyndbg + +#if !defined(_TRACE_DYNDBG_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DYNDBG_H + +#include + +/* capture pr_debug() callsite descriptor and message */ +TRACE_EVENT(prdbg, + TP_PROTO(const struct _ddebug *desc, const char *text, size_t len), + + TP_ARGS(desc, text, len), + + TP_STRUCT__entry( + __field(const struct _ddebug *, desc) + __dynamic_array(char, msg, len + 1) + ), + + TP_fast_assign( + __entry->desc =3D desc; + /* + * Each trace entry is printed in a new line. + * If the msg finishes with '\n', cut it off + * to avoid blank lines in the trace. + */ + if (len > 0 && (text[len - 1] =3D=3D '\n')) + len -=3D 1; + + memcpy(__get_str(msg), text, len); + __get_str(msg)[len] =3D 0; + ), + + TP_printk("%s.%s %s", __entry->desc->modname, + __entry->desc->function, __get_str(msg)) +); + +/* capture dev_dbg() callsite descriptor, device, and message */ +TRACE_EVENT(devdbg, + TP_PROTO(const struct _ddebug *desc, const struct device *dev, + const char *text, size_t len), + + TP_ARGS(desc, dev, text, len), + + TP_STRUCT__entry( + __field(const struct _ddebug *, desc) + __field(const struct device *, dev) + __dynamic_array(char, msg, len + 1) + ), + + TP_fast_assign( + __entry->desc =3D desc; + __entry->dev =3D (struct device *) dev; + /* + * Each trace entry is printed in a new line. + * If the msg finishes with '\n', cut it off + * to avoid blank lines in the trace. + */ + if (len > 0 && (text[len - 1] =3D=3D '\n')) + len -=3D 1; + + memcpy(__get_str(msg), text, len); + __get_str(msg)[len] =3D 0; + ), + + TP_printk("%s.%s %s", __entry->desc->modname, + __entry->desc->function, __get_str(msg)) +); + +#endif /* _TRACE_DYNDBG_H */ + +/* This part must be outside protection */ +#include diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3c6c18f13889..0870e939f255 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,7 +36,9 @@ #include #include #include -#include + +#define CREATE_TRACE_POINTS +#include =20 #include =20 @@ -874,7 +876,9 @@ struct ddebug_trace_bufs { static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); static DEFINE_PER_CPU(int, ddebug_trace_reserve); =20 -static void ddebug_trace(const char *fmt, va_list args) +__printf(3, 0) +static void ddebug_trace(struct _ddebug *desc, const struct device *dev, + const char *fmt, va_list args) { struct ddebug_trace_buf *buf; int bufidx; @@ -893,7 +897,11 @@ static void ddebug_trace(const char *fmt, va_list args) buf =3D this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; =20 len =3D vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); - trace_console(buf->buf, len); + + if (!dev) + trace_prdbg(desc, buf->buf, len); + else + trace_devdbg(desc, dev, buf->buf, len); =20 out: /* As above. */ @@ -903,9 +911,9 @@ static void ddebug_trace(const char *fmt, va_list args) } =20 __printf(2, 3) -static void ddebug_printk(unsigned int flags, const char *fmt, ...) +static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) { - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; =20 va_start(args, fmt); @@ -913,11 +921,11 @@ static void ddebug_printk(unsigned int flags, const c= har *fmt, ...) * All callers include the KERN_DEBUG prefix to keep the * vprintk case simple; strip it out for tracing. */ - ddebug_trace(fmt + strlen(KERN_DEBUG), args); + ddebug_trace(desc, NULL, fmt + strlen(KERN_DEBUG), args); va_end(args); } =20 - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; =20 va_start(args, fmt); @@ -927,19 +935,19 @@ static void ddebug_printk(unsigned int flags, const c= har *fmt, ...) } =20 __printf(3, 4) -static void ddebug_dev_printk(unsigned int flags, const struct device *dev, +static void ddebug_dev_printk(struct _ddebug *desc, const struct device *d= ev, const char *fmt, ...) { =20 - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; =20 va_start(args, fmt); - ddebug_trace(fmt, args); + ddebug_trace(desc, dev, fmt, args); va_end(args); } =20 - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; =20 va_start(args, fmt); @@ -962,7 +970,7 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, con= st char *fmt, ...) vaf.fmt =3D fmt; vaf.va =3D &args; =20 - ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + ddebug_printk(descriptor, KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); =20 va_end(args); @@ -973,7 +981,6 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, const char *fmt, ...) { struct va_format vaf; - unsigned int flags; va_list args; =20 BUG_ON(!descriptor); @@ -983,15 +990,14 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, =20 vaf.fmt =3D fmt; vaf.va =3D &args; - flags =3D descriptor->flags; =20 if (!dev) { - ddebug_printk(flags, KERN_DEBUG "(NULL device *): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL device *): %pV", + &vaf); } else { char buf[PREFIX_SIZE] =3D ""; =20 - ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + ddebug_dev_printk(descriptor, dev, "%s%s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(dev), dev_name(dev), &vaf); @@ -1007,7 +1013,6 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...) { struct va_format vaf; - unsigned int flags; va_list args; =20 BUG_ON(!descriptor); @@ -1017,24 +1022,22 @@ void __dynamic_netdev_dbg(struct _ddebug *descripto= r, =20 vaf.fmt =3D fmt; vaf.va =3D &args; - flags =3D descriptor->flags; =20 if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] =3D ""; =20 - ddebug_dev_printk(flags, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev->dev.parent), - dev_name(dev->dev.parent), - netdev_name(dev), netdev_reg_state(dev), - &vaf); + ddebug_dev_printk(descriptor, dev->dev.parent, + "%s%s %s %s%s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + &vaf); } else if (dev) { - ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", - netdev_name(dev), netdev_reg_state(dev), &vaf); + ddebug_dev_printk(descriptor, &dev->dev, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL net_device): %pV", &vaf); } =20 va_end(args); @@ -1050,18 +1053,16 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; - unsigned int flags; =20 va_start(args, fmt); =20 vaf.fmt =3D fmt; vaf.va =3D &args; - flags =3D descriptor->flags; =20 if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] =3D ""; =20 - ddebug_dev_printk(flags, ibdev->dev.parent, + ddebug_dev_printk(descriptor, ibdev->dev.parent, "%s%s %s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(ibdev->dev.parent), @@ -1069,10 +1070,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dev_name(&ibdev->dev), &vaf); } else if (ibdev) { - ddebug_printk(flags, KERN_DEBUG "%s: %pV", - dev_name(&ibdev->dev), &vaf); + ddebug_dev_printk(descriptor, &ibdev->dev, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } =20 va_end(args); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 ED452ECAAD5 for ; Sun, 4 Sep 2022 21:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235640AbiIDVpg (ORCPT ); Sun, 4 Sep 2022 17:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235869AbiIDVoI (ORCPT ); Sun, 4 Sep 2022 17:44:08 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8863C303DB for ; Sun, 4 Sep 2022 14:42:48 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5653041iod.8 for ; Sun, 04 Sep 2022 14:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=F+IqvxQINaymRL+MafidUTbGzpHBkq2RsFapBWAQydg=; b=N0zhsOBdmXSpqdVIM7Dax53vYiJTKsqF6x9qw6PLO/aFCYoOS0opwP1W/5aTypbefh thcPTdmgHjCwAVeFNHFjBjHzjInzGS+YiXXOrz8p9PMclYRxe1LfcB0y1XUcNo/5BytA YEnLhw/gfAr8rG8KozwOaV+lYe7NXyUjy4JmDGJ94WvqWQr15EnP0FR45EtCb9sixA2H 5PVujoc2/62tw2Rf6QVixL1umMf0g4g0KWpbNPggi2SaHbsUt9ALitBx9exeU1qkh3CT vHElW8wRlXwjNWiUeoUytlqPPgsAovjsIKN3Z9gCGdsWoXgjj0apzjKHP7jxrbSbW8d4 SIYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=F+IqvxQINaymRL+MafidUTbGzpHBkq2RsFapBWAQydg=; b=3Q6QutCUPnMjb7WitR2N3iF/z5Hi7OmUclNAb9YkJHCeoHHVzb2bY8UsHpjXLBLIHq DCj11QemdHDE1GXq1CzAtxdvxyv3gFDslZ3j/BZ8MhX2suk3WkOXysTpe9DpyBhCYIk3 U0Okca/uVSuxCD1HXXWcVIkU1Ymbyvwz0+eq82SzzONwHhdkZlhbN2qXk0ODLXkn74ep XfAD5ok5M4Hq7toZV3XBm2EB54aYEyvTFn9L4dTXizUl3XDb43IV86Evis6roVe7mm0T o3JwneoTLchtMMO98ChOikR52Rwaf5AlKb+0tBIQj69uqlenyUNqIvUG3EhBydzbmP2e yJDA== X-Gm-Message-State: ACgBeo3foEF8DcbYwS3sp3BxFm2SsW4zt1DsyTApyIJsb8xEcSJzermB Nv78UxA2Mtx2GSDbdJ4kzk8= X-Google-Smtp-Source: AA6agR6wneRG7yCu0WnhzdrmY46L82HWUk9b8e+ZYvtbU/eRsNK3PLQqrk215dPJggzpSd7jRHChZQ== X-Received: by 2002:a5e:c319:0:b0:68b:2683:8e26 with SMTP id a25-20020a5ec319000000b0068b26838e26mr17614839iok.129.1662327767546; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:47 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 39/57] dyndbg/drm: POC add tracebits sysfs-knob Date: Sun, 4 Sep 2022 15:41:16 -0600 Message-Id: <20220904214134.408619-40-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" clone DRM.debug interface to DRM.tracebits: ie map bits to drm-debug-categories, except this interface enables messages to tracefs, not to syslog. 1- we reuse the class-map added previously. this reflects the single source of both syslog/trace events 2- add a 2nd struct ddebug_classes_bitmap_param refs 1, reusing it. flags =3D "T", to enable trace-events on this callsite. 3- module_param_cb([2]) - does the sysfs part Signed-off-by: Jim Cromie Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_print.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index c50edbf443d3..75d0cecd7e86 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -45,6 +45,9 @@ unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); =20 +unsigned long __drm_trace; +EXPORT_SYMBOL(__drm_trace); + MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a deb= ug category.\n" "\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n" "\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n" @@ -77,6 +80,13 @@ static struct ddebug_class_param drm_debug_bitmap =3D { .map =3D &drm_debug_classes, }; module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); + +static struct ddebug_class_param drm_trace_bitmap =3D { + .bits =3D &__drm_trace, + .flags =3D "T", + .map =3D &drm_debug_classes, +}; +module_param_cb(tracecats, ¶m_ops_dyndbg_classes, &drm_trace_bitmap, 0= 600); #endif =20 void __drm_puts_coredump(struct drm_printer *p, const char *str) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 61018ECAAD5 for ; Sun, 4 Sep 2022 21:45:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236099AbiIDVpj (ORCPT ); Sun, 4 Sep 2022 17:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235217AbiIDVoT (ORCPT ); Sun, 4 Sep 2022 17:44:19 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163E5303DD for ; Sun, 4 Sep 2022 14:42:48 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id a9so3885569ilh.1 for ; Sun, 04 Sep 2022 14:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Rm4xzfpSQrPPtx8VSoa62A66wbCtcyyvqJRRKDZL61w=; b=Ztu8i1PzYXrrBIVkF2DTluW99gf/zMexybwuV049ePkV9na4V8i7w1QCN6zxYTzykr gWJHK2OLUi+Boeahy3lUbVhZndOD18gcDpF5to3yTILayNYKZ4bgsx/ilM5F1cusady1 0detNR1/ZaP4mXE3QDeOJN3Ua6Em4qgA+SRN1gU8L2pJeKLHb8ULMMjczUSsBwLn+TZH Fl7fIusVg1NIux1kE9DvOselusKgLkhoeoH81jzxT3c3JfNvfJFAW9TRgtjIQDm0ayCV KSsA2K0pqsDfZfpv6h3kPC2JEitI9SjrLzqxJmiXXq4ZsLTfwXk71OymdVL0+ct6JMQE 1v3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Rm4xzfpSQrPPtx8VSoa62A66wbCtcyyvqJRRKDZL61w=; b=y8XCx1na1sitUlZ1EAZU5caINnillSuJN0qLMz/gFXyz3Pi91JMPsMWzGefzfEuzaH RL7T5P8BpuLORytcY/2XRpxvkrF7osFEWjcqqmOcTYinThltpTZr8pWPpdx3AGM+CCfY ElWAwjgfJI6IuG5Yv9/uktExHN9Y4nJqAgqELE7KvzOdtBUz7TqAcQaT95qyr/xFr6AY IzXeffbaiTSJcFauRaFUXwVf/Gz/3P/rlFqeq/N26pt5ZueOR2n9IO6XhstpYZfiHDMB v5aMSFqpJY64sAk8H6BWGbAYj4jIwJr4P37W3BvLDj3ykMm7hwan9XadD443vmMHwvb4 wlLw== X-Gm-Message-State: ACgBeo2ICU2QQH2sxXggbrwa1SXW1qdAwzcFuKeQagtxQjSLhLqmUztS 9wd6Mh3G6sB+pWw96VPHqyU= X-Google-Smtp-Source: AA6agR7t0GY+1q5uTZb5We3a9PhT8Nv5YKHpftI6ooRy+sYIdJ0LN14CtXVDeZuK1HJNkFdvbQHENw== X-Received: by 2002:a92:dc8c:0:b0:2e9:469f:e5a3 with SMTP id c12-20020a92dc8c000000b002e9469fe5a3mr23264515iln.251.1662327768480; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 40/57] dyndbg: abstraction macros for modname,function,filename fields Date: Sun, 4 Sep 2022 15:41:17 -0600 Message-Id: <20220904214134.408619-41-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" The .data table built of struct _ddebug[]s has about 40% repetition in the "decorator" fields: modname, function, filename. The real fix is to "normalize the db", but 1st we need a layer of accessor macros, giving us just one field deref to alter later. So: define 3 field-abstraction macros: desc_{modname,function,filename}(desc). replace all raw field refs in lib/dynamic_debug.c with them. The macros protect against NULL pointer derefs, substituting "_na_" otherwise. This provides a generic guard, opening options to drop the contents of __dyndbg_sites[] opportunistically, and trim kernel/module data. DRM, which could use only .class_id to control drm.debug, could drop them. The 3 macros use a common foundation: _ddebug_map_site(), which will adapt to follow the coming table-split. Also change field names; adding '_' prefix to insure that bare field-refs are found and fixed. Most field uses get the macros, except for dynamic_debug_init(), which will need to follow the rearrangements. NOTE: macros are private, not currently for general use. trace/events/dyndbg.h was a candidate to use these macros, for which I included the header. On rethink, these macros are wrong abstraction for tracing; better to expose a dynamic_prefix_emit(1) flavor, and use it in TP_printk to "decorate" enabled trace-logs like it does for sys-logs. So this patch removes the raw field-refs rather than use the macros. I left the include to mark the intention to use privatish interfaces, see if it draws objections or compile errs. [1] fills caller provided char-buffer, perhaps not ideal for tracefs. A fixed max-size-possible per-callsite (or globally) is practical, but the struct _ddebug_site * val is probably best; it refs a prdbg's site-rec of a builtin or loadable module, which is unique over the pertinent lifetime, and has all the info. WAG,TLDR: "decorating" could be defered until `cat trace`, modulo loadable sites[] data being needed to render after module is unloaded. no functional changes. Signed-off-by: Jim Cromie TP-print-dont-use-desc-foo --- include/linux/dynamic_debug.h | 12 ++++++------ include/trace/events/dyndbg.h | 7 +++---- lib/dynamic_debug.c | 37 ++++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 04f49df308a7..e04f5b0a31e2 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -18,9 +18,9 @@ struct _ddebug { * These fields are used to drive the user interface * for selecting and displaying debug callsites. */ - const char *modname; - const char *function; - const char *filename; + const char *_modname; + const char *_function; + const char *_filename; const char *format; unsigned int lineno:18; #define CLS_BITS 6 @@ -166,9 +166,9 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name =3D { \ - .modname =3D KBUILD_MODNAME, \ - .function =3D __func__, \ - .filename =3D __FILE__, \ + ._modname =3D KBUILD_MODNAME, \ + ._function =3D __func__, \ + ._filename =3D __FILE__, \ .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h index e19fcb56566c..2997289c0e3f 100644 --- a/include/trace/events/dyndbg.h +++ b/include/trace/events/dyndbg.h @@ -6,6 +6,7 @@ #define _TRACE_DYNDBG_H =20 #include +#include =20 /* capture pr_debug() callsite descriptor and message */ TRACE_EVENT(prdbg, @@ -32,8 +33,7 @@ TRACE_EVENT(prdbg, __get_str(msg)[len] =3D 0; ), =20 - TP_printk("%s.%s %s", __entry->desc->modname, - __entry->desc->function, __get_str(msg)) + TP_printk("%s", __get_str(msg)) ); =20 /* capture dev_dbg() callsite descriptor, device, and message */ @@ -64,8 +64,7 @@ TRACE_EVENT(devdbg, __get_str(msg)[len] =3D 0; ), =20 - TP_printk("%s.%s %s", __entry->desc->modname, - __entry->desc->function, __get_str(msg)) + TP_printk("%s", __get_str(msg)) ); =20 #endif /* _TRACE_DYNDBG_H */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0870e939f255..5a22708679a7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -167,6 +167,15 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons return NULL; } =20 +static inline struct _ddebug_site * _ddebug_map_site(const struct _ddebug = *desc) +{ + return desc->site; +} +#define _desc_field(desc, _fld) (desc ? (_ddebug_map_site(desc)->_fld) : "= _na_") +#define desc_modname(desc) _desc_field(desc, _modname) +#define desc_function(desc) _desc_field(desc, _function) +#define desc_filename(desc) _desc_field(desc, _filename) + #define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and @@ -212,16 +221,16 @@ static int ddebug_change(const struct ddebug_query *q= uery, =20 /* match against the source filename */ if (query->filename && - !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, desc_filename(dp)) && !match_wildcard(query->filename, - kbasename(dp->filename)) && + kbasename(desc_filename(dp))) && !match_wildcard(query->filename, - trim_prefix(dp->filename))) + trim_prefix(desc_filename(dp)))) continue; =20 /* match against the function */ if (query->function && - !match_wildcard(query->function, dp->function)) + !match_wildcard(query->function, desc_function(dp))) continue; =20 /* match against the format */ @@ -257,9 +266,9 @@ static int ddebug_change(const struct ddebug_query *que= ry, static_branch_enable(&dp->key.dd_key_true); } #endif - v4pr_info("changed %s:%d [%s]%s %s =3D> %s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + v4pr_info("changed %s:%d [%s]%s %s to %s\n", + trim_prefix(desc_filename(dp)), dp->lineno, + dt->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags =3D newflags; @@ -836,10 +845,10 @@ static char *__dynamic_emit_prefix(const struct _ddeb= ug *desc, char *buf) pos_after_tid =3D pos; if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", - desc->modname); + desc_modname(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", - desc->function); + desc_function(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) pos +=3D snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); @@ -1241,8 +1250,8 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) } =20 seq_printf(m, "%s:%u [%s]%s =3D%s \"", - trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + trim_prefix(desc_filename(dp)), dp->lineno, + iter->table->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\""); @@ -1504,12 +1513,12 @@ static int __init dynamic_debug_init(void) } =20 iter =3D iter_mod_start =3D __start___dyndbg; - modname =3D iter->modname; + modname =3D iter->_modname; i =3D mod_sites =3D mod_ct =3D 0; =20 for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { =20 - if (strcmp(modname, iter->modname)) { + if (strcmp(modname, iter->_modname)) { mod_ct++; di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; @@ -1518,7 +1527,7 @@ static int __init dynamic_debug_init(void) goto out_err; =20 mod_sites =3D 0; - modname =3D iter->modname; + modname =3D iter->_modname; iter_mod_start =3D iter; } } --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 40117C6FA86 for ; Sun, 4 Sep 2022 21:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235947AbiIDVpq (ORCPT ); Sun, 4 Sep 2022 17:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235616AbiIDVoW (ORCPT ); Sun, 4 Sep 2022 17:44:22 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043E9303E2 for ; Sun, 4 Sep 2022 14:42:49 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id h78so5628555iof.13 for ; Sun, 04 Sep 2022 14:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=PMiB8rnsUQPju8onoOnVuDb8slfA1llOhn686i4QNvM=; b=DhIMTIMuvABAe+Hzd9rSSdXTPFxO/+q5Cm+yD63nUFOoFZNB03XM5qcqbF65z2kAOS pOUh728z1/u5qw1UKGnSRJFv2eNFfmUNZA9Pr33CoridKkhzO3KHRwUivKPaXWPPvzes FIn2lGCuNdFOJuALDBDiHixeO3RwF3TScUe2Ec35/WnTE4/rWPnUBReM+TT+MGZi7UiP 8A62RK0snL+KInTqxx0ss+pLhLEPD3uKBa3QC0t9/c7eRXT2KH3ogGVGBr2JOf5Y5Y/C 0o98zKU/C2FCWYR/3SSsXNl5sS/BSOlPYUBKDAmomW9+bzVniS+aWFgMzIAaLAguaPjr OsXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=PMiB8rnsUQPju8onoOnVuDb8slfA1llOhn686i4QNvM=; b=m20xHcPVMP2LtqP5uqeHDyMCk59i1+XcN1UR193jmtrCqrXtR2WUU2jeVk4c27QDGd SlE5IiCVHgAr7scW+qc2wVB6aYxlGsGtyNDyXG11c6f37g1B7usQzWG9HjZUm4aQ0boF 9bX043U8r+CrtldKKchHnCa3HhgQQHWF/6eQzEpASAHTb74NNJKX4HbPQj+aoeGJsnWP Pj/X8f1iM8xs/EE0OM3QQE7nXkTrMuG4SAHdnKxEVVk3fnfwJSt81VjkRjLGWoFqz3Uo 365pXojinNLke/kmHzbkSg/foYG+5O4xx5myr3fdbMdRKDBV6TdTukh1OTTulqvx2G9n YOqw== X-Gm-Message-State: ACgBeo0lLUn/kY0zN4IyFU/cSwoDHz1DV0Jx7rwEc3u/fqwAzq00NxrL xW1shZlQzGFvIMTAJnHADU4= X-Google-Smtp-Source: AA6agR6INbA193jAVbdMDiyXOsWP4jHkkUZzNXaQ1TrC3Xmxtj8ovg2eyPEHbVIhKzd3D9P88Hc01A== X-Received: by 2002:a6b:7b41:0:b0:689:2648:9ce9 with SMTP id m1-20020a6b7b41000000b0068926489ce9mr21451384iop.185.1662327769373; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:49 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 41/57] dyndbg: split repeating columns to new struct _ddebug_site Date: Sun, 4 Sep 2022 15:41:18 -0600 Message-Id: <20220904214134.408619-42-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 has 3 RO-data fields: _module, _file, _function, which have significant repetition in the builtins: 4222 unique records / 8920 callsites on a recent laptop build. Thats just 47% unique, on 24/56 of the unitary record. The quick path to excising this redundancy is: 1- split the table in 2, link 1st to 2nd (done here) 2- de-duplicate the 2nd table. (soon) So split struct _ddebug, move the 3 fields to a new struct _ddebug_site, and add a pointer from _ddebug to _debug_sites. The lineno field stays in _ddebug, so all _sites in a fn are identical. The new ptr from _ddebug -> _ddebug_site increases memory footprint, until step 2 is completed, at which point: old =3D 56 * 8920 new =3D (56-24+8) * 8920 + 24 * 4222 IE: DB<2> p 56 * 8920 499520 DB<3> p 40*8920 + 24 * 4222 458128 Thats 41392 saved, or ~8.3% Further, the site pointer is just temporary scaffolding: - descriptors are in a vector. - new desc._idx field (from spare bits) can get us to 0. set during _init, not by linker - add a header record in front of vector (.gnu.linkonce.dyndbg*) point it up to struct dyndbg_info - dyndbg_info has .sites - same desc._idx gets us sites[._idx] - new desc._map field, gives sites[._map] this allows de-duplication and packing. Once that is done, the savings increases: DB<7> p (56 * 8920) - (((56-24) *8920) + 24*4222) 112752 saved, or 22% STEP 1: dynamic_debug.h: This cuts struct _ddebug in half, renames the top-half to _ddebug_site, keeps __align(8) for both halves. Adds a forward decl for a unified comment for both halves, and added _ddebug.site field to point at a site record. Rework DEFINE_DYNAMIC_DEBUG_METADATA_CLS macro to declare & initialize the 2 static/private struct vars together, and link them together. It places each struct into its own section, so the linker packs 2 parallel arrays, and links them like a ladder. struct _ddebug_info is extended to track _ddebug_site[] just like it does for _ddebug[] and _ddebug_classes[]. The accessor macros desc_{module,filename,function} follow the field-moves with added '->site->' references, and return "_nope_" or "_na_" if the desc or site are null. This makes those ptrs nullable, and their referents recoverable (nothing tries to use this yet). NB: the "_na_" is undone temporarily later, for dev shortcut. Also add const to lineno field. It is set by compiler. In struct ddebug_table, add struct _ddebug_site *sites, to treat new vector just like the module's _ddebug[]s (its __dyndbg section, for loadable mods). While we don't need it now, we will need it to de-scaffold (drop the _ddebug.site). dynamic_debug.c: extern declarations of the section start/end symbols named and initialized in vmlinux.lds.h dynamic_debug_init(): Initialize global builtin_state from initialized cursor var. Trying to do so statically gave: "error: initializer element is not computable at load time" Check (num-descs =3D=3D num-sites), and quit early otherwise. This is an important precondition, w/o it, we cannot really continue confidently. I inadvertently created the situation by having __used on 1/2 of the _ddebug{,_site} pair created by DECLARE_DYNAMIC_DEBUG_METADATA; this created ~70/ extra site records. This "worked", but was unnerving until I tracked it down. Add site iterator & site_mod_start marker, recapping iter/_mod_start. Inside the main loop, validate (site =3D=3D iter->site). This is the full/proper precondition for the expected section contents and inter-linkage; the (num-descs =3D=3D num-sites) check is just a quick necessary-but-not-sufficient version of this. NOTE: this check could be a BUG_ON, esp as any mismatch should have been caught by the quick-check. ATM it is just a pr_err; Id prefer to see errors rather than crashes. Demotes iter->site by replacing iter->site->_module by site->_module. This is a small step towards dropping it entirely. vmlinux.lds.h: add __dyndbg_sites section and start/end symbols, with the same align(8) and KEEP as used in the __dyndbg section. kernel/module/main.c:load_info(): Initialize _ddebug_info.sites with new section address. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 37 +++++++++++++++++++++--------- kernel/module/main.c | 2 ++ lib/dynamic_debug.c | 38 +++++++++++++++++++++++-------- 4 files changed, 60 insertions(+), 20 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 9b8bd5504ad9..1e7ee65e8591 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -351,6 +351,9 @@ __start___dyndbg =3D .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg =3D .; \ + __start___dyndbg_sites =3D .; \ + KEEP(*(__dyndbg_sites)) \ + __stop___dyndbg_sites =3D .; \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e04f5b0a31e2..dcc0e8cc2ef0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -9,20 +9,28 @@ #include =20 /* - * An instance of this structure is created in a special - * ELF section at every dynamic debug callsite. At runtime, - * the special section is treated as an array of these. + * A pair of these structs are created in 2 special ELF sections + * (__dyndbg, __dyndbg_sites) for every dynamic debug callsite. + * At runtime, the sections are treated as arrays. */ -struct _ddebug { +struct _ddebug; +struct _ddebug_site { /* - * These fields are used to drive the user interface - * for selecting and displaying debug callsites. + * These fields (and lineno) are used to: + * - decorate log messages per _ddebug.flags + * - select callsites for modification via >control + * - display callsites & settings in `cat control` */ const char *_modname; const char *_function; const char *_filename; +} __aligned(8); + +struct _ddebug { + struct _ddebug_site *site; + /* format is always needed, lineno shares word with flags */ const char *format; - unsigned int lineno:18; + const unsigned lineno:18; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) @@ -58,7 +66,7 @@ struct _ddebug { struct static_key_false dd_key_false; } key; #endif -} __attribute__((aligned(8))); +} __aligned(8); =20 enum class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, @@ -118,8 +126,10 @@ struct ddebug_class_map { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct _ddebug_site *sites; struct ddebug_class_map *classes; unsigned int num_descs; + unsigned int num_sites; unsigned int num_classes; }; =20 @@ -137,6 +147,7 @@ struct ddebug_class_param { int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); =20 extern int ddebug_remove_module(const char *mod_name); + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -164,11 +175,15 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const char *fmt, ...); =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ - static struct _ddebug __aligned(8) \ - __section("__dyndbg") name =3D { \ + static struct _ddebug_site __aligned(8) \ + __section("__dyndbg_sites") name##_site =3D { \ ._modname =3D KBUILD_MODNAME, \ - ._function =3D __func__, \ ._filename =3D __FILE__, \ + ._function =3D __func__, \ + }; \ + static struct _ddebug __aligned(8) \ + __section("__dyndbg") name =3D { \ + .site =3D &name##_site, \ .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ diff --git a/kernel/module/main.c b/kernel/module/main.c index 6aa6153aa6e0..5a80f18f8e4a 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2113,6 +2113,8 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) =20 info->dyndbg.descs =3D section_objs(info, "__dyndbg", sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); + info->dyndbg.sites =3D section_objs(info, "__dyndbg_sites", + sizeof(*info->dyndbg.sites), &info->dyndbg.num_sites); info->dyndbg.classes =3D section_objs(info, "__dyndbg_classes", sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a22708679a7..f1f354efed5a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -44,6 +44,8 @@ =20 extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct _ddebug_site __start___dyndbg_sites[]; +extern struct _ddebug_site __stop___dyndbg_sites[]; extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 @@ -52,6 +54,7 @@ struct ddebug_table { const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct _ddebug_site *sites; }; =20 struct ddebug_query { @@ -1487,20 +1490,27 @@ static int __init dynamic_debug_init_control(void) =20 return 0; } +fs_initcall(dynamic_debug_init_control); + +static struct _ddebug_info builtin_state; =20 static int __init dynamic_debug_init(void) { struct _ddebug *iter, *iter_mod_start; + struct _ddebug_site *site, *site_mod_start; int ret, i, mod_sites, mod_ct; const char *modname; char *cmdline; =20 struct _ddebug_info di =3D { .descs =3D __start___dyndbg, + .sites =3D __start___dyndbg_sites, .classes =3D __start___dyndbg_classes, - .num_descs =3D __stop___dyndbg - __start___dyndbg, - .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, + .num_descs =3D __stop___dyndbg - __start___dyndbg, + .num_sites =3D __stop___dyndbg_sites - __start___dyndbg_sites, + .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, }; + builtin_state =3D di; =20 if (&__start___dyndbg =3D=3D &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1511,28 +1521,40 @@ static int __init dynamic_debug_init(void) ddebug_init_success =3D 1; return 0; } - + if (di.num_descs !=3D di.num_sites) { + /* cant happen, unless site section has __used, desc does not */ + pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_site= s); + return 1; + } iter =3D iter_mod_start =3D __start___dyndbg; - modname =3D iter->_modname; + site =3D site_mod_start =3D __start___dyndbg_sites; + modname =3D iter->site->_modname; i =3D mod_sites =3D mod_ct =3D 0; =20 - for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { + + if (site !=3D iter->site) + /* XXX: also cant happen, but lets see how it plays */ + pr_err("linkage problem: site !=3D iter->site\n"); =20 - if (strcmp(modname, iter->_modname)) { + if (strcmp(modname, site->_modname)) { mod_ct++; di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; + di.sites =3D site_mod_start; ret =3D __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; =20 mod_sites =3D 0; - modname =3D iter->_modname; + modname =3D site->_modname; iter_mod_start =3D iter; + site_mod_start =3D site; } } di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; + di.sites =3D site_mod_start; ret =3D __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; @@ -1566,5 +1588,3 @@ static int __init dynamic_debug_init(void) /* Allow early initialization for boot messages via boot param */ early_initcall(dynamic_debug_init); =20 -/* Debugfs setup must be done later */ -fs_initcall(dynamic_debug_init_control); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 CFCC5C6FA86 for ; Sun, 4 Sep 2022 21:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235332AbiIDVpu (ORCPT ); Sun, 4 Sep 2022 17:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235911AbiIDVoW (ORCPT ); Sun, 4 Sep 2022 17:44:22 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D031303F0 for ; Sun, 4 Sep 2022 14:42:50 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id r7so3867457ile.11 for ; Sun, 04 Sep 2022 14:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=FwCkCkIuXLu91UbfHdZYDrwIlB+NdbMmm6xvFEQjyUU=; b=RYCkLD0FCIpFqOKsWlElNLu5l8dGxBEngWLZ18ylxy41NG+Qaj5BZrfDLn5uvMF2xo VwhlrGgEcVvma9ILcXWr/GE6ZBBnf6OlwUb6biRCydxCUq3oKWxUcQ2J/MNFVAYtgIqI Xb9AS9cv7UVTnWGcrEevePRMFxuCn/ulpHIE9HVRP/TdyoUsfjS6AF5uOoRVUuWr8vqg 4VPmeMzC0eaHliSJUHUrAHWH8r+EM3TH96DE9T2refzCG1P0lmBG3updh9CAqjc0qY/W hrGlSxiGyrArtn+T2krt991mxFZxt+CbQR1NKOfrS5F4tEvIbplkb8gHJGHTFjrzcpA+ KgHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=FwCkCkIuXLu91UbfHdZYDrwIlB+NdbMmm6xvFEQjyUU=; b=mLTr09jo2o29n3WoWBOKFv/zXTUmEFVsFunqIcPl/c3hsqstT/xFJpqDYFEZNhjypP suHidORsPxnV0COU6yNtgTTxODdtOTLEfjPJSbIC8euAobnmMorizEIQHGQDq6UGjPbc 4xB4p2DsVQl6bzPMWnAR+bhGoMF2GunsQIjl3zxFVZJhnEBDnwb8dDebYCuDGssojZ92 X2frJjL9eRX+kVjAcoDvRL5fp1hrLb9wI1IWYQuXz8oTMPqQJP34zzujowYPmq5ph0Yj IYBKNrX3Dv6UL7L1JfqNEveunOwO+IGHeaQAlDYTXTFagR+ejnhRJmQq5u11EdXbduak 2Piw== X-Gm-Message-State: ACgBeo0g6+qc8BHhtRNd/LblDt4b9Gy4CRVJjy86EVL1CHmvUdt4UYdG TmLPBGGyXw97gG6GoeDcAyQEZQcRw14= X-Google-Smtp-Source: AA6agR6xgn/MlYOoGIi2AaB+WdvqdQ5gYdviqjuZlblXZSMV6/iv7FJf6NsVsV/Y3NPrVDl1/Xe7dA== X-Received: by 2002:a05:6e02:1909:b0:2f0:a558:7113 with SMTP id w9-20020a056e02190900b002f0a5587113mr4717553ilu.55.1662327770538; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:50 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 42/57] dyndbg: shrink lineno field by 2 bits Date: Sun, 4 Sep 2022 15:41:19 -0600 Message-Id: <20220904214134.408619-43-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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.lineno int:18 is bigger than we need: git ls-files | grep -P '\.c$' | xargs wc -l | sort -n | tail -n20 ... 22553 drivers/scsi/lpfc/lpfc_sli.c 28593 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c 46300 drivers/net/wireless/realtek/rtw88/rtw8822c_table.c 48725 drivers/net/wireless/realtek/rtw89/rtw8852a_table.c 1386670 total ... All but one of the biggest of these are just .data tables, and have no code, so would never need a pr_debug(). drivers/scsi/lpfc/lpfc_sli.c, at ~22k lines, would be encodable with 15 bits, but lets just shrink to 16 bits for now. RFC: Is this tantamout to a "don't write files with >64kloc" policy ? Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dcc0e8cc2ef0..c05148dab367 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -30,7 +30,7 @@ struct _ddebug { struct _ddebug_site *site; /* format is always needed, lineno shares word with flags */ const char *format; - const unsigned lineno:18; + const unsigned lineno:16; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 C88B5ECAAD5 for ; Sun, 4 Sep 2022 21:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236155AbiIDVpy (ORCPT ); Sun, 4 Sep 2022 17:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235918AbiIDVoX (ORCPT ); Sun, 4 Sep 2022 17:44:23 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E561303F8 for ; Sun, 4 Sep 2022 14:42:51 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so5653100iod.8 for ; Sun, 04 Sep 2022 14:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NJv9roPGKnaMDb9Znbql4uMkywSuYywvt+PY8YTJJ6Q=; b=HhTTMF5cOvfQxdSZmrczdsrS6DcF+dXJ4prb+yfBwfEsbsV/l8CegD6fvYMQv45pnL Lf3KTZjPRQvn2olpOHp+kmaJ4oJHgCOfWsY3FUgvHVffh1+zc352thh9xXYlfcfH2jPd WHUvSV9qo/7iWc+93e5dgxNXp0BN7YD7iPq5mLd4Lp375zL2U7/g25FtP4jW0poI3Xy1 BVe/2TTcrNFKPS3ucVYZJTTlomYi+IjWKzHykbLWJSIGsDYsRKCTeZerO4ouyzRs9apT ceUwHG+xksDXgJwO4SLD6ULb2vBG1qGluX6Fx9greabj7IG3dRz5uT820IrbROFlv4PW vTYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=NJv9roPGKnaMDb9Znbql4uMkywSuYywvt+PY8YTJJ6Q=; b=HqO74xy7VObjPWt0TOPO8AjwSrLcuwQOmbrJXskySc2jcCX2Cw0QnuGOYwlkXXv4Qo 0R/cfidQXokdQNTgqgtaS0ruNai7W8FLRMz6enNVNIPUfXEYwyhIQyGj+CTvoX9exIvn BlIbNzEZttCXCWGXt7+0lrvw/v8JLKBbFgRrhqjXpgS03H+hAsEltri6fbwb1ckcNCTB L9aDpEWJV+jCsFQhFnzbXIjMjEeXs2GmdUFbaLWzv99KtAnDDuSj5BplfFKVo43/UxGV rtBuLrO+Mhw3rxRtCDZ3mUHMb5yKanRz0ZFX+YXuotckg+tz9FT8NZNwVBcrpCutn6Py L2kA== X-Gm-Message-State: ACgBeo0Wk3JsX/k5PnLbdUJWyN16Dobg5J11BIndbSwXhQwWBmZBq1yO Ut/ERZJxNNzbc4Cc7g7xe+g= X-Google-Smtp-Source: AA6agR4MY52KR1Bw1Ot+iK3sIpDRwZTCG1xc7RrkCdtaGzSPJBBL/OV4txxLoofl2HiIy/rTScLO/A== X-Received: by 2002:a6b:1543:0:b0:688:6fcb:fa76 with SMTP id 64-20020a6b1543000000b006886fcbfa76mr21261370iov.60.1662327771514; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:51 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 43/57] dyndbg: add _index,_map to struct _ddebug Date: Sun, 4 Sep 2022 15:41:20 -0600 Message-Id: <20220904214134.408619-44-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" We now have 2 vectors of data: (__dyndbg, __dyndbg_sites), known to be equal-length, with _ddebug.site connecting them, like rungs on a ladder. In order to drop _ddebug.site, we need to replace the absolute ptr with a cheap relative-address computation: struct _ddebug_site *site =3D _ddebug_map_site(desc); 1st step: (done here) add ._index, ._map fields, and initialize them in __debug_add_module() to N (and =3D each other), where N is each element's position in the builtins (or loaded-module). Then _ddebug_map_site(desc) can compute &descs[0], and then use container_of() to go up 1 struct. RFC: Next steps: (outlined here, not done): 1. UPLINK: Define 2 new header structs, with _uplink fields, pointing at _ddebug_info: struct _ddebug_site_hdr { union { struct _ddebug_info _uplink*; struct _ddebug_site __; // sizeof this }; }; struct _ddebug_hdr { union { struct _ddebug_info _uplink*; struct _ddebug __; // sizeof this }; }; the union forces the allocation to be the bigger of the 2, with the expectation that the pointer will always fit. 2. Reserve a record in front of the __dyndbg* sections. can be done in {module,vmlinux}.lds.h, something like: SECTIONS { __dyndbg_sites : ALIGN(8) { *(.gnu.linkonce.dyndbg_site) *(__dyndbg_sites) } __dyndbg : ALIGN(8) { *(.gnu.linkonce.dyndbg) *(__dyndbg) } } KEEP( *(.gnu.linkonce.__dyndbg_site) *(__dyndbg_sites)) 3. specialize DYNAMIC_DEBUG_METADATA_CLS as DYNAMIC_DEBUG_TABLE. This special macro version creates header records, and puts them into .gnu.linkonce section. Unusually (uniquely?), it is tacitly invoked by dynamic_debug.h on behalf of all printk.h includers. This can result in multiple "declarations" in the same scope, so macro uses __weak and/or __unused to suppress linkage & errors. This created mumble-RELATIVE linkage errors in a few parts of the kernel, I worked around this by just suppressing the declaration if cflags includes -DDYNDBG_NO_TABLE. The up-link is init'd in 2 cases: The file static struct _ddebug_info builtins is initialized by dynamic_debug_init(), with the 3 ELF sections addresses+lengths composing the builtin dyndbg-state. It will be able to also initialize the header.UPLINK fields, as long as the storage space is available. Then rel_map() can rely upon it to provide the &site ref for a callsite's desc*, if it is enabled. Then at runtime (assuming initialization is correct): - use _index to get &descs[0] - container-of gets .UPLINK to &dyndbg_info - info->sites[_index] - replaces .sites - info->sites[_map] - allows de-duplicated vector position. M --- include/linux/dynamic_debug.h | 3 +++ lib/dynamic_debug.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index c05148dab367..268e903b7c4e 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -31,6 +31,8 @@ struct _ddebug { /* format is always needed, lineno shares word with flags */ const char *format; const unsigned lineno:16; + unsigned _index:14; + unsigned _map:14; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) @@ -60,6 +62,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_DEFAULT 0 #endif unsigned int flags:8; + #ifdef CONFIG_JUMP_LABEL union { struct static_key_true dd_key_true; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f1f354efed5a..506a7e2e59d6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1344,6 +1344,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, const char *modname) { struct ddebug_table *dt; + int i; =20 v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); if (!di->num_descs) { @@ -1364,6 +1365,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, */ dt->mod_name =3D modname; dt->ddebugs =3D di->descs; + dt->sites =3D di->sites; dt->num_ddebugs =3D di->num_descs; =20 INIT_LIST_HEAD(&dt->link); @@ -1372,6 +1374,12 @@ static int __ddebug_add_module(struct _ddebug_info *= di, unsigned int base, if (di->classes && di->num_classes) ddebug_attach_module_classes(dt, di->classes, di->num_classes); =20 + for (i =3D 0; i < di->num_descs; i++) { + di->descs[i]._index =3D base + i; + v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, + di->descs[i].site->_function, di->descs[i].lineno); + } + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 D02FCECAAD5 for ; Sun, 4 Sep 2022 21:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236164AbiIDVqB (ORCPT ); Sun, 4 Sep 2022 17:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235920AbiIDVoY (ORCPT ); Sun, 4 Sep 2022 17:44:24 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17E1C30558 for ; Sun, 4 Sep 2022 14:42:52 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e7so3873365ilc.5 for ; Sun, 04 Sep 2022 14:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=XI+lDDMQn1sJTAtsYXCSCZllHbtd6NOelDveTu16Um2gjNpYLeMWEPdHoroi+WJR56 k3PgFGFfbCQMOWVL4snzUZdVG+0cVnNUbfzxIKDLpC2iJQFgtJDx0CvxlhMkm+BuNHYM JOpIUa7zmX68L2U/aSqdB7PBn6ttAlQuheS/8IeqXuRiGsnhj+Lnu52QEV+kNwnXaeJD afRgsXfC7uf0JeApZ0fm2iin8GGl0CcHiwA1rJtoEcVABdqcneG5T6RL110N966WpM0o k1FblDutKG52QhJ9j7imv5ETtSUwiKKH84KtJRukZEMY244luC3ugPo7akWliqMbT+Gf LhEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=8QHK+ndyCc3ULphn7X+8yAfVmN/K8VHNeIKnKblt+9QGohCuUTqmIc0vAq71c+myWs CDHAR2vf3GlyK/GUGy4W/TE5etOlul3190KKv/gewOHsTT2TEgcc9AsD2TWd/xABQBi7 2PkKBXwKYMe9Im0yyZwb3fW1yi//LYuH3db/aO+rzlt0DP8NImumKqxyNBSCCZgqegnu cpvcAlKVTcAktF+XMhJCjYZ7gS+gx1Wn3nn+WteGl6Sn9nXNpffm1EIvdKrWyq/QEtrb 6Ie1EkWa98NjugP/8l4wBGhBgFvQFK9lGKNLcuOkvIO+RSVo40ccmK1PgP7ncivfw2Kr zChg== X-Gm-Message-State: ACgBeo0TeBlVKXdvMtNvKAkwRyT4tbhz0CNXKY8o28Kiz4sLKYZZtSzC 7/j1Gjg7/T18hDiwc3WdcJg= X-Google-Smtp-Source: AA6agR6GJ3545nMVzxW2kytCo0sZT1XkmI6FXzQ5bdXfVdq6vQh7IQ0VQLKX9DkPjjjN1oLgs/PH0w== X-Received: by 2002:a92:dcc2:0:b0:2e4:38f2:a9f6 with SMTP id b2-20020a92dcc2000000b002e438f2a9f6mr24500432ilr.130.1662327772508; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:52 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 44/57] dyndbg: extend __ddebug_add_module proto to allow packing sites Date: Sun, 4 Sep 2022 15:41:21 -0600 Message-Id: <20220904214134.408619-45-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" In order to actually reclaim useful blocks of memory, we need to repack the vector of redundant site recs, not just detect the duplicates. To allow this, extend __ddebug_add_module()s prototype by adding: struct _ddebug_site *packed_sites - address of empty "stack" unsigned int *packed_base - index of Top-of-Stack This allows dynamic_debug_init() to tell __ddebug_add_module() where to push the unique site recs it finds while de-duplicating, and to communicate the new TOS back for the next iteration. Since we know we are shrinking data, we can overwrite _ddebug_sites[], for both builtins, and loadable modules, via ddebug_add_module(). For ddebug_add_module(), which is called from kernel/module/main, the 2 args: reuse the module.sites vector, with a 0 offset. This will allow de-duplication of the local vector. No de-duplication is done yet, so no use of the stack. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 506a7e2e59d6..1b57e43e9c31 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1341,7 +1341,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, * and add it to the global list. */ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, - const char *modname) + const char *modname, struct _ddebug_site *packed_sites, + unsigned int *packed_base) { struct ddebug_table *dt; int i; @@ -1390,7 +1391,8 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, =20 int ddebug_add_module(struct _ddebug_info *di, const char *modname) { - return __ddebug_add_module(di, 0, modname); + unsigned int packed_base =3D 0; + return __ddebug_add_module(di, 0, modname, di->sites, &packed_base); } =20 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ @@ -1506,7 +1508,7 @@ static int __init dynamic_debug_init(void) { struct _ddebug *iter, *iter_mod_start; struct _ddebug_site *site, *site_mod_start; - int ret, i, mod_sites, mod_ct; + int ret, i, mod_sites, mod_ct, site_base; const char *modname; char *cmdline; =20 @@ -1550,7 +1552,8 @@ static int __init dynamic_debug_init(void) di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; di.sites =3D site_mod_start; - ret =3D __ddebug_add_module(&di, i - mod_sites, modname); + ret =3D __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; =20 @@ -1563,11 +1566,13 @@ static int __init dynamic_debug_init(void) di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; di.sites =3D site_mod_start; - ret =3D __ddebug_add_module(&di, i - mod_sites, modname); + ret =3D __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; =20 ddebug_init_success =3D 1; + vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in _= _dyndbg section\n", i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 D88F6C6FA82 for ; Sun, 4 Sep 2022 21:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235805AbiIDVqF (ORCPT ); Sun, 4 Sep 2022 17:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235930AbiIDVoZ (ORCPT ); Sun, 4 Sep 2022 17:44:25 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 729982F01E for ; Sun, 4 Sep 2022 14:42:54 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id r7so3867495ile.11 for ; Sun, 04 Sep 2022 14:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=2DUNNF4TyZPmUhIDyquoFTYgxu+2+I569ry9sz7h+V8=; b=mQmCZeXOpRyxBBvjbWVrCXsXx7gHTM8N/UQTvxQw6KuXSPexo1h3FD1ucxeyNJT+xH FCrl38VbY4XTggjAdID94f6qwWEzanDmr/mM2z9ppbD2bi++cdR0KFPdSDwIzMEdviuE T7rb8LW++Dfbale5om0KJkTeWydx42PLJzEbIaIRUShArRNRdH3N5bm567jsKFUoVvyE yNkTMgfq+82gXrYwwjc07JfVO8XbjrtDoDwJo5YA9vGk40vjd+duz80CzMwmFoM7NXkY 5BL2wv2zhIlR6b9Vj7PAu5z7gJVid5GmJmcNvK4vsfDXHVxr7IqKWTFLJl2NVdYInAfp DlOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=2DUNNF4TyZPmUhIDyquoFTYgxu+2+I569ry9sz7h+V8=; b=kDEQrpzPoAggHxQfaOLEpucylxTdXNDPgTNZWq5trsghEtp4yPCfSCXrMColDJLANp ZS5x/oeSsSjhk1TyaO2rWC4q1w85dypgjMkw1yO83cwjUsUZeTj8SJdPJHuudP1PucQF fCk1E/IY52S86nHtXqb4ml6os0M2wYpzguRC5TqageUnCKyMgVxjNYGkApSR4nnuIyPI 1LQHdM50G3ejgJvf8pJRU4YzyK4Ccikv42tdEE7Wv7oKkkYI6k2Ornwyu8g1FHSJwW4O v+9k28kJUEqJnCDLEEqmJqHs2+Z0VwruykeYjG/6k+p9ls9i2OzF6//0eK6SkwnQnK50 R6/Q== X-Gm-Message-State: ACgBeo1TXAXlUIeQi/B3brcuMb/d6LpmaU2ptbVVoNR/P68yq8B3av6j waY0ml4LntRligUQBV00TX8= X-Google-Smtp-Source: AA6agR7R7ppBFr3r3vC4WEGb4c102hUehmHvwf5LRPNlvppZUrjQH2NK84HPqLyTxmmaZ5tAXemtqA== X-Received: by 2002:a05:6e02:b2d:b0:2ec:b5eb:cd63 with SMTP id e13-20020a056e020b2d00b002ecb5ebcd63mr9305275ilu.291.1662327773546; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:53 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 45/57] dyndbg: de-duplicate sites Date: Sun, 4 Sep 2022 15:41:22 -0600 Message-Id: <20220904214134.408619-46-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" In __ddebug_add_module(), detect repeated site records (by function name changes), and push changes onto the stack/vector passed in from dynamic_debug_init(). For ddebug_add_module(), this transparently de-duplicates the local sites vector (passed in recently added stack-base, and offset 0). Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1b57e43e9c31..41c23ec979f4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1347,7 +1347,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, struct ddebug_table *dt; int i; =20 - v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + v3pr_info("add-module: %s.%d sites, start: %d\n", modname, di->num_descs,= base); if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1376,11 +1376,19 @@ static int __ddebug_add_module(struct _ddebug_info = *di, unsigned int base, ddebug_attach_module_classes(dt, di->classes, di->num_classes); =20 for (i =3D 0; i < di->num_descs; i++) { - di->descs[i]._index =3D base + i; - v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, - di->descs[i].site->_function, di->descs[i].lineno); - } =20 + if (di->descs[i].site->_function !=3D packed_sites[(*packed_base)]._func= tion) + memcpy((void *) &packed_sites[++(*packed_base)], + (void *) di->descs[i].site, sizeof(struct _ddebug_site)); + else + di->descs[i].site =3D &packed_sites[(*packed_base)]; + + di->descs[i]._index =3D i + base; + di->descs[i]._map =3D *packed_base; + + v3pr_info(" %d %d %s.%s.%d - %d\n", i, *packed_base, modname, + di->descs[i].site->_function, di->descs[i].lineno, *packed_base); + } mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1539,7 +1547,7 @@ static int __init dynamic_debug_init(void) iter =3D iter_mod_start =3D __start___dyndbg; site =3D site_mod_start =3D __start___dyndbg_sites; modname =3D iter->site->_modname; - i =3D mod_sites =3D mod_ct =3D 0; + i =3D mod_sites =3D mod_ct =3D site_base =3D 0; =20 for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 4D133ECAAD5 for ; Sun, 4 Sep 2022 21:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236202AbiIDVqO (ORCPT ); Sun, 4 Sep 2022 17:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235961AbiIDVor (ORCPT ); Sun, 4 Sep 2022 17:44:47 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C38122FFEA for ; Sun, 4 Sep 2022 14:42:55 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id b17so3907090ilh.0 for ; Sun, 04 Sep 2022 14:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=H201e8MxjjTWEZ5tX/zGuFZYDJJzszurQVKd2l3pA3I=; b=D5hVd8nWFbqRRkXkdpXZg4jOmNIfneov3THSYEMdUbvWnNl8Ne1nblV6QviWBWEGUg 2zMyuA7+zIirnNTNheDbR8jO4BMAl558jaE/EZxKR7+4koCB4I8+25Qe/kL8kQDF2Sho 9kDP0guazA6Lb4dxbqmjP5mGHurmuwBcuEMnuT3go1J7kq5fY3n584tb1fc7uABf1zin bHRRoPHY51s4kfci15ECF8xV6cBQQdgXuN4xECAP+d7JlGSq0KHUrs/nvlXcdLRTejSg qoOn5DPm1HXTaLGGK4GTAQmXYSy4e+uxehju05I6ClOoAcojZ1q7+CbFrz/rCbP0Qb06 zY5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=H201e8MxjjTWEZ5tX/zGuFZYDJJzszurQVKd2l3pA3I=; b=sLoCRiJ7cNIV8/AmeXVHmR2lt21+mRtkNBAN9WQiuRuZEKcHPWq+pqJJS4bHUNxmQ1 YhXZ8U0x2PTC5wIzkwo4nrKW/JslaIJEju/SabqmMPb+QQnq8/qgB2Oaj1lsB2D/3SMF oEBRALux4M5YYTSOKQBluRDnG3RyTFmCF2zF1lPzWthHIoW1OAZoji9ItWvuzof3/1hP GUVibBctKr7Dms5yLYFDnynxdWHz/VLVe0zsrpRFxQlUHwULEtxE7D/Si9Iy2C5HmCl4 UB5HaW/wDzp/rbsrPo1N+Ft5MusItWx3vfJbVgYk4feyc23lJ8JpFZL4RgcgsZqgHLRL a2Tw== X-Gm-Message-State: ACgBeo2ocjUdluGoqpqcKEv3E/frSD6fR6/UrQ6B6InO5zGqP18sgIzD 0aNHgoObssUtuCbgd8Do9CM= X-Google-Smtp-Source: AA6agR6fMqZIkP1YOEGKlykQp2j5uHw/5o/cVx4vJBZLBlUDQYIi3bLhanGx4QpvBqJmpIkwB4O4Nw== X-Received: by 2002:a05:6e02:19ca:b0:2df:68c:4a6d with SMTP id r10-20020a056e0219ca00b002df068c4a6dmr24133939ill.32.1662327774363; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 46/57] dyndbg: drop site-> in add-module, more needed Date: Sun, 4 Sep 2022 15:41:23 -0600 Message-Id: <20220904214134.408619-47-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" --- lib/dynamic_debug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 41c23ec979f4..059212df68f9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1347,7 +1347,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, struct ddebug_table *dt; int i; =20 - v3pr_info("add-module: %s.%d sites, start: %d\n", modname, di->num_descs,= base); + v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_des= cs, di->num_sites, base); if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1375,19 +1375,20 @@ static int __ddebug_add_module(struct _ddebug_info = *di, unsigned int base, if (di->classes && di->num_classes) ddebug_attach_module_classes(dt, di->classes, di->num_classes); =20 + //BUG_ON(di->num_descs !=3D di->num_sites); + for (i =3D 0; i < di->num_descs; i++) { =20 - if (di->descs[i].site->_function !=3D packed_sites[(*packed_base)]._func= tion) + if (di->sites[i]._function !=3D packed_sites[(*packed_base)]._function) + memcpy((void *) &packed_sites[++(*packed_base)], - (void *) di->descs[i].site, sizeof(struct _ddebug_site)); - else - di->descs[i].site =3D &packed_sites[(*packed_base)]; + (void *) &di->sites[i], sizeof(struct _ddebug_site)); =20 di->descs[i]._index =3D i + base; di->descs[i]._map =3D *packed_base; =20 - v3pr_info(" %d %d %s.%s.%d - %d\n", i, *packed_base, modname, - di->descs[i].site->_function, di->descs[i].lineno, *packed_base); + v3pr_info(" %d %d %s.%s.%d\n", i, *packed_base, modname, + packed_sites[*packed_base]._function, di->descs[i].lineno); } mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 2E162ECAAD5 for ; Sun, 4 Sep 2022 21:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236197AbiIDVqJ (ORCPT ); Sun, 4 Sep 2022 17:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235957AbiIDVoq (ORCPT ); Sun, 4 Sep 2022 17:44:46 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9702F02B for ; Sun, 4 Sep 2022 14:42:55 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k2so3867984ilu.9 for ; Sun, 04 Sep 2022 14:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jSafBWcpIkewykTpB/1313WvVuyh8yQZEmhBKVyM37c=; b=kbrF6hjoM+H17g9j3Wc1/6pJQXLvRnZ3Vs2WK1V3kWoZOwTfI3zERDRkFgtpBOrFAe aGn093m3smVeCRZc5LHalL7AoxbuS4AQdvZJaVIGnimvkEeM+rU3RRvd61Y/+6IWXHfl kzGQAdJFvZEfilUjxUNjkQBoZrnnNuWzDxd3Yt6Ikt65YhKsu8QQofbdJP1Nb7Jw0VW5 kMVkkJh4rdB9IpjDMcRVjEMDMbxOf5ddpY8akTKF8dSThHmxapKpkB5IEwhZVzCE7tj7 3JBKIi1e8jUIyR7UaiNXs4jjXjUOieSwp2MgZNZauf5xpbvtBGKzVaok6AF7eoTkzZnt HL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=jSafBWcpIkewykTpB/1313WvVuyh8yQZEmhBKVyM37c=; b=wffhvnBOS4uTD4xJNZ8APLLmUwHlKtokiC37Ki7APapz2Vjc+d6yoNivrxGWormUYy HMXk3FpcV37E3ubp1fGrL0EKaWCpl3aDWdaqnOj3yZAImYePh965gJerUE0diV2lL+OA twVfwKwMNLFkjaqjW2IHU7iwD9DQxaMDFNGyYCCzbdSV88VInkk0hQcBzhWBzYFPto0A RanDVMDZoOboa5YM7JGFkOcd1UZIWMCtpEfsMf48WBLz03nm1EXLXAdbTsLubEwZBXRz dnglBzjO6HObXIlLPCb1d6EXYqiYS7rrx/YoTu2MrXMSTV8bmz/LxzIYRrFIVPr+A8cJ mhWQ== X-Gm-Message-State: ACgBeo0SxrfX96LLObiBE23z1JPiwRASW+C5//Lij1TiNhTecIAvPWvP PGZq1P0XEEUwITyvQE7O1rs= X-Google-Smtp-Source: AA6agR5AVD3WIg2eP3iWjFE39m5/nR6rpJNEPwSMnDilTle2doeCtgXvqbPXlS48tak7nK63rsd6XQ== X-Received: by 2002:a05:6e02:1b86:b0:2f1:76ec:4b91 with SMTP id h6-20020a056e021b8600b002f176ec4b91mr848152ili.191.1662327775227; Sun, 04 Sep 2022 14:42:55 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 47/57] dyndbg: demote iter->site in _init Date: Sun, 4 Sep 2022 15:41:24 -0600 Message-Id: <20220904214134.408619-48-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 059212df68f9..65b0a1025ddf 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1547,7 +1547,7 @@ static int __init dynamic_debug_init(void) } iter =3D iter_mod_start =3D __start___dyndbg; site =3D site_mod_start =3D __start___dyndbg_sites; - modname =3D iter->site->_modname; + modname =3D site->_modname; i =3D mod_sites =3D mod_ct =3D site_base =3D 0; =20 for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 35502C6FA86 for ; Sun, 4 Sep 2022 21:46:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236224AbiIDVqV (ORCPT ); Sun, 4 Sep 2022 17:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235976AbiIDVov (ORCPT ); Sun, 4 Sep 2022 17:44:51 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F1330569 for ; Sun, 4 Sep 2022 14:42:56 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id s11so3868383ilt.7 for ; Sun, 04 Sep 2022 14:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=58gChvxjBedxDU/dSXgKq8f75Aq/PMP0VWOkECUeGr8=; b=J2tQsdq2kkHf85Z9ASRTiHs9OI3ZDVILIcK9yZOObu9+KlrqqjVNIjRz1rl5rphOwC 2Qfnz0oI/RsX3V70MD8E8G/yZztrNm2ZfOZnCp9690q1IH4JJ+adDmarycETlY/12rhr Db+6+SqEctFD/7m0SrX4AuGqEeuaJOmohsGrTlCLPTPTc/eFNhQn9dKNl96NeOx5rxdC vum//49JpYe1Z4oGVnwyv1uBitMZ8t5aokHuE388ICOZLGyjaZC6ZUwl7qnvJ1ZVUgUl OCs0CimfeNixxoHVLc+cIByGyUxmeix8tj9SCyBEQkzsOFFYl2FMPL60Yd7P36fczO+9 Pthw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=58gChvxjBedxDU/dSXgKq8f75Aq/PMP0VWOkECUeGr8=; b=SkSiGK73jNuad5Uz2i40yZXm+WpZBDP2kK90HVI9kfgt5kBfVy69K2lU/wTUxwwAGR VxRpyKmmuMSw5pYUWpvqwGEeir8upPnflVkPe9C0G4A7Cfu3N3mWrBrGTC0HmxhJV6iL F35jryZEve4E6snxSBIcX3c3dC961UOE6j6EnR2odW2gRSBUwc6YD5qWxu31COV26wCg e3ZTbFTlDHUClxYvoT+R5nBp6JFjcY4i33erCIDncZoNzUdIy74offcmxlQGQGCISvk5 D5S3OtzoqHXjedDHaOq8psRamq+vSkvWVNAo+aflgsnHBTtPoWsCdnjw0lxdYADSPsIX FUlQ== X-Gm-Message-State: ACgBeo3PbfEcL5Qdj8K0rYJN2/Vyy7WmBcvHXCrKFHfPhlTF92p5DTel zBbS84YALbi9/TCezgs0vvU= X-Google-Smtp-Source: AA6agR61bCYoBFhO606MrMj2e5JJ9ontZpH/7gcxtdHyPlYtKYvvYkTqL53A1Ak5xf1hQmk380rWDQ== X-Received: by 2002:a05:6e02:16cd:b0:2ea:e75b:f357 with SMTP id 13-20020a056e0216cd00b002eae75bf357mr19038138ilx.110.1662327776105; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:55 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 48/57] dyndbg: add .gnu.linkonce slot in vmlinux.lds.h KEEPs Date: Sun, 4 Sep 2022 15:41:25 -0600 Message-Id: <20220904214134.408619-49-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 linker symbols and KEEPs for .gnu.linkonce.dyndbg and .gnu.linkonce.dyndbg_sites sections, placing them in front of their respective dyndbg and dyndbg_sites sections. This placement gives us a known relative offset (ie -1) from the start of the vector to the header, letting us use container_of to get it. The _index added previously allows determining &descs[0] from any desc[N]. The .gnu.linkonce. collapses possible multiple declarations into a single allocation, with a single address. todo: will need similar for modules.lds.h Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 1e7ee65e8591..20fdea9efd78 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -348,9 +348,13 @@ __start___dyndbg_classes =3D .; \ KEEP(*(__dyndbg_classes)) \ __stop___dyndbg_classes =3D .; \ + __dyndbg_header =3D .; \ + KEEP(*(.gnu.linkonce.dyndbg)) \ __start___dyndbg =3D .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg =3D .; \ + __dyndbg_site_header =3D .; \ + KEEP(*(.gnu.linkonce.dyndbg_sites)) \ __start___dyndbg_sites =3D .; \ KEEP(*(__dyndbg_sites)) \ __stop___dyndbg_sites =3D .; \ --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 84223C6FA82 for ; Sun, 4 Sep 2022 21:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236215AbiIDVqR (ORCPT ); Sun, 4 Sep 2022 17:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235978AbiIDVow (ORCPT ); Sun, 4 Sep 2022 17:44:52 -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 C52A73056F for ; Sun, 4 Sep 2022 14:42:57 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id h14so3864019ilh.10 for ; Sun, 04 Sep 2022 14:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ghge3Dg1q/uGEuUESUrEdkwsT+z6CpJtuRfuq34U0Ug=; b=FLT5bN9bU1jESQsj9wEWPf6TBBHS0oph0LypFJwzq/K+zCkxyteteH2bTqZQBcNzRk mSR3h7PMvUN4YMVkvnO87hK2EpNkCDlGSKyeeqjogwoe6lhs1W0j8NVv5K50LsJtZg06 R92M/cvFSPip9b/dMAktsgXw9ub1l1yxpBS3OvRLmDew3VfDVMnqQ0y++Z8JirN4wlxB lJnxEt70v9wGz0k/jpVu8dHy7KvJOhLu72eHep8RD2rQzQKX8nJI5JvRr6ZFWV/vp1QA rb8QvbLzf2xps15VlW8JMp2QgHnpXqCAJLTT4tXeVn3zK7n/t3dqhX+s0crDVymyRVVS JLpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Ghge3Dg1q/uGEuUESUrEdkwsT+z6CpJtuRfuq34U0Ug=; b=4xB2IrqrDHwLRbIMQaThPEhjDLVLDsXVBcR8RMuuR2+/ZoXubICgD3AWF/uuwHI/FI nSgEzDDpIANPiwqr0IgF3mK3J76orSqJpKrZVDlAwvkhdZZDEsZ3WjnQk5KdT4r4mzes YpNufESAwKR6q3ia6rNIY/DBPuVLd6qPg58oEUFAGxkGsop0kw5t4vo9xflmi+Hmoy3c ViAuFlQIZkHXB1th1ELYEFjbuGuPrbzmcWXZu25tFH+871ZcicQ4m+hRaZeWc970yXsc 3GLNWxhRxfQyUXtLKrQT1sVVXzKaxCIVovE/EJZeFa1zHhlOeJrgVWtuY9Lt82tI8vFf f6ZA== X-Gm-Message-State: ACgBeo0riSQaNTDcQww+APQvr2ryMXMAFxbHZvtJR0b9Qq9aHnl8rxVv anlx3FMCcEjZhoL3nBxyIG0= X-Google-Smtp-Source: AA6agR7yrIYfyzVDzlMev9fxaOVFcrN/YRY+eo0Bb7o+kB7gpv9wc7uwho5jDTzaHbxaUMbJjOU49g== X-Received: by 2002:a92:ad0d:0:b0:2e6:4294:bc45 with SMTP id w13-20020a92ad0d000000b002e64294bc45mr24581884ilh.278.1662327777020; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:56 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 49/57] dyndbg: add structs _ddebug_hdr, _ddebug_site_hdr Date: Sun, 4 Sep 2022 15:41:26 -0600 Message-Id: <20220904214134.408619-50-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 new structs _ddebug_hdr and _ddebug_site_hdr, latter for symmetry. The job of the struct _ddebug_hdr is to: Contain an _uplink member, which points up to the _ddebug_info record that keeps builtin and module's dyndbg state. That record is init'd (by dynamic_debug_init for builtins, or find_module_sections for loadables). Be declared in .gnu.linkonce.dyndbg section, which places it just before the __dyndbg section; a fixed relative offset. This allows _ddebug_map_site(desc) to cheaply compute &descs[desc._index], &descs[0], then container_of() to get the header and its ._uplink, to the _ddebug_info, which gives access to ->sites[desc->_map]. Structurally, the header has a single unnamed union (which exposes its field names upward) containing an embedded struct _ddebug{,_site} (this forces the size to be compatible with the array/section its destined for), shared with our new struct _ddebug_info * _uplink member, which is also inside an unnamed struct, to allow adding other fields later to use the remaining space. In dynamic_debug.c: ref the linker symbols for the headers, print them to confirm expected linkages; things look proper. Add a header ref to struct _ddebug_info, to facilitate the validity checks. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 23 ++++++++++++++++++++++- lib/dynamic_debug.c | 9 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 268e903b7c4e..f23608c38a79 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -126,8 +126,29 @@ struct ddebug_class_map { #define NUM_TYPE_ARGS(eltype, ...) \ (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) =20 -/* encapsulate linker provided built-in (or module) dyndbg data */ +/* define header record, linker inserts it at descs[0] */ +struct _ddebug_hdr { + union { + struct _ddebug __; /* force sizeof this */ + struct { + struct _ddebug_info * _uplink; + /* space available */ + }; + }; +}; +/* here for symmetry, extra storage */ +struct _ddebug_site_hdr { + union { + struct _ddebug_site __; /* force sizeof this */ + struct { + struct _ddebug_info * _uplink; + }; + }; +}; + +/* encapsulate linker provided built-in (or module) dyndbg vectors */ struct _ddebug_info { + struct _ddebug_hdr *hdr; struct _ddebug *descs; struct _ddebug_site *sites; struct ddebug_class_map *classes; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 65b0a1025ddf..91fe7fb5dda9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -49,6 +49,9 @@ extern struct _ddebug_site __stop___dyndbg_sites[]; extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 +extern struct _ddebug_hdr __dyndbg_header[]; +extern struct _ddebug_site_hdr __dyndbg_site_header[]; + struct ddebug_table { struct list_head link, maps; const char *mod_name; @@ -1522,6 +1525,7 @@ static int __init dynamic_debug_init(void) char *cmdline; =20 struct _ddebug_info di =3D { + .hdr =3D __dyndbg_header, .descs =3D __start___dyndbg, .sites =3D __start___dyndbg_sites, .classes =3D __start___dyndbg_classes, @@ -1545,6 +1549,11 @@ static int __init dynamic_debug_init(void) pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_site= s); return 1; } + + /* these 2 print the same, until _TABLE is added */ + v2pr_info("%px %px \n", __dyndbg_header, __dyndbg_site_header); + v2pr_info("%px %px \n", di.descs, di.sites); + iter =3D iter_mod_start =3D __start___dyndbg; site =3D site_mod_start =3D __start___dyndbg_sites; modname =3D site->_modname; --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 3FFB4ECAAD5 for ; Sun, 4 Sep 2022 21:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235461AbiIDVqZ (ORCPT ); Sun, 4 Sep 2022 17:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235314AbiIDVpB (ORCPT ); Sun, 4 Sep 2022 17:45:01 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3525A3056B for ; Sun, 4 Sep 2022 14:42:58 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id b142so5642581iof.10 for ; Sun, 04 Sep 2022 14:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0iGLn9xqCpcC4gcXCQSb7q1CfO8AItXp+UrSrC23ofg=; b=c4Kq7xloZvvHFQ9epBPNdcfT88slUONFGhsZx5MMGEMETHKqfUD9s2gzih6ALSi3wD RrSDXPBRasBgiwo4/u96iVTFZBqUgPsrGJ215FEXB49z7jnLyWi457WMuaGNd/EON1XH GyjBZNFnOS45dRu6gLJPWVkFsKVueCkOjPTRK+IINcSb2jbyp3YwEPuMkYNSzl/rirQM d5EwuNynlS8h4OY8pAJTaF7QeWBKZcUVuMJzzAnk0maYPeDvxCRYSxmx7XIOTzxGp1yV PLaexfCoB2wQoSDMH+kN17KC+TwYCpQd6YSNc7LXPW74NfB8khKnhZvXekFB8EQPRMeQ pFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=0iGLn9xqCpcC4gcXCQSb7q1CfO8AItXp+UrSrC23ofg=; b=JpYUBZRUMdd4BztQ7N/0XRDInqLHaIrNoFtJ3UHdvqAdSxaSr6sO9j7WTz3YeXL+72 hN0SuVGC5R93c5UGg4UffFEQ5nwX+VCrMFpPMDZ0Vxu8cLPUITnPimeW7KIhs377pGI1 okByBvZcAuNhu5fzK081A6aRxDfbW4cQxsuTf8rP/OAYvm3g198g3ioZrw6G/eILehxK x3oX1i7Hzee/r7NIGR/JA3lUFZqRU2z1etijx8NS/Y0dM7YP2bBEYJ8BG4kWWE+eT7CX cjHAgSbKTo/nWTHrXxGJQlgOAUfpu3rejs8fiI5uqjSLIL/HotD0YSl0mGXpiMhjfceZ MS4Q== X-Gm-Message-State: ACgBeo0pvWakI2eycTfZ4oDKeWFUfc8yYFtw6alQ05RhaVj8xv0QdY9Y aZusjuX5QZu1gsKGuWbI2PHpo/ZmUsU= X-Google-Smtp-Source: AA6agR5hVc9DnYKL0ZIAQuzKxXKG0S5DufyPzrHmQJwD8MfDjPFuhObXx/a4iT1L7ykoRUbvzDY2Pw== X-Received: by 2002:a05:6638:1350:b0:349:f94d:5ea7 with SMTP id u16-20020a056638135000b00349f94d5ea7mr24681226jad.129.1662327777931; Sun, 04 Sep 2022 14:42: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:57 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 50/57] dyndbg: count unique callsites Date: Sun, 4 Sep 2022 15:41:27 -0600 Message-Id: <20220904214134.408619-51-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" Count de-duplicated callsites. Since the _ddebug_site excludes lineno, all callsites in a function are identical, and this effectively counts functions in the module with callsites. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 91fe7fb5dda9..891d70d7fed4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1348,7 +1348,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, unsigned int *packed_base) { struct ddebug_table *dt; - int i; + int i, num_funcs =3D 0; =20 v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_des= cs, di->num_sites, base); if (!di->num_descs) { @@ -1381,12 +1381,11 @@ static int __ddebug_add_module(struct _ddebug_info = *di, unsigned int base, //BUG_ON(di->num_descs !=3D di->num_sites); =20 for (i =3D 0; i < di->num_descs; i++) { - - if (di->sites[i]._function !=3D packed_sites[(*packed_base)]._function) - + if (di->sites[i]._function !=3D packed_sites[(*packed_base)]._function) { + num_funcs++; memcpy((void *) &packed_sites[++(*packed_base)], (void *) &di->sites[i], sizeof(struct _ddebug_site)); - + } di->descs[i]._index =3D i + base; di->descs[i]._map =3D *packed_base; =20 @@ -1397,7 +1396,7 @@ static int __ddebug_add_module(struct _ddebug_info *d= i, unsigned int base, list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); + vpr_info("%3u debug prints in %d functions, in module %s\n", di->num_desc= s, num_funcs, modname); return 0; } =20 --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 E5C46C6FA86 for ; Sun, 4 Sep 2022 21:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236245AbiIDVq3 (ORCPT ); Sun, 4 Sep 2022 17:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235328AbiIDVpC (ORCPT ); Sun, 4 Sep 2022 17:45:02 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2BA230576 for ; Sun, 4 Sep 2022 14:42:59 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id r7so3867536ile.11 for ; Sun, 04 Sep 2022 14:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KACUwbv9zFDFS+/NnZ2+bHc0BJ5XxAtoDioY/cngaq0=; b=VWLo9KQRx3wUEpHavD9gtPYNFllTyy4JKxvs/7m7tkQZM4ST377wbMAzvfbzKUgbOp J6WuHZ3P93mqwHnELmx4xWY2iE88bkmZTSJqZgzV49g9rgdp//m9df+iAKw5mapuizNM 8N7/7jcJanbJgpES8DxAtzXNIpOD8ZbW5WOPK05nV0i1YT9y6m46gm5tX0ZuDvQutVME hVXVPzZsqJYaB2x7eaQgiQ5QGXMW5MZGs2s9lLUmDUh275cuM3Hr9LM8UftEseh/RA6Z Yc6+zDt9i1m5X50alTa/P6gMXlOYHL2RiMbZY6SXX3tIiEk2zkHyzL+A2td9lp2Hi3c2 vR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=KACUwbv9zFDFS+/NnZ2+bHc0BJ5XxAtoDioY/cngaq0=; b=vXjYzP9v7C+uaxpH6wOxKAteQHD3A+c3HeXK34TG8+XoECNKSzYg9Fvndzb5V454RS XAc3pBEENdGur5yRJCkaio3CUrJRRobwhFixtFzgkpKyKqj6y8rsri9JC55a4v20ZNNV yb/5q4t8/COUkwEZQUx7TCfDw61smrdDqYIlXD7xMQdDfZl3Z/8q8xdaaVFY38iGvsOf vNPiicG98qijWmAh0xKfWtgIFcExV7Bnf3UFSuRUq1DOgN7IVxRy9kRxxHEYBPbRR0Vm CPCJEe4TbMtZ6803UKEvKD7nGVbp6jeAxyaEZTKnQ6XTyD5oQkf7tOL/Z3ovviz8nfvT ao0A== X-Gm-Message-State: ACgBeo3JFRsICJWQn3bDPTxdRAlIHwwVjiFui88HFpl0Blg/j1rEKrAs C6tENR5hjZYjqx+lbr6qDrw= X-Google-Smtp-Source: AA6agR4Fn4lGPNDj+VkdpCwid3ve66XVQ8L4VIZBVbVLfcwMhJmhHwO+CmYwocy3EXC3pDUoc7POZw== X-Received: by 2002:a05:6e02:1c2b:b0:2e9:f263:2942 with SMTP id m11-20020a056e021c2b00b002e9f2632942mr24514448ilh.74.1662327779197; Sun, 04 Sep 2022 14:42:59 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:58 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , lkp@intel.com Subject: [PATCH v6 51/57] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE Date: Sun, 4 Sep 2022 15:41:28 -0600 Message-Id: <20220904214134.408619-52-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several subtrees, including efi, vdso, and some of arch/*/boot/compressed, with various relocation errors, iirc. Avoid those problems by adding a define to suppress the "transparent" DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems myself, lkp@intel.com found arm & sparc problems, and may yet find others. Reported-by: # on [jimc:lkp-test/dyndbg-diet] recently Signed-off-by: Jim Cromie --- arch/arm/boot/compressed/Makefile | 2 ++ arch/sparc/vdso/Makefile | 2 ++ arch/x86/boot/compressed/Makefile | 1 + arch/x86/entry/vdso/Makefile | 3 +++ arch/x86/purgatory/Makefile | 1 + drivers/firmware/efi/libstub/Makefile | 3 ++- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/M= akefile index 41bcbb460fac..f2d7a3b62727 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -81,6 +81,8 @@ compress-$(CONFIG_KERNEL_LZMA) =3D lzma_with_size compress-$(CONFIG_KERNEL_XZ) =3D xzkern_with_size compress-$(CONFIG_KERNEL_LZ4) =3D lz4_with_size =20 +KBUILD_CFLAGS +=3D -DNO_DYNAMIC_DEBUG_TABLE + libfdt_objs :=3D fdt_rw.o fdt_ro.o fdt_wip.o fdt.o =20 ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index 77d7b9032158..58ed4d64c978 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -30,6 +30,8 @@ obj-y +=3D $(vdso_img_objs) targets +=3D $(vdso_img_cfiles) targets +=3D $(vdso_img_sodbg) $(vdso_img-y:%=3Dvdso%.so) =20 +KBUILD_CFLAGS +=3D -DNO_DYNAMIC_DEBUG_TABLE + CPPFLAGS_vdso.lds +=3D -P -C =20 VDSO_LDFLAGS_vdso.lds =3D -m elf64_sparc -soname linux-vdso.so.1 --no-unde= fined \ diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/M= akefile index 35ce1a64068b..b76bbf9fc504 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -36,6 +36,7 @@ KBUILD_CFLAGS :=3D -m$(BITS) -O2 $(CLANG_FLAGS) KBUILD_CFLAGS +=3D -fno-strict-aliasing -fPIE KBUILD_CFLAGS +=3D -Wundef KBUILD_CFLAGS +=3D -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS +=3D -DNO_DYNAMIC_DEBUG_TABLE cflags-$(CONFIG_X86_32) :=3D -march=3Di386 cflags-$(CONFIG_X86_64) :=3D -mcmodel=3Dsmall -mno-red-zone KBUILD_CFLAGS +=3D $(cflags-y) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 12f6c4d714cd..3182728f9f4d 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -29,6 +29,9 @@ vobjs32-y :=3D vdso32/note.o vdso32/system_call.o vdso32/= sigreturn.o vobjs32-y +=3D vdso32/vclock_gettime.o vobjs-$(CONFIG_X86_SGX) +=3D vsgx.o =20 +# avoid a x86_64_RELATIVE error +KBUILD_CFLAGS +=3D -DNO_DYNAMIC_DEBUG_TABLE + # files to link into kernel obj-y +=3D vma.o extable.o KASAN_SANITIZE_vma.o :=3D y diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 31c634a22818..8d264836ae64 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -35,6 +35,7 @@ PURGATORY_CFLAGS_REMOVE :=3D -mcmodel=3Dkernel PURGATORY_CFLAGS :=3D -mcmodel=3Dlarge -ffreestanding -fno-zero-initialize= d-in-bss -g0 PURGATORY_CFLAGS +=3D $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILI= NG PURGATORY_CFLAGS +=3D -fno-stack-protector +PURGATORY_CFLAGS +=3D -DNO_DYNAMIC_DEBUG_TABLE =20 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. Th= at # in turn leaves some undefined symbols like __fentry__ in purgatory and n= ot diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/l= ibstub/Makefile index 3ef67431f05e..2b7e34555c5a 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -14,7 +14,8 @@ cflags-$(CONFIG_X86) +=3D -m$(BITS) -D__KERNEL__ \ $(call cc-disable-warning, address-of-packed-member) \ $(call cc-disable-warning, gnu) \ -fno-asynchronous-unwind-tables \ - $(CLANG_FLAGS) + $(CLANG_FLAGS) \ + -DNO_DYNAMIC_DEBUG_TABLE =20 # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 EFC97C6FA82 for ; Sun, 4 Sep 2022 21:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236259AbiIDVqd (ORCPT ); Sun, 4 Sep 2022 17:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236031AbiIDVpC (ORCPT ); Sun, 4 Sep 2022 17:45:02 -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 7726C30F43 for ; Sun, 4 Sep 2022 14:43:00 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id y187so5724197iof.0 for ; Sun, 04 Sep 2022 14:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HlXlcsu2RqT6fAUiV6NVhuDn1t0xR93nZ+jChKYhqUw=; b=aHV/k9J2PuitBnlhA4br73E9JnLl2gCBHHBTGdkL9KmqcRS5bomgzwR0OaqXBlVyql Mf+7Y+KsEOXcIs+D0+rNcc1xfUx+tf11ZEtL7jgmdcXn3KKcYRtVgMKv2QivMhgwGB6p qhysutFwua8FbpIFvlVp/S3j8MzU+FtQko8iiKsgLlooadXPLQQ21I6Q1NTrYJTip/4D 0VC0OYdPKhw0V3Mzu3DZ0R5yhcn852KcFxvjVL4Bi2PKi8TFHfnlMTt0MfuMqEB1W0cT r3SV72vbw59OuMsz2HCPNecCDPTzT4EzG4nBHs7LsaOq7fTjOvTkLYW8hBG4OuYPJt9E DnRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=HlXlcsu2RqT6fAUiV6NVhuDn1t0xR93nZ+jChKYhqUw=; b=YMl0yUJ7tzTCPCoRdH79r7coEEza+075rGzzhIJcwko+kyIMRPgyDuuP44wzmrgAta RW2gASxWJKQzS2e6Hm9FzYIQvMZSv8vxhLrcp4qn4hWfPniwj9NrWeZKHdDuyNcqb2+x M3WbKzBA3taMGMuUE70BPne4TTkpCc5fzf18XpHe8bLU8C2ea1x+mwpig14548OqkDoP f6TQUWa2lsxkRQKyrxhidoEfDGNTVLzzuBO9DyHiTWg3ehnT6mgWn6RL8fIVRNVpFMZ9 /9bqrvP/jq2W/Qr2P/dwQT8UMuQlI53wZfm2Iv9OgBaRRZNYv5G2PdHu+RCwvvBEUiqb 8xWQ== X-Gm-Message-State: ACgBeo3CuufZnDa0Un7RURVyrTqaoh1mZG8wFjcEB7Lzi+lORLQXoAhm qKXbXgj9XNE5t2l7jvg8R2E= X-Google-Smtp-Source: AA6agR7vlI7R7BZjvt5nOZUe1nHbAjNSYfJLtX8tg1fOrQTMkIvWzLEFddRnIK11jzK+Lp9kCqNOZQ== X-Received: by 2002:a05:6638:22d1:b0:34f:5d31:5fe with SMTP id j17-20020a05663822d100b0034f5d3105femr6114929jat.185.1662327780173; Sun, 04 Sep 2022 14:43: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:59 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 52/57] dyndbg: add DEFINE_DYNAMIC_DEBUG_TABLE, use it tacitly RFC Date: Sun, 4 Sep 2022 15:41:29 -0600 Message-Id: <20220904214134.408619-53-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" This defines a new macro (tbd: tweak name) which is a special version of DEFINE_DYNAMIC_DEBUG_METADATA_CLS(). Unlike that macro, which declares callsites in pairs of desc/site recs. This macro declares a pair of header records, which the linker script then places once (.gnu.linkonce.) into the front of the respective sections. For builtins, the .linkonce gives us a single header preceding all ~3-5k callsites. It uses __unused, __weak, .gnu.linkonce to avoid trouble with multiple inclusions, and should not consume space when not linked to by a callsite in a loadable module. Atypically, this macro is also tacitly invoked in the header, which is indirectly included by printk.h. This means 2 things: it mostly insures that source files will declare it at least once, and that multiple decls resolve to the identical storage address. I did this with the expectation that I could let the linker compute the offset and initialize ._index accordingly, but that resulted in some "linker cant compute" error. Ive initialized it in __ddebug_add_module() instead. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f23608c38a79..23d3d2882882 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -220,6 +220,32 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) =20 +/* + * DEFINE_DYNAMIC_DEBUG_TABLE(): This is a special version of + * DEFINE_DYNAMIC_DEBUG_METADATA(). It creates a single pair of + * header records, which the linker scripts place in front of their + * respective sections. + * + * To allow for a robust runtime test in dynamic_debug_init(), the + * pair of records is hardwired into a self-reference loop which can + * be validated before the field is altered to support _ddebug_map_site() + */ +#define DEFINE_DYNAMIC_DEBUG_TABLE() \ + /* forward decl, allowing loopback pointer */ \ + struct _ddebug_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header; \ + struct _ddebug_site_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg_site") \ + _LINKONCE_dyndbg_site_header =3D { \ + ._uplink =3D (void *) &_LINKONCE_dyndbg_header \ + }; \ + struct _ddebug_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header =3D { \ + ._uplink =3D (void *) &_LINKONCE_dyndbg_site_header \ + } + #ifdef CONFIG_JUMP_LABEL =20 #ifdef DEBUG @@ -390,4 +416,12 @@ static inline int param_get_dyndbg_classes(char *buffe= r, const struct kernel_par =20 extern const struct kernel_param_ops param_ops_dyndbg_classes; =20 +#if ((defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)= )) \ + && defined(KBUILD_MODNAME) && !defined(NO_DYNAMIC_DEBUG_TABLE)) + +/* transparently invoked, except when -DNO_DYNAMIC_DEBUG_TABLE */ +DEFINE_DYNAMIC_DEBUG_TABLE(); +#endif + #endif --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 C73A0ECAAD5 for ; Sun, 4 Sep 2022 21:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235880AbiIDVqh (ORCPT ); Sun, 4 Sep 2022 17:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235709AbiIDVpL (ORCPT ); Sun, 4 Sep 2022 17:45:11 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E09303EE for ; Sun, 4 Sep 2022 14:43:01 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id s11so3868428ilt.7 for ; Sun, 04 Sep 2022 14:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=BbbFDk5Ds3TKsvXVbegzI7CpK80eT1rLEmQAVhGGmkbjefDTu1gcIWX3uZ+Gm3W16k 3S2yBAZFyR4M8ryCfllvuDfTEF5RipMBjPts8hfi0pV7bgB3wzkcHuY4zKj4khhmKXMX pSl1t58XXxStJLZnSVd/tYgQeSDea1W2Q0b2Yjqp1FxlZFqw6LWpNqFhC6szuGaRu8dl 5KSWJpEvt20IxDYiChjLMX8wBoKwHlILNtfzF8+iMXyfBHmY6aJSuvXzt1gP3PkSoi/Q ObHbdHfGYhfOUrMIzj4dzek2gnNfsuuTirJYodRLuPa4LRKsvPAHjppmK36ztUBZgFy/ TBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=S9KnXZcqnACuZ6So5NKeF0/w0Odl3CYb2eJjRI+hzl4EYdj2jAYvoFY/bHYgTT6DzT 3vOZ56uH3/YIaYjRue7AfJv56/W+En5Zvt549lJ1KqXsPu2YgdXNAm7v2lGq1GA1/bdx mWRh9tyLhfKm+aei1TrqP15/BM+PazEWy6oii6vOKmY1YLx/MFKtTLNGnNyGfs8WnHeH FQR6Vp9Iwob/0M6WTNsupBSuPawfTJz+Yt05A/e5sfQjJOBSKP6wXxHNN5K/6aXiLoEQ +DG3DI1NXQ8F+qSzEYVqbYerlqfhV8ufL/MiEz2/WIP5E4TcQ9fnk9rQBTJHW//VOu+n kpxg== X-Gm-Message-State: ACgBeo1lBiIs/nj6ru9E8zXtgJQpwoto6rBswyA2WExa1+cy89g8m1hX W8uD5IBsCd0qH1YldCD3KyI= X-Google-Smtp-Source: AA6agR5Ky+BjL0NnfIX4cYKS1KnsINOXh0NpNlMijj01ekGHcYdvtJWlYQecsvf47LfzeAoLHEZ2MA== X-Received: by 2002:a05:6e02:1524:b0:2ec:71c6:7b85 with SMTP id i4-20020a056e02152400b002ec71c67b85mr9725292ilu.237.1662327781031; Sun, 04 Sep 2022 14:43: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:00 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 53/57] dyndbg: add/use is_dyndbg_header then set _uplink Date: Sun, 4 Sep 2022 15:41:30 -0600 Message-Id: <20220904214134.408619-54-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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 static int is_dyndbg_header(d), which verifies that the arg is initialized as expected; that it points to the _ddebug_hdr & _ddebug_site_hdr records initialized by DYNAMIC_DEBUG_TABLE(). That init macro sets the _uplink fields in the 2 records to point at each other. This is an impossible situation for the regular callsite record pairs built by *_METADATA_CLS(), so it provides a robust verification that linkage happened as we require/depend upon. In dynamic_debug_init(), is_dyndbg_header() validates the header, and sets _uplink to builtin_state. Thereafter, ddebug_map_site() can use it, and we can drop the _ddebug.site member, and shrink the DATA footprint. --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 38 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 23d3d2882882..ed3e1e1c08eb 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -149,6 +149,7 @@ struct _ddebug_site_hdr { /* encapsulate linker provided built-in (or module) dyndbg vectors */ struct _ddebug_info { struct _ddebug_hdr *hdr; + struct _ddebug_site_hdr *site_hdr; struct _ddebug *descs; struct _ddebug_site *sites; struct ddebug_class_map *classes; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 891d70d7fed4..0a68fbfd8432 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1339,6 +1339,25 @@ static void ddebug_attach_module_classes(struct ddeb= ug_table *dt, vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); } =20 +/* + * detect the hardwired loopback initialized into the header pairs' + * _uplink member. In dynamic_debug_init(), it verifies the presence + * of the header, before setting its _uplink to either &builtin_state + * or the module's embedded _ddebug_info. __ddebug_add_module() will + * also use it.. + */ +static int is_dyndbg_header(struct _ddebug_hdr *hdr) +{ + struct _ddebug_site_hdr *sp; + + if (!hdr || !hdr->_uplink) + return 0; + + sp =3D (struct _ddebug_site_hdr *) ((struct _ddebug_hdr *)hdr)->_uplink; + return hdr =3D=3D (struct _ddebug_hdr *) + ((struct _ddebug_site_hdr *)sp)->_uplink; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1351,6 +1370,15 @@ static int __ddebug_add_module(struct _ddebug_info *= di, unsigned int base, int i, num_funcs =3D 0; =20 v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_des= cs, di->num_sites, base); + + if (is_dyndbg_header((struct _ddebug_hdr *)&di->descs[0])) { + pr_info("module header\n"); + di->hdr =3D (struct _ddebug_hdr *) di->descs; + di->descs++; + di->sites++; + di->num_descs--; + di->num_sites--; + } if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1525,6 +1553,7 @@ static int __init dynamic_debug_init(void) =20 struct _ddebug_info di =3D { .hdr =3D __dyndbg_header, + .site_hdr =3D __dyndbg_site_header, .descs =3D __start___dyndbg, .sites =3D __start___dyndbg_sites, .classes =3D __start___dyndbg_classes, @@ -1548,11 +1577,16 @@ static int __init dynamic_debug_init(void) pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_site= s); return 1; } - /* these 2 print the same, until _TABLE is added */ - v2pr_info("%px %px \n", __dyndbg_header, __dyndbg_site_header); + v2pr_info("%px %px \n", di.hdr, __dyndbg_site_header); v2pr_info("%px %px \n", di.descs, di.sites); =20 + if (is_dyndbg_header(di.hdr)) { + di.hdr->_uplink =3D &builtin_state; + } else { + pr_err("missing header records: cannot continue!\n"); + return 1; + } iter =3D iter_mod_start =3D __start___dyndbg; site =3D site_mod_start =3D __start___dyndbg_sites; modname =3D site->_modname; --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 90C9AC6FA82 for ; Sun, 4 Sep 2022 21:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236287AbiIDVqo (ORCPT ); Sun, 4 Sep 2022 17:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235833AbiIDVpW (ORCPT ); Sun, 4 Sep 2022 17:45:22 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5EBC30F48 for ; Sun, 4 Sep 2022 14:43:02 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id y187so5724227iof.0 for ; Sun, 04 Sep 2022 14:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bXSeYH0zduNfWYtAn2/GFLXR9T03/2CnSS0WiVim3VQ=; b=Kz5c1apWMX0yddvgXTrt/BjoeN52CrK81vVC2ejDG94BrieUIvPuQxqUc9mOpTS/PP HWECHkoY/OGUf08e39Nmu5OrgrRhJWG04JFoAaPLsxT6JyFH/YDSudtSKAU+VFekFYsq Vod9PDrJCKlyWzWt7qenFWfsvqXS3nuOE+JpI9yW2OwLoVmYddOY5g5wBsTWGPdp/8D4 T8EWSg90FSXg58mfxM0h4Ijo4DgetN371n10Vzcly6r5kLaSzcQu1NTLn9EFrrE/z+XJ JBzGq1uSt6X2fse4mVKP1vmF2LWn1W1sfDqy+6kqDBUE4JOdFjuhQGLvtnC0Saz04FMW fgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=bXSeYH0zduNfWYtAn2/GFLXR9T03/2CnSS0WiVim3VQ=; b=3P0llUGmhLrShxFvOD8K817PfE6iYcIYWVOUSG/SG6W+eNnDyrd3U+iaMVk3ElJ7pQ YBnrXtbH0xTYcYdp0UEoxLdkQfahJwBttDV1PfdQuWsnjh2uDTSoA2641/4eN/CaNbXx lw3dwtsqFaNrYzLHN/a2GV92QMQ4huiFVgSqK7hOc505xYwM3y695OdJlneu1cSjj672 1xTVbQje9YKiuQMUgYfJnZJf12utPcbb17ioY61Vfag55eeti28unv4Q7P7PD7JHS/Ku Y7sTyxU2hJylpmI0IXXG+xEfhxLDaS0tGmRGevHUeuBZV78Qhw0H4S5BaHo39dKEpf6X ER1g== X-Gm-Message-State: ACgBeo3DKyjuRUWv0h8PxjlNe4uZSM9CaVHxiOj1tuBNpJqiXSrUXg6k sn46fb7ckVmBOZ2K9Q3xrGM= X-Google-Smtp-Source: AA6agR4F0Y5uoS0j9obmZc9hPIHDQS7tGY0siR2ILOqRr5ep1L+AxeY27R3APLGSgxbHOp+TIgipXA== X-Received: by 2002:a05:6638:40a8:b0:346:8e3c:8141 with SMTP id m40-20020a05663840a800b003468e3c8141mr24647914jam.107.1662327782109; Sun, 04 Sep 2022 14:43:02 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:01 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 54/57] dyndbg: add .gnu.linkonce. & __dyndbg* sections in module.lds.h Date: Sun, 4 Sep 2022 15:41:31 -0600 Message-Id: <20220904214134.408619-55-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" For a long time now, loadable modules have tacitly linked the __dyndbg section into the .ko, as is observable in dmesg by enabling module.c's pr_debugs and loading a module. Recently, __dyndbg_sites was added, following the original model. But now, we need to explicitly name those (__dyndbg, __dyndbg_sites) sections in order to place new .gnu.linkonce.dyndbg* sections in front of them. This gives us the properties we need for _ddebug_map_site() to drop the _ddebug.site pointer: fixed offset from &__dyndbg[N] to &__dyndbg[0] container_of gets &header header has ptr to __dyndbg_sites[] __dyndbg_sites[_map] gives de-duplicated site recs NOTE HEAD~1 took headers off front of descs,sites and saved them into _ddebug_info, this puts the gnu.linkonce.* records into those vectors. Signed-off-by: Jim Cromie --- include/asm-generic/module.lds.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/module.lds.h b/include/asm-generic/module.= lds.h index f210d5c1b78b..328c48dfc88c 100644 --- a/include/asm-generic/module.lds.h +++ b/include/asm-generic/module.lds.h @@ -4,7 +4,17 @@ =20 /* * can specify arch-specific sections for linking modul= es. - * Empty for the asm-generic header. + * + * For loadable modules with CONFIG_DYNAMIC_DEBUG, we need to keep the + * 2 __dyndbg* ELF sections, which are loaded by module.c + * + * Pack the 2 __dyndbg* input sections with their respective + * .gnu.linkonce. header records into 2 output sections, with those + * header records in the 0th element. */ +SECTIONS { +__dyndbg_sites : ALIGN(8) { *(.gnu.linkonce.dyndbg_site) *(__dyndbg_sites)= } +__dyndbg : ALIGN(8) { *(.gnu.linkonce.dyndbg) *(__dyndbg) } +} =20 #endif /* __ASM_GENERIC_MODULE_LDS_H */ --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 EEFB6C6FA82 for ; Sun, 4 Sep 2022 21:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236080AbiIDVqt (ORCPT ); Sun, 4 Sep 2022 17:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbiIDVpW (ORCPT ); Sun, 4 Sep 2022 17:45:22 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C06630F4C for ; Sun, 4 Sep 2022 14:43:03 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id d16so3873630ils.8 for ; Sun, 04 Sep 2022 14:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=CI4O5/XsaFLXciSt5Rdge4MemsUClxFVBZfystEbNfehM5+pbWGL+3/LfbSrWpLkDe QLouWGHfFHkP9Q9uTLPz7X3ERsbJXjw8LNi6aoavpvlpTPh0dTvh+IgfdUCbYJdj0GgH lUfG76Rd0gmLjbbl/3rZMOmYqTD+WkTN/9K2f2dm2qZHEDNaVZgbBO5+nFxuSbB/CFz4 0MWqrUks5jKXTp61hPvRrQtbY7qo2RxRkVavCrphAIUunhh48rh0GzTzPFGrJ6BKZ0CD yShrbz0hun/rGp39oZ6PrAdWgNTyqGMKHUoak/rTVekwOK81+67c+ffYoQ1p3mVC8bzd oPTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=UKEYYXR83PsD/sLaeIv86Nev4PbhIk/5RfQK266quicJ2zR6vrMV9JaxDU4lCFlzg/ kFCwzs4kf9b4aEe1kX8ADZV1fxAIg7gtmQMk3vY9tqYPvq/KK1riYzo3BmRmNrN5kOUv f32CeNVUsWnDNwXdfHddOQ33USs+qiwamefgHpxwvm7XH2Aj2zZl5+jwtuVr36yZ8s0I nbrzKB3bYhqb+miQ4HC9LM5S063p9YfAsT/N/mJ+2aZoBewtcLEDB9J6WRRcjTRaiIdM jrPBfFcGHsODmiYkiFxQsvED255ZaOqIr3jXeG/+uHak9RT2f9W2FSVd1OxNzNtwoQOW ZlrA== X-Gm-Message-State: ACgBeo0APjm57J1bvPDaCWn4gkM7KubZO3q8CPGVMayYjyFLH+5lOFoG JgtuHge/M+GhhKSFdxU1x5s= X-Google-Smtp-Source: AA6agR7eGPKnIe81RJVDfoPI3jJBBD+OXvseERYIHoYQlkUb2mdyRY/RHX6luTHiUDhiH85tZBOfIg== X-Received: by 2002:a05:6e02:180c:b0:2f1:5405:4bba with SMTP id a12-20020a056e02180c00b002f154054bbamr1923294ilv.152.1662327782986; Sun, 04 Sep 2022 14:43:02 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:02 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , david@redhat.com Subject: [PATCH v6 55/57] dyndbg: dynamic_debug_sites_reclaim() using free_reserved_page() WAG Date: Sun, 4 Sep 2022 15:41:32 -0600 Message-Id: <20220904214134.408619-56-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" STATUS: broken with some over-free, punt and comment out late_initcall Implement dymamic_debug_sites_reclaim(as a late_initcall) to free the tail~47% of the builtin __dyndbg_sites[] vector back to the buddy allocator. Code is copied from mm/init.c:free_initmem(), wo the poisoning. Comments cargo culted wo grokking. v3pr_info: dyndbg: freeing range: ffffea00000c5500-ffffea00000c5700, ffffffff83154668= -ffffffff8315c480 dyndbg: ie range: ffffea00000c5500-ffffea00000c5700, ffffffff83154000= -ffffffff8315c000 dyndbg: freeing page: ffffea00000c5540, ffffffff83155000 dyndbg: freeing page: ffffea00000c5580, ffffffff83156000 dyndbg: freeing page: ffffea00000c55c0, ffffffff83157000 dyndbg: freeing page: ffffea00000c5600, ffffffff83158000 dyndbg: freeing page: ffffea00000c5640, ffffffff83159000 dyndbg: freeing page: ffffea00000c5680, ffffffff8315a000 dyndbg: freeing page: ffffea00000c56c0, ffffffff8315b000 Presuming those are 4k pages, 28kb is reclaimed, which is reasonably consistent with the numbers below; 1532/2761 compresson of 64KiB. I have fixed one edge-case over-free, which gave me a coredump on ```cat control```, there may be (one) other. dyndbg: 2762 prdebugs in 235 modules, 11 KiB in ddebug tables, 86 KiB \ in __dyndbg section, 64 KiB in __dyndbg_sites section CC: david@redhat.com # free_reserved_page() tip Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0a68fbfd8432..194367bc13fb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1542,6 +1542,7 @@ static int __init dynamic_debug_init_control(void) fs_initcall(dynamic_debug_init_control); =20 static struct _ddebug_info builtin_state; +static __initdata struct _ddebug_site *last_site; =20 static int __init dynamic_debug_init(void) { @@ -1622,11 +1623,12 @@ static int __init dynamic_debug_init(void) if (ret) goto out_err; =20 + last_site =3D &__start___dyndbg_sites[site_base]; ddebug_init_success =3D 1; =20 - vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in _= _dyndbg section\n", - i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), - (int)((i * sizeof(struct _ddebug)) >> 10)); + vpr_info("%d prdebugs in %d functions, %d modules, %d KiB in ddebug table= s, %d,%d kiB in __dyndbg,_sites sections\n", + i, site_base, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 1= 0), + (int)((i * sizeof(struct _ddebug)) >> 10), (int)((site_base * sizeof(st= ruct _ddebug_site)) >> 10)); =20 if (di.num_classes) v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); @@ -1652,3 +1654,40 @@ static int __init dynamic_debug_init(void) /* Allow early initialization for boot messages via boot param */ early_initcall(dynamic_debug_init); =20 +static int __init dynamic_debug_sites_reclaim(void) +{ + unsigned long addr, end, start; + /* + * from mm/init.c:free_initmem (void) wo poisoning + * The init section is aligned to 8k in vmlinux.lds. + * Page align for >8k pagesizes. + */ + start =3D (unsigned long)__start___dyndbg_sites; + end =3D (unsigned long)__stop___dyndbg_sites; + addr =3D (unsigned long)last_site; + + vpr_info("full range: %px-%px, %lx-%lx\n", + virt_to_page(start), virt_to_page(end), start, end); + + vpr_info("freeing range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + addr &=3D PAGE_MASK; + addr +=3D PAGE_SIZE; + end &=3D PAGE_MASK; + end +=3D PAGE_SIZE; + + vpr_info("ie range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + if (verbose < 2) { + vpr_info(" skipping reclaim cuz its broken by `cat control`\n"); + return 0; + } + for (; addr < end; addr +=3D PAGE_SIZE) { + vpr_info("freeing page: %px, %lx\n", virt_to_page(addr), addr); + free_reserved_page(virt_to_page(addr)); + } + return 0; +} +//late_initcall(dynamic_debug_sites_reclaim); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 48E5BECAAD5 for ; Sun, 4 Sep 2022 21:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236300AbiIDVqy (ORCPT ); Sun, 4 Sep 2022 17:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235438AbiIDVpX (ORCPT ); Sun, 4 Sep 2022 17:45:23 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D2C30F53 for ; Sun, 4 Sep 2022 14:43:04 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id l16so3889318ilj.2 for ; Sun, 04 Sep 2022 14:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=enn6xVuYphe+hXVPoV5iWIYr1g8ASji6MTEr9zuj34c=; b=MHZ+j5vq+DgcrRYUNssA/mQhOIh3IuE7Zq+aUJb41YdzWZC9PSDSIhOvEQ3TdCICX5 WTCvmLp7RobRHWpiQpug9Ise55wiJ4uYADB3QCMYatUnEHE8Jziwms0gNLdJzSy1SzKa weVrPvvMaJPWqT6SfVFtUwOQv+sOyCuhrhi/oJW7xApjkbYa3ldckzG68imOVm76KV+m Xwjrlq1ZQVkjBcKsJbOYdKGeSdp/d/LglobU+D8HgN3Kz9AvMJF9xfzvrS0x23RcYOMb o7tMHOwXqEMULGc4tCi168zLZkAoPrmdiBkQzY7FRbs0xD1GH/Ij8ZhWMXzT0upfwrl7 rC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=enn6xVuYphe+hXVPoV5iWIYr1g8ASji6MTEr9zuj34c=; b=voXIalhND1PVrKyliNAGLhRCZqP1dIgxSarh4mUzBCyLdtsXCMLswyBoKGL4ndY18M odM++oA1qwZy4SdTsxPhjsswg4Q8UgNrZO4d8jJ4RxST6oMNXBpuj/65YQe1kh5Ix2Od xx5OQKJ/u6HFvmdPJAsNiH8CRZslWnXwpAZ9WfljMyeoItD540VT6XQ6IX+I8Hi94GSv FUMoOqANSS5DAX40lKkjB4gUfVRjmPu77hl6TthykFoUi3C8FbxYIQ/cYSLp3xJwhid2 pZmMXDOHYywtcQh6vPWth3VfkPtIvqzPWKNwp/YLVcla45eZVMfoM+O7rkDTBCC+y42i UC6Q== X-Gm-Message-State: ACgBeo2PyjGfnFkco54p39BtQGF2zqNc6pS/sGp5/fy8eP/oHe8EO38z 0qvUvzwl8lE2KfmvT22SbAQ= X-Google-Smtp-Source: AA6agR5YpuT8Q9JQCumSZI1qIIDzfmGUPYBDoLNXJiZ6x9bW2LfTNC3WN5DzbhXOp2lE4bQ4o8fKCA== X-Received: by 2002:a05:6e02:1605:b0:2ed:be80:59ae with SMTP id t5-20020a056e02160500b002edbe8059aemr7558764ilu.319.1662327783877; Sun, 04 Sep 2022 14:43: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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:03 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 56/57] dyndbg: work ddebug_map_site Date: Sun, 4 Sep 2022 15:41:33 -0600 Message-Id: <20220904214134.408619-57-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" attempt container-of, broken, missing use of uplink... took that out. ptr computations are naive, and wrong. Deeper prob is lack of _ddebug_vec, with header and descs in same struct. maybe. builtin_state looks right in debugger --- lib/dynamic_debug.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 194367bc13fb..11fea1f818a7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -173,8 +173,25 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons return NULL; } =20 -static inline struct _ddebug_site * _ddebug_map_site(const struct _ddebug = *desc) +/* + * mapping from desc to site is multi-step: + * - _index back to &descs[0] + * - container-of to get header struct above + * - ._uplink field, pointing to _ddebug_info (for builtins, loadables) + * - di->sites[desc->_map] + */ +static struct _ddebug_site * _ddebug_map_site(const struct _ddebug *desc) { + struct _ddebug_info *di; + struct _ddebug const *d0 =3D desc - desc->_index * sizeof(struct _ddebug); + + di =3D (struct _ddebug_info *) d0; + + v3pr_info("map_site idx:%d map:%d %s.%s di:%px site:%px ds:%px\n", + desc->_index, desc->_map, + desc->site->_modname, desc->site->_function, + di, desc->site, &di->sites[desc->_map]); + return desc->site; } #define _desc_field(desc, _fld) (desc ? (_ddebug_map_site(desc)->_fld) : "= _na_") @@ -866,7 +883,7 @@ static char *__dynamic_emit_prefix(const struct _ddebug= *desc, char *buf) return buf; } =20 -static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) +char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) { if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) return __dynamic_emit_prefix(desc, buf); --=20 2.37.2 From nobody Sat Apr 11 12:31:06 2026 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 8A21DC6FA82 for ; Sun, 4 Sep 2022 21:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236313AbiIDVq5 (ORCPT ); Sun, 4 Sep 2022 17:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235850AbiIDVpZ (ORCPT ); Sun, 4 Sep 2022 17:45:25 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A144030F65 for ; Sun, 4 Sep 2022 14:43:05 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id n202so5657655iod.6 for ; Sun, 04 Sep 2022 14:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gc3CEPtxYjk29+Wh9qd9Uhba+Qcycq/xTeA557V/yJA=; b=pjBlhL+ATdSasCB8eiAlDBtg6VQZe3cAxxbzs1dn4fhsTGll1ZJKZVPkMR2mAe6vQD +1ZUleBqb9yFLUkLQLuRp4esV7jUMm+9nkPY8LhEgMfb+aZzAVC2mkPJrqbpGbEQhkRo beZ5FNifB5rdJxWg7R8D5bcVcnK7tDty4bpm3uL/kbFe0gGnoJy6MFouLJWvzkGtbSFw KbDqjScDXUcFQ9R/5Be0XLDU0graPMWJvrt9XQvpuQIZmHQO8jVZA6GPpMTQquJWxpzE uymD2AvAzBcc+9sFlbROngihXuT8MzFti5OGgYB/TVQyB52NFye/DNbIZ9Wq82jlh8uk kuiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=gc3CEPtxYjk29+Wh9qd9Uhba+Qcycq/xTeA557V/yJA=; b=GqbEPPa37T4YeyUTp4aAgPldX7heCECALg4/cr84gDsu4ldpNjH2cBCue9QRBuc36Q KUG5PL+lDRhWO15vxVaoRpRpLKMTb/fLOabbkdVgrUj40BkNfJiamCQM0xXtR0b9XfAu qdGr4WPcsQIsMMH7Wv6sp8/yjEn0CAQjTqJIVAH3Y1+RPoCBzea9Lu0YyOH3FrOwqt2n m+PacxqndtesHASfCr88QALvXMgRcm+ZeNxxjUzAX8eLL0EiOpaEkP99RKq+npjLpKmh eYvJcguPdLpgbbQ0SnOSACJyC8J+jRL61B+qszZnXummrjKQcbtnpuZKaJC5qzxtg873 Cvnw== X-Gm-Message-State: ACgBeo1WCfh0AswQzgHqb+PsnjHtv2QPy9eIhFZaLXYN2t9GrSWDUw2J y+kShT5N0jo16wnkNjfVrx8= X-Google-Smtp-Source: AA6agR62BzXzT17KlWx9uqQOlpAhM116jyafKxT3anpuAMgqBhik1FZ5pmVPGg2GE9QdKZVv5ooKrQ== X-Received: by 2002:a05:6638:24c2:b0:346:ce9e:3eff with SMTP id y2-20020a05663824c200b00346ce9e3effmr25894336jat.262.1662327784843; Sun, 04 Sep 2022 14:43:04 -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 e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:04 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 57/57] dyndbg: fiddle with readback value on LEVEL_NAMES types Date: Sun, 4 Sep 2022 15:41:34 -0600 Message-Id: <20220904214134.408619-58-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-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" my test scripts were writing one val, reading back val+1 echo L3 > p_level_names cat p_level_names L4 fix this w a -1 offset. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 11fea1f818a7..7d458601a61b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -830,6 +830,8 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); =20 case DD_CLASS_TYPE_LEVEL_NAMES: + return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl - 1); + case DD_CLASS_TYPE_LEVEL_NUM: return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); default: --=20 2.37.2