From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9071EECAAD5 for ; Sun, 4 Sep 2022 21:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbiIDVoX (ORCPT ); Sun, 4 Sep 2022 17:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbiIDVnY (ORCPT ); Sun, 4 Sep 2022 17:43:24 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B382F3B8 for ; Sun, 4 Sep 2022 14:42:38 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k2so3867811ilu.9 for ; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=wrWdD5DCeuwxIKmi8edwooIcWywqt3OjpL8zqDahPx8JbsVW9NE6o54pZNBz375bvW UOeQ9pMC3GvOkyXHSHc6XnrhcPD1AqXd+eONzfXyPH3oluJItvjBh5PoBXTHV3slO8O0 nWUQW3w/nx+pF7dhWWr7nHhpaOc3Tc5luANf8KAq3jLnMr5rO3FrR/tE0k0gT+GphOHI NiONNrfcvo0RcNqdk/UL/+RGPnqqG+N4Xy3SOAZ/7rCXTOc3WxJK3kMesv31u1KTMsUG qSaVOj0DePbh/B6f7o2V76koDWvI0CoI9lPABCtfbDShGwR2LOfDEWkTrtEd5vIZs530 Fdwg== X-Gm-Message-State: ACgBeo0f7DPyUuXftzdLJXOms4AwPerT2SWMn1DxGIW0XX7etICLcSbM t4ydKY3LtGQxh+lW0YhEVrQ= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; 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; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-circuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * -- 2.37.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E757C6FA86 for ; Sun, 4 Sep 2022 21:45:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E32F910E2C1; Sun, 4 Sep 2022 21:43:03 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59D4610E1DA; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868182ilt.7; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=ZWIiJgo6z8EnI+7dI1ZQzNMp0CNkvvlf3FRsDpxY0lYxUdxzYnNRFWnBjgAVYOKwsi y0GOwyFh8iroqpY1q8SO/11RzFor2DpX30dDhw4CSspPJ/PMJFVD2AqLIw1GOZz+3pFJ RcVUI2Y6Ae0WXGqyU2wW2WORZmkDrR0s2ZKd74wO0lYZ8L2kShlJmRey9n3hOJ/OPpZr 0fqPgqiOL0ScSap078YpUiszKTrdI0uUWnr0B7hZEVleN4MLPq+zxo042WthPfMK9dSJ XMAPDgPRFpAfy+zuRXztzb3aINKiffIEM48LpWwAB/q5Xpw2aWIx7MH+49/MnOs7Wm1t w6hg== X-Gm-Message-State: ACgBeo0Riq3x5VgqkkCwQwFkSpiwGtla2WLPMW0YvzhsiQ2i79BjLUn8 JaRW9msVbnI7gUNrpzUvoB4= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-gfx] [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; 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; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-circuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * -- 2.37.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03E00ECAAD5 for ; Sun, 4 Sep 2022 21:47:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4246010E274; Sun, 4 Sep 2022 21:43:38 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59D4610E1DA; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868182ilt.7; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=ZWIiJgo6z8EnI+7dI1ZQzNMp0CNkvvlf3FRsDpxY0lYxUdxzYnNRFWnBjgAVYOKwsi y0GOwyFh8iroqpY1q8SO/11RzFor2DpX30dDhw4CSspPJ/PMJFVD2AqLIw1GOZz+3pFJ RcVUI2Y6Ae0WXGqyU2wW2WORZmkDrR0s2ZKd74wO0lYZ8L2kShlJmRey9n3hOJ/OPpZr 0fqPgqiOL0ScSap078YpUiszKTrdI0uUWnr0B7hZEVleN4MLPq+zxo042WthPfMK9dSJ XMAPDgPRFpAfy+zuRXztzb3aINKiffIEM48LpWwAB/q5Xpw2aWIx7MH+49/MnOs7Wm1t w6hg== X-Gm-Message-State: ACgBeo0Riq3x5VgqkkCwQwFkSpiwGtla2WLPMW0YvzhsiQ2i79BjLUn8 JaRW9msVbnI7gUNrpzUvoB4= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; 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; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-circuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * -- 2.37.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB805C6FA82 for ; Sun, 4 Sep 2022 21:47:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E332F10E135; Sun, 4 Sep 2022 21:43:35 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59D4610E1DA; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868182ilt.7; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=ZWIiJgo6z8EnI+7dI1ZQzNMp0CNkvvlf3FRsDpxY0lYxUdxzYnNRFWnBjgAVYOKwsi y0GOwyFh8iroqpY1q8SO/11RzFor2DpX30dDhw4CSspPJ/PMJFVD2AqLIw1GOZz+3pFJ RcVUI2Y6Ae0WXGqyU2wW2WORZmkDrR0s2ZKd74wO0lYZ8L2kShlJmRey9n3hOJ/OPpZr 0fqPgqiOL0ScSap078YpUiszKTrdI0uUWnr0B7hZEVleN4MLPq+zxo042WthPfMK9dSJ XMAPDgPRFpAfy+zuRXztzb3aINKiffIEM48LpWwAB/q5Xpw2aWIx7MH+49/MnOs7Wm1t w6hg== X-Gm-Message-State: ACgBeo0Riq3x5VgqkkCwQwFkSpiwGtla2WLPMW0YvzhsiQ2i79BjLUn8 JaRW9msVbnI7gUNrpzUvoB4= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, robdclark@gmail.com, seanpaul@chromium.org, joe@perches.com Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; 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; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-circuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * -- 2.37.2