From patchwork Thu Nov 11 22:02:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12615747 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1100C433F5 for ; Thu, 11 Nov 2021 22:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF71C61215 for ; Thu, 11 Nov 2021 22:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbhKKWFb (ORCPT ); Thu, 11 Nov 2021 17:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234271AbhKKWF2 (ORCPT ); Thu, 11 Nov 2021 17:05:28 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A602C061203; Thu, 11 Nov 2021 14:02:39 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id v65so8790354ioe.5; Thu, 11 Nov 2021 14:02:39 -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=J66KFihbece2lAcU0d7M95Qa/rbqjUiPkgLP3JGipo0=; b=U2tKsdHYXdvLx/enESVerJKS6uIK0PeSwozEJKb5dafak6cfLExklz+OtssLCqcenP GnkPDlS0TljiYTrk5J2vFy7mNoZp1G5v1LXTnNUTkj2uooE1W1PROHNVFs0Uip8Od7jb l1MriD07x68ONxt8aVzPXUJU2qyYmH/SA7kRoIDshl3w5Ay8XNcHJ33R6Np2/C3/d3VS Rdo6XunFGKzhDRbe4kLnwUjGeqIPGT43fkONnnNdWyu38aEeMAPE+Q48IR+tByrxWDfe vrWx0HTjzEgSNX1or8e63lYdyqP12pmvRttfcAMbVk05NCmApwLMduiv8SbVvcA64KgG Kasw== 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=J66KFihbece2lAcU0d7M95Qa/rbqjUiPkgLP3JGipo0=; b=nVTdM/daEKYdvOHRopVzv+sjJe21yJHF6IJ7MdsapsIwigIVqb3Mp8lrHCt8cHvE45 mRdHXqBF1PyiVQOoo/kEqYQ8QkuoTVQ7R47mEBcuiAjQj4fqbb9YFbtz3mh876XtjdIz 2pygMSALVnPNR8WtOuy2IYvEpm0eFUvKZLb5Bqb6/g4d9JBF1ZIU+ZQPqztzQQjFPQoN rV3rvtwpgQZ88VUqgHU9xnXYYYI5CItKv/s7Z9c48ZEmmh4pBqEz2sdQMWpQhU9DwZOJ w/WqFbxLWSyTrmtbwyGH6+HuD6iVgEuemixDALOO0FK6VW5LWaByUirgpGbVBjNemdK9 JmNw== X-Gm-Message-State: AOAM531bvEr8nKXUMgpXSJptoXbuAPvjiPhZdYW+0vQHEmEpR2iH2JZR lacgUV0Qy1k+1Z0UORbfrDI= X-Google-Smtp-Source: ABdhPJzAqJ33biNIVtn4cwuQ1oFC2tm1ZBvYksYgIqVzJ3BWyVbO9tEbLor9fCd0F6q5gHex6OCMPg== X-Received: by 2002:a6b:7e44:: with SMTP id k4mr6625097ioq.103.1636668158326; Thu, 11 Nov 2021 14:02:38 -0800 (PST) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t5sm2612315ilp.8.2021.11.11.14.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 14:02:37 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, robdclark@gmail.com, sean@poorly.run, daniel.vetter@ffwll.ch, seanpaul@chromium.org, lyude@redhat.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v10 07/10] drm_print: instrument drm_debug_enabled Date: Thu, 11 Nov 2021 15:02:03 -0700 Message-Id: <20211111220206.121610-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211111220206.121610-1-jim.cromie@gmail.com> References: <20211111220206.121610-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Duplicate drm_debug_enabled() code into both "basic" and "dyndbg" ifdef branches. Then add a pr_debug("todo: ...") into the "dyndbg" branch. Then convert the "dyndbg" branch's code to a macro, so that the pr_debug() get its callsite info from the invoking function, instead of from drm_debug_enabled() itself. This gives us unique callsite info for the 8 remaining users of drm_debug_enabled(), and lets us enable them individually to see how much logging traffic they generate. The oft-visited callsites can then be reviewed for runtime cost and possible optimizations. Heres what we get: bash-5.1# modprobe drm dyndbg: 384 debug prints in module drm bash-5.1# grep todo: /proc/dynamic_debug/control drivers/gpu/drm/drm_edid.c:1843 [drm]connector_bad_edid =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:309 [drm]___drm_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:286 [drm]__drm_dev_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:1491 [drm]drm_vblank_restore =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:787 [drm]drm_crtc_vblank_helper_get_vblank_timestamp_internal =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:410 [drm]drm_crtc_accurate_vblank_count =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_atomic_uapi.c:1457 [drm]drm_mode_atomic_ioctl =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_edid_load.c:178 [drm]edid_load =_ "todo: maybe avoid via dyndbg\012" At quick glance, edid won't qualify, drm_print might, drm_vblank is strongest chance, maybe atomic-ioctl too. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 392cff7cb95c..a902bd4d8c55 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -381,6 +381,11 @@ enum drm_debug_category { #define DRM_DBG_CAT_DP DRM_UT_DP #define DRM_DBG_CAT_DRMRES DRM_UT_DRMRES +static inline bool drm_debug_enabled(enum drm_debug_category category) +{ + return unlikely(__drm_debug & category); +} + #else /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* join prefix + format in cpp so dyndbg can see it */ @@ -414,12 +419,13 @@ enum drm_debug_category { #define DRM_DBG_CAT_DP "drm:dp: " #define DRM_DBG_CAT_DRMRES "drm:res: " -#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ +#define drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + unlikely(__drm_debug & (category)); \ + }) -static inline bool drm_debug_enabled(enum drm_debug_category category) -{ - return unlikely(__drm_debug & category); -} +#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* * struct device based logging @@ -582,7 +588,6 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DRMRES, fmt, ##__VA_ARGS__) - /* * printk based logging *