Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5296080rwb; Tue, 6 Sep 2022 23:57:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SQWIfvUITGvWis75k2bWr0Svq1OHvjdyl+FK5RrZ1GNbbOqhKyedh9/+ii4U4NsMkbqZ8 X-Received: by 2002:a63:698a:0:b0:41c:8dfb:29cb with SMTP id e132-20020a63698a000000b0041c8dfb29cbmr2163843pgc.170.1662533837171; Tue, 06 Sep 2022 23:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662533834; cv=none; d=google.com; s=arc-20160816; b=nXPz4sJ5l/pAy5trz14KNu3HxUANhyjO7GhpBUe1eH5Ks7WwS3nr6Bgh/pgNcK284O RICllXyaoenLGF8fvw817/VQR+7zT26G2MdG4rp18ptGLRc2wxf+2tUTmB5cBQv2EuEV WsLt6DrJ9Dfx1n/dKZp2onXnJ+LI1ZTDpzuUZ5yvRxymZXm22vAqYfwEcpttCe++YWI1 AD9e0MaiHzboztiE4VGj94sFh4x1jS0V+B6lOQ99j1IF2G3mkKtvwCZBwY2oG6oSAxfE Yopt0pwRc9qPzwqFSWSCqEZah6anEkA1OKcVBA2ADpxOuSIXrRbczeZB3EGbriF5KceO zV6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=XaRjxOyW2MEx2tct3s/cWA1lvtbzxTStc/wVzUlH2uc=; b=DPy6Fku0eSgcz5cPjBI0Lkoz+tYhZfrDf252mKpwvmzajruFiFjQCTfqMNgczkltde o9QuwMMa5IqCjyNdGk2WiqB83F89zOBvo3Pk3CSvC7Az7ZRl0n8nx+cb6RKhdukjzakY xCqqFXhr7pEzbCiw2TBeex3OwKQNwo9TU616dNkBeOqgv9YM6ebjopDLJbcwgEUceuKY Ysbr/b8mbeXqOQR9t7DR5VetKvIgp9awp8FXGAbFnasrwwwEIekBpW3b+/klNXilIY4m hhNlLIjAF9HoojuentlY4t2QobuOOAg+2cTySYF4Ox+cqZ4A5ALQ5yfC4a1T9M7QreHd VDww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=eJz5MxKi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a170902ef4900b0017452480670si15519148plx.228.2022.09.06.23.57.02; Tue, 06 Sep 2022 23:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=eJz5MxKi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbiIGGlV (ORCPT + 99 others); Wed, 7 Sep 2022 02:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiIGGlL (ORCPT ); Wed, 7 Sep 2022 02:41:11 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455689DF84 for ; Tue, 6 Sep 2022 23:40:47 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id t5so18172444edc.11 for ; Tue, 06 Sep 2022 23:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date; bh=XaRjxOyW2MEx2tct3s/cWA1lvtbzxTStc/wVzUlH2uc=; b=eJz5MxKi7mTMm27o1zpVdo60zEiEVoggVNSQwDnTq4bJZ7gHO3YNiu08p+PQ2rcmSb 3QSyS4dX+Q5bzpsYXbcOwTNfKOO11SM/M0ZEG8S6e1vMQdkzyubH7JDOuLegIbn+/PVw wAzNRlVnOnDnNxYNB5FtBmZ18lDBwqCdT89Vc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=XaRjxOyW2MEx2tct3s/cWA1lvtbzxTStc/wVzUlH2uc=; b=pNiDYfwgcOxLwXvDap7oUKySo+9ZScrZaTVfKiLVxZ2lF65fqpWViVSrIwaacF/dwx Lmg5lA9FP7fN4IrHLwj1wEzbFflPJj7wem6nBqh1j/l7o2qIWu5MXYLTiYmxSgbtkrZz adEywRtHFmc0N3MpOkNvoFiqUrwuRsolqdsg4IhDWEYeAjWh5BnTkxajJFS3sv3pjaWt zms296iNqt3CdnREQtHqjNlUGbai0GIuHZKUp4kSNuGk8DjZYieCP04P80PEWaGNRKE6 ue6V0nTACzUDBDI/U9FDnTloq9UeuIn2V8QSYbaKw2q0iOkd+XQ1RazNX4AGF1SzkAoQ 08eA== X-Gm-Message-State: ACgBeo0N9JcjxKoK9wEHutrBxjdC2W5TI9zGZPDdksr+ccY+w2YCH+/5 mX9xyLGBq4ThbQtfMmLl2CzGWw== X-Received: by 2002:a05:6402:33c5:b0:447:e4a3:c930 with SMTP id a5-20020a05640233c500b00447e4a3c930mr1825745edc.401.1662532845316; Tue, 06 Sep 2022 23:40:45 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-33.fiber7.init7.net. [212.51.149.33]) by smtp.gmail.com with ESMTPSA id a26-20020aa7d91a000000b0044ee18e5f79sm2424487edr.28.2022.09.06.23.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 23:40:44 -0700 (PDT) Date: Wed, 7 Sep 2022 08:40:42 +0200 From: Daniel Vetter To: Jim Cromie Cc: 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, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com Subject: Re: [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Message-ID: Mail-Followup-To: Jim Cromie , 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, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com References: <20220904214134.408619-1-jim.cromie@gmail.com> <20220904214134.408619-29-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220904214134.408619-29-jim.cromie@gmail.com> X-Operating-System: Linux phenom 5.18.0-4-amd64 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 04, 2022 at 03:41:05PM -0600, Jim Cromie wrote: > 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 So instead of having 3 here as a "you need to hack it in to see what should be converted" I have a bit a different idea: Could we make the public version also a dyndbg callsite (like the printing wrappers), but instead of a dynamic call we'd have a dynamically fixed value we get out? I think that would take care of everything you have here as an open. Otherwise I'd just drop 3 for the series we're going to merge. -Daniel > --- > 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 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch