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: 12692321 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 19670C433EF for ; Thu, 11 Nov 2021 22:08:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D894361052 for ; Thu, 11 Nov 2021 22:08:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D894361052 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0/oPcM8JAG9vvmDB0QwwdAH9YajYmJrGhUBTkeb18tI=; b=KHJpmCNLmhG9T0 4t2rdI2iApxy7AGN5L91ID1HgC+UGXNVny8p/jkjIJ/SXtC0yxFEIu3u6NtKHPj8gPyipZRWBm+0l 3e20ZDGI5M307e/uQg/LoMfKVyc3tXqd6ehzScKzfULeKebR5P7SS4CjM6ZJWTRLK0NVpCuQ+YKWc 7ONNaUTnBjJO6RG2CqR6tl3eRYbEWzTgohL/P/hSxAB24zcZoNynm6x3mi2Y5HU4gNwEuOKZiHJO2 CiLW58IJIoFQAiYcwobdi1wBMggtDc+ATC925Mn8T55+jEwtx5P9NPli7a8X3uJ5IbhBNXr4SjvnD gyWtrQoLPLiLUz3wF1SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlICN-008qyC-Gh; Thu, 11 Nov 2021 22:05:36 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlI9X-008phE-DB for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 22:02:42 +0000 Received: by mail-io1-xd29.google.com with SMTP id e144so8798337iof.3 for ; 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=58wX+OAgSWwXSYihjYEYemNuSEA9vo4rg0tqt0emf7k0U/mZdWjaHJ4OeSv3Cl54oY CFOn7sU6jMi3f+3b4hu6HqbBF3WJCaCX6hpcQyEocM2zMqx1cPI+cNfWso3FWnP8E4zW QBVw9X0SEkifHtZ2XWTKtv/9Vq+LCNJeFLybKPhCFpkMQgGeaOfWkOQbvDYVk3W1okYI UNZ4gLJjOXfRZgKneoaW1jJfAkWCzNWg41wh1XI7NdreLeJVOkJ1a1VkwD4f2TlmAFTY h/8IpkqM/TAj3KTVCFZIi9Xb9Vrt19oloWaSmnuARQgGXcWpyvw4N/LRRNHSuN0+cKYz SHTg== X-Gm-Message-State: AOAM530oI7lDeKxe1JkctjQxeta074PFc7QCQB8NJVN5N/EO7rPKvNY1 F1vgGBnL8TjR5Y8Zy+SQSu4= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_140239_509225_5864FE4E X-CRM114-Status: GOOD ( 12.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 *