From nobody Mon Apr 6 01:42:42 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 6245DECAAD5 for ; Mon, 12 Sep 2022 05:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbiILF3L (ORCPT ); Mon, 12 Sep 2022 01:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiILF3H (ORCPT ); Mon, 12 Sep 2022 01:29:07 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D513724096 for ; Sun, 11 Sep 2022 22:29:06 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id c4so6145461iof.3 for ; Sun, 11 Sep 2022 22:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wMnPW8sQPrVL8KagTR37lorbRR14ltjvlMMWJEAyAGg=; b=kYdKfVRUHlEG8+qImsA7YlTFI6xkeavOLcLlAeaIDOOOft1rL8LHX2rXIYFWOUMWrW 7xhAtwhgEZAyu6Eksym85vqzKNSVzO11Djoxh0+nGLS76/MmHS/4lN75YfTElKnDj5n6 cGkWS9r2H+MOvAI1qDPQ6x37zKEH3KB+dHQKLDg65any2sWEqLh1Fl1KbMzlOZ5Osi2V fDqyOsPxLFgrxqZPDDRvALJtcqZpweGo3waYTwMty3aifd6H1runl+nhfxEK/WjTvjum 03JUOyVCZYGKgKaxDYYmiW980Ua9wdKRpiI15/eJjGEr9NevmdQ/8vHHi3OhLpz2GOws 0tCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wMnPW8sQPrVL8KagTR37lorbRR14ltjvlMMWJEAyAGg=; b=phXyPm+Smubl8QV0QBzLrSDP8Oww32L2D2Q3XfHa429LVLMX+uVEbU7JnHtFsbk4QV hdyjzfd4CcHyvbqAamfpsmrJ8PTHpwSZiyPggI1TuN+Ev3QKbEOFDgGH0uFNxiVLof2z Ne0BVvyPvXtTTgthCqw57tYWe3NNUkjSQUFBjIJ9tQI+rSZwfkHGztFcdb6Muv+sdtZc rZWrzJow6b8E4bYRrV5gAclo5ZukgYrL/kRVJ5oOpEVD8WGWJHbpUf1VnT5mZorHOUHb KHfDvSBN6k+K2Vo6jimX2os3pLIXjg1Kw/Vx8D6keTRyEms3ydW6Du7Ovm6eeAM39+p6 uoJg== X-Gm-Message-State: ACgBeo3tCSVNMkeWPt8haiaoDItmCtbmq4DRIm3/Abjt4gZX2dBZXJrh r0W0Crlv2yu6Dbapiq8IU0c= X-Google-Smtp-Source: AA6agR7a8UvflaCOS0O/szEoMKv+7GfDEj8qn5sgo2pmielI/CNoxVV+xn7kMWI0aVvEe2oJDYnezw== X-Received: by 2002:a02:6386:0:b0:349:d0b1:bb7 with SMTP id j128-20020a026386000000b00349d0b10bb7mr13293720jac.172.1662960546197; Sun, 11 Sep 2022 22:29:06 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:05 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 1/9] drm_print: condense enum drm_debug_category Date: Sun, 11 Sep 2022 23:28:44 -0600 Message-Id: <20220912052852.1123868-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" enum drm_debug_category has 10 categories, but is initialized with bitmasks which require 10 bits of underlying storage. By using natural enumeration, and moving the BIT(cat) into drm_debug_enabled(), the enum fits in 4 bits, allowing the category to be represented directly in pr_debug callsites, via the ddebug.class_id field. While this slightly pessimizes the bit-test in drm_debug_enabled(), using dyndbg with JUMP_LABEL will avoid the function entirely. NOTE: this change forecloses the possibility of doing: drm_dbg(DRM_UT_CORE|DRM_UT_KMS, "weird 2-cat experiment") but thats already strongly implied by the use of the enum itself; its not a normal enum if it can be 2 values simultaneously. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..b3b470440e46 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -279,49 +279,49 @@ enum drm_debug_category { * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... */ - DRM_UT_CORE =3D 0x01, + DRM_UT_CORE, /** * @DRM_UT_DRIVER: Used in the vendor specific part of the driver: i915, * radeon, ... macro. */ - DRM_UT_DRIVER =3D 0x02, + DRM_UT_DRIVER, /** * @DRM_UT_KMS: Used in the modesetting code. */ - DRM_UT_KMS =3D 0x04, + DRM_UT_KMS, /** * @DRM_UT_PRIME: Used in the prime code. */ - DRM_UT_PRIME =3D 0x08, + DRM_UT_PRIME, /** * @DRM_UT_ATOMIC: Used in the atomic code. */ - DRM_UT_ATOMIC =3D 0x10, + DRM_UT_ATOMIC, /** * @DRM_UT_VBL: Used for verbose debug message in the vblank code. */ - DRM_UT_VBL =3D 0x20, + DRM_UT_VBL, /** * @DRM_UT_STATE: Used for verbose atomic state debugging. */ - DRM_UT_STATE =3D 0x40, + DRM_UT_STATE, /** * @DRM_UT_LEASE: Used in the lease code. */ - DRM_UT_LEASE =3D 0x80, + DRM_UT_LEASE, /** * @DRM_UT_DP: Used in the DP code. */ - DRM_UT_DP =3D 0x100, + DRM_UT_DP, /** * @DRM_UT_DRMRES: Used in the drm managed resources code. */ - DRM_UT_DRMRES =3D 0x200, + DRM_UT_DRMRES }; =20 static inline bool drm_debug_enabled(enum drm_debug_category category) { - return unlikely(__drm_debug & category); + return unlikely(__drm_debug & BIT(category)); } =20 /* --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 50FC1ECAAA1 for ; Mon, 12 Sep 2022 05:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbiILF3O (ORCPT ); Mon, 12 Sep 2022 01:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiILF3I (ORCPT ); Mon, 12 Sep 2022 01:29:08 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D41672408F for ; Sun, 11 Sep 2022 22:29:07 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id l16so4005593ilj.2 for ; Sun, 11 Sep 2022 22:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bnCHvGKNAXNGvseJ5Qe9gG23X6P5GOGM0apmqa4fpLc=; b=g6XxCUqwa5xgZmbtvXIlvM7H8WCH+JLEDHfNuH6D4MuKTRcQu4V+nAncVQxlQOuW/p xQworH3QdEMVrUkcRzUcCbWsMwpLJLyxXh+80viA7j3cveGOj7AYjVGG+h1Zweo3hSrj qjbMXP0W5dPiOddfR9bS7ANafeoklyGdkAvKs9FcFESpMNWl3M16ecoZCbfyfl7Thfl8 87Wfl+biMW+AL5eZDDe+l9GD1rorbsJettPPxmKNrqe/53Gc/ch+Y1uAoiO+yDA8D82+ R2xXcZVaOHsrC0zs+dhQvcVWHno2znz5ouuY8TMe8UzXYZcBmPqaigYco188i6bzOw2Y tjgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bnCHvGKNAXNGvseJ5Qe9gG23X6P5GOGM0apmqa4fpLc=; b=yQMfow/w4iSKk1o9xk+TlOc7pcVKH1IQhFYAKVDg1Nki24vhvefxkeZA1vzeQHzXIM ceKcaPPIHhnuuY47Vtzfl/sdGumYO6SKZSla1AT4PElsWsA5UxsT41MMUoWQr2xd0WmZ MwhFk+SvC3Zc/n3+3rHBEsgifJtzAfmfUnAmgwVcvIKhvlyM2PL8VAMfsSPiGVtIIHJS 7lDC2q/PqlbitFlTYAq12UEF4p+Ku/Uz0stYr/Est5l2cfTI+BnOp+6Udsrawd5F/7KQ P9XA6IHR6myIFNSKMqYCo2TEe4cle/SJxMr5I9OEqwqt7dqKQdR7p1gztwVYsmAbI2uJ C9jA== X-Gm-Message-State: ACgBeo0ZTeZ3Oyp69oTfeBaCwgwiULIoZGGtKZxWNjlkhwNmlWPhGHTd cYwksdj1YBzF6lG+AAHGalw= X-Google-Smtp-Source: AA6agR7m+aIr78HestSNGiiCjuBt8mOW2W4BVSV2esuU7Tzrr3TQpjmGtQxoiYu+pDDtV6XRFDk8bQ== X-Received: by 2002:a05:6e02:1a86:b0:2f0:64bf:83a9 with SMTP id k6-20020a056e021a8600b002f064bf83a9mr10040022ilv.270.1662960547137; Sun, 11 Sep 2022 22:29:07 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:06 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 2/9] drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers. Date: Sun, 11 Sep 2022 23:28:45 -0600 Message-Id: <20220912052852.1123868-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DECLARE_DYNDBG_CLASSMAP across DRM: - in .c files, since macro defines/initializes a record - in drivers, $mod_{drv,drm,param}.c ie where param setup is done, since a classmap is param related - in drm/drm_print.c since existing __drm_debug param is defined there, and we ifdef it, and provide an elaborated alternative. - in drm_*_helper modules: dp/drm_dp - 1st item in makefile target drivers/gpu/drm/drm_crtc_helper.c - random pick iirc. Since these modules all use identical CLASSMAP declarations (ie: names and .class_id's) they will all respond together to "class DRM_UT_*" query-commands: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: This changes __drm_debug from int to ulong, so BIT() is usable on it. DRM's enum drm_debug_category values need to sync with the index of their respective class-names here. Then .class_id =3D=3D category, and dyndbg's class FOO mechanisms will enable drm_dbg(DRM_UT_KMS, ...). Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie a different NAME =3D> class_id mapping), changes are made according to each module's private class-map. No callsites are actually selected by this patch, since none are class'd yet. Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++ drivers/gpu/drm/display/drm_dp_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_crtc_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_print.c | 27 +++++++++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 12 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 13 ++++++++++++ include/drm/drm_print.h | 3 ++- 7 files changed, 92 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index 429fcdf28836..5f091cb52de2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include =20 #include "amdgpu.h" #include "amdgpu_irq.h" @@ -185,6 +187,18 @@ int amdgpu_vcnfw_log; =20 static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work= ); =20 +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + struct amdgpu_mgpu_info mgpu_info =3D { .mutex =3D __MUTEX_INITIALIZER(mgpu_info.mutex), .delayed_reset_work =3D __DELAYED_WORK_INITIALIZER( diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/disp= lay/drm_dp_helper.c index e5bab236b3ae..196dfb1e8d87 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #include #include @@ -40,6 +41,18 @@ =20 #include "drm_dp_helper_internal.h" =20 +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + struct dp_aux_backlight { struct backlight_device *base; struct drm_dp_aux *aux; diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_h= elper.c index 8a6d54515f92..a8cee6694cf6 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -32,6 +32,7 @@ #include #include #include +#include =20 #include #include @@ -51,6 +52,18 @@ =20 #include "drm_crtc_helper_internal.h" =20 +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + /** * DOC: overview * diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..ec32df35a3e3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -40,7 +40,7 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned int __drm_debug; +unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); =20 MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a deb= ug category.\n" @@ -52,7 +52,30 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each= bit enables a debug cat "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -module_param_named(debug, __drm_debug, int, 0600); + +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +module_param_named(debug, __drm_debug, ulong, 0600); +#else +/* classnames must match vals of enum drm_debug_category */ +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + +static struct ddebug_class_param drm_debug_bitmap =3D { + .bits =3D &__drm_debug, + .flags =3D "p", + .map =3D &drm_debug_classes, +}; +module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); +#endif =20 void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915= _params.c index 6fc475a5db61..d1e4d528cb17 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -29,6 +29,18 @@ #include "i915_params.h" #include "i915_drv.h" =20 +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + #define i915_param_named(name, T, perm, desc) \ module_param_named(name, i915_modparams.name, T, perm); \ MODULE_PARM_DESC(name, desc) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouvea= u/nouveau_drm.c index 561309d447e0..fd99ec0f4257 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 #include #include @@ -70,6 +71,18 @@ #include "nouveau_svm.h" #include "nouveau_dmem.h" =20 +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b3b470440e46..668273e36c2c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -35,7 +35,7 @@ #include =20 /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; =20 /** * DOC: print @@ -275,6 +275,7 @@ static inline struct drm_printer drm_err_printer(const = char *prefix) * */ enum drm_debug_category { + /* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 83C47C6FA89 for ; Mon, 12 Sep 2022 05:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbiILF3R (ORCPT ); Mon, 12 Sep 2022 01:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiILF3J (ORCPT ); Mon, 12 Sep 2022 01:29:09 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F1B24096 for ; Sun, 11 Sep 2022 22:29:08 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id b17so4016554ilh.0 for ; Sun, 11 Sep 2022 22:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=BxsNyjaSCN3M5RS6ZFNO6kAmQm4emaU2OKjak3iFgTE=; b=StO/GsB8hj9YkNNltx4lvRbnjAHnbJxchSfOXJVSs2L/Oxd8JlcfwqNENxoWBghF4I n2P058InrElqYFUqnE9tzBt8jzivZqs1vK+FW1qEma1mlNIEsVDWJY10NmDhSq/GjEg9 AuqKnPkag4XdKpkjIDqz0sOX9Ee/SZ1v7Aq/A7104ww+9jhQA/N+f5QF0fj6I+KAb52A xLDo0BarRly1Z4gPy4L2/NXPyzyN8TK/b/EASu7S0BQamzTBFYvMuJJE1gMzUIBmV9dt XhfZoiYZp7cQE6ouChfRE4o9/mF3n9q+35CRfvZwJEVW9QJslK2xKWUtVf1VCJs9ZrL+ L95w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BxsNyjaSCN3M5RS6ZFNO6kAmQm4emaU2OKjak3iFgTE=; b=VEWPYP+QyGQ4JtFk6+uJtFFweKpzjeIDbJ59tuM13/PghtbGzcAobM3XiRV7hmW9hp FAGXbaY/rpwCNOaVqGjRkVt1bztuflBcijkFlU6YE0tSVg34htsKf/djxth9sWYZhFxy KNf8VTAn+m62MUA44YMDmqXFJygwXeuchGTax+IePJ6cGULp7UsXp1R2OravNbiZvTFg l0FV4L+2oIAVh7Ti2xToWnz2dsn9Rc3RS9HhG7qFQxOSSeF5F7L7dV9F6cDz4Se/SWqw giUWNL35BFfL8aNBrso/IQWybtDjQbnzyMpMfslBn9GHb6BHFYsF7x69gOryrdPhBszT ah5A== X-Gm-Message-State: ACgBeo0TLfox1XjbPfuwuIzZvokO3cz+IRoxHG/ZpinZCZuY2R87JtXT BUcEaqH6suPj/8HP5TJeHq0= X-Google-Smtp-Source: AA6agR5PpeOBEgwIfMHJVxjeUmdiR5b1EQ0cGcYYHCLwaJWcVgjcrpm0vTlSxZcBxEaguf1eteqxig== X-Received: by 2002:a05:6e02:1a04:b0:2f2:d2f7:a6db with SMTP id s4-20020a056e021a0400b002f2d2f7a6dbmr9591568ild.74.1662960548169; Sun, 11 Sep 2022 22:29:08 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:07 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 3/9] drm_print: interpose drm_*dbg with forwarding macros Date: Sun, 11 Sep 2022 23:28:46 -0600 Message-Id: <20220912052852.1123868-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" change drm_dev_dbg & drm_dbg to macros, which forward to the renamed functions (with __ prefix added). Those functions sit below the categorized layer of macros implementing the DRM debug.category API, and implement most of it. These are good places to insert dynamic-debug jump-label mechanics, which will allow DRM to avoid the runtime cost of drm_debug_enabled(). no functional changes. memory cost baseline: (unchanged) bash-5.1# drms_load [ 9.220389] dyndbg: 1 debug prints in module drm [ 9.224426] ACPI: bus type drm_connector registered [ 9.302192] dyndbg: 2 debug prints in module ttm [ 9.305033] dyndbg: 8 debug prints in module video [ 9.627563] dyndbg: 127 debug prints in module i915 [ 9.721505] AMD-Vi: AMD IOMMUv2 functionality not available on this syst= em - This is not a bug. [ 10.091345] dyndbg: 2196 debug prints in module amdgpu [ 10.106589] [drm] amdgpu kernel modesetting enabled. [ 10.107270] amdgpu: CRAT table not found [ 10.107926] amdgpu: Virtual CRAT table created for CPU [ 10.108398] amdgpu: Topology: Add CPU node [ 10.168507] dyndbg: 3 debug prints in module wmi [ 10.329587] dyndbg: 3 debug prints in module nouveau Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 10 +++++----- include/drm/drm_print.h | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec32df35a3e3..29a29949ad0b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -279,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const cha= r *level, } EXPORT_SYMBOL(drm_dev_printk); =20 -void drm_dev_dbg(const struct device *dev, enum drm_debug_category categor= y, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, + const char *format, ...) { struct va_format vaf; va_list args; @@ -301,9 +301,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_deb= ug_category category, =20 va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); =20 -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -320,7 +320,7 @@ void __drm_dbg(enum drm_debug_category category, const = char *format, ...) =20 va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); =20 void __drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 668273e36c2c..c429c258c957 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -335,7 +335,7 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category categor= y, +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, const char *format, ...); =20 /** @@ -384,6 +384,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_deb= ug_category category, } \ }) =20 +#define drm_dev_dbg(dev, cat, fmt, ...) \ + __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -485,10 +488,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, */ =20 __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 +#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) + /* Macros to make printk easier */ =20 #define _DRM_PRINTK(once, level, fmt, ...) \ --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 AB6E0ECAAA1 for ; Mon, 12 Sep 2022 05:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiILF3U (ORCPT ); Mon, 12 Sep 2022 01:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiILF3L (ORCPT ); Mon, 12 Sep 2022 01:29:11 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA883240B1 for ; Sun, 11 Sep 2022 22:29:09 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id s11so3993279ilt.7 for ; Sun, 11 Sep 2022 22:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hvW6/T6Cu72NQNfFfc0LhYHeClJNDYHLK7XVJp6RWjY=; b=eppAjAsuUmGBxIeOj6rGT5Zzj4kd14EFQg7EeefJa06tgwqgcjL7pCtXjIqpTgMxTu IWg9xEhhX2cRxVmomkNo5CVf8pUgpx8USZA+YnIwiOD3whjJ11U6bebniALvADonx8Wb jKfs6HSmgUBSuF8noAcfkvEAqXRd+zKU/jMwZahue/n+QMxo6WK5q3ddpkwVDT1hLzJo XOrNKwsJQXSMFEDsDF1lC37OceslIDiHLe4MBDdzp0L/VCEQyqLyKOKSkDDmETPXA6Ql F2+VVER5RKWQ6VwhtRdejFqwE2dBTM6gpZ9/y9lGJ70Yu/CoL7S/H07XF9of86iaf9He sh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hvW6/T6Cu72NQNfFfc0LhYHeClJNDYHLK7XVJp6RWjY=; b=IxOMt4pROrh+/cnif631asaq5L+AeiZdxQWCzwg7VPtBpAoQq6ibNWE066lzcj2rcI On/hVr4HWgJGGFOC6s+Q8XY784dD0Atvl9/Pm0ZSaOS17/mWEmQ5zK3xssE1p8RuBDPJ NdiO5901qEy6sK2Euyhia1dmyO3r61CceWk4Xr2M7WhHWWuGaUxtCpYdkSPSWDyNcbIZ fbQSY8LUq7KWrkCaT9SnRGrJ2Ij+oJpBRGI5Uxc4xCDeKmWle462Ab/SFWKZPmk/PWpN bJZOc3Q89Ip9ukHlK3L0/4oewju0kHZ/Hw4sDR4WYNjNvAPqSrDYq7cS7ZICIVdGoH4I gW5Q== X-Gm-Message-State: ACgBeo1cOHfoVbjlHZTLJ2Jq2Pzx29MUquNNqGEPHiqAojwlwNeLwKSf rKa4UM8YdpjTI/FR4IusgCI= X-Google-Smtp-Source: AA6agR4VJPaBwHPf7er126QoRWoFsAbD2ztO278tK6mflIQcNK3updSOLOr20syBs+uCTsSAZ5nxdQ== X-Received: by 2002:a05:6e02:1524:b0:2ec:71c6:7b85 with SMTP id i4-20020a056e02152400b002ec71c67b85mr9839711ilu.237.1662960549182; Sun, 11 Sep 2022 22:29:09 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:08 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 4/9] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Date: Sun, 11 Sep 2022 23:28:47 -0600 Message-Id: <20220912052852.1123868-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, wrap __drm_dbg() & __drm_dev_dbg() in one of dyndbg's Factory macros: _dynamic_func_call_no_desc(). This adds the callsite descriptor into the code, and an entry for each into /proc/dynamic_debug/control. #> echo class DRM_UT_ATOMIC +p > /proc/dynamic_debug/control CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy/n is configurable because of the .data footprint cost of per-callsite control; 56 bytes/site * ~2k for i915, ~4k callsites for amdgpu. This is large enough that a kernel builder might not want it. Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 12 ++++++++++++ drivers/gpu/drm/Makefile | 2 ++ include/drm/drm_print.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 6c2256e8474b..2438e0dccfa1 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -50,6 +50,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 e7af358e6dda..6828197967a6 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -3,6 +3,8 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. =20 +CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) +=3D -DDYNAMIC_DEBUG_MODULE + drm-y :=3D drm_aperture.o drm_auth.o drm_cache.o \ drm_file.o drm_gem.o drm_ioctl.o \ drm_drv.o \ diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index c429c258c957..2d2cef76b5c1 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -384,8 +384,14 @@ void __drm_dev_dbg(const struct device *dev, enum drm_= debug_category category, } \ }) =20 +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, cat, fmt, ...) \ __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) +#else +#define drm_dev_dbg(dev, cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) +#endif =20 /** * DRM_DEV_DEBUG() - Debug output for generic drm code @@ -492,7 +498,13 @@ void ___drm_dbg(enum drm_debug_category category, cons= t char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#else +#define __drm_dbg(cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) +#endif =20 /* Macros to make printk easier */ =20 --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 25122ECAAA1 for ; Mon, 12 Sep 2022 05:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbiILF3b (ORCPT ); Mon, 12 Sep 2022 01:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiILF3M (ORCPT ); Mon, 12 Sep 2022 01:29:12 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCF9248C4 for ; Sun, 11 Sep 2022 22:29:10 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id b17so4016577ilh.0 for ; Sun, 11 Sep 2022 22:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RsTMiP9rOdYWd/CJgD5lf62E3pBpPHn3iKvnTstCS5k=; b=W9eQyswY9d9anzLo9n6+2UK5jd3zMCdtrygDAwAMSM7s0OU1949CgrWCW8nXchSyiL Rog3WeOHPKLi6deSZZsGF6nKh2qwU427KlJN3lgjMNhMhEA207r8rQIWQMlJAmvRiuQq zMWFezmy7K7fs/TLe6IvtHaUnMRiNKtiTq84uBmku0pVplN+YeWuv5BK6Zv8wx3Ii8Aw oyz/EnibqRPHntszYzw90+D5NTdmo/PcbaVPw6zgiZT5VnjiJa7WL43/vlBm5Kglnbsj k2uDPVf6h0P/D1ZZv02s6Gu/jJWVdpMqlAXICXVv59sh0KVnzWtAFdhLIcXQ1FGPUOV2 JWzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RsTMiP9rOdYWd/CJgD5lf62E3pBpPHn3iKvnTstCS5k=; b=4o0mY7IwlVU28PiaViQjDriwbMxuRGzExcxALex7G/mIhntZ9aGtgb3pnsUSW4CIe2 p8D6cXdvSa5EqXnJLTdW9Q+wkeNqyEshvZB30/SfBEuYqrgl1iJuF8yqhOt3b+glf1Kn g8thmCchCaMVYCx8R8Lr1zhBZgvtsiIS6tko/IUO8VDyOienbKnXxk0zHRE/d3FE4MV+ mEmDmsl7kLyv+IUfmaPSGEIzmkKNnAMGsMR6DG4dE1o/TxWEjZv0Sx9/ybHytRC8HNTK LEBfzNjp1evBmqDUelByW5ToN7rK7F3S2PFsbIGKTX0rTQf8VUJjj2fBU14hxmss+yzU prjw== X-Gm-Message-State: ACgBeo2RoKW1DtLko3VricRYlGEaWYCYlvQk40Iv/NdXE5EUdz/VfFRz T1EKsrij2ADWgxkXV0ZU3eg= X-Google-Smtp-Source: AA6agR5KpMxoafFECoggp6f+wIRK77w1QiltMXIK40Ocyg037/uILmvU26N7K21NwVRWoJyGf7uoPQ== X-Received: by 2002:a92:6912:0:b0:2ea:fa2e:462d with SMTP id e18-20020a926912000000b002eafa2e462dmr9379940ilc.155.1662960550217; Sun, 11 Sep 2022 22:29:10 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:09 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 5/9] drm-print.h: include dyndbg header Date: Sun, 11 Sep 2022 23:28:48 -0600 Message-Id: <20220912052852.1123868-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" lkp robot told me: >> drivers/gpu/drm/drm_ioc32.c:989:2: error: call to undeclared function '_dynamic_func_call_cls'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] DRM_DEBUG("comm=3D\"%s\", pid=3D%d, dev=3D0x%lx, auth=3D%d, %s\n= ", Since that macro is defined in drm_print.h, and under DRM_USE_DYN*=3Dy configs, invokes dyndbg-factory macros, include dynamic_debug.h from there too, so that those configs have the definitions of all the macros in the callchain. This is done as a separate patch mostly to see how lkp sorts it. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 2d2cef76b5c1..f8bb3e7158c6 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include =20 #include =20 --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 9B0A2ECAAA1 for ; Mon, 12 Sep 2022 05:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbiILF3g (ORCPT ); Mon, 12 Sep 2022 01:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiILF3Q (ORCPT ); Mon, 12 Sep 2022 01:29:16 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 069E6248CF for ; Sun, 11 Sep 2022 22:29:11 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id 138so5127073iou.9 for ; Sun, 11 Sep 2022 22:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=i5t2bbZH1qhLqkOMOWZd9/3/gcmt6p6QRrw1EPy3Aj4=; b=qOh/R9lECFRWqs7dMZp6LrjZUUMurRbhAZWpZcjLAW+XOtO1yvv7fBHHkJlyTkEucK bNKga9KrZesxfbiOu7HM8ANgJZHDoqwdfsPZFrTfCG9+8ck3qVQfNh50M6VT9fPXdTT3 yCIwfUy2bmo3w9zPxVHJ5CyInYMBcFLrr5XF9nQLAuyFYD2kfNrIikXSEvV1Y6pVVYkw Diz05DSsd348fuMY0DVxkeWIalSgUwLsHBeFt4iaaeXKtlv1GwIJSDEFcGI5kG/Zi8Ah gY2azQthIsvm3qIMoheAO62ri04by6YxAvUELnbEbTUTrYpOPK37gYr3K6qm534XdYWw zPOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=i5t2bbZH1qhLqkOMOWZd9/3/gcmt6p6QRrw1EPy3Aj4=; b=BSFDUFANhUVTNSNp2W3ajHi5aHW5Nswtdoys+gteBYjewgIny/aU1FKkpjjL291aSF GktNGafnn075cBFD3tdXoDyPHoWhgvoMLsGS7H7anIjLpBGWRr3rfMst2LwMR7J9Iuhv x/PKsa8QvCTxfdVm7X/8HhTFssQF4azXH6GOpp/Hhf9HCl47lyV90VVmw0ZKx6w/1WIG fHEnSYXbDzE1LeJstK0gm+k90qkMRhmk5S665Xq0A4Cv8eaZp2960X9cKgOHqDZ2Es3b dZH8VRPfqRaBQ+wQyodmxHIYefMsexWa1bLOQ5HQU4XgBauEfiisBwL7UXAMQd1Ko6zN WSZg== X-Gm-Message-State: ACgBeo3+0TNsGMXYjBY7tcOntLq1RtjRMuHz6n1tX1R7lGjZjA6V9IIX sdQ0K3OIxdkvMppVbGIfUqg= X-Google-Smtp-Source: AA6agR6nheDh2F55KS2HuAKuH7mmoLFpxaM+Y9nxKrP34wlXBlmFd+JSKxJMWlB4fe03p4UZt179JQ== X-Received: by 2002:a05:6638:2729:b0:35a:4666:5dad with SMTP id m41-20020a056638272900b0035a46665dadmr379273jav.250.1662960551093; Sun, 11 Sep 2022 22:29:11 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:10 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 6/9] drm-print: add drm_dbg_driver to improve namespace symmetry Date: Sun, 11 Sep 2022 23:28:49 -0600 Message-Id: <20220912052852.1123868-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" drm_print defines all of these: drm_dbg_{core,kms,prime,atomic,vbl,lease,_dp,_drmres} but not drm_dbg_driver itself, since it was the original drm_dbg. To improve namespace symmetry, change the drm_dbg defn to drm_dbg_driver, and redef grandfathered name to symmetric one. This will help with nouveau, which uses its own stack of macros to construct calls to dev_info, dev_dbg, etc, for which adaptation means drm_dbg_##driver constructs. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index f8bb3e7158c6..dfdd81c3287c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -468,7 +468,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, =20 #define drm_dbg_core(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) -#define drm_dbg(drm, fmt, ...) \ +#define drm_dbg_driver(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) @@ -487,6 +487,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) =20 +#define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__) =20 /* * printk based logging --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 C8D92ECAAA1 for ; Mon, 12 Sep 2022 05:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbiILF3k (ORCPT ); Mon, 12 Sep 2022 01:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbiILF3Q (ORCPT ); Mon, 12 Sep 2022 01:29:16 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1AA248DF for ; Sun, 11 Sep 2022 22:29:12 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id k13so2304157ilc.11 for ; Sun, 11 Sep 2022 22:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XL7ChPS99XFJL4oCOKSZfP/JHI1hyG5bYnzMTIDbg5Q=; b=ZPz/N1MZg7ftF0tlcoRwr9HNj0wMrzzU21myESb5DbbDCQo4xNwx0qr2GossY/Q+uO ZdpsYR6a9TLoWWI0eDoBTYm4MnozH77pypOSGaDyQIl4oefREBwcO/EJS16nj18QJtwq 0TwpXRFSqPJodz6YVHbri98npEro/MGK6/DNd2yaWRYDZS/AV7i5FvuiVN1NH6w9hDQX f3U/bWFDOcVK9ezCKsiVEVx1FsO0cVIIZUyHq0XODhXrol856oqiGW4oq7Evgh4EM5oO lRuFkAM/jpe7Ztz6wB17kJCX/13m/ha0hPZ/RzLt0H9haHMTvpcVsVvKOa+E/Rlucqbh muxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XL7ChPS99XFJL4oCOKSZfP/JHI1hyG5bYnzMTIDbg5Q=; b=c5py7ZTLAdr+7vYR6I+jbaju4VOXPBLVma975uOhzQEVuOCEF5MdOE+eBY7Z4rVRp1 2FjD5nn0nNoWPS3YXWHBTyetoUuKXRcnxdVtNDRzHn9s9obWtsSd7X9vsZ3CPLKxTV+b inUVIhT6cF0j8kWw4CcTH7ZYH9ZXv8mu9+8OSXVmzuS5sR6WdoHRtcxt30mlyHwkyMoM 8BuoQbUAbd+F9VqIPFKdznGhmPn38dGzvRUHhQliNv1hWRrt/amVIMdTWrxqO5SKvxP8 1atUDCwBEToVmi8nSSX3ULco4jmRcWTJtgADBGBn1LjEML9SXy1kkAh+FWnBqqtkJvxe FoZA== X-Gm-Message-State: ACgBeo3GTuHYkj6KBPOFmLe2Xe9ZdK16Z1OaEpQPhmdNCibQxmXJBP+e MA/+DQ+Sdj9uL4kYl8daWYU= X-Google-Smtp-Source: AA6agR47BQemS+MqJvt/2ptLpkQUnDhJDO4pC9EpCD+Bj0LzBAng5f40HRcbFyGQO4ZMBWidtzdolA== X-Received: by 2002:a05:6e02:2195:b0:2eb:8a31:43d8 with SMTP id j21-20020a056e02219500b002eb8a3143d8mr9194040ila.315.1662960552177; Sun, 11 Sep 2022 22:29:12 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:11 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 7/9] drm_print: optimize drm_debug_enabled for jump-label Date: Sun, 11 Sep 2022 23:28:50 -0600 Message-Id: <20220912052852.1123868-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-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" When CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, the drm.debug API (a macro stack, calling _+drm_*dbg() eventually) invokes a dyndbg Factory macro to create a descriptor for each callsite, thus making them individually >control-able. In this case, the calls to _drm_*dbg are unreachable unless the callsite is enabled. So those calls can short-circuit their early do-nothing returns. Provide and use __drm_debug_enabled(), to do this when config'd, or the _raw flags-check otherwize. And since dyndbg is in use, lets also instrument the remaining users of drm_debug_enabled, by wrapping the _raw in a macro with a: pr_debug("todo: is this frequent enough to optimize ?\n"); For CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dn, do no site instrumenting at all, since JUMP_LABEL might be off, and we don't want to make work. With drm, amdgpu, i915, nouveau loaded, heres remaining uses of drm_debug_enabled(), which costs ~1.5kb data to control the pr_debug("todo:..")s. Some of those uses might be ok to use __drm_debug_enabled() by inspection, others might warrant conversion to use dyndbg Factory macros, and that would want callrate data to estimate the savings possible. TBH, any remaining savings are probably small; drm.debug covers the vast bulk of the uses. Maybe "vblank" is the exception. :#> grep todo /proc/dynamic_debug/control | wc 21 168 2357 :#> grep todo /proc/dynamic_debug/control drivers/gpu/drm/drm_edid_load.c:178 [drm]edid_load =3D_ "todo: maybe avoid = via dyndbg\n" drivers/gpu/drm/drm_vblank.c:410 [drm]drm_crtc_accurate_vblank_count =3D_ "= todo: maybe avoid via dyndbg\n" drivers/gpu/drm/drm_vblank.c:787 [drm]drm_crtc_vblank_helper_get_vblank_tim= estamp_internal =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/drm_vblank.c:1491 [drm]drm_vblank_restore =3D_ "todo: maybe= avoid via dyndbg\n" drivers/gpu/drm/drm_vblank.c:1433 [drm]drm_vblank_enable =3D_ "todo: maybe = avoid via dyndbg\n" drivers/gpu/drm/drm_plane.c:2168 [drm]drm_mode_setplane =3D_ "todo: maybe a= void via dyndbg\n" drivers/gpu/drm/display/drm_dp_mst_topology.c:1359 [drm_display_helper]drm_= dp_mst_wait_tx_reply =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/display/drm_dp_mst_topology.c:2864 [drm_display_helper]proc= ess_single_tx_qlock =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/display/drm_dp_mst_topology.c:2909 [drm_display_helper]drm_= dp_queue_down_tx =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/display/drm_dp_mst_topology.c:1686 [drm_display_helper]drm_= dp_mst_update_slots =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_dp.c:1111 [i915]intel_dp_print_rates =3D= _ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_backlight.c:5434 [i915]cnp_enable_backli= ght =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_backlight.c:5459 [i915]intel_backlight_d= evice_register =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_opregion.c:43 [i915]intel_opregion_notif= y_encoder =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_opregion.c:53 [i915]asle_set_backlight = =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_bios.c:1088 [i915]intel_bios_is_dsi_pres= ent =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/display/intel_display_debugfs.c:6153 [i915]i915_drrs_c= tl_set =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/i915/intel_pcode.c:26 [i915]snb_pcode_read =3D_ "todo: mayb= e avoid via dyndbg\n" drivers/gpu/drm/i915/i915_getparam.c:785 [i915]i915_getparam_ioctl =3D_ "to= do: maybe avoid via dyndbg\n" drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c:282 [amdgpu]vcn_v2_5_process_interrup= t =3D_ "todo: maybe avoid via dyndbg\n" drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:433 [amdgpu]vcn_v2_0_process_interrup= t =3D_ "todo: maybe avoid via dyndbg\n" :#> Signed-off-by: Jim Cromie --- - simplify drm-debug-enabled choices, @DanVet --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, struct va_format vaf; va_list args; =20 - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; =20 va_start(args, format); @@ -308,7 +308,7 @@ void ___drm_dbg(enum drm_debug_category category, const= char *format, ...) struct va_format vaf; va_list args; =20 - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; =20 va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..9af57d3df259 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,30 @@ enum drm_debug_category { DRM_UT_DRMRES }; =20 -static inline bool drm_debug_enabled(enum drm_debug_category category) +static inline bool drm_debug_enabled_raw(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } =20 +#define drm_debug_enabled_instrumented(category) \ + ({ \ + pr_debug("todo: is this frequent enough to optimize ?\n"); \ + drm_debug_enabled_raw(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * the drm.debug API uses dyndbg, so each drm_*dbg macro/callsite gets + * a descriptor, and only enabled callsites are reachable. They use + * the private macro to avoid re-testing the enable-bit. + */ +#define __drm_debug_enabled(category) true +#define drm_debug_enabled(category) drm_debug_enabled_instrumented(categor= y) +#else +#define __drm_debug_enabled(category) drm_debug_enabled_raw(category) +#define drm_debug_enabled(category) drm_debug_enabled_raw(category) +#endif + /* * struct device based logging * --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 F1FC2ECAAD5 for ; Mon, 12 Sep 2022 05:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229512AbiILF3p (ORCPT ); Mon, 12 Sep 2022 01:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiILF3a (ORCPT ); Mon, 12 Sep 2022 01:29:30 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E831C248E6 for ; Sun, 11 Sep 2022 22:29:13 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id k9so3983801ils.12 for ; Sun, 11 Sep 2022 22:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ITRLSs656UGwBL27WS4PAEu4z+TFhuXj9Pi0xXaA2Xg=; b=d7h6IZ2LL+KeqOCYEFWUbsFBPvMYig1ya0J6yk6hWgz6wtXs7P6zqZ6Xot9UX9tCrr GyEkWPYn/VaYlXHqjEeTgHVCkEQt72UzCC/ckoMkbFpajeedGN4cg8ApmR/cMRCBSBV5 6AKLco4R4+Wg7M6AcVKIB7xnZblixRODxoBH0/LBbAhgH8rSmMvyM7Nudac0CBv2oyjR xR4U3Tq1LfiT3tkoN2mlsb/zyHjl+L/QP+A8+Xc+fnkJiz2vDoxLYp0N6xJSup/9RgCU I+Cx7YVC3+o0Ka+vYgjJunU3sQ1PaJjoGD6lVXJkqkGp/iAS5C/9y+D9q/IdQ/LLZ+Da NBpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ITRLSs656UGwBL27WS4PAEu4z+TFhuXj9Pi0xXaA2Xg=; b=VqsMiARKPn2BxYssT/U1ho4gCnTKYLLYVcStZqLgj518YLhgmf1zSF3D4gLdBtiG8S agFdLM8kezNPi/bJ3tEg9lRQVNCqbf7uOc4OCWc1054NGoyS0uK33iZvsJf7oIHi8Cds vwR2bM9pYZDyiF6gNG3WtJnsq/0se+j/zuejrVjGj4pe4CrkfnowKtVi3cdreHsp7DJm Ip4AkiI6Q8c7BUE7nqimrHmr34ZMPtzI4+RzNw8M547Cwq62RAH7HSFQBs83WClyT0z6 Z2IOp3yHyLie4dSpJRfjS+T5uUPOlhWFKq6EHarFQYWhilzZXniWwctI8PCXkaDT6DWI rh0g== X-Gm-Message-State: ACgBeo0DKvVvUp+7ybCgWlgjvh+fKWvdg7PNuYHbXZMCGxkhRwRV1qbk bJ0Vahd2CAC+eRimtOZrpi0= X-Google-Smtp-Source: AA6agR5rCdnktWACXOjdGxRE7qHq3+fz7tOLmcMPlmy2aCmo61R329L72SfNxKqfY0Lm57XE7rOiSA== X-Received: by 2002:a05:6e02:1caf:b0:2f2:1639:63a0 with SMTP id x15-20020a056e021caf00b002f2163963a0mr9415574ill.5.1662960553105; Sun, 11 Sep 2022 22:29:13 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:12 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 8/9] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Sun, 11 Sep 2022 23:28:51 -0600 Message-Id: <20220912052852.1123868-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" drm_print.c calls pr_debug() just once, from __drm_printfn_debug(), which is a generic/service fn. The callsite is compile-time enabled by DEBUG in both DYNAMIC_DEBUG=3Dy/n builds. For dyndbg builds, reverting this callsite back to bare printk is correcting a few anti-features: 1- callsite is generic, serves multiple drm users. it is soft-wired on currently by #define DEBUG could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading here, they describe only the generic site, not end users IOW, 1,2 are unhelpful at best, and possibly confusing. reverting yields a nominal data and text shrink: text data bss dec hex filename 462583 36604 54592 553779 87333 /kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 -dirty/kernel/drivers/gpu/drm/drm.ko Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cb203d63b286..ec477c44a784 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -23,8 +23,6 @@ * Rob Clark */ =20 -#define DEBUG /* for pr_debug() */ - #include =20 #include @@ -185,7 +183,8 @@ EXPORT_SYMBOL(__drm_printfn_info); =20 void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) { - pr_debug("%s %pV", p->prefix, vaf); + /* pr_debug callsite decorations are unhelpful here */ + printk(KERN_DEBUG "%s %pV", p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_debug); =20 --=20 2.37.3 From nobody Mon Apr 6 01:42:42 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 43DFAECAAA1 for ; Mon, 12 Sep 2022 05:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiILFaB (ORCPT ); Mon, 12 Sep 2022 01:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiILF3a (ORCPT ); Mon, 12 Sep 2022 01:29:30 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8110228E35 for ; Sun, 11 Sep 2022 22:29:15 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id y15so3995966ilq.4 for ; Sun, 11 Sep 2022 22:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=mSClBv+YMHjCelLo1EhsewE6hP3wTbgC0DRNv0VPhHs=; b=StDGxERICaNtO/MWOKOgGPpN0K/uy13ONokxOkqYAaZjX4KHAFnRfhTBCc8bQhit2y gZ3Ur1wskb70k9V1X9Ri0sdLVe5gMaVvXggpW/8GLtLDasXI3SwKAh9hsDCAiGf9etTX VKoftvlSsWhFNzRgf6bemRyfW4xndlHtY2NeTaav7UHg/DS296GlPC+y9dgRFppIDy2N S4ica+O5t6X0MzR0pVGPNyA6AHxlFkKlLWnTV0d+xhCXTrQPCy2KtUCPBkLDFGGvxXBi 4hYd5j6zidurXvxchTCxDDr/jsVm2aDJvfe8y6mB3bozzLYGhNkpdaRhdFxmcwDcfocy cjxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=mSClBv+YMHjCelLo1EhsewE6hP3wTbgC0DRNv0VPhHs=; b=bvZVe1CRXjJL+JzW2G1GEVDJ51xJmJSQOT1Ww7Lr1FIu5sIKtel5MalhSwVIGLbJCk SlUDo0ZSjae8lHODZvxXVod1kLWqdmlZvY2VFncSy55z/0LvEo7TEjpVtyQ+vRNi+G4R rKXPcYp4NZmcJ52YEwTMGoMh2qaNLvYBgSq7yQa2A+qxOSX2CRhF2tubO3z7N1NtSc82 5MNUD1Bp9fQM2jWANlY6CVUtrl47NfKL5aaa8DV5C22euk3rxOiED5zMcPWhNvHEcQOL KaTuhveOZDovKvTBXc/xTs+jZxNzvCT7fyDz5CbEATbWaUJmopBQjsKxC4pOV0cc3EKW KwUQ== X-Gm-Message-State: ACgBeo2D1yEH8OKyuXb5Uhn349KYP0CcFkX9zJKiOtQZS3USXHGsERJZ 2IsHkyFk0COuKLHKioBnqCg= X-Google-Smtp-Source: AA6agR6WOElTbvZcWBDLNgRT1L6h9WJGhihQJW5zGPjIJBCSEhK0r/DX6Fq17h9F3h/cF/FQ/QryDw== X-Received: by 2002:a05:6e02:214f:b0:2f1:87fb:783b with SMTP id d15-20020a056e02214f00b002f187fb783bmr9708111ilv.161.1662960554820; Sun, 11 Sep 2022 22:29:14 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id q16-20020a056e02079000b002eb75fb01dbsm3006057ils.28.2022.09.11.22.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:29:14 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v7 9/9] drm_print: add _ddebug descriptor to drm_*dbg prototypes Date: Sun, 11 Sep 2022 23:28:52 -0600 Message-Id: <20220912052852.1123868-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912052852.1123868-1-jim.cromie@gmail.com> References: <20220912052852.1123868-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" upgrade the callchain to drm_dbg() and drm_dev_dbg(); add a struct _ddebug ptr parameter to them, and supply that additional param by replacing the '_no_desc' flavor of dyndbg Factory macro currently used with the flavor that supplies the descriptor. NOTES: The descriptor gives these fns access to the decorator flags, but they do none of the dynamic-prefixing done by dynamic_emit_prefix(), which is currently static. DRM already has conventions for logging/messaging; just tossing optional decorations on top probably wouldn't help. Instead, existing flags (or new ones, perhaps 'sd' ala lspci) can be used to make current message conventions optional. This suggests a new drmdbg_prefix_emit() to handle prefixing locally. For CONFIG_DRM_USE_DYNAMIC_DEBUG=3DN, just pass null descriptor. desc->class_id is redundant with category parameter, but its availability is dependent on desc. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 8 +++++--- include/drm/drm_print.h | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec477c44a784..5b93c11895bb 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include #include @@ -278,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const cha= r *level, } EXPORT_SYMBOL(drm_dev_printk); =20 -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, - const char *format, ...) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -287,6 +288,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, if (!__drm_debug_enabled(category)) return; =20 + /* we know we are printing for either syslog, tracefs, or both */ va_start(args, format); vaf.fmt =3D format; vaf.va =3D &args; @@ -302,7 +304,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_d= ebug_category category, } EXPORT_SYMBOL(__drm_dev_dbg); =20 -void ___drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, co= nst char *format, ...) { struct va_format vaf; va_list args; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 9af57d3df259..a44fb7ef257f 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -354,9 +354,10 @@ static inline bool drm_debug_enabled_raw(enum drm_debu= g_category category) __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); -__printf(3, 4) -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category categ= ory, - const char *format, ...); +struct _ddebug; +__printf(4, 5) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...); =20 /** * DRM_DEV_ERROR() - Error output. @@ -406,11 +407,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 /** @@ -514,17 +515,17 @@ void __drm_dev_dbg(const struct device *dev, enum drm= _debug_category category, * Prefer drm_device based logging over device or prink based logging. */ =20 -__printf(2, 3) -void ___drm_dbg(enum drm_debug_category category, const char *format, ...); +__printf(3, 4) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, co= nst char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); =20 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) #else #define __drm_dbg(cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ - cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) #endif =20 /* Macros to make printk easier */ --=20 2.37.3