Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp304227pxm; Tue, 1 Mar 2022 21:33:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxN2Y5uhgVw5p1bSQR94lGedodE/n0852lEt5+ADG786UC3mxs9ZYKSmFW6c9yVSGs+KfJn X-Received: by 2002:a17:907:7f94:b0:6da:64ec:fabc with SMTP id qk20-20020a1709077f9400b006da64ecfabcmr452708ejc.717.1646199231113; Tue, 01 Mar 2022 21:33:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646199231; cv=none; d=google.com; s=arc-20160816; b=ePqDV8MJgogyxGFjtcBajjOp+B1zox9wR1Jl07Q9kC4tGwuIFVY+gCNyFK44xvuluo pon2Q5r0yGLsaliiLXjyJqJONDUYNY/nIogJtvNF7Xp+IymB1aPkj98V4xr+sF/8loRl hJfVMe/GOHs02A7JtALh27/0ROMMHjjIYEqm+4VTc/BVKpqmxbpx+L+jytGq34DvE3uZ kY+DnbtVzVhWz4Fwjldn6JGWULFVjrDuqgxsG7FqSc29/AMIDFYNqgET3gVw8EmKegnk zP7onWAa6xUAaE7KU3qKYMXe4RVlgejO5QoFmnstLPEzZ271FJANTUx1IcUheOKbbr2j vNXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=C8CNiT2lyDN+3IatOMR7Sb+BUt/vnKvmX55KCTNOPgEZAnrN/9yrKoTzvwSk20I7XF I2hbuIa8pFSNCQZmxHzPttYYDaOSgqZiSTxmnwGPuKqZVizLFYzI9LIynvQ6NoYbeJuP eJd2YEuArN20JlffPtvILSDfhmWDumxrMrAmSxCwnTLIPgJhoNRnmASeKY30AVKStgEY FrKKLfLeOF1pfe0OoL3oAgMTLxMSmq9Nuy+tCcAYN5/oDh8Sm8dGT7Apx7fm6HNFkSih LA05DbkfcFqe1R88E+MSVKhH671u7Q1ZpgvMqRPaiqy+EhPZB0kRi2sGMU972ZrIUZfU n1ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oJhuKNsk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g24-20020aa7c858000000b0040ac83fde56si9419178edt.234.2022.03.01.21.33.28; Tue, 01 Mar 2022 21:33:51 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=oJhuKNsk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236335AbiCAQsI (ORCPT + 99 others); Tue, 1 Mar 2022 11:48:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236280AbiCAQrk (ORCPT ); Tue, 1 Mar 2022 11:47:40 -0500 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 842C647AD6 for ; Tue, 1 Mar 2022 08:46:58 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id j5so13017410ila.2 for ; Tue, 01 Mar 2022 08:46:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=oJhuKNskV8n8Y8k0p/nIWuqwzzuMNDEluIiOHKAl0o576sJ1HPmRAKwNtC0X5KmTRs icMnlJSV+BczI1iwr7ypddurkANPfvk9tsYf/4EbkWXKlYetwA8+4j8ArceUw5Io7h7K ZrLqtCzX4cF7W11tK0Q8kscz3jW9YVmyvhXJ6tM2RAWChlGzGfnAbi7AeOQUh6jAsc8i s4WnZLmkfuJbU39kjc7Q0zp4JZR9Fp4abkEVMeb1E0VqoTXqwjZ4QZG8+CyxesEOq0lc J9Meq3KHG/8uJe2DtjjhdZqXfODRh7ATy82QI4Bx2bxrqVI4Yplqmg1iKFonLatSEcFK Dt5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=14+i519RyXRhGHkk7y/NizorIrgQMa72y8v5Vs7LOmo=; b=BRyV9WYDHU5wxgaNbmpKAujden7iO0d1Kve0jwhleUqVO+lK8i0PtWp5DjjX3korac PIpGgtcihhBVok4gRgcgjW8xL+oYvnTmA41ofOo22TJMxXLi2wbQfQpxuNiaO9cOa9sL +BVsSQsj6jZl3PdSai0OGZnlQr8/N+OAqX3zdMhBlijV9wBckTR5taAL4aGS8c6ycXL4 FPZbKpWpIUNg0faixt/7pK+N+ckBHW37pqylnn4v91BiwvDNBOLdVZj0sY6kjkq2SDKt ICmZUgjZHCSJO6rzcAgeZ1EXb5JnU0/6kxvBv3YYWJUrV2C1nxgVoP8Iqq23F71/0YdM ugPg== X-Gm-Message-State: AOAM532ANJAd0k8YQblX7oO5mSpj9vtixadNcLhqHDSqnBKUUcnv01G/ dL0C9FMirvI3m52W4ynlAOc= X-Received: by 2002:a05:6e02:2142:b0:2bf:ad10:e00e with SMTP id d2-20020a056e02214200b002bfad10e00emr23607973ilv.114.1646153217457; Tue, 01 Mar 2022 08:46:57 -0800 (PST) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::f10e]) by smtp.googlemail.com with ESMTPSA id o3-20020a6b5a03000000b00640a33c5b0dsm7272411iob.17.2022.03.01.08.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:46:57 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 10/13] drm_print: refine drm_debug_enabled for dyndbg+jump-label Date: Tue, 1 Mar 2022 09:46:26 -0700 Message-Id: <20220301164629.3814634-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220301164629.3814634-1-jim.cromie@gmail.com> References: <20220301164629.3814634-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled (free of call/NOOP side effects). For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, it identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index e45ba224e57c..92e6e18026da 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -262,7 +262,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_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); @@ -285,7 +285,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 06f0ee06be1f..38ef044d786e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -319,11 +319,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 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.35.1