Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3308926pxb; Fri, 5 Nov 2021 13:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHyC6MmboNbURG2mnvlMv0enKMl3RlNhM+wG7wX1jdEGDOaeZPJZDeUm3tYgSBk6X2NM2B X-Received: by 2002:a17:907:9707:: with SMTP id jg7mr45952374ejc.533.1636143755183; Fri, 05 Nov 2021 13:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636143755; cv=none; d=google.com; s=arc-20160816; b=wxKEXMsBvkO3Zhv+WleBV2S9rerPLGuxnkVpUJY3xDRdqeJHX4u9L7GDpNDEKnueIW jS9GvEX/k9+gAqv1HGzwLTwe3g48QrJB6mySO+kq8+hCKgq4jk2pCj0j0v9DLqS06uIq Zr5ESleTbu0eiCqqaI5Rsfexb4QXvAn1EiZ5Hnofo1YjkASO/wu8QfJx4poznnLHUhjI anlfrnlckIqMfL0Ru3s/hGVw+QleM0afbBEPQeUp13tGEt8aOk7bo2EIDPaYpzulalS3 vUNEMw0qLHe+FJ2ZHrV3MKVDrAZkvGnSFUHP3EAMd8uiXl+I3n9XNnqo7ZLRc3acRaWe 1SgQ== 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=J66KFihbece2lAcU0d7M95Qa/rbqjUiPkgLP3JGipo0=; b=dgHtv7exK8WLuC4FNIqSFaz3RX+TKveZ00wVtpjZDO5w/IwJVOTuL5erFrz/n+zk7O 6kjInUNuY1+aXwDJdqRzrZMRUfCs9jI9OhfRIcPriX5jk7lIfEjl1fQ+e7voT0nfQ7RJ YG5Ic13JI5DvvMNznrKGEPMRbygRUklSvnjJE2GuR8FyVq0yw39fdRIbBrIvsR+AkmTk 0m9wMteZhDy7NMlG8BbX29d0SEfEMFaSmf3meREdzgMhlXprznZ/rVYZ0DJYd19D+05v /XZXptooTMnfKJrGU36ro68MtgEOgAwu5t7vREy4d2Mnf2j63t0lgEyhjLmaa7CBbn/H xBug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zs7izjPd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka2si11892927ejc.6.2021.11.05.13.22.11; Fri, 05 Nov 2021 13:22:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zs7izjPd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233374AbhKETaC (ORCPT + 99 others); Fri, 5 Nov 2021 15:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233393AbhKET3y (ORCPT ); Fri, 5 Nov 2021 15:29:54 -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 E2DAFC061208 for ; Fri, 5 Nov 2021 12:27:14 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id l19so10582546ilk.0 for ; Fri, 05 Nov 2021 12:27:14 -0700 (PDT) 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=Zs7izjPdlXFjhHgcGVV/4D0TKcfPMJ6/bIu99IfZYafZ6L9xSfvMl0llVYUYvQoKvN C+b5ytYureEUj/xGBFGDOLEC1nlkqp2EtUZqNh6SIqcEnIVKIEoxFDyLLPkAzsasJ1Ze mW3mY2+YIs/6+Ad3/vtfXeaJf5dHuXPg9eRkgrGJsYq8qcYLPEPir1ozQ1EcyGPLDQsk s/I+LRdEGwhoijCzPIajrPNdy+Jp1VhZxnKRjU9V/YFzrpvvY1+as+3J/Hp40iR3fY2w xZumcT1EHtV6ANVvmoU1u4cgM5WTAxrE3VRMqTnHNWluDY0sE/hnimP2UECkG3p5wmhY pj9A== 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=w4rWcQ6JQwNpltSU4p7Y/VPRcUcM/5GMkaIgTwnfrnzU5VSo4bgLZPQ9UcdWda1IMS tnOQlqvgxIRgLwQrvN+DIABfLjhp3ipQ+ZxrA5Zcm/SANyqnS+AvABtFCnZZOAZnzmJJ dXRN/kMeW9u8ARogXYlix917/ihMcZDaoPHQ6fWTDlO8OCSZJCSeFFdpsBd2neEzXsOO c3w8JsCqJLeXKYsNNLuSytvJntVfPcBXEmVLLpwLUuirjPMO4j0TOBQZL7BoGBjyv/wJ v9qJ+uK5KW2Eez+F0md8tnNPr8qcMeLdG+Lm3InkQaWGuBthyRkaTwzBvXqcw9cgMEuq AMCQ== X-Gm-Message-State: AOAM5300VlxE+iuxRIpDoRufylQLN0DmNA9Hp6c4SFRu4oPVZ7+YrdXr 04ZjmZ2yIUFcq3cJqg5CnEc= X-Received: by 2002:a05:6e02:158c:: with SMTP id m12mr42153254ilu.64.1636140434310; Fri, 05 Nov 2021 12:27:14 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id l18sm4338617iob.17.2021.11.05.12.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Nov 2021 12:27:14 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, robdclark@gmail.com, sean@poorly.run, daniel.vetter@ffwll.ch, seanpaul@chromium.org, lyude@redhat.com, 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 v10 07/10] drm_print: instrument drm_debug_enabled Date: Fri, 5 Nov 2021 13:26:34 -0600 Message-Id: <20211105192637.2370737-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211105192637.2370737-1-jim.cromie@gmail.com> References: <20211105192637.2370737-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 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 * -- 2.31.1