From nobody Tue Jun 23 17:17:21 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 450BAC433F5 for ; Tue, 1 Mar 2022 16:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236258AbiCAQrf (ORCPT ); Tue, 1 Mar 2022 11:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234469AbiCAQrb (ORCPT ); Tue, 1 Mar 2022 11:47:31 -0500 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 A49ECDF9B; Tue, 1 Mar 2022 08:46:50 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id i1so6378516ilu.6; Tue, 01 Mar 2022 08:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WgWVdTddSK1VIvJpihEOxrT4Mi3SIzAJw8C0VgfJ1+E=; b=ZyIqslhYvDH+znU49RDNGGBtdf2Hx25EKBLYyLNACYFixw48LAxXuDhuXdvN2vYeV0 XtVH31Chbhr2WBzD6kuN2Lz7Aq+1wtlZukZS0en4xgMbIdXnVLKXVxq/s8o5v54hvmbr +v/3ebOGaZG+QRjCOwG4LGK73r4S2U8Ik1iea312xRwkjMKD5XcO0+V3Zr5uaVlkFpZ6 hZJZ8yZ5Rh0tqRdJg4cL4zVkFORCWrFm1fmiKLAeBYsrqNKwmLTjrWspHnjSm+tRlfKv iW1YRmjCT7tc86d4IU91fXGtrPZWxgYvQhvUdvUCycWPlc8fa3md+RIZKr5NCtx0XegN W6+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WgWVdTddSK1VIvJpihEOxrT4Mi3SIzAJw8C0VgfJ1+E=; b=zSj/hd/fcrYNj1xHMorLpVgBdVXVjtWKDDUOrSBx++E0rxYFa1G8o2Qj0NmqW29tBg viClcwLicV9RspMq2At6f7CwbRN3pbQxXMWqqfhgWLpFO76Pdm7EGrVNCvbadJdMWCsD oERUg6kcFtGL4Laxh0HKhb+UyS6coln/3Z1K/wdOgt2NN2L7FCYLUeLr+Z7q7Euzcbae ACHqnZcxvWvEU8jJx3YYt//nD9nW2JUahvlyAp5noAQHQgX7fkovon0HtBLQwWkPuRMG i7yFDpFaTxlPuqiq+dCfICbCsg/EFVyvtEQQe3qAnbvHEMs+VEdpeTPTIE1u3Z2UTbnG x1sQ== X-Gm-Message-State: AOAM532iELnAqsQv4PmcBm5gAweUoevM/WYBsJIvOEzTWSpk3+69k3wM rzIMAnb0podQWVKVHsmQxHw= X-Google-Smtp-Source: ABdhPJy2WosYoNk36kwc3YDo4CJeoXCvRi+g+pvs1KuGqtjA+5zI4UvsFnn0cAKS/KsQmhNn9fQ6aw== X-Received: by 2002:a05:6e02:1986:b0:2c4:804:2e6a with SMTP id g6-20020a056e02198600b002c408042e6amr2063617ilf.130.1646153210047; Tue, 01 Mar 2022 08:46:50 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:49 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie , vincent.whitchurch@axis.com, stable@vger.kernel.org Subject: [PATCH 01/13] dyndbg: fix static_branch manipulation Date: Tue, 1 Mar 2022 09:46:17 -0700 Message-Id: <20220301164629.3814634-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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, did not use that result, but used 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 work properly, 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 CC: stable@vger.kernel.org Signed-off-by: Jim Cromie --- 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.35.1 From nobody Tue Jun 23 17:17:21 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 2955EC433EF for ; Tue, 1 Mar 2022 16:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236276AbiCAQrj (ORCPT ); Tue, 1 Mar 2022 11:47:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236126AbiCAQrd (ORCPT ); Tue, 1 Mar 2022 11:47:33 -0500 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 8B55DDF90 for ; Tue, 1 Mar 2022 08:46:51 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id c23so19134150ioi.4 for ; Tue, 01 Mar 2022 08:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lhV/42e6eHfwU41W+fsYtA842umTK2PqsPSs56IFY9s=; b=b0XFOPQQtftOUKQtzQ1SczPNAL06mxzYyK81asDMfPHqm9i4vsleWJKbkJTJ2toh9V LqvUC9Efzp9mUwked5iUQutUoT/CMi0Wt/BI/qydVgSdTff37ajJrEWsApuv/ryKtZHf b1Ib+obI3LvAckFehII201hkxYJqay1FwVREroYt2kj7XH1LqEm3F9MKHP++RKxfRHP1 lZq2IALqhVVYAZMs+9ikBcsH6pHf1TTYmYzxyjAqBaNCIPWr3rgC3viNVzK5vG1E+8Ej fwHRsKEEqnjrQfalzrCRZkReHG0hV2evFHB/kaYf90P2XOS7BO9eLgrqd+GmfKuGX9/b ylDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lhV/42e6eHfwU41W+fsYtA842umTK2PqsPSs56IFY9s=; b=d6ng8LI0ZnwOYJUr7Lni5p/RaVrvQp09SkuosfMmCbnp807xGZIQX/0wBx81T8SEQo J70kEpIFRuFoOlwKu4T5hvxshoLKCCQAhp89WWUavAkESPpgsBauecMxhrckDFaxjveF b/fh3/wFEgr3PoUKr8diWUrAWEAIor/X4l14RleS5WF2c5Hy3uK25cN6Mc9IPWiIoqCe GTcMpK1hg7KReDl3KI43PILNlzm5VHAALDmgsUYZQozl6tyjvylzTwck4ITW0tK2YChV YY3Bd91TSAiL/lka6VH7dbef2ktnnin8LfsHTmjNDh6weQYascARJdukvivHxRVvuxxZ 8eqw== X-Gm-Message-State: AOAM531sKgKdUOQpMzYHSUXH3I7lLSWUZzkttxFy9m9dM7ODouA3uc9L oV+4947MPgb01jlhlh9w1w4= X-Google-Smtp-Source: ABdhPJyltdv3uPBpXYxkeLyl2Z38goOsdaSeZwkXpBk8K+/sV1GWBrbjawEOplTOJ0R7R48B4/v/jg== X-Received: by 2002:a02:a905:0:b0:314:9cc6:c1fc with SMTP id n5-20020a02a905000000b003149cc6c1fcmr22042511jam.220.1646153210854; Tue, 01 Mar 2022 08:46:50 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:50 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie , Rasmus Villemoes Subject: [PATCH 02/13] dyndbg: add class_id field and query support Date: Tue, 1 Mar 2022 09:46:18 -0700 Message-Id: <20220301164629.3814634-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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 defines/uses 10 enum drm_debug_category's to create exclusive classes of debug messages. To support this directly in dynamic-debug, add the following: - struct _ddebug.class_id:4 - 4 bits is enough - define _DPRINTK_SITE_UNCLASSED 15 - see below and the query support: - struct _ddebug_query.class_id - ddebug_parse_query - looks for "class" keyword, then calls.. - parse_class - accepts uint: 0-15, sets query.class_id and marker - vpr_info_dq - displays new field - ddebug_proc_show - append column with "cls:%d" if !UNCLASSED With the patch, this command enables current/unclassed callsites: #> echo drm class 15 +p > /proc/dynamic_debug/control parse_class() accepts 0 .. _DPRINTK_SITE_UNCLASSED, which allows the >control interface to explicitly manipulate unclassed callsites. After parsing keywords, ddebug_parse_query() sets .class_id=3D15, iff it wasnt explicitly set. This allows future classed/categorized callsites to be untouched by legacy (class unaware) queries. DEFINE_DYNAMIC_DEBUG_METADATA gets _CLS(cls,) suffix and arg, and initializes the new .class_id=3Dcls field. The old name gets the default. Then, these _CLS(cls,...) modifications are repeated up through the stack of *dynamic_func_call* macros that use the METADATA initializer, so as to actually supply the category into it. NOTES: _DPRINTK_SITE_UNCLASSED: this symbol is used to initialize all existing/unclassed pr-debug callsites. Normally, the default would be zero, but DRM_UT_CORE "uses" that value, in the sense that 0 is exposed as a bit position in drm.debug. Using 15 allows identity mapping from category to class, avoiding fiddly offsets. CC: Rasmus Villemoes Signed-off-by: Jim Cromie fixup class-id preset fix2 --- .../admin-guide/dynamic-debug-howto.rst | 7 +++ include/linux/dynamic_debug.h | 54 ++++++++++++++----- lib/dynamic_debug.c | 48 ++++++++++++++--- 3 files changed, 88 insertions(+), 21 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index a89cfa083155..8ef8d7dcd140 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 number:0-15 =20 * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -143,6 +144,7 @@ against. Possible keywords are::: 'module' string | 'format' string | 'line' line-range + 'class' integer:[0-15] =20 line-range ::=3D lineno | '-'lineno | @@ -217,6 +219,11 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file =20 +class + This expects a single integer in range: 0-15. + 15 is used/reserved for existing/unclassed callsites, + and is defaulted in unless specified to >control + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..d4b48f3cc6e8 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 4 + unsigned int class_id:CLS_BITS; +#define _DPRINTK_SITE_UNCLASSED ((1 << CLS_BITS) - 1) /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -87,7 +92,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, \ @@ -96,8 +101,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_SITE_UNCLASSED, \ + "classid value overflow") + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_SITE_UNCLASSED, fmt) =20 #ifdef CONFIG_JUMP_LABEL =20 @@ -128,18 +139,26 @@ 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__); \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) =20 -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) =20 +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) + +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(id, _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) + /* * "Factory macro" for generating a call to func, guarded by a * DYNAMIC_DEBUG_BRANCH. The dynamic debug descriptor will be @@ -148,15 +167,24 @@ 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_SITE_UNCLASSED, 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_no_desc_cls(fmt, cat, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), cat, \ + fmt, func, ##__VA_ARGS__) + +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), \ + _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) =20 #define dynamic_pr_debug(fmt, ...) \ _dynamic_func_call(fmt, __dynamic_pr_debug, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a56c1286ffa4..ee2129becacc 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -55,6 +55,8 @@ struct ddebug_query { const char *function; const char *format; unsigned int first_lineno, last_lineno; + unsigned int class_id; + unsigned int class_marked:1; }; =20 struct ddebug_iter { @@ -134,13 +136,13 @@ 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%u\n", + msg, + query->function ?: "", + query->filename ?: "", + query->module ?: "", + fmtlen, query->format ?: "", + query->first_lineno, query->last_lineno, query->class_id); } =20 /* @@ -170,6 +172,10 @@ static int ddebug_change(const struct ddebug_query *qu= ery, for (i =3D 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp =3D &dt->ddebugs[i]; =20 + /* match against the class_id, either given or default */ + if (query->class_id !=3D dp->class_id) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -308,6 +314,21 @@ static inline int parse_lineno(const char *str, unsign= ed int *val) return 0; } =20 +static inline int parse_class(struct ddebug_query *query, const char *str) +{ + int rc; + unsigned int val; + + rc =3D kstrtouint(str, 10, &val); + if (rc < 0 || val > _DPRINTK_SITE_UNCLASSED) { + pr_err("expecting class:[0-%d], not %s\n", _DPRINTK_SITE_UNCLASSED, str); + return -EINVAL; + } + query->class_id =3D val; + query->class_marked =3D 1; + return 0; +} + static int parse_linerange(struct ddebug_query *query, const char *first) { char *last =3D strchr(first, '-'); @@ -421,6 +442,9 @@ 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")) { + if (parse_class(query, arg)) + return -EINVAL; } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -428,6 +452,10 @@ static int ddebug_parse_query(char *words[], int nword= s, if (rc) return rc; } + /* post-validate the query, set default */ + if (!query->class_marked) + query->class_id =3D _DPRINTK_SITE_UNCLASSED; + vpr_info_dq(query, "parsed"); return 0; } @@ -900,7 +928,11 @@ 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(m, dp->format, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id !=3D _DPRINTK_SITE_UNCLASSED) + seq_printf(m, " cls:%u", dp->class_id); + seq_puts(m, "\n"); =20 return 0; } --=20 2.35.1 From nobody Tue Jun 23 17:17:21 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 3E28AC433EF for ; Tue, 1 Mar 2022 16:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236378AbiCAQrw (ORCPT ); Tue, 1 Mar 2022 11:47:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236238AbiCAQrf (ORCPT ); Tue, 1 Mar 2022 11:47:35 -0500 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 9644DDF9B for ; Tue, 1 Mar 2022 08:46:52 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id w7so19124268ioj.5 for ; Tue, 01 Mar 2022 08:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IlOodLUUCH3VK1coffQTSgB1I0zc1Wqs31DSZFOVkN0=; b=RBcGCFXDJJ8ZzrE9Vk7GKX+ExX4lzIRqYzuB0ySgH+QVMsCgCQ0Pnn2qyQbra9yrcy kIF87tPEy75YEiRUopxkM91EB3D6xmlZXnKBeGuRFkilb3M3Th/U6tsDt2b8I3Nt66Jy 0urroe3FqevNlZzh4VW1jDt8woXXi6Y32gvwPmz6Wxuw4wi2/4L6hrI+LlU6f+zZcHfI PcPV5PKjEjgV+0H4u/JSd7irDQ8MTBtJ7SVBSRmz2Rt7Ea4/dFzWzp15VpZ0YWgpnkvZ 0Cud/7r/bZ3hPZU0RniaPZ2NLp9673D8ZEmRUw42KUv6OkWgAmt+qjOwc8TjPQj69y2V IL5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IlOodLUUCH3VK1coffQTSgB1I0zc1Wqs31DSZFOVkN0=; b=glbi97AYSV0BZLT0osLsN+lM0CmeNkW+jA/dVpriyeeWi4lf2anTUriew5iTD8S5wS yy9bPw6geKWO2DliJfTAbh7Uz0Zx/+zqierG1PQTSzCgNLhBKHw4KHAcRy8uopQ3lRpD Q1DjlsStMR8KRf8Hw9XhTk1EGmIMOW9qU91/Dxg/ElbNPOtp/teUB2k0DHccocz4q+6O X2wTqghJAxa4cuk5RnEIJPj1NJLoC9xM7/x39jUor07QOmYK7dPukedQ4332Jb7elXIm HTCC24kDcYplOb2rmjgypG8YATZA0EUgDPcVd01wT7FE1pNFEGDlT0FOzUtwJ9W3+wdL 4WdQ== X-Gm-Message-State: AOAM533FD5TjiHvN0PskLECWQciZyfH7NsqszzdZ0MOhxhQefNXPEXfW 17rJyNk0m5OZ71azzFSKhJ8= X-Google-Smtp-Source: ABdhPJyOq028c+35LWrtfkpWWOPiU4KlcOVtTzmuzVxvWiAYOjcUo0xbHrlGL9pyn8a1tPjvd0i7lQ== X-Received: by 2002:a05:6638:6a7:b0:317:494c:35a9 with SMTP id d7-20020a05663806a700b00317494c35a9mr4810361jad.140.1646153211744; Tue, 01 Mar 2022 08:46:51 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:51 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 03/13] dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks Date: Tue, 1 Mar 2022 09:46:19 -0700 Message-Id: <20220301164629.3814634-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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" DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, var, bitmap_desc, classes..) allows users to create a drm.debug style (bitmap) sysfs interface, to control sets of pr_debug's according to their .class_id's This wraps existing "class" keyword and behavior: echo "module drm -p ; module drm class 0 +p ; module drm class 2 +p" >co= ntrol With the macro in use, this is equivalent: echo 0x05 > /sys/module/drm/parameters/debug To use: DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, "pmfl", "drm.debug - bits =3D> categories:", /* vector of uint:4 symbols, ala enum drm_debug_category, 15 is EOL */ DRM_UT_CORE, DRM_UT_DRIVER, DRM_UT_KMS ... ); The 3rd arg is a string with any of the dyndbg.flags [pmflt_]+ Full exposure of the flags here lets the module author: - fully customize/take-over the decorations of enabled sites. generally leaving decorations to user is preferred. - aim the debug-stream: now printk, later tracefs. using both together means more work (p or T, in practice) iface doesn't care about new flags added later - declare 2 separate sysfs-knobs, one each for p, T, if desired. - decorations are per callsite, shared across sysfs-knobs for any controlled classes To support the macro, the patch adds: - int param_set_dyndbg_classbits() - int param_get_dyndbg_classbits() - struct kernel_param_ops param_ops_dyndbg_classbits Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. get/set use an augmented kernel_param; the arg refs a new struct dyndbg_bitmap_param containing: A- the vector of classes (drm.debug "categories") being controlled This in-line vector of constants (uint [0-14]) specifies a sequence of controlling bits (by position, starting at 0) with the values naming the class_id's mapped to that bit. A value of _DPRINTK_SITE_UNCLASSED terminates the vector processing by param_set_dyndbg_classbits(), and is appended by the macro to insure a defined termination after max 15 classes are applied. Technically, the vector is a flex-array, but its size is practically limited to max 15 in length (repeats are pointless). B- a pointer to the user module's ulong holding the bits/state. By accessing client's bit-state, we coordinate with existing code that still uses drm_debug_enabled(), so they work unchanged. The change to ulong allows use of BIT() etc. NOTES: _DPRINTK_SITE_UNCLASSED =3D 15, ie 2**CLS_BITS-1, deserves special mention; it already marks all existing pr-debug callsites, only the new drm.debug callsites are initialized to other (DRM_UT_*) values. _DPRINTK_SITE_UNCLASSED is used in param_set_dyndbg_classbits() to limit the range of bits that are processed to what fits in uint:4. It also terminates the class-id list passed into the macro, so dont use it halfway through your list of classes-to-control. param_set_dyndbg_classbits() compares new vs old bits, and only updates each class on changes. This maximally preserves the underlying state, which may have been customized at some point via `echo $cmd >control`. So if users really want to know that all prdbgs are set precisely, they must pre-clear then set. Identity mapping in (A) is encouraged. Your vector should exclude 15, if used, it terminates the list prematurely; any following bit mappings will be ignored (it is the default/non category). The whole (A) vector/list passed to the macro is: - not strictly needed: 0-N bits are scanned, only N is needed in the macro interface to do this, not the whole list. - 0-N list allows juggling the bit->class map Identity map is preferred. 15 terminates list if used. (macro impl does this) That said, (A) is self-documenting; the explicit list is greppable, 'DRM_UT_*' provides lots of clues. Further, it could be upgraded, something like: _pick_sym_(DRM_UT_CORE, "mumble something useful about CORE debug") _pick_sym_(a,b) a // gives us what we need here _pick_help_(a,b) #a " : " b // mod-info fodder Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 50 +++++++++++++++++++++++ lib/dynamic_debug.c | 77 +++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index d4b48f3cc6e8..e83c4e36ad29 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -209,6 +209,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_classbits(const char *instr, const struct kernel_para= m *kp); +int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp= ); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 #include @@ -255,6 +259,52 @@ static inline int dynamic_debug_exec_queries(const cha= r *query, const char *modn return 0; } =20 +struct kernel_param; +static inline int param_set_dyndbg_classbits(const char *instr, const stru= ct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classbits(char *buffer, const struct ke= rnel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 +#define FLAGS_LEN 8 +struct dyndbg_classbits_param { + unsigned long *bits; /* ref to shared state */ + const char flags[FLAGS_LEN]; /* toggle these flags on bit-changes */ + const int classes[]; /* indexed by bitpos */ +}; + +#if defined(CONFIG_DYNAMIC_DEBUG) || defined(CONFIG_DYNAMIC_DEBUG_CORE) +/** + * DEFINE_DYNAMIC_DEBUG_CLASSBITS() - bitmap control of classed pr_debugs + * @sysname: sysfs-node name + * @_var: C-identifier holding bit-vector (Bits 0-14 are usable) + * @_flgs: string with dyndbg flags: 'p' and/or 'T', and maybe "fmlt" al= so. + * @desc: string summarizing the controls provided + * @classes: vector of callsite.class_id's (uint:4, 15 is reserved) + * + * This macro implements a DRM.debug API style bitmap, mapping bits + * 0-14 to classes of prdbg's, as initialized in their .class_id fields. + * @_flgs chooses the debug recipient; p - syslog, T - tracefs, and + * can include log decorations; m - module, f - function, l - line_num + */ +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, _var, _flgs, desc, ...) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_classbits_param ddcats_##_var =3D { \ + .bits =3D &(_var), \ + .flags =3D _flgs, \ + .classes =3D { __VA_ARGS__, _DPRINTK_SITE_UNCLASSED } \ + }; \ + module_param_cb(fsname, ¶m_ops_dyndbg_classbits, \ + &ddcats_##_var, 0644) + +extern const struct kernel_param_ops param_ops_dyndbg_classbits; + +#else /* no dyndbg configured, throw error on macro use */ + +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "CONFIG_DYNAMIC_DEBUG* needed to use this macro: " #f= sname) + +#endif + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ee2129becacc..7eb1c31f870d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -611,6 +611,83 @@ int dynamic_debug_exec_queries(const char *query, cons= t char *modname) } EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); =20 +#ifdef CONFIG_MODULES +#define KP_MOD_NAME kp->mod->name +#else +#define KP_MOD_NAME NULL /* wildcard */ +#endif +#define FMT_QUERY_SIZE 128 /* typically need <40 */ +/** + * param_set_dyndbg_classbits - bits =3D> categories >control setter + * @instr: string echo>d to sysfs + * @kp: kp->arg has state: bits, map + * + * Enable/disable prdbgs by their "category", as specified in the + * DEFINE_DYNAMIC_DEBUG_BITGRPS.classbits argument. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classbits(const char *instr, const struct kernel_para= m *kp) +{ + unsigned long inbits; + int rc, i, matches =3D 0, totct =3D 0; + char query[FMT_QUERY_SIZE]; + const struct dyndbg_classbits_param *dcp =3D kp->arg; + + if (!dcp) { + pr_err("set_dyndbg_classbits: no bits=3D>queries map\n"); + return -EINVAL; + } + rc =3D kstrtoul(instr, 0, &inbits); + if (rc) { + pr_err("set_dyndbg_classbits: expecting unsigned int\n"); + return rc; + } + vpr_info("set_dyndbg_classbits: new 0x%lx old 0x%lx\n", inbits, *dcp->bit= s); + + for (i =3D 0; i < _DPRINTK_SITE_UNCLASSED && + dcp->classes[i] < _DPRINTK_SITE_UNCLASSED; i++) { + + if (test_bit(i, &inbits) =3D=3D test_bit(i, dcp->bits)) + continue; + snprintf(query, FMT_QUERY_SIZE, "class %d %cT", dcp->classes[i], + test_bit(i, &inbits) ? '+' : '-'); + + matches =3D ddebug_exec_queries(query, KP_MOD_NAME); + + v2pr_info("bit-%d: %d matches on class:%u\n", i, + matches, dcp->classes[i]); + totct +=3D matches; + } + *dcp->bits =3D inbits; + vpr_info("total matches: %d\n", totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg_classbits); + +/** + * param_get_dyndbg_classbits - classbits reader + * @buffer: string description of controlled bits -> classes + * @kp: kp->arg has state: bits, map + * + * Reads last written bits, underlying prdbg state may have changed since. + * Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp) +{ + const struct dyndbg_classbits_param *p =3D kp->arg; + unsigned long val =3D *p->bits; + + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", val); +} +EXPORT_SYMBOL(param_get_dyndbg_classbits); + +const struct kernel_param_ops param_ops_dyndbg_classbits =3D { + .set =3D param_set_dyndbg_classbits, + .get =3D param_get_dyndbg_classbits, +}; +EXPORT_SYMBOL(param_ops_dyndbg_classbits); + #define PREFIX_SIZE 64 =20 static int remaining(int wrote) --=20 2.35.1 From nobody Tue Jun 23 17:17:21 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 13A38C433F5 for ; Tue, 1 Mar 2022 16:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236351AbiCAQru (ORCPT ); Tue, 1 Mar 2022 11:47:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236229AbiCAQrf (ORCPT ); Tue, 1 Mar 2022 11:47:35 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B543F89A for ; Tue, 1 Mar 2022 08:46:53 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id h28so1056333ila.3 for ; Tue, 01 Mar 2022 08:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AbSflc6torbg6et0qHRbYffNYt1UwJtGJnvXLb74Egg=; b=a8NcLGv6QnSm81bZgtybm/3TJdwwz3ps9+oLhVSAoJ+G/F66Z5LI3EaMGrmwmMwoY/ yN0K1Zb0IC09OPzL/6RZfTa+5oVdKazhzZQAWYbJD37M9x+9oeYMawEilUhvtLM0WXcR ZC7jzMONS65JLV4KjlMIrdW70fQNiig+49kQLkE5W2ssRsp3JG87GZa+4v5Oxybm2Ywb AhcIV856HuWZVHbBZ/SDoDMxW523jT/3sASvL1zw2zqCXBR9R8KGCF+2yklmEIb7dkEO DT+moribozBiXnVturfKp/uYzSgSWReXJDmNfjVA1A3shp+SX+48AxB1tRVWLd7KWQBa EkAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AbSflc6torbg6et0qHRbYffNYt1UwJtGJnvXLb74Egg=; b=CCZKs0pFgWa95gBXJ8OTFnKGQBPRErV6eEPESnIcw6nKxXjM55S+uCP0e72BpEYD0K mAL9OP3XTrjaknpg/cEz5nuaFPQMB2CddEE9NnzVhhXx4sieOhbCBM4zEZcBVv26d22A OmgYgkCvNvodSMk/3JW1snSs7uIvX9XvgWhp+jmrCsRVQvwohSsShn/8DAxQehJRG37I gZ3KH2To8+ZSLTPpNdaQRZBQy41To37BwBWYHy8eUlnYhnhHm3NFx0p9S+yX3vmqns0h e5GsM/7JGxaAXUNKejWQY8Q0VyTwicYUFF0JJ6d4IIKveCmjslfVXf1COZMK0fyZWJEm 9OSQ== X-Gm-Message-State: AOAM531+PzlCbrd9nFMd0kv0zrOSAMzz4s7NEblZg4RMoxJ27zZGlEBA TxqZmiGtK+mLVTTDhUY98mI= X-Google-Smtp-Source: ABdhPJy6L6EDsvK7PBArj9g4nyI0AQq/wSqykPlUuAfjt8JbLKlKA0YR9SYeFaMso7gOJB6AzgaOww== X-Received: by 2002:a92:dd86:0:b0:2bc:805c:23c7 with SMTP id g6-20020a92dd86000000b002bc805c23c7mr23352416iln.279.1646153212757; Tue, 01 Mar 2022 08:46:52 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:52 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 04/13] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Tue, 1 Mar 2022 09:46:20 -0700 Message-Id: <20220301164629.3814634-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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 effectively obsoleted by Commit:HEAD~2, so remove it. The export was added here: commit a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec= _queries()") commit 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") Its intent was to allow drm.debug to use the exported function to implement its drm.debug bitmap api using dynamic_debug. Instead, HEAD~2 implements the bitmap inside dyndbg, and exposes it in a macro declarator, and HEAD~1 uses the macro to connect __drm_debug to the supporting callbacks. Since there are no other expected users, and any prospects would likely reuse the bitmap or a straightforward extension of it, we can drop this function until its really needed. This also drops the CONFIG_DYNAMIC_DEBUG=3DN stub-func, and its pr_warn(), which I avoided in 2012, then added in 2020 :-/ 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 e83c4e36ad29..664bb83778d2 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -60,9 +60,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); @@ -253,12 +250,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; -} - struct kernel_param; static inline int param_set_dyndbg_classbits(const char *instr, const stru= ct kernel_param *kp) { return 0; } diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 7eb1c31f870d..60b2572e64f0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -582,35 +582,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); - #ifdef CONFIG_MODULES #define KP_MOD_NAME kp->mod->name #else --=20 2.35.1 From nobody Tue Jun 23 17:17:21 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 8A08BC433EF for ; Tue, 1 Mar 2022 16:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbiCAQrn (ORCPT ); Tue, 1 Mar 2022 11:47:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236266AbiCAQrg (ORCPT ); Tue, 1 Mar 2022 11:47:36 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB0A427F9 for ; Tue, 1 Mar 2022 08:46:54 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id 9so12973247ily.11 for ; Tue, 01 Mar 2022 08:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z8u4MF+f5/cGlLGB0/vAj9alSkuZujSqlEVmUNGHTX4=; b=EoKe1Vmlza53p81HMtpffi/FybfHcwZEbuj/YR2K3DkCNQ8dNkbtA0D9ABl/k5l3CT iGyWhO/JC3xToc7WdDDe0J+ymBPPVaDNKXdQWnDoeKbt0KlRdtLDXXvQ5HSCTvDwPVzx ti+sbATfop4sNR8TEufa/jTcJ+HVvV1fANPunTC4VWAIpR0vZkosU5xD2ut9CmD9uJHI aIALlS8bGfvMoC6BLuRrKwww+3/sdpVpBhcVl/CQfvcn/H6oJY06xsn13OjGB8qV0RUY Kg1qEE/FBSjxSN/b6N6YsuuMx0aFX3nWar49uUGKCDkOzaSm3Ym1QpmVJLghds3pYZt9 PPsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z8u4MF+f5/cGlLGB0/vAj9alSkuZujSqlEVmUNGHTX4=; b=YhPkomnQXAOTaNfjmtK7WJL8fPw8fquUxa5Gv5KdahIsz1gwe5T/R26bAd1yXwqpz6 BACHNmXf/A4utOfUgIM6gPMDyI3y9lw9CWrQ5ZtyXb0d9Fp50DYV+V1QoP2B/bF4rP/4 b0eXJomXaBjGM3+8Z8xoXMLJxHRmoQYc68tw3K6ze02m69lYVjldpSPuMBaKca8XMvyP aHdEe0TOabCvNmcxfJ5PVpfQ0qAI7Moc1RpvCiwZqCFsqDS+Fw0Iietp8BINCOcKcOOk hkWwrzsH0QbduQ0OnmAn82Xvum5DOE6AahKJ2kJpIAyHUn9PyHGHOTPIMXEEMCh84d7I KnvQ== X-Gm-Message-State: AOAM533j+lsxgA3FOs+loQvqoEo5mDa0sFhd0Lc1yRlX+M7Y0Z7mecjV F4FdtNToPwve44Zv4IJSBY0= X-Google-Smtp-Source: ABdhPJxK5WeEUVyEuTuND3j4vG/YJnSaxYEpQFY4ZNpRm7OJTrBmY08zUwihDnew7RXNG33rQR7jMw== X-Received: by 2002:a05:6e02:1bc3:b0:2c1:a992:9ffa with SMTP id x3-20020a056e021bc300b002c1a9929ffamr25168133ilv.124.1646153213496; Tue, 01 Mar 2022 08:46:53 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:53 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 05/13] dyndbg: improve change-info to have old and new Date: Tue, 1 Mar 2022 09:46:21 -0700 Message-Id: <20220301164629.3814634-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" move site.flag update after the v4pr_info("change") message, and improve the message to print both old and new flag values. Heres new form: dyndbg: changed net/ipv4/tcp.c:2424 [tcp]tcp_recvmsg_locked pT -> _ 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 60b2572e64f0..ab93b370d489 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -158,7 +158,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); @@ -223,11 +223,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 -> %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.35.1 From nobody Tue Jun 23 17:17:21 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 D1A42C433EF for ; Tue, 1 Mar 2022 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236300AbiCAQrq (ORCPT ); Tue, 1 Mar 2022 11:47:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236262AbiCAQrg (ORCPT ); Tue, 1 Mar 2022 11:47:36 -0500 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 C8EC542A34 for ; Tue, 1 Mar 2022 08:46:54 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id d3so12992456ilr.10 for ; Tue, 01 Mar 2022 08:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/iB17natQD1MoZXV2qkvWvbusYAfF8+WZi2MjQWQu/w=; b=SHplEMJ4dgHQP7e3PXFiBHg0b5PrXGyYSjVU4WM97MmcMC8lOxaE+n44zic8aROkue YJdXX8P0waLgppC8wUfg3TPWWpPLZ43WMZhNXseOpaKUIiaQwABtxpUf9fsu7DNCjstI 8IbA0ejfY82JTbCixhin11dJbzKOp6EHlG+zrVV9HCZcuvwQdSz48pnbzG4vk7M7RlUx VG6drh2X1ywcyBZ2WRkNyO5FWAldJ8e+ijz/Zx5BvGVUqczqyRyvgZZFm9AAh9aHCAtt JMjSVUBelGF+64eRHC6eM1PvoM0Y5Piq4V6fEpZLUed4c0GPKgFKSFH3RGyUaBYCImXz GMWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/iB17natQD1MoZXV2qkvWvbusYAfF8+WZi2MjQWQu/w=; b=63a8YLeK73HIbS1z1nbaYTOc47j1wXfm1Jc8Vwbjd1IC5KwGqHkZjziQOPTzjHyTW/ hbEgx7yrAQGmhrBDhNu6PM/4btj7wdmqVhM2AS5xKSmoqLZS/PBMGjXR6jSkLPy9n+R5 sA5ii0umJ5iUnysKPS7MUwI2uuK5FWFJknzNvQdRLdIltEOeUUEay/hjXkaiBlYTSmZb tLO2kPGumL6Je5Zc5quf5g7DErN6Eny4G8KrG3Ada99zNr6uPaXpxvWgDhX5DScohAvS yY5pOuYF7lfWWzpWyuINSKhIRBySLi/3vGIZ6QF2IB8uHXVd7gGtysvz9PYFnODZky4w +FxQ== X-Gm-Message-State: AOAM530819LR3QamJ2itReKiBvIk44R6yhGFSz7UZohbm9YGelLCH24a Ma9DDPjmsY1ltcJq20aFI5k= X-Google-Smtp-Source: ABdhPJxLY8uCZOj8gfXThodH+sbeS3tw4N8aFtECPOV8owdml6wtey6aG7AC7+fAtaCy8s8BIGAwZg== X-Received: by 2002:a05:6e02:20e8:b0:2c1:e164:76e6 with SMTP id q8-20020a056e0220e800b002c1e16476e6mr23670264ilv.135.1646153214231; Tue, 01 Mar 2022 08:46:54 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:53 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 06/13] dyndbg: abstract dyndbg_site_is_printing Date: Tue, 1 Mar 2022 09:46:22 -0700 Message-Id: <20220301164629.3814634-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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" Hide flags test in a macro. no functional changes. 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 664bb83778d2..106065244f73 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -56,7 +56,7 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 - +#define dyndbg_site_is_printing(desc) (desc->flags & _DPRINTK_FLAGS_PRINT) =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 --=20 2.35.1 From nobody Tue Jun 23 17:17:21 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 E9E89C433EF for ; Tue, 1 Mar 2022 16:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236358AbiCAQsB (ORCPT ); Tue, 1 Mar 2022 11:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236271AbiCAQrg (ORCPT ); Tue, 1 Mar 2022 11:47:36 -0500 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 ADA2043AD6 for ; Tue, 1 Mar 2022 08:46:55 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id h28so1056416ila.3 for ; Tue, 01 Mar 2022 08:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eZXNUqubAB8NNsFmaxywjAoPOWysBIvPMcZdY6L3itE=; b=cBscgP41htfLiQ2OxXZNjPjNT9epnka4RNeYhMMNLhyziuaJKqWOTub2OdKwwH+Odg J81R3HY12eJs4g9jm8hFhikPRdw6qltg4xzra8tbEs3CjKMzN6in5GunPnNjmfjsjaiG t4ebdJlrUqEuN3pXln5duyqK4vRfkT1DYJJNirI9i9zrekSiuqB8QcqS8UDKyEZFRPqU nDmtvEHpFBOZGze2PwgXG69dTSUgVZGOPFnpm019TLO/CRtkIX9DmS76vLmXKfstiTCe efQB6kpsKZ3f/wz++gAVH2/IqK9MFU0Mh3mzGpPrY0n7uWiHaMmfqE00x6Ppn5EtM/op Us5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eZXNUqubAB8NNsFmaxywjAoPOWysBIvPMcZdY6L3itE=; b=h40ZZkgsA8xbfLZq1+mTgmNM3pSLLq00aQkv+pgCiiRIfNZ4qdeTWcJNdkwCFRQEUo T66h2rnNdcT36AJ2e1JQnC0Ws+T+SdLkdoipbQSLPgfUB16O1khRj8o88b6pUR2uGSP0 BtBLHXEczcwHp/19zAjpX0WytNBj8yOzD1YZQdJuY9nP6Lawb7id34OBTW4CS6fskWno C2wu4spstch7Rz/5ux+yxaMyj8CLy90ExPGv6qyEuhZEwmSMpKmkOY7UD0qEbnKf2SSn k8trEjegi+EnY6hBpXZRpl795Mo5s1/lirVX11SyuADi53+QR3meHckmoEeFtb52XBjm Erww== X-Gm-Message-State: AOAM533OcpkJkERGPJcv8YPQM+NMg3d0TCFyP/o2c9PEyJwt8eVx8PPH caDIP0MhDa8yilYxgX5qYBg= X-Google-Smtp-Source: ABdhPJwoqnkXIbxFZaZCJRvZ08M8RqoA/qmhVFDfhpmycRS1WR6s4XCCJA+9fPCrhqrKWS3Wy3AylQ== X-Received: by 2002:a92:c26b:0:b0:2c2:9037:a788 with SMTP id h11-20020a92c26b000000b002c29037a788mr23790624ild.95.1646153215064; Tue, 01 Mar 2022 08:46:55 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:54 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 07/13] drm_print: condense enum drm_debug_category Date: Tue, 1 Mar 2022 09:46:23 -0700 Message-Id: <20220301164629.3814634-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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 "classes", explicitly initialized with 0x-bitmasks which could be simplified as BIT(X)s. But lets go further: use natural enumeration (int, starting at 0), and do the BIT(cat) in drm_debug_enabled(cat) at runtime. While this slightly pessimizes the bit-test, the category now fits in 4 bits, allowing it in struct _ddebug.class_id:4. This sets us up to adapt drm to use dyndbg with JUMP_LABEL, thus avoiding all those bit-tests anyway. Signed-off-by: Jim Cromie --- 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.35.1 From nobody Tue Jun 23 17:17:21 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 A2AFFC433EF for ; Tue, 1 Mar 2022 16:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbiCAQsG (ORCPT ); Tue, 1 Mar 2022 11:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233440AbiCAQrh (ORCPT ); Tue, 1 Mar 2022 11:47:37 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C2ADF9B for ; Tue, 1 Mar 2022 08:46:56 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id q4so13053664ilt.0 for ; Tue, 01 Mar 2022 08:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yubkIm83qdloKERgFDUIX083yqNPWzHEzjvX+hTfJ+Y=; b=ISLm3V/IeiSDg5+vhkENxW8YE87dpmigL0ocrTSt3CRgNZkAy1Rz6YjEeVshUsSI9o cV/iEN5PW5UM7azuw3NI4Y36/pPbzowJnMAv9WrteAVy5ODETIp7a3oAQGx0Ts0kBLsX nLwB8485WMmCEirVOC5OQ5s1gSSXNTWcK9Oo0cDBO1SUWbbPtWYkO/7WA2Ek5C3F+Ic0 pYlNubvK0/z/A17e5ALxwEI5yukvuizRefuVJcUjefpF0/A/HlSREXoQXhU6D/pGK6mr 7zkLvPozhR95fGHbY3Q69TRIqPzApRIjqSoxQRtHDhAKlwnxzwqNoV4S3Q6JP2X6qtqM HB4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yubkIm83qdloKERgFDUIX083yqNPWzHEzjvX+hTfJ+Y=; b=ARd4mWSXGAAxs9rtbqMo6FTnZGF5VHFSZKJlZK/EVOtwd5aXMyhjyAJ1VPzcX7LcYQ TAg99Z7ySNweN1VEQlEk8bdjQPtXBjlgCIG+GtCBQmSvEwtdW4VGRVIktDP973ofbD5S yFcMKy8mwYiAKCGVd6QrRFREP46ilsgRh/9R21ghdCpzfbwLkgvb1lALlzqYW51pUTWZ xDwY0ZJoV8dqycObwYRdapaszd2o8sHONvc2p9CsUSicmx0pxeRrYUYmHYqjTgfWilyT Ln58DJHSWzzVSqwzG+MNjveOYTkbAsVx5duJeW7WqWcy7qzCvzZcS57Cleok2SqLXKfQ IAmQ== X-Gm-Message-State: AOAM5330xV13nSf0YU6t69HEl42o9oaEOypwwRardsrRxIHViuWYgHqf jZabbMqUVdTvZEswoKjpCI4= X-Google-Smtp-Source: ABdhPJxJxOoHiU5RuG9v29v8mzh4AH6zyJup46I/ZGT8FLfyyHklpIIpJBYuJj3VKTdtc8iQV4y46A== X-Received: by 2002:a05:6e02:1b8e:b0:2c2:2750:1178 with SMTP id h14-20020a056e021b8e00b002c227501178mr23158574ili.126.1646153215928; Tue, 01 Mar 2022 08:46:55 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:55 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 08/13] drm_print: interpose drm_*dbg with forwarding macros Date: Tue, 1 Mar 2022 09:46:24 -0700 Message-Id: <20220301164629.3814634-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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_dev_dbg() & drm_dbg() sit below the categorized layer of the DRM debug API, and implement most of it. These are good places to insert dynamic-debug jump-label mechanics, allowing DRM to avoid the runtime cost of drm_debug_enabled(). Set up for this by changing the func names by adding '__' prefixes, and define forwarding macros to the new names. 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 f783d4963d4b..e45ba224e57c 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -256,8 +256,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; @@ -278,9 +278,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; @@ -297,7 +297,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 b3b470440e46..4bed99326631 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -334,7 +334,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 /** @@ -383,6 +383,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 * @@ -484,10 +487,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.35.1 From nobody Tue Jun 23 17:17:21 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 0363AC433F5 for ; Tue, 1 Mar 2022 16:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236299AbiCAQsE (ORCPT ); Tue, 1 Mar 2022 11:48:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236273AbiCAQri (ORCPT ); Tue, 1 Mar 2022 11:47:38 -0500 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 5C10942A34 for ; Tue, 1 Mar 2022 08:46:57 -0800 (PST) Received: by mail-io1-xd35.google.com with SMTP id q8so19131790iod.2 for ; Tue, 01 Mar 2022 08:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0+vGdwnLXxq+vC4sl8UqWBm6MtHqZ6WUpG5Xunn2VjE=; b=Y9vdKRiy1LVLPdctywLbN6QCrXRx56Gx5lTtDCh5IN2ywIY+43Wc1189effJMOtnpH SPRVnu+rQdFrY4nbsr/X0Tl59+MXTBKCrjx0FQPX07k41vSsNLVrkakYlc0QmVVK+h2q 092CeG3jSjdrFlI9/Y4HAjNV9Id+QXscMqyuF/Ze6zkSXqyW1Jx1JEIraIfhwnv6Tht0 07uM3ams1hj07arG6XGES1AZCVndh7T1RLIStRWqSUg3Vd5BUtOeAtDjuRKYiB5p3e2K px6AahJKa6FpRx1/RuVlfPzLEaJMrSd6i6z4tu102bysfwTkJGqIZrUzTOZcQw7V+hvq ZeAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0+vGdwnLXxq+vC4sl8UqWBm6MtHqZ6WUpG5Xunn2VjE=; b=sGq7D2+W6Ftd/hVPdk6zail+RXNWC8lzfZhZfArA7K5qLAxnztBA4gx/tQOJluP0k5 9CAPf1f/No6YFMsFEPduEnlCJRm08q19PPxT9hmteobzJj0HBkQtA7eg6rNxQE9RKc6o 7oP1Li3TC1uXEepOdqDaPp3rKQs8MfMhBRv+cs667u+73QiolNd4Ys3hA6HrEQKC59NO bSFvjE9zUvf9tFU0MXN8LJdKtERfZaGOoc5VTrE27YzViw768UEk8PkXhLLnws3mUltE T6psA6fT/ot19f9AkbIs6JwaX+3YMImjAjdoE7NpSmjvyA6k1kr4TRS60KZxO473VtIZ FotQ== X-Gm-Message-State: AOAM5302dJae/h4MU5E9gaoSoKAg+Rz8x0R7lvnZEs81FhZ9nD/5XwUj rrCbmpitsk9woUGkZKEaPKM= X-Google-Smtp-Source: ABdhPJy0tPH4U6OUwXrRch++hJX0lrV1A1jXL0sL4KTY9VhC8iDBQ0QHS39oNPc66nlJCmpTF11DlA== X-Received: by 2002:a02:9999:0:b0:314:4a83:ac2e with SMTP id a25-20020a029999000000b003144a83ac2emr20751025jal.37.1646153216698; Tue, 01 Mar 2022 08:46:56 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:56 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 09/13] drm_print: wrap drm_*_dbg in dyndbg jumplabel Date: Tue, 1 Mar 2022 09:46:25 -0700 Message-Id: <20220301164629.3814634-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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 makes the (~4000) callsites controllable, typically by class: # 0 is DRM_UT_CORE #> echo module drm class 0 +p > /proc/dynamic_debug/control =3DN: keeps direct forwarding: drm_*_dbg -> __drm_*_dbg() I added the CONFIG_DRM_USE_DYNAMIC_DEBUG item because of the .data footprint cost of per-callsite control; 56 bytes/site * ~2k,4k callsites (for i915, amdgpu), which is significant enough that a user might not want it. Using CONFIG_DYNAMIC_DEBUG_CORE only eliminates the builtin portion, leaving only drm modules, but still 200k of module data is a lot. 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 b1f22e457fd0..ec14a1cd4449 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -63,6 +63,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_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 301a44dc18e3..24e6410d6c0e 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 4bed99326631..06f0ee06be1f 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -383,8 +383,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 @@ -491,7 +497,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.35.1 From nobody Tue Jun 23 17:17:21 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 9EB4CC433EF for ; Tue, 1 Mar 2022 16:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236341AbiCAQsJ (ORCPT ); Tue, 1 Mar 2022 11:48:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236280AbiCAQrk (ORCPT ); Tue, 1 Mar 2022 11:47:40 -0500 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 842C647AD6 for ; Tue, 1 Mar 2022 08:46:58 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id j5so13017410ila.2 for ; Tue, 01 Mar 2022 08:46:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=oJhuKNskV8n8Y8k0p/nIWuqwzzuMNDEluIiOHKAl0o576sJ1HPmRAKwNtC0X5KmTRs icMnlJSV+BczI1iwr7ypddurkANPfvk9tsYf/4EbkWXKlYetwA8+4j8ArceUw5Io7h7K ZrLqtCzX4cF7W11tK0Q8kscz3jW9YVmyvhXJ6tM2RAWChlGzGfnAbi7AeOQUh6jAsc8i s4WnZLmkfuJbU39kjc7Q0zp4JZR9Fp4abkEVMeb1E0VqoTXqwjZ4QZG8+CyxesEOq0lc J9Meq3KHG/8uJe2DtjjhdZqXfODRh7ATy82QI4Bx2bxrqVI4Yplqmg1iKFonLatSEcFK Dt5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=BRyV9WYDHU5wxgaNbmpKAujden7iO0d1Kve0jwhleUqVO+lK8i0PtWp5DjjX3korac PIpGgtcihhBVok4gRgcgjW8xL+oYvnTmA41ofOo22TJMxXLi2wbQfQpxuNiaO9cOa9sL +BVsSQsj6jZl3PdSai0OGZnlQr8/N+OAqX3zdMhBlijV9wBckTR5taAL4aGS8c6ycXL4 FPZbKpWpIUNg0faixt/7pK+N+ckBHW37pqylnn4v91BiwvDNBOLdVZj0sY6kjkq2SDKt ICmZUgjZHCSJO6rzcAgeZ1EXb5JnU0/6kxvBv3YYWJUrV2C1nxgVoP8Iqq23F71/0YdM ugPg== X-Gm-Message-State: AOAM532ANJAd0k8YQblX7oO5mSpj9vtixadNcLhqHDSqnBKUUcnv01G/ dL0C9FMirvI3m52W4ynlAOc= X-Google-Smtp-Source: ABdhPJy/KCJFD5deAvJ68PlxwkNGgiICpCoLJxeZujYYZFdY6j2sWFoALhEsYtn+vDVwYE5UiaxVTg== X-Received: by 2002:a05:6e02:2142:b0:2bf:ad10:e00e with SMTP id d2-20020a056e02214200b002bfad10e00emr23607973ilv.114.1646153217457; Tue, 01 Mar 2022 08:46:57 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:57 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 10/13] drm_print: refine drm_debug_enabled for dyndbg+jump-label Date: Tue, 1 Mar 2022 09:46:26 -0700 Message-Id: <20220301164629.3814634-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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 (free of call/NOOP side effects). 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, it 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 e45ba224e57c..92e6e18026da 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -262,7 +262,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); @@ -285,7 +285,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 06f0ee06be1f..38ef044d786e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -319,11 +319,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.35.1 From nobody Tue Jun 23 17:17:21 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 0B4D1C433FE for ; Tue, 1 Mar 2022 16:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236381AbiCAQsL (ORCPT ); Tue, 1 Mar 2022 11:48:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236284AbiCAQrl (ORCPT ); Tue, 1 Mar 2022 11:47:41 -0500 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 F351448306 for ; Tue, 1 Mar 2022 08:46:58 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id i1so13002813ila.7 for ; Tue, 01 Mar 2022 08:46:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+1diemf3MRoXdblNNavyGZGnh4l9BWi+2yg35q/w2I=; b=fZzouo8Gq4lZgktfrleVNOZJgE7AAveGDRPW5fk+Y2hAGgIwA66+3FomMB4cLs+w8V U9QyWzk7IircTiOz7sIgxqqwq2uB86JSHs84Roy4ZE/xcD1rg1/K2jxn3QMud3EINs8G MvxPZvP7qy+PBCo/7GB4xNa675NiFtSeu3al+TEiaV8Ol9KByxYskONt9Gl74piL2sPe tls31NghJiSek1de4mUm7xgKA3JzEBz5F3BY4KLbfokTiBbfeKZFZboEdGanaPPY6nO0 dRV5SIb/uMqg2+3TfKK3olU3HlO/5b+PnLjiDlw99GeQywftdZxM6zxD9Zg0FqSViFyu Z1tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m+1diemf3MRoXdblNNavyGZGnh4l9BWi+2yg35q/w2I=; b=sVW+oiW3xYfJ88X/QN9y943DQ6P99t2F+345mYDX9xDOh6X+76qxkgDcJ+qKhIl+vh izm8MiToTCzUipLvdhudNqTOCjaLTtMmMfZ0n50v7Zx4XLvcLLtOOmuBdNrOpHLAPtFa JxBFeVui7uQxr3lKMZWBCdCAWJcBhMQVSm5GKP/KI242nzyBbbKGGyeHhcMlKy3LJ9LR nSdNWBvVDQtAA0/sRPP8PnSLHEs4UmZrG/HqIw1m0yttSG8XlzispozKnDBvDrwxIsW3 9s/uK73OzbzpiYZY6p2nmw9W7GoOtRCgWz9HwvxjCPisifFuQ+X30Z1J4pMEd/NYJHMr KEig== X-Gm-Message-State: AOAM530wtwKhRUAoWFncmUURQQgGiwI2+o0cfGv6SpRtXQeWHsbZ4LjJ PUmhT23k5z9Ah4sDH3ybcB4= X-Google-Smtp-Source: ABdhPJwf7VxPkYrrRG/vET57AY/ByM1ZpdNgjy505b5OX+6OmR5WWqWAqy/trwzf4yd2fyO7wN3M4A== X-Received: by 2002:a92:b009:0:b0:2c2:c409:1252 with SMTP id x9-20020a92b009000000b002c2c4091252mr15603632ilh.8.1646153218282; Tue, 01 Mar 2022 08:46:58 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:58 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 11/13] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Tue, 1 Mar 2022 09:46:27 -0700 Message-Id: <20220301164629.3814634-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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. its hardwired on currently could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading 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 /lib/modules/5.16.0-rc4-lm1-00008-ge= d3eac8ceeea/kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 /lib/modules/5.16.0-rc4-lm1-00009-g6= ce0b88d2539-dirty/kernel/drivers/gpu/drm/drm.ko NB: this was noticed using _drm_debug_enabled(), added earlier. 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 92e6e18026da..24c57b92dc69 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 @@ -162,7 +160,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.35.1 From nobody Tue Jun 23 17:17:21 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 6D76FC4332F for ; Tue, 1 Mar 2022 16:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236364AbiCAQsO (ORCPT ); Tue, 1 Mar 2022 11:48:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236286AbiCAQrl (ORCPT ); Tue, 1 Mar 2022 11:47:41 -0500 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 B143D37A18 for ; Tue, 1 Mar 2022 08:46:59 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id d62so19073599iog.13 for ; Tue, 01 Mar 2022 08:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QEgu+Ofez++Uoa48K1+2ND2BjCIRiQBeP9KERq1IVJk=; b=SGMp0SOcz7owiggI/NOG9AwUqWuY3WHOdlY2OGCh5F/TYFEM2fwwXAdKj6sqz21oGb 6ijQil2ZV5qIEOwn3P3eEiaoBAVmRRUWcqMYc9nuR4fdhXx1K0Y53Ua2G1/U1Jx5MvSK TWd6g6MnQUAkcYcfHbaXaO3gi/f7JGcZFVrzmt3Fp6AYxUbSEFozYjmoR0Ozv1kkdTIz bT0DgSs6/M7zvCeiZFj3NZejf9fKNELzgv7gg/JY5HL1V01l5wbt+1FNuZqM1l2Vk5p5 cfPOHYK6402xHwms11aXn4SOWJc6T0G0J7X+j5y2w4YbGGlxsWQ/Ve8WuYR0azZe2iCS Yi6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QEgu+Ofez++Uoa48K1+2ND2BjCIRiQBeP9KERq1IVJk=; b=4mURlo4LAk7OnesIvzylnO3t40YGbSaZzf3rfKyKwC8XhCNNKgP2mEgEPzYcB699oT aRGeJcvoNU4CsIHeg62iTVMJUZ2gf2tVf2sxtNZ7qvrnYojEVXQj0pfI0IWToOxOcBhc s40ugnI7B2YJA09T277YSd4ZNf5AfpBqA4WqwQ6aNs/JgK/dYl4Oq8SgeA6Ih6w0VJQR lqMoQcOTvsS/rI99aDQh2rQCCJk0aWvGuk6u6siSLRmI1uwuFSEEmBsfyFlKOkYG05iS m+0zxfyj2vTRAeTHySO2ESTFpv7zez1+iNimK45SdV9ZRQduJlSSGN7HLuML9m7qXmLn ds3A== X-Gm-Message-State: AOAM531rtyULVmgI2TkjL9qzNKnuf0SFL7RyemR1LrarrshcO3cMX3pj LInRGGwR87Ol+eGoPiPfbc0= X-Google-Smtp-Source: ABdhPJwQtRT66y/VO028x0oItbv2Me7FXE+5HFxgf3gbLT46jXc9mytuAJ/FLenQ38OHlfr0Q0QC5w== X-Received: by 2002:a02:3503:0:b0:314:c32d:edd4 with SMTP id k3-20020a023503000000b00314c32dedd4mr22646020jaa.36.1646153219049; Tue, 01 Mar 2022 08:46:59 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:58 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 12/13] drm_print: add _ddebug desc to drm_*dbg prototypes Date: Tue, 1 Mar 2022 09:46:28 -0700 Message-Id: <20220301164629.3814634-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a struct _ddebug ptr to drm_dbg() and drm_dev_dbg() protos. And upgrade the current use of _dynamic_func_call_no_desc(); ie drop the '_no_desc', since the factory macro's callees (these 2 functions) are now expecting the arg. This lets those functions act more like pr_debug(). It also means that these functions don't just get the decorations from an underlying implementation. DRM already has standards for logging/messaging; tossing optional decorations on top may not help. use that info provide it to dyndbg [1], which can then control debug enablement and decoration for all those drm.debug callsites. For CONFIG_DRM_USE_DYNAMIC_DEBUG=3DN, just pass null. NB: desc->class_id is redundant with category, but !!desc dependent. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 23 +++++++++++++---------- include/drm/drm_print.h | 23 ++++++++++++----------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 24c57b92dc69..c9b2a2ab0d3d 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -255,8 +255,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; @@ -264,22 +264,25 @@ void __drm_dev_dbg(const struct device *dev, enum drm= _debug_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; =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 (dyndbg_site_is_printing(desc)) + dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + } else { + if (dyndbg_site_is_printing(desc)) + printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + } va_end(args); } 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 38ef044d786e..13d52b60f388 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include =20 #include =20 @@ -361,9 +362,9 @@ static inline bool drm_debug_enabled(enum drm_debug_cat= egory 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, ...); +__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. @@ -413,11 +414,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 /** @@ -520,17 +521,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.35.1 From nobody Tue Jun 23 17:17:21 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 97E65C433EF for ; Tue, 1 Mar 2022 16:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234281AbiCAQsS (ORCPT ); Tue, 1 Mar 2022 11:48:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236302AbiCAQrr (ORCPT ); Tue, 1 Mar 2022 11:47:47 -0500 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 6A159427CD for ; Tue, 1 Mar 2022 08:47:00 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id q4so13053836ilt.0 for ; Tue, 01 Mar 2022 08:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdO1ZIStJEydDaNsVVTQjhQ+J41BBA4J8A/jLwHByaA=; b=dT5dHERfA7NfWxTqoX5UtBav5p4kPFdv7+9TmqWHP2bK+wtMIESMJrFmYKma5Icf0g +7nH1hhjR4WQRsb9PMzzil9FEypu4su5C84YyCt6kDqnr1M6NLcZDGU/SwMSpwj2DFos 2vfYqxcM6kV8dFiT0U/ekaSAV9UJ41JUIN8voJPJ/Th/mun4QzZUEITNp47YhjnH1sGf RHg66r1G4QkiH7zmyGmQD42lVmIsQf3Kekrsvrnm5ksV+v6PLwvKvC/5CNI7DJQjGb1P L89SbkL5rK2xjVuAKdrnLoDaf54r35tPdpRGmlTIY1LYozgr3fHBjpLQLrcKRj0+9wPd JzoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EdO1ZIStJEydDaNsVVTQjhQ+J41BBA4J8A/jLwHByaA=; b=YvVKmni7GXcn8PzUt2VHFMqJLCBuiD2ewvDEHLZz0utM6ZbqwBJpeGufaYNLAT0Hgv 7xn+NJshx5HOaiCIKRsF2xvK6EyOZJudW4PB3diQUzCscmwEl+zSuTxZNm+Kg9FbnGDn Ub7P0eG40hc6pqQN7hOGY51OWQ0HDoDBf7b43wIXdLkN74gNNhwDCKUidZvuIIE1Qi7g 8ztCOQdlEmp2IdTm6fkY3yiFgC/khuQxGykva63By4z0PBa3WOOujbbaMQULeD6cx8mV 91mu1jS1PB8+oCg6UYncLR5RrYbyEgjL4vdQSAwPSCFnJyD3ht4buuDNseglgkfTWWAL kZmQ== X-Gm-Message-State: AOAM532yp/5Qslvyc5jCXQDOE3qDIHcIn/QtKd7Xar0tOs5CJXfydYnH bk/pRGOqqDKQobh8/TGCjHg= X-Google-Smtp-Source: ABdhPJy5GYUXGxdbJtTLoRtjbRmr21Q8zu5mMzrgQM87ZqsoqtWRy3CiT7iy1mU5TW1fmPqVkcyi4A== X-Received: by 2002:a05:6e02:1be9:b0:2c2:85a8:50cc with SMTP id y9-20020a056e021be900b002c285a850ccmr24316094ilv.131.1646153219788; Tue, 01 Mar 2022 08:46:59 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:59 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 13/13] drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug Date: Tue, 1 Mar 2022 09:46:29 -0700 Message-Id: <20220301164629.3814634-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-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" if CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, use new macro to create the sysfs bitmap to control drm.debug callsites. DEFINE_DYNAMIC_DEBUG_CLASSBITS( debug, __drm_debug, "p", "drm.debug - control summary", /* inline vector of _ddebug.class_id's to be controlled, max 14 vals */ 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 ); NOTES: The @_flgs used here is "p", so this bitmap enables input to syslog only, matching legacy behavior. Also, no "fmlt" decorator flags are used here; that is discouraged, as it then toggles those flags along with the "p". This would overwrite any customizations a user added since the sysfs-knob was last used. Still, there may be cases/reasons. _ddebug.class_id is uint:4, values 0-14 are valid. 15 is reserved for non-classified callsites (regular pr_debugs). Using it terminates the scan, don't use it halfway through your list. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 20 ++++++++++++++++++-- include/drm/drm_print.h | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index c9b2a2ab0d3d..d916daa384e5 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -38,7 +38,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" @@ -50,7 +50,23 @@ 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 +DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, "p", + "enable drm.debug categories - 1 bit per category", + 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); +#endif =20 void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 13d52b60f388..419140bf992d 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -36,7 +36,7 @@ #include =20 /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; =20 /** * DOC: print @@ -527,7 +527,7 @@ __printf(1, 2) void __drm_err(const char *format, ...); =20 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -#define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) +#define __drm_dbg(cat, fmt, ...) ___drm_dbg(NULL, cat, fmt, ##__VA_ARGS__) #else #define __drm_dbg(cat, fmt, ...) \ _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ --=20 2.35.1