From nobody Wed Jun 24 09:55:37 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 9E7E9C433EF for ; Fri, 11 Mar 2022 04:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346389AbiCKEtZ (ORCPT ); Thu, 10 Mar 2022 23:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346227AbiCKEtT (ORCPT ); Thu, 10 Mar 2022 23:49:19 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBD8597293 for ; Thu, 10 Mar 2022 20:48:16 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id r2so296813ilh.0 for ; Thu, 10 Mar 2022 20:48:16 -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=oAf0LosuiaLpXGtYs0EMjapukN/Wz4GaZEg3vD6y6ak=; b=FGomt3SpUqyItDxQTS6QatofCRhiZIi82c83FcZW5lAA7Hia4dUP0QS/5UI8s6V1iG p9ewH/E8qTORsPj4+OnlwfDOXUVrf8HA+fTwEUNyHVWnEW32jyMqS0HEMeua00mED9fG Jt5WhOje3GPSyOyvOMadpj6kIzq9ffhFw1is+8tPx5sOzNgcO1DanXFs7auqvAQR2OBg O5UhHrzIh8D2tX1MtSnEyQ5Xl0wYsAOwDwWqf53yNtM1nYFJb6c8e8muyyQDgIBl6Ddw xd1IC+TTQp3rkOr7C1IvU2aLj6DFtJpHblfIL1P1+F7+iR/oDHQO/VvQ8mZgMhLKEvdi yJug== 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=oAf0LosuiaLpXGtYs0EMjapukN/Wz4GaZEg3vD6y6ak=; b=hO6GHXaH+veNPN3qEZPTAs+u1k7nhpIGcxi5OzyuMfaE6HlgpC/lxULS5iD+DtAYvd sTiRNRtuSpfO8+QHo9r0/tT3XUpOP+D5CajapAIjaOFOT454VR4qrZK+JGOIRSd0+1qU 96Znnxe1o+3kTsngZFMGzEogQpcYaJsqxeslw7+8Ryo5jySj1ga+YqYYKzpvxnue3FU4 1SToHH/sSmPmTqM/KAY3ivh4vOE2wve2sw/88nqumvlBlB36ddMcBNale5hWfO7aBAnl GulDZTfEF19OzdZgvHt2GvtrXXAgYmtZIRM11e4NxR9Y0t6fuLoq4pa/rCVkgpNBgu0C JY3Q== X-Gm-Message-State: AOAM533oxc7U6me8QKPmoUIF/V7Dq7v5k79qxN3dQUtjxxXom874Kq2+ ScavoWIKoe+IPPCAwJZGut0= X-Google-Smtp-Source: ABdhPJwFZHg/BgFkwfNAHNLyEDOYNqmvUk/C+4ceSxeoTbqDRVietvJzifHbTMNcdfYqz0MT1Xo4PA== X-Received: by 2002:a05:6e02:1946:b0:2c7:730d:3e35 with SMTP id x6-20020a056e02194600b002c7730d3e35mr2075171ilu.179.1646974096273; Thu, 10 Mar 2022 20:48:16 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id q9-20020a5edb09000000b00645c7a00cbbsm3529834iop.20.2022.03.10.20.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 20:48:15 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH 1/5] dyndbg: fix static_branch manipulation Date: Thu, 10 Mar 2022 21:47:52 -0700 Message-Id: <20220311044756.425777-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311044756.425777-1-jim.cromie@gmail.com> References: <20220311044756.425777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In https://lore.kernel.org/lkml/20211209150910.GA23668@axis.com/ Vincent's patch commented on, and worked around, a bug toggling static_branch's, when a 2nd PRINTK-ish flag was added. The bug results in a premature static_branch_disable when the 1st of 2 flags was disabled. The cited commit computed newflags, but then in the JUMP_LABEL block, failed to use that result, instead using just one of the terms in it. Using newflags instead made the code work properly. This is Vincents test-case, reduced. It needs the 2nd flag to 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 Signed-off-by: Jim Cromie -- .drop @stable, no exposed bug. Acked-by: Jason Baron --- 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 Wed Jun 24 09:55:37 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 D224AC433FE for ; Fri, 11 Mar 2022 04:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346416AbiCKEtc (ORCPT ); Thu, 10 Mar 2022 23:49:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346245AbiCKEtV (ORCPT ); Thu, 10 Mar 2022 23:49:21 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59129F6F9 for ; Thu, 10 Mar 2022 20:48:17 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id k25so8882133iok.8 for ; Thu, 10 Mar 2022 20:48:17 -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=p/gDed9mjWquugw1564Om0fYtLE4xfr9AocRWQTn5xo=; b=jErl+su4dJeS3EQkkpi1iLYNAS3TmiC0jxACivDDuEtAYLY/eLagJuqigxKlvk64WX 5WLYdI92cpRdtRFdtk3BUZbdgCRZ6XgZNAgWdXw1U5FPG1WwJ68MQDXNKtNieZof7Cgx 6e06R3gstJOSvat4MICVWUH0/hEVsr6bAPB+rWAxkrpTl5bJLGgekdwAXt2/jRcuk+wA f8+k56xzsAE+JXSLkOjBCOCC1SkX/LAlCDEd4pgkvco+6lCcijf8fzQwU1yH3z9yFZon gz8ESQbN83D3wBrlFPC0iF4gUf5SgB3Xkbp6PFtlodS+n0adYiWGauHIS3zweH4Ya5mt Ygog== 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=p/gDed9mjWquugw1564Om0fYtLE4xfr9AocRWQTn5xo=; b=zobwO6Lbgg+sopm70Z3CWSX6fFVqOXwQ51dIGVlSsv4t22nLrNe0xZJBOB4rpP39qA 1ZqRgyCmp30lJebLWm/ocZcC8t0uqoSZHCqQ2XPgiQxvmD04KUDJHfjJ0Mls/DRpTuYd prPohJIBgi3OQMXjsRicRKDG1igxHVQeUuThCC5BYGDvLw+BztJwBzmotOugAFByNKYN Ut+3ifb6dJ1EQZS53pMN2EciH2eqZMC1XLapRgPqftNUVE3+6yp+4fSuOmTMwgCNQBdd +5ipunV2R1MRYycBeOFF83LqWxZ0Aeb7rF4y6kB/Og82wsq4m/WyhCDMeuwUTWtQUp7h ivIQ== X-Gm-Message-State: AOAM533+bp13sdaFbbgr76OaAn70S/sxvK/FUMmB8FEWxBioLx7vpwJT 7cCi2p2qNLq7EML0GZ1PYTE= X-Google-Smtp-Source: ABdhPJwwdoTGV4SvWOjo2Ipfd01ftsUEq0qX/CG6aBP3wvzzeccqEmHlrksixYn4WBjOarqSuHuZwQ== X-Received: by 2002:a05:6638:4102:b0:314:32a6:90bc with SMTP id ay2-20020a056638410200b0031432a690bcmr7045899jab.168.1646974097052; Thu, 10 Mar 2022 20:48:17 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id q9-20020a5edb09000000b00645c7a00cbbsm3529834iop.20.2022.03.10.20.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 20:48:16 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jim Cromie Subject: [PATCH 2/5] dyndbg: add class_id field and query support Date: Thu, 10 Mar 2022 21:47:53 -0700 Message-Id: <20220311044756.425777-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311044756.425777-1-jim.cromie@gmail.com> References: <20220311044756.425777-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, one can enable current/unclassed callsites by: #> 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. Default .class_id =3D 15 means that ``echo +p > control`` no longer toggles ALL the callsites, only the unclassed ones. This was only useful for static-branch toggle load testing anyway. RFC: The new _CLS macro flavor gets a warning from DRM/dri-devel's CI, but not from checkpatch (on this subject). a8f6c71f283e dyndbg: add class_id field and query support -:141: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'id' - possible side-eff= ects? +#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) I couldn't fix it with a ``typeof(id) _id =3D id`` construct. I haven't seen the warning myself, on the _CLS extended macro, nor the original. CC: Rasmus Villemoes Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 7 +++ include/linux/dynamic_debug.h | 54 ++++++++++++++----- lib/dynamic_debug.c | 48 ++++++++++++++--- 3 files changed, 88 insertions(+), 21 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index a89cfa083155..8ef8d7dcd140 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -35,6 +35,7 @@ Dynamic debug has even more useful features: - line number (including ranges of line numbers) - module name - format string + - class number:0-15 =20 * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -143,6 +144,7 @@ against. Possible keywords are::: 'module' string | 'format' string | 'line' line-range + 'class' integer:[0-15] =20 line-range ::=3D lineno | '-'lineno | @@ -217,6 +219,11 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file =20 +class + This expects a single integer in range: 0-15. + 15 is used/reserved for existing/unclassed callsites, + and is defaulted in unless specified to >control + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..d4b48f3cc6e8 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -6,6 +6,8 @@ #include #endif =20 +#include + /* * An instance of this structure is created in a special * ELF section at every dynamic debug callsite. At runtime, @@ -21,6 +23,9 @@ struct _ddebug { const char *filename; const char *format; unsigned int lineno:18; +#define CLS_BITS 4 + unsigned int class_id:CLS_BITS; +#define _DPRINTK_SITE_UNCLASSED ((1 << CLS_BITS) - 1) /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -87,7 +92,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); =20 -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name =3D { \ .modname =3D KBUILD_MODNAME, \ @@ -96,8 +101,14 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ + .class_id =3D cls, \ _DPRINTK_KEY_INIT \ - } + }; \ + BUILD_BUG_ON_MSG(cls > _DPRINTK_SITE_UNCLASSED, \ + "classid value overflow") + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_SITE_UNCLASSED, fmt) =20 #ifdef CONFIG_JUMP_LABEL =20 @@ -128,18 +139,26 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #endif /* CONFIG_JUMP_LABEL */ =20 -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) =20 -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) =20 +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) + +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(id, _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) + /* * "Factory macro" for generating a call to func, guarded by a * DYNAMIC_DEBUG_BRANCH. The dynamic debug descriptor will be @@ -148,15 +167,24 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS_= _) #define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) + _dynamic_func_call_cls(_DPRINTK_SITE_UNCLASSED, fmt, func, ##__VA_ARGS__) + /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc_cls(fmt, cat, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), cat, \ + fmt, func, ##__VA_ARGS__) + +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), \ + _DPRINTK_SITE_UNCLASSED, \ + fmt, func, ##__VA_ARGS__) =20 #define dynamic_pr_debug(fmt, ...) \ _dynamic_func_call(fmt, __dynamic_pr_debug, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a56c1286ffa4..ee2129becacc 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -55,6 +55,8 @@ struct ddebug_query { const char *function; const char *format; unsigned int first_lineno, last_lineno; + unsigned int class_id; + unsigned int class_marked:1; }; =20 struct ddebug_iter { @@ -134,13 +136,13 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) fmtlen--; } =20 - v3pr_info("%s: func=3D\"%s\" file=3D\"%s\" module=3D\"%s\" format=3D\"%.*= s\" lineno=3D%u-%u\n", - msg, - query->function ?: "", - query->filename ?: "", - query->module ?: "", - fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno); + v3pr_info("%s: func=3D\"%s\" file=3D\"%s\" module=3D\"%s\" format=3D\"%.*= s\" lineno=3D%u-%u class=3D%u\n", + msg, + query->function ?: "", + query->filename ?: "", + query->module ?: "", + fmtlen, query->format ?: "", + query->first_lineno, query->last_lineno, query->class_id); } =20 /* @@ -170,6 +172,10 @@ static int ddebug_change(const struct ddebug_query *qu= ery, for (i =3D 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp =3D &dt->ddebugs[i]; =20 + /* match against the class_id, either given or default */ + if (query->class_id !=3D dp->class_id) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -308,6 +314,21 @@ static inline int parse_lineno(const char *str, unsign= ed int *val) return 0; } =20 +static inline int parse_class(struct ddebug_query *query, const char *str) +{ + int rc; + unsigned int val; + + rc =3D kstrtouint(str, 10, &val); + if (rc < 0 || val > _DPRINTK_SITE_UNCLASSED) { + pr_err("expecting class:[0-%d], not %s\n", _DPRINTK_SITE_UNCLASSED, str); + return -EINVAL; + } + query->class_id =3D val; + query->class_marked =3D 1; + return 0; +} + static int parse_linerange(struct ddebug_query *query, const char *first) { char *last =3D strchr(first, '-'); @@ -421,6 +442,9 @@ static int ddebug_parse_query(char *words[], int nwords, } else if (!strcmp(keyword, "line")) { if (parse_linerange(query, arg)) return -EINVAL; + } else if (!strcmp(keyword, "class")) { + if (parse_class(query, arg)) + return -EINVAL; } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -428,6 +452,10 @@ static int ddebug_parse_query(char *words[], int nword= s, if (rc) return rc; } + /* post-validate the query, set default */ + if (!query->class_marked) + query->class_id =3D _DPRINTK_SITE_UNCLASSED; + vpr_info_dq(query, "parsed"); return 0; } @@ -900,7 +928,11 @@ static int ddebug_proc_show(struct seq_file *m, void *= p) iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape(m, dp->format, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id !=3D _DPRINTK_SITE_UNCLASSED) + seq_printf(m, " cls:%u", dp->class_id); + seq_puts(m, "\n"); =20 return 0; } --=20 2.35.1 From nobody Wed Jun 24 09:55:37 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 39D40C433F5 for ; Fri, 11 Mar 2022 04:48:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346424AbiCKEtg (ORCPT ); Thu, 10 Mar 2022 23:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346282AbiCKEtV (ORCPT ); Thu, 10 Mar 2022 23:49:21 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ACC5A1472 for ; Thu, 10 Mar 2022 20:48:18 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id b5so5233790ilj.9 for ; Thu, 10 Mar 2022 20:48:18 -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=KzXspZ2sHsVi+5ALCIQ5k/5igVC8NcVQPghR6yPzH8w=; b=fY1SIv/XhNKWqCeGlwB2/Bb/aVhHowjDaAiImHJJhYGh8jCyUbgkwIxZ5HQ9njvC0Y 8NF6Xg2ptMg2eOXxmIPiLf7fEXmH7hhjD6Ak+OJowzsAR8EsWMQdpwU2+IYccDdx7BaQ pUcO1/sDz5xRuSAqmqdQNf7eNQJiScZfm/1pv6QCvL/40lckUU1N+LpiZNe/KrQEmt8J 97RORvSzfccY/dNG6IbULEM8v3pTpkOAZemDyN9IGSM4QxLvCNZcaEwn5Ro3YxW6AY8a Fu+/hvmKYdO1XArFnkN62Rd8/yhJU3fsmV9Q4usUJeqT/pTtBo+JvOSrupcaCrJSB+BG bAag== 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=KzXspZ2sHsVi+5ALCIQ5k/5igVC8NcVQPghR6yPzH8w=; b=Vb5Fz6+xikg4pjYA9Jxd92E/fY7a2eovH2vNLWRUzcx0ARLVYGPC+Yyk8hWAeHmht3 H9pgpwWoDcHAodmeyrSis8cjyTN+8BbiHlCCUr0H3jKP35HkAWNmzpSxBa9vOfwQ5Y48 Y3EIrUEWauomXxRt9HGU5D6UC3KabsxJegdT6wzTwcoh1JmK1NMpTWuvzTNI2g86e6W0 mn2k2yh+vRVOmJzCVL0fL3ay6KClI7ZZrq5VfwgN4g6HVawyKQehNEHck6EnEy6n2Hl4 h7nif79Fj5wmFk3jEjN5Dlu/SPlLCPpO4q1QTAdoISjybJrPY+FCfyd6xG48+k3fAGak i+rw== X-Gm-Message-State: AOAM533HNSgM+87ae3AYLRyss16sHnjHE6sgIk15mEyKFpgsk/q8jg9O hwL7RYvLGrPM3djDOYL2OQs= X-Google-Smtp-Source: ABdhPJygvxVm9dbbN1fsjiunWgAh9jHo5gsGbKbLIDc+K1fRb01o6rwc7qQKPhrRRnes0kv/qGvaow== X-Received: by 2002:a92:6c08:0:b0:2c6:123f:48c9 with SMTP id h8-20020a926c08000000b002c6123f48c9mr6693153ilc.22.1646974097869; Thu, 10 Mar 2022 20:48:17 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id q9-20020a5edb09000000b00645c7a00cbbsm3529834iop.20.2022.03.10.20.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 20:48:17 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jim Cromie Subject: [PATCH 3/5] dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro Date: Thu, 10 Mar 2022 21:47:54 -0700 Message-Id: <20220311044756.425777-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311044756.425777-1-jim.cromie@gmail.com> References: <20220311044756.425777-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: bash-5.1# echo < /proc/dynamic_debug/control > module drm class 0 +p > module drm class 2 +p > END With the macro used (in a client), this is basically equivalent: # but this also clears other flags, if theyre set echo 0x05 > /sys/module/drm/parameters/debug To use: DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, "pmfl", "drm.debug - bits =3D> categories:", /* vector of uint:4 symbols, ala enum drm_debug_category, 15 is EOL */ DRM_UT_CORE, DRM_UT_DRIVER, DRM_UT_KMS ... ); The 3rd arg is a string with any of the dyndbg.flags [pmflt_]+ Full exposure of the flags here lets the module author: - fully customize/take-over the decorations of enabled sites. generally leaving decorations to user is preferred. - aim the debug-stream: now printk, later tracefs. using both together means more work (p or T, in practice) iface doesn't care about new flags added later - declare 2 separate sysfs-knobs, one each for p, T, if desired. - decorations are per callsite, shared across sysfs-knobs for any controlled classes To support the macro, the patch adds: - int param_set_dyndbg_classbits() - int param_get_dyndbg_classbits() - struct kernel_param_ops param_ops_dyndbg_classbits Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. get/set use an augmented kernel_param; the arg refs a new struct dyndbg_bitmap_param containing: A- the vector of classes (drm.debug "categories") being controlled This in-line vector of constants (uint [0-14]) specifies a sequence of controlling bits (by position, starting at 0) with the values naming the class_id's mapped to that bit. A value of _DPRINTK_SITE_UNCLASSED terminates the vector processing by param_set_dyndbg_classbits(), and is appended by the macro to insure a defined termination after max 15 classes are applied. Technically, the vector is a flex-array, but its size is practically limited to max 15 in length (repeats are pointless). B- a pointer to the user module's ulong holding the bits/state. By accessing client's bit-state, we coordinate with existing code that still uses drm_debug_enabled(), so they work unchanged. The change to ulong allows use of BIT() etc. NOTES: _DPRINTK_SITE_UNCLASSED =3D 15, ie 2**CLS_BITS-1, deserves special mention; it already marks all existing pr-debug callsites, only the new drm.debug callsites are initialized to other (DRM_UT_*) values. _DPRINTK_SITE_UNCLASSED is used in param_set_dyndbg_classbits() to limit the range of bits that are processed to what fits in uint:4. It also terminates the class-id list passed into the macro, so dont use it halfway through your list of classes-to-control. param_set_dyndbg_classbits() compares new vs old bits, and only updates each class on changes. This maximally preserves the underlying state, which may have been customized at some point via `echo $cmd >control`. So if users really want to know that all prdbgs are set precisely, they must pre-clear then set. Identity mapping in (A) is encouraged. Your vector should exclude 15, if used, it terminates the list prematurely; any following bit mappings will be ignored (it is the default/non category). The whole (A) vector/list passed to the macro is: - not strictly needed: 0-N bits are scanned, only N is needed in the macro interface to do this, not the whole list. - 0-N list allows juggling the bit->class map Identity map is preferred. 15 terminates list if used. (macro impl does this) That said, (A) is self-documenting; the explicit list is greppable, 'DRM_UT_*' provides lots of clues. Further, it could be upgraded, something like: _pick_sym_(DRM_UT_CORE, "mumble something useful about CORE debug") _pick_sym_(a,b) a // gives us what we need here _pick_help_(a,b) #a " : " b // mod-info fodder Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 50 +++++++++++++++++++++++ lib/dynamic_debug.c | 77 +++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index d4b48f3cc6e8..e83c4e36ad29 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -209,6 +209,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 +struct kernel_param; +int param_set_dyndbg_classbits(const char *instr, const struct kernel_para= m *kp); +int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp= ); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 #include @@ -255,6 +259,52 @@ static inline int dynamic_debug_exec_queries(const cha= r *query, const char *modn return 0; } =20 +struct kernel_param; +static inline int param_set_dyndbg_classbits(const char *instr, const stru= ct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classbits(char *buffer, const struct ke= rnel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 +#define FLAGS_LEN 8 +struct dyndbg_classbits_param { + unsigned long *bits; /* ref to shared state */ + const char flags[FLAGS_LEN]; /* toggle these flags on bit-changes */ + const int classes[]; /* indexed by bitpos */ +}; + +#if defined(CONFIG_DYNAMIC_DEBUG) || defined(CONFIG_DYNAMIC_DEBUG_CORE) +/** + * DEFINE_DYNAMIC_DEBUG_CLASSBITS() - bitmap control of classed pr_debugs + * @sysname: sysfs-node name + * @_var: C-identifier holding bit-vector (Bits 0-14 are usable) + * @_flgs: string with dyndbg flags: 'p' and/or 'T', and maybe "fmlt" al= so. + * @desc: string summarizing the controls provided + * @classes: vector of callsite.class_id's (uint:4, 15 is reserved) + * + * This macro implements a DRM.debug API style bitmap, mapping bits + * 0-14 to classes of prdbg's, as initialized in their .class_id fields. + * @_flgs chooses the debug recipient; p - syslog, T - tracefs, and + * can include log decorations; m - module, f - function, l - line_num + */ +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, _var, _flgs, desc, ...) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_classbits_param ddcats_##_var =3D { \ + .bits =3D &(_var), \ + .flags =3D _flgs, \ + .classes =3D { __VA_ARGS__, _DPRINTK_SITE_UNCLASSED } \ + }; \ + module_param_cb(fsname, ¶m_ops_dyndbg_classbits, \ + &ddcats_##_var, 0644) + +extern const struct kernel_param_ops param_ops_dyndbg_classbits; + +#else /* no dyndbg configured, throw error on macro use */ + +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "CONFIG_DYNAMIC_DEBUG* needed to use this macro: " #f= sname) + +#endif + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ee2129becacc..704361af5b23 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 Wed Jun 24 09:55:37 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 7C0ABC433F5 for ; Fri, 11 Mar 2022 04:48:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346430AbiCKEtj (ORCPT ); Thu, 10 Mar 2022 23:49:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346367AbiCKEtW (ORCPT ); Thu, 10 Mar 2022 23:49:22 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 407CF96828 for ; Thu, 10 Mar 2022 20:48:19 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id x4so8906544iom.12 for ; Thu, 10 Mar 2022 20:48:19 -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=/h9xFvawkOKYC2TFtGI3znCZsvzaWHfu4sF1ThE8sW8=; b=Zh/GmixJA2Bkf+z3osxm52SixJc6N5HkApUb2Sp4YGoESKhGGarMHbycUmY/c6Dz4J +xK6+F/W73MpUprLT70tAmHEUqNOYAibOBVn/qnSaB5/rEQVsqqczquFlpxgR1J6wk0M kbOZ/NOewpqCsHafnHbqm2A5Lf7hQfpJ43mC8fN2jZThxq+HG4T1ItPSF8mYPAY/XPGd qfrdVcgaU60hqfL84zXmEEPWBRZc0F5S63EKjTShBYTzQyn3feampBV7byM6fXOxZeo+ dCdZKUt0qW4bASMO7CIYGnErd2OblUZJi3Z3Wk2Rp3k1mFnoHGT2abEHrvk7R3J0bqw9 IKww== 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=/h9xFvawkOKYC2TFtGI3znCZsvzaWHfu4sF1ThE8sW8=; b=tXU+F3KCjIB+dzQrxE3osK/FYsLHRehCRt1KgE3LLYaOxlLmPmKVpCvwUWWWIdtbmf m9yobyCiKsUEL0LtCElKRCXcSEr+EGyG68ztf38W0C6wWQ3QwvoZRSstccmEyxK5msUP SJk7vlHKlLrHIZM6sNiTVtuuBsewtLAEc9mfYI9lPUBmYBFU31nx/ov1p8bjVupbbk9N Gy3KaB5fQhWYk3W3xzHTuABayCpg8Jv/a6qpFmmQuYqqnHpOpFvvnPYJJRfEbe0k2bRM b3Ryt207FgQ9bRXj2okMwlQnq895G7tSJ3vBiI4ihdvcR/Adtmwy8cc9F39nEBAydn+f sBfg== X-Gm-Message-State: AOAM5329wz+LD2/45oaAzuV4Y3xjQ5kVNbhQObEEWygFXgbTdfBtgI6W K78OyXn0gG86qjwmqGWzwcA= X-Google-Smtp-Source: ABdhPJx9nc37H2OIUHqJB2EjVVVmHJqmzNnu/dUpgVAbx3aqEwg8oB7jd+HVTBgzb+5P6OYmKvD6dg== X-Received: by 2002:a05:6638:2586:b0:319:ac56:5f2f with SMTP id s6-20020a056638258600b00319ac565f2fmr6752417jat.146.1646974098620; Thu, 10 Mar 2022 20:48:18 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id q9-20020a5edb09000000b00645c7a00cbbsm3529834iop.20.2022.03.10.20.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 20:48:18 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jim Cromie Subject: [PATCH 4/5] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Thu, 10 Mar 2022 21:47:55 -0700 Message-Id: <20220311044756.425777-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311044756.425777-1-jim.cromie@gmail.com> References: <20220311044756.425777-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. 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, using the internal fn that the export wraps. Since there are no other expected users, and any prospects would likely reuse the bitmap or a straightforward extension of it, we can drop the exported 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 :-/ Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_q= ueries()") Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") 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 704361af5b23..b15a9c715e5b 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 Wed Jun 24 09:55:37 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 76651C43217 for ; Fri, 11 Mar 2022 04:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346438AbiCKEtn (ORCPT ); Thu, 10 Mar 2022 23:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346357AbiCKEtW (ORCPT ); Thu, 10 Mar 2022 23:49:22 -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 1AC57B0EBF for ; Thu, 10 Mar 2022 20:48:20 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id r2so296857ilh.0 for ; Thu, 10 Mar 2022 20:48:20 -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=OBRXqLWuyBojQser+FbveA33IOgP8H/VueHlz3pP7BU=; b=Dyxrf9L35Hr+o6Rm/FEKjC+JQ97HPxYkwKzea8dMbY2oborFn0jItr+z4C7tIGKC97 8CTghaUFfyVolu/8SQcbgXHPRbOQmxXT2ukp7wit0PME42zZ0LDpu5Y6PvMe6BtiPWp2 3cEDeZCu8FaaXKll6oe67z4fOGMc7dx1mDtWbpssZseAEqblBKdkJfMuaQ6AyVYbdjcL +ZVZHqKsDL4/ypd8F/RCAVTmLiZ8m493W9XdltdXs4JDb6MH+YOg5OjHhSaZK9kQahIm bIvpqdAjCHCEwQfHGz4fLPTwo0UfpgOUXu6y0+tbuz5pW4PXETXeTy7a/bk0DayQSzFo 7Efg== 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=OBRXqLWuyBojQser+FbveA33IOgP8H/VueHlz3pP7BU=; b=fGR1Z7cEMtjkzeKk/uoPtRfDoTvq5KNyQGwbrQWG/yBHG/tfhqJOPdgWbfZaig82E6 ZC3bUpl6WdD/Y9xk1ChV1w4+CAMwati/fwQOTj8jF8/DAynyqQjPN1MySDoUxasMuKAe ynFiN8y5NM8R1iaROyxwcCsSPg4TiMlChjxyo4gkyPBKLWNBElCYX69ZVx4a204j5gH6 PPcImALWAdMcNazaLh67sUzPPY1Tf7ZovlExR3jFAfAesLJE0CEaAUKYF0t/m73pnXZW gag5Qx4Fn8BzfssU9zD5/diKvhRv+mInCrnvck86T/9ZnPlG7/GFbws7JtNAoWxrqFpS Fn5Q== X-Gm-Message-State: AOAM5305mf4ED00CmbrI8rrP3/rQJj75bQNN3FZj0SfE6fS9aqcl3uV+ CAehfN6O8+YR0uiXdHst1jI= X-Google-Smtp-Source: ABdhPJwJ5EfN6gJUuWZfyYHiS3993axqKmOQimf6tP1CjpSIoyz16zSG/Fwey29yVYI3Ip9G+rcrEQ== X-Received: by 2002:a05:6e02:11a4:b0:2c6:40dc:d30 with SMTP id 4-20020a056e0211a400b002c640dc0d30mr6420886ilj.283.1646974099505; Thu, 10 Mar 2022 20:48:19 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id q9-20020a5edb09000000b00645c7a00cbbsm3529834iop.20.2022.03.10.20.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 20:48:19 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jim Cromie Subject: [PATCH 5/5] dyndbg: show both old and new in change-info Date: Thu, 10 Mar 2022 21:47:56 -0700 Message-Id: <20220311044756.425777-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311044756.425777-1-jim.cromie@gmail.com> References: <20220311044756.425777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" print old -> new flag values in the info("change") message. 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 b15a9c715e5b..cceac8ebbacd 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