From nobody Sun Jun 28 00:50:46 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 36FCAC433F5 for ; Thu, 17 Feb 2022 03:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233027AbiBQDsz (ORCPT ); Wed, 16 Feb 2022 22:48:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbiBQDsw (ORCPT ); Wed, 16 Feb 2022 22:48:52 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48421C0506; Wed, 16 Feb 2022 19:48:39 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id q8so2225543iod.2; Wed, 16 Feb 2022 19:48:39 -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=PFLx2BNFItOcSBVBzOes2CcfuiOg9MZFNk4GMlp3FEWB8qTgBL5FbKnZoRAKYReNL/ ReDNJ2jxVfhXYWmadIOhteBp5jp1Sev1vNmsZeyjXjVlSxi4P2CC/txIQX7x9no42fno 35b9yd+0zjb90kjD0RTZWE4ze/Nt2mO0Dv2OBbNMV0VvkEHUdLIB1FJ8RryJH/Fwzuky RLM4b4LiDs6AJEA/W6MVIubgvSU1zPeT1bXXrH157OyjpS7EBS2G9qdbF4skflStaHXi nfMGkMcVbjqWYUHs2Td7/xiydiYvo50td+/vQ/lbFICW72LMNHR+7cwzpp61v9C8G6jN 5c0g== 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=4nFyqzaluVju0um2nE9FK6QUhRvTEXSsrIybkjQhfv/UGaZApxeR/5OFh9FZycazfb 39cTG82c5vF8cKtYN7aVy8ed6huuWJ1q1ZizP7pUQLtHyW3MSQ6SoiscH+xqDO5aGM2N 36xXhpLglvI4siL7qnmiaw7ZrUKTCnM9zeCllT/sa2aaoCSQ51zqoN06OvjYvS1XZt8G DL2SbfTvs6uFdzkrJFx3NaQx0xZnsYbsHu5DPZGOUnwUTURNTOUr6uVXKP5Oje049d98 9Ptlu7lZA1Y1GqD7kbGXabX2DCsRSbXyTA94k03FOk6wN0Ctwe38MjEFtTlCL0bXB3tT i8zQ== X-Gm-Message-State: AOAM531lxSzH1BVQr3yzQ9SABg4bswQDgt9naQGHXzvXmz/eeeo9ZASc MHnaVlYjDsRhLrp44AOInow= X-Google-Smtp-Source: ABdhPJw368F4fr7QiyGQIds6VCL1NhGqtcNQKtxpD3CT5e3gMbNyzA1gjwbx4VI1KL4OErxP7BRLbw== X-Received: by 2002:a02:a808:0:b0:30e:e741:5457 with SMTP id f8-20020a02a808000000b0030ee7415457mr687157jaj.289.1645069718640; Wed, 16 Feb 2022 19:48:38 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:38 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie , vincent.whitchurch@axis.com, stable@vger.kernel.org Subject: [PATCH 01/13] dyndbg: fix static_branch manipulation Date: Wed, 16 Feb 2022 20:48:17 -0700 Message-Id: <20220217034829.64395-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 5FB3BC433F5 for ; Thu, 17 Feb 2022 03:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233050AbiBQDs5 (ORCPT ); Wed, 16 Feb 2022 22:48:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbiBQDsz (ORCPT ); Wed, 16 Feb 2022 22:48:55 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A51C114A for ; Wed, 16 Feb 2022 19:48:41 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id t6so2173585ioj.12 for ; Wed, 16 Feb 2022 19:48:41 -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=BdwOLzD+GmHRt6StUBsL48/C/2vAmKHyntzDsiIEmgk=; b=c/0f2VPHTS0ofL2B4J92kixIqQ2iZlmvNWO1wPcUvzX/DITA7vcpA8jR0EizNqT1JZ xD8qtSIYsbh86Nt8HtjMUoqXMczzlOSacQOKClBJ1f/sRP3PsUlM8skyV7fs2/5HE7fi aCgS3/oZd5KREbhsmXbZLuG+UuGzLXIPSTAHxecCCSefjxRikJb5B/UCclZd4Wf2DzSF prtqhGfMWmogWLrPZEyKkFm0QG0tGC1GiBROMYtLhvKC5LX4NaireehHbr/HEqJKQXat 6+aesh4TPNr6lhImkvQwjyTI3Dr3/cJ7biN+l2XhwNeLgNSBjUtlRXbir82PfKHZmiQp 7pyA== 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=BdwOLzD+GmHRt6StUBsL48/C/2vAmKHyntzDsiIEmgk=; b=CQvMgX+fH1B+Tmr0kuVphxljYWyxyJ0jwQeihMQw7Eq4O0rtGt0Q24hN4jJl+NXlvs x4TBjtRZkOPreULBvNUg68Qd6CejJc4R251vCusJ6wJb7L0MBROHjplsGFh/VuMHsfjT egy3n6fTsQJ2odYtCJQYtAjuyumw5V6bgRb7a0JL88yql6f17TKJaoUxvkavKg80rbFD h988c7UTY8lisb36LnY5FpGZyC7FaifhKIaODgs4yB8Qybd2a7vWKUo7WnmZCPG3Z8fc fVuB/A9+MvisliKdf8VE/MGjYXNl6SNO5KjP5uM41gOn6JWjPdJ/IZBaeEJgajec9rDF 5xAA== X-Gm-Message-State: AOAM533YvNy5N4uUvHIYMzPgcPsXjYh2JW7IzYRWjjewiFtoi10eXAna jzDFZ/hCmztpqfruYQTfGF4= X-Google-Smtp-Source: ABdhPJxEqQ0IPmsI5sQzrNorPS0wtFkC0MQn3KAyUwKrC1nFlagr1jAC5TG7jGUiw4LETuYqKpJ76Q== X-Received: by 2002:a05:6638:1315:b0:314:85c1:f99b with SMTP id r21-20020a056638131500b0031485c1f99bmr613188jad.269.1645069720478; Wed, 16 Feb 2022 19:48:40 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:40 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 02/13] dyndbg: add class_id field and query support Date: Wed, 16 Feb 2022 20:48:18 -0700 Message-Id: <20220217034829.64395-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 | 38 +++++++++++-- 3 files changed, 83 insertions(+), 16 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..eb3209a7aef0 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", + 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->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 Sun Jun 28 00:50:46 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 0F96BC433FE for ; Thu, 17 Feb 2022 03:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233088AbiBQDtC (ORCPT ); Wed, 16 Feb 2022 22:49:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbiBQDs6 (ORCPT ); Wed, 16 Feb 2022 22:48:58 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55206C4280 for ; Wed, 16 Feb 2022 19:48:44 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id z2so2195594iow.8 for ; Wed, 16 Feb 2022 19:48:44 -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=6PjYElXLHY8EElBLxhH7hX+f6tj2nXv2er8BaUyyz9Q=; b=Df4EFL7dnE8UPIWveP1K240H9+va5ZvmcrTbmVMORo67e1IDR5fu0tJ2fh/9CeZkVh mFaa73rQyId1lGm8x0qMRznHY/LYuzUO8HjVeXtjgSPkgjMV9Sp7tMGXqYyV4Vr16MOw UZ9IBv/bT7gAN6cEoyw8E0dZ3A3oyAMPhSDllOcbdzasdncDjVaADS1HjCuByHGqf7db O/SFew7/F9cymS6QZoxMmZ/TNEACWUD8ec0wQDtSTdoDTLLtD+fqaeayfbsVLg7ZPHXy PSuSVVXSkbq3wnczRae5sTeMgWu50lZja+1jiFU3Rdlq3xjFOjM5SsP5jPZXCJLmVLJ5 0UMg== 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=6PjYElXLHY8EElBLxhH7hX+f6tj2nXv2er8BaUyyz9Q=; b=gcG7D/AXvo6cCW42fm2F81s7ScMnAdzwkbov73Nhi9eRKJjunh44v+hCP8Uk2adJOD BwS54pLlXrM5Uyj4Ta1YFa/yersoNQezUOnybejOGjRyQHffz7oUS4ePbhf78UfUoCdW rFOItcAIQpe8cc04e95o9pQtu8KaxzHGK0fI8pr34UTpBHWVdYBoNXm3kJelfRoP0CFq PiBVS6qM7h93edIy9Vb+TBt0cNWPu1EAWk+mJ8FiyV8PqqlibG2aGbGVJYM0ZwESFI2p TWyP/9bXD63nnO+2GJ72w22MTz7Ab4h4Caj37aGNk/EHXSlRqAkna51qVZXOklU+vqxm B8rg== X-Gm-Message-State: AOAM531k8qJNGxGuFPHhD093zmvQiUptve/X0Q9wm5TmjoTbnEliniES 9NfZfZi1OuNjy7mfSrKkX/E= X-Google-Smtp-Source: ABdhPJzR9sH68uU0hAppvHEZBaT9Ym9z655Xbz/X/cCa28As7DCvs+Zf1Eo78kfs4qYWT2yHGQ0vlw== X-Received: by 2002:a02:7104:0:b0:307:8124:ede0 with SMTP id n4-20020a027104000000b003078124ede0mr732465jac.191.1645069723675; Wed, 16 Feb 2022 19:48:43 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:43 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 03/13] dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks Date: Wed, 16 Feb 2022 20:48:19 -0700 Message-Id: <20220217034829.64395-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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. generally toggling both together is silly iface doesnt 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 eb3209a7aef0..262178167358 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 Sun Jun 28 00:50:46 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 883F4C433F5 for ; Thu, 17 Feb 2022 03:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbiBQDtG (ORCPT ); Wed, 16 Feb 2022 22:49:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233057AbiBQDs7 (ORCPT ); Wed, 16 Feb 2022 22:48:59 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62CC6C5D82 for ; Wed, 16 Feb 2022 19:48:46 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id z2so2195645iow.8 for ; Wed, 16 Feb 2022 19:48:46 -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=cv79QYaUsMAAW7S/s1dtOMu7WJ+uJ1+n4LJB7u+qFpQ=; b=dKgXzlD3UZyGeg9LfmO72MXogRWhEZS2KgD9Ny8xfRLtb8Z5bKD9lA3kZkFSI91Vbz Q65LdonvyeE2wmCVSYSgWkh2CvnZyHORYp9iYjjydxqtAFVEHOzZhi/8pcGTOj7qXRpj DeHvqoFfNamaUr46tuAOy0X/O2rz4vbFD0JZdEg7C9s3V79ErcXFC6hX0hF++2z7HK9G fw2dLHdl4ktkYuBfcUfFpxm8Y8L/SRSOdE9Slb4ul1wW2Uff+wtsh39mwB1tCLWjRkyU wM6a3PWLRZFfiT78Afc0X7WSLIxynX2x1rsFRTsoRJEFMrFUbL5+z1SsPolWyBtYL3lR r2Hw== 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=cv79QYaUsMAAW7S/s1dtOMu7WJ+uJ1+n4LJB7u+qFpQ=; b=3gkLP2biHpBk2Mf1jD1sIjC/1AhJaQyb2tyTvQGCW84AvvnJouG+mUneuH8biFl219 /Eo7zTfnRQPFoiHdGBDQvrrp0nwyq1omfxTmwf1FIMDIpoERKSDY9wPCqsgaBmWv/l6y gi7lrUQHbL4Rhp8+BmIeyGXkYxa/9rw0OBu1nTYAk/wCHixeI4PUS1D38mx91giAW8dt 9pL4Qqo8okgUArZzVnWyo0qS9IwbNskbZmYoXxFX6stU3J1PdV1KAedL4IfWMsYaZHab KJxCw0jB+9UhsjKuLHrnVyohlLsv+V+VPp3cHw1L4Q5rJL68cm6ZNWo9akJBpT4QlGB3 me0w== X-Gm-Message-State: AOAM532UE6W424sAsjjNttzRRg1WwTgXRYuqGlJW4d9/mVU7XZ0MnSK5 jhIOX5DP2hNNJm+gy+9/QJbzKy25P4JG1w== X-Google-Smtp-Source: ABdhPJw97wYH8FJ7BpO7tlo6qMx3uqv2AZ/tNfoqW4OM6ihOD9Tnv+wrk2lKNzvVE03mCxmq0Bugog== X-Received: by 2002:a05:6638:1489:b0:30c:b8a4:90a5 with SMTP id j9-20020a056638148900b0030cb8a490a5mr772639jak.8.1645069725780; Wed, 16 Feb 2022 19:48:45 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:45 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 04/13] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Wed, 16 Feb 2022 20:48:20 -0700 Message-Id: <20220217034829.64395-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 262178167358..b72632212a65 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 Sun Jun 28 00:50:46 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 671A7C433FE for ; Thu, 17 Feb 2022 03:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbiBQDtJ (ORCPT ); Wed, 16 Feb 2022 22:49:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233061AbiBQDtB (ORCPT ); Wed, 16 Feb 2022 22:49:01 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA1BC0506 for ; Wed, 16 Feb 2022 19:48:47 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id t6so2173756ioj.12 for ; Wed, 16 Feb 2022 19:48:47 -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=losT24laQK9QPGecBoWrVc+10iJJY8vD90LsvY3Cts8=; b=YDLt3Q4XVCU3SNY6uD7/FtoBt1YQ4vttc8gh9hCegP9KTPTewYcgxbnMNm35qs3sAN 83UuPyJiUycHSA5bqOW/TvnLpQ8ZL3hOV9hye+FMmwPZAsKyYaddsz4SNiz5qTk7zw+B V3zhfseOndqMAok28xM0o/fGD/E3AZIxhNC/DXcYBPUGtMnP1DEgi34hn45krZaAVCYh A0krsFznnlGBVOsrhLynW7/WtLAXCEiEqme6dgmGmAzf2kxKEThugOK0qfV1r2FpW2mD r8HYUa4v0OFsi6wanQA50eghIq6p284MDyFzJ4I76OeLxkDX1pmk806sJvl9H4j4X1Ln gf1w== 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=losT24laQK9QPGecBoWrVc+10iJJY8vD90LsvY3Cts8=; b=z5L2Cm7JJYyRpXtzS01KdXoFt+UeNhtOMQnQxwtPJi3ZRtB8Eho2MgpQltm5N70jH1 IIx4eON4H0GgTY9kQXJemggYHl5QG3mMfT7hu59Fv0tBBuP9ZYsTLfSV/Swyk+u70vHE ndH4UMbSlbYLM9QxJM9o/2FXPi8UDZAFz39cOtUxRd+EnZLM4dwljcQILYl+kisfmEd5 EzOyCY+78APS2Ow7o3dQh7kVCCLthWI/MES69NjHeTCfyXi6SuCXUULo7eCefynlfy3q Gno2oLBq+4j49w1cfN8ymPvBuAV6c6GXkUEC59KO8jAdqKuauPMNtnwLIDfcR/U/6tlQ I++g== X-Gm-Message-State: AOAM5324oEehOx36d/uXv1BDsBhBZD/X2+Ltc/EPeEU6XKLEoFomSTw7 rDVGhUHsDdTnFkO8pSI0Jfk= X-Google-Smtp-Source: ABdhPJx/Tr8OkP8qQpMLDvFxZS1XzdR9P911qy0L55Cd/GZXU+ZPYahqdvxDhccEVXq+mEUJ/as2nA== X-Received: by 2002:a05:6638:2387:b0:314:7ce4:1be8 with SMTP id q7-20020a056638238700b003147ce41be8mr745234jat.286.1645069726592; Wed, 16 Feb 2022 19:48:46 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:46 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 05/13] dyndbg: improve change-info to have old and new Date: Wed, 16 Feb 2022 20:48:21 -0700 Message-Id: <20220217034829.64395-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 b72632212a65..77db640396a8 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 Sun Jun 28 00:50:46 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 A6B6FC4332F for ; Thu, 17 Feb 2022 03:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233174AbiBQDtK (ORCPT ); Wed, 16 Feb 2022 22:49:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233064AbiBQDtB (ORCPT ); Wed, 16 Feb 2022 22:49:01 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DBB8C5DA4 for ; Wed, 16 Feb 2022 19:48:48 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id m185so2182884iof.10 for ; Wed, 16 Feb 2022 19:48:48 -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=qTiK1jRdbDaFcQDx4cC+rxVcCZ8P6wZaDMePsvS5oqxzwhZzFsPen2E3O6rCOSxtiA DessncBQIZpwkAo1jwFHEpBRUQcGQnZT43gcngp/B8U5FSKO0ZddtRZQMM3LjLjHqNep LEoPZz3WvGyMJi1ikGUAIH4vGeMDAnyGlbLgB3iA+hGgK4WwVgbeSDeEHWoEm0NNGq2m jHhdwz8+UoyFVLVXJHDqJsFfBqOWCr4Cio0d+nnldQlSY/xWYMoFTt8VfNNAjwXryYvC IPVepN0QxjTudnVEUuK3Do+0p5JhpLLYNizjiCFkrbRHwAs142s4qaQi3OapvpHue2eI ALRw== 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=CloEuUvyf4SWM/WiOXtFUlUHfWozrnUylveoWQG8YMGHod+xaSYuZE1mxv9L+r1p1O pBgkDOnRdnHX48AqCvGYB9sDuOVU3axuQdvFxFzQE0RFPnzTX6RPT+vSiHR3y9+yGJ8T +VR7NlUXMLTOPiOT3muSuwQchYceGKbew70nVBaYQyLUyfAzifoWTxFZVqAquaYoBNTL yEJR0UDlYheu6mvr1iFTBrymYZ7Fqk7ktuTB7TIOs/b0b3JBIdbf7XJZ4YSzGFsodHYq qGWdT0V3R/5ebSLaO4HDCJ+z3dwqlTXHQg1+mpqg4hx4t8AxfMUzgId9F+DSC4OaOYgu 17TQ== X-Gm-Message-State: AOAM53289sRSLc1yXUSiGz39jb6fCCZVacI55FKJDuJzmbWN/oiE75O7 OhwRywXEJOIt+e+pDZIELPY= X-Google-Smtp-Source: ABdhPJxOywT+Bw4mOSbi+xuyE29k5QgNi8ekJ3xSmi3CrQ8bBxZkdSh03E3QGwSUqfaeD1zoTLwAxA== X-Received: by 2002:a05:6602:2e87:b0:60e:9b40:cd62 with SMTP id m7-20020a0566022e8700b0060e9b40cd62mr647311iow.204.1645069727595; Wed, 16 Feb 2022 19:48:47 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:47 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 06/13] dyndbg: abstract dyndbg_site_is_printing Date: Wed, 16 Feb 2022 20:48:22 -0700 Message-Id: <20220217034829.64395-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 5A922C433EF for ; Thu, 17 Feb 2022 03:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233186AbiBQDtM (ORCPT ); Wed, 16 Feb 2022 22:49:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbiBQDtC (ORCPT ); Wed, 16 Feb 2022 22:49:02 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC99C5DB1 for ; Wed, 16 Feb 2022 19:48:49 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id d7so1365078ilf.8 for ; Wed, 16 Feb 2022 19:48:49 -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=AwrxFJhmF4G+MvuDdELRdQNvbWui/ZmZm5aRVhg7QpY32AwSFVlNWa7zOXHeQ0e+cH wtknls6AXe3/sQ615mZwc3LxxjbFp5vdYoENvncru8NXiKtvRjVHDHOcc1czRzm11p/d 5gMpGvKHvpvTD5QXZ7+3u0PE5bimGbjnxkwavRK/JEbo5dFnfHPVsji4YrIJWXz9uBRO 0Lp/qC0XJyvGgMXBUJNhtBQzXfDabdhJ0aiT0Xn/+2m7taSwrj79YKTaGPXihjNwuE6y l5mZvDvxxG7gI/At8IpBjPFc32pigevpyz8mtnKwBqem5o0q5ZZ/unnFLYHjoX5mUiqL 5kIg== 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=GRQ7gd6tB+x8t09DE5yd++i7FazwCWMYb8dR4n1Evx4L8yitRuE6+i/JxpX8Ja1Ro1 wnEjCliYJwF9mdt0GJ+U6G8s20DUES/sxxC+C/Fup0Ke84KyHATuIG8qjxfSqAuz/S+8 bhzmqvAPehJDm8jL/BUmDq8bFHDJmqH1tgSk2m4SEl0zWbnYmm+ch5miIsgRCVwiiMyk 0CDPJVTKQCqISy51F4vEoI4YChca8bt1RkK2X8356IOao81Fs4GkW1Qn4OVncDZTKFmX YjEkX0bm7DFdqFrdfy2CMzBC2cfAqLGjqeVKXPxw+BtCfxmOwAf3VyEDykktyKSms7co K6pg== X-Gm-Message-State: AOAM5330r+JDvaQqw+jkXGvmsdWIUH7cMYOvFtB2EdYesIAt9wXEPzr4 sG005zpMpTOfS0az1FJASDo= X-Google-Smtp-Source: ABdhPJy1Fv4risoix7swzSlE1sOKWWdc6gcHljvdxt8ZU2IPf0XZA3hS8LpNHrUIAPX2AlZXkOxl1A== X-Received: by 2002:a05:6e02:1a0d:b0:2bf:58c2:97af with SMTP id s13-20020a056e021a0d00b002bf58c297afmr770183ild.85.1645069728378; Wed, 16 Feb 2022 19:48:48 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:48 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 07/13] drm_print: condense enum drm_debug_category Date: Wed, 16 Feb 2022 20:48:23 -0700 Message-Id: <20220217034829.64395-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 A9580C433F5 for ; Thu, 17 Feb 2022 03:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233203AbiBQDtN (ORCPT ); Wed, 16 Feb 2022 22:49:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbiBQDtD (ORCPT ); Wed, 16 Feb 2022 22:49:03 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E7EC0506 for ; Wed, 16 Feb 2022 19:48:49 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id y20so2233740iod.1 for ; Wed, 16 Feb 2022 19:48:49 -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=N1IkzBPBU/xJbo1PKkybMqkfWAIZsR6V2YWUlr/wuluFy+5Vw2QTXHgRMKh/jowF/E msSbyBi6jCA1HO6o6ohcDrXTynt5+/ZQHCR250mlg1SHvuEi5qzQiFVAFcybPHmVyxf3 JbOXGcwIDGtcwP4dBWPHdoopigc9FdHTcapQoe0xaeUneF5xxv2xRXDAQp7RrU8d/Pl9 s9hiQ6wp7rqx43o8gAXfpv6A2NreoiXaEIRU/6ixQvnF3VmN0sfIBRBCd6dAQMPRDMsM oj2Oj7n7u6hZbbSyPjfwfj6fDlPRYPJlvHtnyeL4qF3vmtl8ot230CgMELVbfzKhjFhw g9ig== 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=q1nAOsTUUVdEQR7slcnONI+LabiOHwB6VBtTs/vf52IBEyLx7GWjVoS0T6Q8LiRIIq BXV+Z8ydj+E/5nzFSRyqSte1q+QTHz7gqrO6QH/oTUNxLOKHcHams2KYmvoqKaD9zlW3 Mfy273FVWy8kFObW4kB8S6UZVx33f7lql76hMZG0QfDqYALGA5n6dTWDOqm2ZMCxsKpx 51r8cx6yyG1p8KJbd8wrCgyoJj9qhlCvYbHPvE97nJH/TqVR2+xpVStbzk/9hoYuIlEY avW5LbjsBLfiFPkfQ/3UZUnZyUKbI+OxoblD2cfZXfwC/b5L5AdRccDkB8+/AKAC63gx Hr7g== X-Gm-Message-State: AOAM533QG8/LjBsDli+2XV14LOnXuybUvvYGgrR1Vgwv0H2bAbJaE2DU iV4vPC9IoZvs2h3HAuIttHw= X-Google-Smtp-Source: ABdhPJyXKQlyPhg9qrLLs3CjhrhOjCktwIEw8sMQ+X+99JL80wUnSMgiJ4m7gTwWkHGlQBBJ2w7oAw== X-Received: by 2002:a05:6638:389e:b0:313:f3ea:b18f with SMTP id b30-20020a056638389e00b00313f3eab18fmr764155jav.206.1645069729327; Wed, 16 Feb 2022 19:48:49 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:49 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 08/13] drm_print: interpose drm_*dbg with forwarding macros Date: Wed, 16 Feb 2022 20:48:24 -0700 Message-Id: <20220217034829.64395-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 45F5BC433FE for ; Thu, 17 Feb 2022 03:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbiBQDtU (ORCPT ); Wed, 16 Feb 2022 22:49:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233101AbiBQDtE (ORCPT ); Wed, 16 Feb 2022 22:49:04 -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 C5268C4E3B for ; Wed, 16 Feb 2022 19:48:50 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id d7so1365111ilf.8 for ; Wed, 16 Feb 2022 19:48: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=0+vGdwnLXxq+vC4sl8UqWBm6MtHqZ6WUpG5Xunn2VjE=; b=aWO7UUGoKdXAsOZ3ARe2QJZJsrpeOf90ACB+ee6E79imlC7MDWWeD+AJr3qahesHxu nJovj3uldI2xz69oSyxx+syBvSgbjfhTqygbS8A0KPRXtBpX0LMFKLZ6CB+56OaSzBqb hfTdtez1ED7QAtIvGY62HlNG2fIjyr7ow9Skk12dszA/e817Qatb3b1lQgFjQQZ0JiZj WWc36Ta/bs/CspzWamVlOMcvgjtO94zzf8D8v9NxDy0gmnlhRwmPysV4iMJOn928huyw /tizg//HbxArKb+EFHMAnLKG/J1xmrK4YIYMjh//d11ltRHZXwWiLDMFTkhaeV9fDWZs a1Xg== 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=wMoPrVaF+kL6U11PCX0yUTDkPzm9mTM30Yhb1SInM6s2vp8NfT0E9nO980jGFKZ+hh EIstKMBtM1VykkK01Bhf5Y/DnU0/InExAnjce8YzRB5TQMMqBlqt3pAB2eEFWo9OrGnq E4rWLHLVf1L4HTa6fxQZd1C1dh0ZwPPlYzogWqnxIwz+aH2EHtVro6md3RMVsWvDeCcH mjBaDd70l4xOmEXU5PXGZB4CKR1Av4zWvi85lIIv0inqUmHKAM562NiT1Yt4/qJBrf9R fT629YJymG4GdwxzB0ezlv072/kRLEiNACzZkywYvn2VySov7j/sK8+BS+M2ELAPfvAC jDIg== X-Gm-Message-State: AOAM530vuZhZnBGD4nRyMxJmR+03lEZny3y6xUlv0iYmQMwXxVCxfZPK 5txSIyMFchxJdIr1EPlKUC4= X-Google-Smtp-Source: ABdhPJz3VeOj8gAqU2/ZIke90ZJ3eMraSlFGZ9r9Aru1QvXJbSIWXwhnlF3/c5ShXmdBBtEfbc0lQA== X-Received: by 2002:a05:6e02:1a41:b0:2be:6abe:103d with SMTP id u1-20020a056e021a4100b002be6abe103dmr765171ilv.204.1645069730202; Wed, 16 Feb 2022 19:48:50 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:49 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 09/13] drm_print: wrap drm_*_dbg in dyndbg jumplabel Date: Wed, 16 Feb 2022 20:48:25 -0700 Message-Id: <20220217034829.64395-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 E1731C433F5 for ; Thu, 17 Feb 2022 03:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbiBQDt1 (ORCPT ); Wed, 16 Feb 2022 22:49:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbiBQDtF (ORCPT ); Wed, 16 Feb 2022 22:49:05 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB7BC5DA4 for ; Wed, 16 Feb 2022 19:48:51 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id a26so2205250iot.6 for ; Wed, 16 Feb 2022 19:48: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=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=oHx5SA+pA20pWvzGLkJ4yhng4E+IvjuoVEMElPdEpgwBAXZX8Ayc2SvfCLXwvFcehP o0AHme5wuSQ63YxgN3QSc0rUbOV/j/+6G6zQRS4NCVt/yEL1Crq/uwf9UDEKebgjg//9 QjwYPtTiQ0qXnz1UoGaup0sTfsdK8RdEHeUiQduq7H62ZAi7uIXJLbm6AdTtwuFcGXuD HV1h9OqMqWbRjdNwm8pC+0EWihoDDr44lxgfi0RIrrwF4+9Cz21iiE95YFoJBmglrB4c uqhiYzFY7DXRbPHXJsC8Kzs9wY0qwRswwrK0gBC7Y2uHlx1hH59CcbFMZGDMbalV1nve ffkA== 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=fgx2EXdO7UwfcUOsRUAVkGAxShYZOhTIqY4knDoYFyV2Xd8YyrTaU19mBR6U/RzRc7 f8Ypxi86UboyqJ1JsRss4HejeEPm+BBG2DJw5tUMLYCaFvcSqq7pU6MfAwOPU2Dbm2M8 Kn3Mh9WHtnyIjTRTqj16pXMXwHv+WUHymBh6v15beAwSy4+N5RY+pMvSzsmXxTAwLHvC hMLu6fNFszkK22yUBTnZI+3M8BvbGeHwNiKkA+P4sNw1KpIIEPefZmtmuYV05nLSnVfE ytYRNh+poWSQkLBM1udu9EW4fwtO3paFlC0C69wnYHpkDG0EYhP5U1cb3Gpy8ps44k72 2XUQ== X-Gm-Message-State: AOAM533Z4P/PSBrNKDJsWfLLDe/PIjbHnosnS9YHpBkdNJwW0oWStvUx oSeoQXVQLKnYSvydxTrNELc= X-Google-Smtp-Source: ABdhPJwQdM+YASo9bZwGxmAll7Ye37UoRGfnFLBMbW70/Q8CqJm3xpdtwTbFefjn4OZb9vDTlUFoSw== X-Received: by 2002:a05:6638:1350:b0:314:7f2a:ab14 with SMTP id u16-20020a056638135000b003147f2aab14mr717303jad.215.1645069731093; Wed, 16 Feb 2022 19:48:51 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:50 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 10/13] drm_print: refine drm_debug_enabled for dyndbg+jump-label Date: Wed, 16 Feb 2022 20:48:26 -0700 Message-Id: <20220217034829.64395-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 0929BC433FE for ; Thu, 17 Feb 2022 03:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233308AbiBQDtc (ORCPT ); Wed, 16 Feb 2022 22:49:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233206AbiBQDtO (ORCPT ); Wed, 16 Feb 2022 22:49:14 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9958EC5DBC for ; Wed, 16 Feb 2022 19:48:52 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id f13so1372390ilq.5 for ; Wed, 16 Feb 2022 19:48: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=m+1diemf3MRoXdblNNavyGZGnh4l9BWi+2yg35q/w2I=; b=piNFTBhwQ7mhrk0SHb3PWRDl5OjBX/bAyNasGSPh1MsbJOAUlq4M54/Ycs9JEz1OkK ajhk18Y44UImCvX03at6dUQBwc5j8vy67kAtnKDCOYHUbW3oNqVu5AQYP1CNBcWAJXyx 7ATDZmawW4xanGN6qmHekUzUPlIwkViD3xOIQiA9DMIvaFoN//ASa3mFsYgEglo1/2wS FriiPIYnPHJvQnETNxtDTyeu0G+YT4qQXT6YzncWfiy55/qVnfJYcUY7uI45Z/ZaMfJ+ XKf9lW5gCeT4210yp9SCnnt0FkxKMe9FDNoK3D32OZBZfcoopIMU3gCIg3tOjq2EODRt hGUA== 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=ArRp68a9gGlOgho/48SH/BVVGsBkGXQ1+JUiBYa5QK2nwpKs7Wjqex/aPpNN0GUpa3 /FZ1A57ufzSlyfxaP/R2AhmEAJV9ECHUzWEXNHZEIPkunhZ19PKj3Mu4uJUxszWHxuvb d9SA74sQunyNAWZn+yH3jS2jJCqqRK53493oLGtCbZ5YCDVIfgKp7c0inmU/8Xg3lkse y33u3X2MwNrfEnxNIU0JQcvEj9TWGBqqfsDsqGNu1e8HVx6i2gqC4VTYMz59Mez6C4SW gx6XnRH0qjebg6bmAGLAZKTzWvK5EMF3WxlgYId+amVa4g25WVNnAQ6Ekq0yjzyaxN99 RQRg== X-Gm-Message-State: AOAM530wDIcU3V+6djWyC/pSxXGwEsGYqb7dZkOv3OSLu6h0/avKVZ6g Fq1TA7Llb/5+Drqzb1p7jPQ= X-Google-Smtp-Source: ABdhPJzlC3U68DCLsbYeOcinMvhFhlX0fVCV6UVlgNQZ/JDGtbLNJFcAGBXvUWtwMqJomXO85pvLPw== X-Received: by 2002:a92:cece:0:b0:2be:a529:d457 with SMTP id z14-20020a92cece000000b002bea529d457mr750693ilq.154.1645069732006; Wed, 16 Feb 2022 19:48:52 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:51 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 11/13] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Wed, 16 Feb 2022 20:48:27 -0700 Message-Id: <20220217034829.64395-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 44E91C433FE for ; Thu, 17 Feb 2022 03:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233484AbiBQDtf (ORCPT ); Wed, 16 Feb 2022 22:49:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233220AbiBQDtR (ORCPT ); Wed, 16 Feb 2022 22:49:17 -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 7AF29C6242 for ; Wed, 16 Feb 2022 19:48:53 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id h11so1361991ilq.9 for ; Wed, 16 Feb 2022 19:48: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=QEgu+Ofez++Uoa48K1+2ND2BjCIRiQBeP9KERq1IVJk=; b=c1JeYHRFs5svhKtU+Ma4tZuA1JP1VGAyb5UJut5hn3b+E/pkz4W6ai6Wi07gw9nx0u IJlaKZ1JgaK+etmpo8bVgK993gcuAQTJ85hKZNvC7mbhzNti3nrRKPiMeA5cy+BRNPXn q+7FmioValLExz+ZdCNnxwwsoXMa2G4dtMO7YG1oXpyH4HDMwlppdpOMwt8l8BATxVtu D5e063IVeRG46r9SCc3fM59VGWiK5172LjkMtGK13zLg09HTaAmMkaTMEB72l+5RvYV/ HlHFzFSqBHJ/GmG2G9sNcd/lWFFlzJlqrO5TGL4sAVzk2p+at9nmsgBlhy7IgHUVzEqO z6+A== 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=kkIgF7ziiG3oWHjHIiFCELLjT6rQTBvkDb4G3psemRgMvZmeU8Z48Ah8R3jU99/eW/ krn/uVeZT5gabLOFLcMV8HuzBzcMU0B95C0ay9KbANfdxfHFFQ9Y8ZhXMXroMJY64E5k 8jBp2XBc4lv6jhwEiEsNl0WpvQqUnO1cToa9VO4k5sUaHHu/DCvNxVnYo4/hJBDBo4hm B14gtQR3im+WLaeBb1NgxoarSRbIxFfQU18xQMxYHfTc7YIrvHDZY8OTtwJ0ezKNLKnQ 7wks7zoYad30gLWjhhPveikv0P5Lejix8FuDjoflUEsSJ9yEumJDtnawlkWMhft1hJpa aFbQ== X-Gm-Message-State: AOAM530HXDzegHVzmUccUGySnfTuSjfmnyDt8WnyxK+wviiOwirbWvOX QbAsA+vlKfte/ZN0M5XNKcc= X-Google-Smtp-Source: ABdhPJyyUYLLjO/ZjDmiQ2qjpAZbgsdUUcVllJavrIsnuUX4/fgc6pmjbTxk2ccQkswLRYw9SI0fLw== X-Received: by 2002:a92:ca4a:0:b0:2ba:878e:fd12 with SMTP id q10-20020a92ca4a000000b002ba878efd12mr743076ilo.139.1645069732854; Wed, 16 Feb 2022 19:48:52 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:52 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 12/13] drm_print: add _ddebug desc to drm_*dbg prototypes Date: Wed, 16 Feb 2022 20:48:28 -0700 Message-Id: <20220217034829.64395-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 Sun Jun 28 00:50:46 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 E48B7C4332F for ; Thu, 17 Feb 2022 03:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbiBQDth (ORCPT ); Wed, 16 Feb 2022 22:49:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233259AbiBQDtR (ORCPT ); Wed, 16 Feb 2022 22:49:17 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F4ECC0506 for ; Wed, 16 Feb 2022 19:48:54 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id c14so1374976ilm.4 for ; Wed, 16 Feb 2022 19:48: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=Al57ZNKX5lnblKHtWXH/Bsh3z6Q/ha1M5NnWcexkJRI=; b=V0r7t+t0Kk8YqhDL5yttmCVdcakOAJfOvunaP5rUIXFehX50brE0txV/ZP/yfOIiJ0 OZOMuTviWiLPhKj6tYIt+g1vii30xz4wooVCZaC1Sf0se7ci4nGLIYuNE2MHe+fqWJv6 SUd9Gn7k9KBrlbJ51tAD6K8Rn9LOerLRVIIlqlxyQOioGqU8chuma2FAB0o2HF0mpXOs EabrXT7RY8/P2i99gy5Ft3xcRe1gpyfpDE9jfckgpO9vjSLMN83CqB2PQRC6rwXFly/M +lEeEu1AtjaTnaxUJFl7Ucop5hD5N/MkNhLu+FTKEb6ZI/OBs3rZe9v4rgSYKctmBxgf FeMw== 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=Al57ZNKX5lnblKHtWXH/Bsh3z6Q/ha1M5NnWcexkJRI=; b=A0xgUwUQ3j7bpUlYYz5C5oa3eenNVFlEG6BG0XywW3kqWDrdEAD8/Vbl4A5zMwEno0 ajc0Yh0nhJZIgKW++fzCd/L7CQylHxZ7ErxZeCXK0TjttFLpxj7w2cq6ioIBrFFTr62f CEWjN0FyxnE3iczk2C7XEPJCW80g1t6oh/qCJogOZzqaKvOomoxKDd3sWLJ+BDv3174J za5TS0o5/+PynZH4Jcx3eT7UhWHF3PZQPmLZSGiqxhpZ2zNAuAJ4bJiabyuL6j3TH7Sh JrCBvGcYYFFRqL06eT8qyZ7BJnB5QKVoj3E/Q7+tBq7t6T+LUpW4lopG1+79CrjWUF+l //Dg== X-Gm-Message-State: AOAM532XDpSUFfJo4bwllqt57PONjrIA6xcP7GQvMSZUeRFu/INDUWOZ ksQ2pZjJX/BnJU6C08gGcVU= X-Google-Smtp-Source: ABdhPJwpadjkqlwkn/peOpycjU/cPxWs8v84Mc4rTvbPvVHvXR0owgAgjr32VA6mTQgW+Q005SRNiQ== X-Received: by 2002:a92:d242:0:b0:2b9:a33b:9068 with SMTP id v2-20020a92d242000000b002b9a33b9068mr786669ilg.144.1645069733685; Wed, 16 Feb 2022 19:48:53 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::1b19]) by smtp.googlemail.com with ESMTPSA id l16sm1127874ilc.54.2022.02.16.19.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 19:48:53 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, 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: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH 13/13] drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug Date: Wed, 16 Feb 2022 20:48:29 -0700 Message-Id: <20220217034829.64395-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220217034829.64395-1-jim.cromie@gmail.com> References: <20220217034829.64395-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 undo any customizations a user added once the sysfs-knob is 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