From patchwork Fri Jan 7 05:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706244 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C39F6C4321E for ; Fri, 7 Jan 2022 05:30:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E91B113214; Fri, 7 Jan 2022 05:29:53 +0000 (UTC) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by gabe.freedesktop.org (Postfix) with ESMTPS id AEC8111318F; Fri, 7 Jan 2022 05:29:51 +0000 (UTC) Received: by mail-il1-x131.google.com with SMTP id j15so2716922ilq.4; Thu, 06 Jan 2022 21:29:51 -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=lpR+Wzjsd8/n8K/fL3FJZojKGtiDXaXpVwmgPUkzxkk=; b=kcdk3FaUVivat78Z34FqwhxWMsSOmhYYOZs8AddqrFD6uYNmMpus66TSk2xpzFxtrV BntfkHVOpBKu5HtkucweUsJ41cdONGyAsGe7l+QkQZiX4qxlyanuiwUSfnTGu7p9DCj1 yGdeIKcBH2R4dcLa7lUtyEBbv9/F3a1T3PVKKHODTp76KhbNeksGua5ZOSkuIUNTGLHr AmSO2L2nfE3g5Ct/RfDrCrBBCA7RQrIoOi3/tAej9GHaMaw2VASYGCAsMZ56CUeqQIuc T3IyHODCHXrsGFuNsQiTrsGqQUoUeHFsmMvn7QDiMQKUznwB3go5VNeQfo/JIEI4ez5s KcbQ== 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=lpR+Wzjsd8/n8K/fL3FJZojKGtiDXaXpVwmgPUkzxkk=; b=GIT6E8d0mOkPLMFGtPjo/zxm7wrp1y7/9jYoTGZT7U1Icbhiek9+RVPjDwH96Gh8qc mTdn2wM82qMXduDEcLd+d7kCg0UmBs19sgk9fHe6YF/h4tV7xDUXTZ47WMqIvZtwdKxb NgcflkAlmcstcbGJswmZP5EFGwVVctW2ZNcltLIGcQD2vD9grG1Fi1YESDF5Db59tfrI 8pBg3pNTzs8rF+k5CuyjjHa13MPfzQnLP9PfFD9x5juJl5L2loKuCk+XbB7C9mNzdosT C7NVwQnKiREFc2VnzQMyXMZva9VnZgPfo+l2vQnXuF2++jEvWAS3vqh6Sez59JQ0ZKuw Be4w== X-Gm-Message-State: AOAM5319oxbuyDxHfxqf+7cGKAxT2PD8zXykDtTNXTmPPsQedFHVV6KM kBg4ykm5pkHlgNz7wgMcrJ0= X-Google-Smtp-Source: ABdhPJwJw2VOt3cs2Z4BotAI96BncuuqFpweYCpjRMmtvlP3qpc+7bG6DCXhRkMcKsekCrQJu3i+gQ== X-Received: by 2002:a05:6e02:1348:: with SMTP id k8mr25875405ilr.297.1641533391036; Thu, 06 Jan 2022 21:29:51 -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 c18sm1843446iod.18.2022.01.06.21.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:50 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:24 -0700 Message-Id: <20220107052942.1349447-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 01/19] dyndbg: add _DPRINTK_FLAGS_ENABLED X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, vincent.whitchurch@axis.com, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Distinguish the condition: _DPRINTK_FLAGS_ENABLED from the bit: _DPRINTK_FLAGS_PRINT, in preparation to add _DPRINTK_FLAGS_TRACE next. Also add a 'K' to get _DPRINTK_FLAGS_PRINTK, to insure is not used elsewhere with a stale meaning. CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 10 ++++++---- lib/dynamic_debug.c | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..257a7bcbbe36 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -27,7 +27,7 @@ struct _ddebug { * writes commands to /dynamic_debug/control */ #define _DPRINTK_FLAGS_NONE 0 -#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ +#define _DPRINTK_FLAGS_PRINTK (1<<0) /* printk() a message using the format */ #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1) #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) @@ -37,8 +37,10 @@ struct _ddebug { (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) +#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK + #if defined DEBUG -#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT +#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif @@ -120,10 +122,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #ifdef DEBUG #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - likely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + likely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #else #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + unlikely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #endif #endif /* CONFIG_JUMP_LABEL */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dd7f56af9aed..78a2912976c1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -86,7 +86,7 @@ static inline const char *trim_prefix(const char *path) } static struct { unsigned flag:8; char opt_char; } opt_array[] = { - { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_PRINTK, 'p' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, @@ -210,10 +210,10 @@ static int ddebug_change(const struct ddebug_query *query, if (newflags == dp->flags) continue; #ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + if (dp->flags & _DPRINTK_FLAGS_ENABLED) { + if (!(modifiers->flags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + } else if (modifiers->flags & _DPRINTK_FLAGS_ENABLED) static_branch_enable(&dp->key.dd_key_true); #endif dp->flags = newflags; From patchwork Fri Jan 7 05:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706245 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BB16C433F5 for ; Fri, 7 Jan 2022 05:30:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AF3D11321E; Fri, 7 Jan 2022 05:29:54 +0000 (UTC) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05F97113214; Fri, 7 Jan 2022 05:29:53 +0000 (UTC) Received: by mail-il1-x133.google.com with SMTP id o1so3643459ilo.6; Thu, 06 Jan 2022 21:29:52 -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=CdkftQqQNv/OqkWYbExR0c5h8hkYftad3zXE6/ffMXs=; b=A05OlVZNEl+qPoFA0HUlJIfImnTZc2bA0RUaeqMLJ53X1friDFLgKSVSA6hmwwsy22 tWI6wHkmVsrVd/coDCoALVwCK2ckhx/c7FGVj6bPB3CODaNSMK15IOakHnUWDYBrEASi zlGqGf3FtgUGoRvWM+zIm1gma8S0zNkWp4ptXQjJoS1HyRo+VZg1PNmhiR1UHSETBuAd 2cUlAlMe++EBBBA8C2mZ6mj06cYagKW5LUyoZU98sDlUW4juW8l8i2u/KIn+t1RliDlf tbFKZ/FpBcQU7PK6RZoYCImQL/fk4OAWxlwRV4CxliXLLXSrUnRR23PbY/UKCbV4DWz+ Kybg== 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=CdkftQqQNv/OqkWYbExR0c5h8hkYftad3zXE6/ffMXs=; b=4WZS0nO0AQZKWiQvh9ppZ2/404P2NHimUv0yh43W2KZDOd0G5Ysd/zSg1uQD3u2Bu5 lFzWSz2AuIWqWqbuaRQMbhhXT2Jo5v4yIb+QHYJ9hq4jhbP1M5PvxyfJdSpCJOv+cJct mZhK/w5dKXD8lgOHAvlat2s8nH8HoV59L+gkmMf6A4w6QXQqER3Lyebz3GsP3B8sMB1e UpTz0aqg3O3QgvC/cd7w/qorUJDoQjsxA3g6swuoe+Q2uf4Vmev2g1EVCqixAinxFY5Z vXToYqb6l9sFsAl2CFU1BRpAdHnb8PBOgP3UeehvAYuGJSFDq/EIidWg4eQBacIV0++j /NpQ== X-Gm-Message-State: AOAM530kV/2zGGP/GqjtaWuDs15sFhbLpBZTwS6xRKJLYsDo40HjwyZj M1MTqK4CfA3VLyv/QHgzclo= X-Google-Smtp-Source: ABdhPJyUg6/UkVla9SknnWDUILQsZ44OvsYQsd/nvHiUBfrWChy+SNyC1BoBl8Avpv3Jww8vX10z9Q== X-Received: by 2002:a05:6e02:1a86:: with SMTP id k6mr28045756ilv.223.1641533392219; Thu, 06 Jan 2022 21:29:52 -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 c18sm1843446iod.18.2022.01.06.21.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:51 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:25 -0700 Message-Id: <20220107052942.1349447-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 02/19] dyndbg: add _DPRINTK_FLAGS_TRACE X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, vincent.whitchurch@axis.com, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" add new flag, and OR it into _DPRINTK_FLAGS_ENABLED definition CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 257a7bcbbe36..e0c2d7c0938b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -37,7 +37,9 @@ struct _ddebug { (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) -#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK +#define _DPRINTK_FLAGS_TRACE (1<<5) +#define _DPRINTK_FLAGS_ENABLED (_DPRINTK_FLAGS_PRINTK | \ + _DPRINTK_FLAGS_TRACE) #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK From patchwork Fri Jan 7 05:29:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706246 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07196C4332F for ; Fri, 7 Jan 2022 05:30:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC069113221; Fri, 7 Jan 2022 05:29:55 +0000 (UTC) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26EB0113216; Fri, 7 Jan 2022 05:29:54 +0000 (UTC) Received: by mail-il1-x134.google.com with SMTP id o1so3643485ilo.6; Thu, 06 Jan 2022 21:29:54 -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=iwfS1KATHD4qlF4EIAswj+v50MYv6dXEgUQ2kHGwxaY=; b=kLxZUeIiUHVpFydZkyGdzXJ27X73eVmnvUhjCBe6B6DjPI0Pf+xMAbzxg+u5iKIVNQ 4WM76bt3BfUMZbbTwgdsNVD6jnfZybduM/LCiv8jGZmFzAqq8akfEnHGeWxZ1+tiZjw6 Rq+2hbxKQx4aW9PNWwj6wvN9v9Neg+tTdIWV0i+ZetRoXN4hcr/wtT2P3fBostoTCDwZ h+zsCzE7033XDvFul+qtLtGkSKYLJLMg4aHvunIv5/WMkQjLgauWgd3HmELztB8Qyjaq tM/r4XIyGMG9FB+euiCZGnBekoii88bKl9KtUnfUepfzZJPNcoCbTO7pT0A7xiInYAjT pihg== 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=iwfS1KATHD4qlF4EIAswj+v50MYv6dXEgUQ2kHGwxaY=; b=Vf0QI0V3HtpLLFbipnndZG+GzWfWMpo6C82OYOmdrydK3L9S4XX6eSELQFU72Zt+pT qs1bQkIqvdRM70OAWaHyer73dwDCzh8fMC8qzc0gj7PdXfLls8MUeXDTKP4JVvYkGxe/ XG29fX+DaqtRHWu36rRq7raCBS6mWwNXWwkG53VaQ9Vtp4RBZoT+gJYbcGell3EXIeX9 kFo7DggfED9NVnPHfqeLnTOlPzTirwWRALgZ6bfgu4VRy2+AHBM2xE0IBQVHHwBA+uQU UEraMcXq2GVSZOLh1OmLUYoNTWgyr040d93ZG9m4lTOVek29n0T2RLLorOlvMO4fy24N e0FQ== X-Gm-Message-State: AOAM532Pn/rWLUaP/JqKRiZ3V+wdC+iLsDNRI4IRHP3Djm8xafo/7+0P 0rug1G/dtSrAEGIwiV0MFmU= X-Google-Smtp-Source: ABdhPJxJuqCjFl5e7DAMZoQn88gADlHCPWi3iC9gJSxC0rmA5z56lvaNsv1+DXz8Gou8DtO0ZHXUfg== X-Received: by 2002:a92:ddc4:: with SMTP id d4mr4637305ilr.281.1641533393416; Thu, 06 Jan 2022 21:29:53 -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 c18sm1843446iod.18.2022.01.06.21.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:53 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:26 -0700 Message-Id: <20220107052942.1349447-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 03/19] dyndbg: add write-to-tracefs code X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, vincent.whitchurch@axis.com, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" adds: dynamic_trace() uses trace_console() temporarily to issue printk:console event uses internal-ish __ftrace_trace_stack code: 4-context buffer stack, barriers per Steve call it from new funcs: dynamic_printk() - print to both syslog/tracefs dynamic_dev_printk() - dev-print to both syslog/tracefs These handle both _DPRINTK_FLAGS_PRINTK and _DPRINTK_FLAGS_TRACE cases, allowing to vsnprintf the message once and use it for both, skipping past the KERN_DEBUG character for tracing. Finally, adjust the callers: __dynamic_{pr_debug,{,net,ib}dev_dbg}, replacing printk and dev_printk with the new funcs above. The _DPRINTK_FLAGS_TRACE flag character s 'T', so the following finds all callsites enabled for tracing: grep -P =p?T /proc/dynamic_debug/control Enabling debug-to-tracefs is 2 steps: # event enable echo 1 > /sys/kernel/tracing/events/dyndbg/enable # callsite enable echo module foo +T > /proc/dynamic_debug/control This patch,~1,~2 are based upon: https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com/ .. with simplification of temporarily reusing trace_console() rather than adding a new printk:dyndbg event. Soon, add 2 new events capturing the pr_debug & dev_dbg() args. CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 1 + lib/dynamic_debug.c | 155 +++++++++++++++--- 2 files changed, 130 insertions(+), 26 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index a89cfa083155..3c8f104a143f 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -228,6 +228,7 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. + T enables callsite to issue a dyndbg:* trace-event f Include the function name in the printed message l Include line number in the printed message m Include module name in the printed message diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 78a2912976c1..3fd035cd4653 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -87,6 +88,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINTK, 'p' }, + { _DPRINTK_FLAGS_TRACE, 'T' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, @@ -628,6 +630,96 @@ static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) return buf; } +/* + * This code is heavily based on __ftrace_trace_stack(). + * + * Allow 4 levels of nesting: normal, softirq, irq, NMI. + */ +#define DYNAMIC_TRACE_NESTING 4 + +struct dynamic_trace_buf { + char buf[256]; +}; + +struct dynamic_trace_bufs { + struct dynamic_trace_buf bufs[DYNAMIC_TRACE_NESTING]; +}; + +static DEFINE_PER_CPU(struct dynamic_trace_bufs, dynamic_trace_bufs); +static DEFINE_PER_CPU(int, dynamic_trace_reserve); + +static void dynamic_trace(const char *fmt, va_list args) +{ + struct dynamic_trace_buf *buf; + int bufidx; + int len; + + preempt_disable_notrace(); + + bufidx = __this_cpu_inc_return(dynamic_trace_reserve) - 1; + + if (WARN_ON_ONCE(bufidx > DYNAMIC_TRACE_NESTING)) + goto out; + + /* For the same reasons as in __ftrace_trace_stack(). */ + barrier(); + + buf = this_cpu_ptr(dynamic_trace_bufs.bufs) + bufidx; + + len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); + trace_console(buf->buf, len); + +out: + /* As above. */ + barrier(); + __this_cpu_dec(dynamic_trace_reserve); + preempt_enable_notrace(); +} + +static void dynamic_printk(unsigned int flags, const char *fmt, ...) +{ + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + /* + * All callers include the KERN_DEBUG prefix to keep the + * vprintk case simple; strip it out for tracing. + */ + dynamic_trace(fmt + strlen(KERN_DEBUG), args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } +} + +static void dynamic_dev_printk(unsigned int flags, const struct device *dev, + const char *fmt, ...) +{ + + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + dynamic_trace(fmt, args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + dev_vprintk_emit(LOGLEVEL_DEBUG, dev, fmt, args); + va_end(args); + } +} + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; @@ -642,7 +734,8 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - printk(KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + dynamic_printk(descriptor->flags, KERN_DEBUG "%s%pV", + dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); } @@ -652,6 +745,7 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -661,16 +755,18 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (!dev) { - printk(KERN_DEBUG "(NULL device *): %pV", &vaf); + dynamic_printk(flags, KERN_DEBUG "(NULL device *): %pV", + &vaf); } else { char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, dev, "%s%s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev), dev_name(dev), - &vaf); + dynamic_dev_printk(flags, dev, "%s%s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev), dev_name(dev), + &vaf); } va_end(args); @@ -683,6 +779,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -692,22 +789,24 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev->dev.parent), - dev_name(dev->dev.parent), - netdev_name(dev), netdev_reg_state(dev), - &vaf); + dynamic_dev_printk(flags, dev->dev.parent, + "%s%s %s %s%s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + &vaf); } else if (dev) { - printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev), - netdev_reg_state(dev), &vaf); + dynamic_printk(flags, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); + dynamic_printk(flags, KERN_DEBUG "(NULL net_device): %pV", + &vaf); } va_end(args); @@ -723,29 +822,33 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + unsigned int flags; va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, - "%s%s %s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(ibdev->dev.parent), - dev_name(ibdev->dev.parent), - dev_name(&ibdev->dev), - &vaf); + dynamic_dev_printk(flags, ibdev->dev.parent, + "%s%s %s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(ibdev->dev.parent), + dev_name(ibdev->dev.parent), + dev_name(&ibdev->dev), + &vaf); } else if (ibdev) { - printk(KERN_DEBUG "%s: %pV", dev_name(&ibdev->dev), &vaf); + dynamic_printk(flags, KERN_DEBUG "%s%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf); + dynamic_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", + &vaf); } - va_end(args); +va_end(args); } EXPORT_SYMBOL(__dynamic_ibdev_dbg); From patchwork Fri Jan 7 05:29:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706247 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0E48C433F5 for ; Fri, 7 Jan 2022 05:30:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CFAD113228; Fri, 7 Jan 2022 05:29:58 +0000 (UTC) Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by gabe.freedesktop.org (Postfix) with ESMTPS id CAC5C11321F; Fri, 7 Jan 2022 05:29:55 +0000 (UTC) Received: by mail-il1-x135.google.com with SMTP id b1so3830543ilj.2; Thu, 06 Jan 2022 21:29:55 -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=dzzF7/8GOpzrKBOwrzHckJzGxvjjvSqXBZy9kNIR228=; b=MWSI8cTZPy+vSDbzcCvskKGF68nj/ywu4/0G04NC/GBBSbv1Jls/TQxzBWMEet96WG AfEoB+DR7klyRZFOdiPKA54Lgyi3OOa1tDTTvh7cH0S42eaaENGud0GamJdWkQNgFmVX N9Uh/inRxdkZmJtVskb5jndWsazsHFP+hqWqHm61bafcXnQoZpzAQtIDEWVjWvVQZKvW 9L6OQb2hjIhLMThvt+JVsEL4GvpD0ayNeRJtcLS7R0/lu88DxFw1WNqp5bAAduLErTMd Jxf6AKm8vLxSMiGVwM+YGvMDA/hGIAXYnKUURGD7uSI0u1AjIVwYvg0WHXUfjURDuCRx rQRg== 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=dzzF7/8GOpzrKBOwrzHckJzGxvjjvSqXBZy9kNIR228=; b=3wwcDl1uY3lCJPUPwzowNx9Qpncruo2UdutoTPgwqrdT9tkpzKQCUbiQs6w2o0g/O3 2RZkZqIeVbUs8ePxsjEMMJDZxub1A+ssjNCsd8Ijv/feLqaX2CqSu+ONDZshFp2/jYH3 XQ6NWQisYj9EInJMX4qhTAhm4NVPi0fRgWKypxKgvavWEzBxtPRHJ7OumSreu4cl84lE QBsJwyyL/dM5uheci4ZYTBW8O/ne4nPbaZZqf5Sc1KCOuZf8DQJz/aAFZL9dAFqeYfwA xGWPIk+N17g7zZrgYoP4UAt1gl7pbinnpUOyJvcfJJRGAtqo3oGWv9OyNsu2wExJ5NtH YntQ== X-Gm-Message-State: AOAM533ds2CCDoddR1/RPNMhcK4xX3NM6pr58YwTB/B63aC1sp3jNSwC 7SRgFEIvcGdbnNDRSQGk9/g= X-Google-Smtp-Source: ABdhPJyup5o4rcMhORpT6ZFSPR3dezD1mphacqC7xfzSWFaUJlmduh7V7awhW8PNm3PB34a2m2uxPw== X-Received: by 2002:a05:6e02:545:: with SMTP id i5mr27549553ils.128.1641533394782; Thu, 06 Jan 2022 21:29:54 -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 c18sm1843446iod.18.2022.01.06.21.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:54 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:27 -0700 Message-Id: <20220107052942.1349447-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 04/19] dyndbg: add trace-events for pr_debug, dev_dbg X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In commit HEAD~1, pr_debug temporarily issued a printk:console event. Replace that use with 2 new events: bash-5.1# ls events/dyndbg/ devdbg enable filter prdbg ..called from pr_debug(), dev_dbg() respectively for dyndbg builds. This links the old pr_debug API to tracefs, via dyndbg, allowing pr_debug()s etc to add just a little more user-context to the trace-logs, and then at users option, less syslog. The 2 trace_* calls accept their caller's args respectively, keeping the available info w/o alteration; ISTM this is the best basis to add filtering later. 1- struct _ddebug *descriptor, giving tracefs all of dyndbg's info. 2- struct device *dev, for trace_devdbg(), if !!dev To pass the descriptor into the trace_*() calls, the callchain up to __dynamic_{pr_debug,{dev,netdev,ibdev}_dbg} are altered to provide it. The 2nd event also gets the struct device *dev if !!dev, otherwise a trace_prdbg() is issued, since we have an event for that, and don't need to waste the trace-buffer space. Signed-off-by: Jim Cromie --- include/trace/events/dyndbg.h | 67 +++++++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 53 ++++++++++++++------------- 2 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 include/trace/events/dyndbg.h diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h new file mode 100644 index 000000000000..82620b10e968 --- /dev/null +++ b/include/trace/events/dyndbg.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dyndbg + +#if !defined(_TRACE_DYNDBG_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DYNDBG_H + +#include + +/* capture pr_debug() callsite descriptor and message */ +TRACE_EVENT(prdbg, + TP_PROTO(const struct _ddebug *desc, const char *text, size_t len), + + TP_ARGS(desc, text, len), + + TP_STRUCT__entry( + __dynamic_array(char, msg, len + 1) + ), + + TP_fast_assign( + /* + * Each trace entry is printed in a new line. + * If the msg finishes with '\n', cut it off + * to avoid blank lines in the trace. + */ + if ((len > 0) && (text[len-1] == '\n')) + len -= 1; + + memcpy(__get_str(msg), text, len); + __get_str(msg)[len] = 0; + ), + + TP_printk("%s", __get_str(msg)) + +); + +/* capture dev_dbg() callsite descriptor, device, and message */ +TRACE_EVENT(devdbg, + TP_PROTO(const struct _ddebug *desc, const struct device *dev, + const char *text, size_t len), + + TP_ARGS(desc, dev, text, len), + + TP_STRUCT__entry( + __dynamic_array(char, msg, len + 1) + ), + + TP_fast_assign( + /* + * Each trace entry is printed in a new line. + * If the msg finishes with '\n', cut it off + * to avoid blank lines in the trace. + */ + if ((len > 0) && (text[len-1] == '\n')) + len -= 1; + + memcpy(__get_str(msg), text, len); + __get_str(msg)[len] = 0; + ), + + TP_printk("%s", __get_str(msg)) +); + +#endif /* _TRACE_DYNDBG_H */ + +/* This part must be outside protection */ +#include diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3fd035cd4653..2efdc4f1553f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,7 +36,9 @@ #include #include #include -#include + +#define CREATE_TRACE_POINTS +#include #include @@ -648,7 +650,8 @@ struct dynamic_trace_bufs { static DEFINE_PER_CPU(struct dynamic_trace_bufs, dynamic_trace_bufs); static DEFINE_PER_CPU(int, dynamic_trace_reserve); -static void dynamic_trace(const char *fmt, va_list args) +static void dynamic_trace(struct _ddebug *desc, const struct device *dev, + const char *fmt, va_list args) { struct dynamic_trace_buf *buf; int bufidx; @@ -667,7 +670,11 @@ static void dynamic_trace(const char *fmt, va_list args) buf = this_cpu_ptr(dynamic_trace_bufs.bufs) + bufidx; len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); - trace_console(buf->buf, len); + + if (dev == NULL) + trace_prdbg(desc, buf->buf, len); + else + trace_devdbg(desc, dev, buf->buf, len); out: /* As above. */ @@ -676,9 +683,9 @@ static void dynamic_trace(const char *fmt, va_list args) preempt_enable_notrace(); } -static void dynamic_printk(unsigned int flags, const char *fmt, ...) +static void dynamic_printk(struct _ddebug *desc, const char *fmt, ...) { - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); @@ -686,11 +693,11 @@ static void dynamic_printk(unsigned int flags, const char *fmt, ...) * All callers include the KERN_DEBUG prefix to keep the * vprintk case simple; strip it out for tracing. */ - dynamic_trace(fmt + strlen(KERN_DEBUG), args); + dynamic_trace(desc, NULL, fmt + strlen(KERN_DEBUG), args); va_end(args); } - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -699,19 +706,19 @@ static void dynamic_printk(unsigned int flags, const char *fmt, ...) } } -static void dynamic_dev_printk(unsigned int flags, const struct device *dev, +static void dynamic_dev_printk(struct _ddebug *desc, const struct device *dev, const char *fmt, ...) { - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); - dynamic_trace(fmt, args); + dynamic_trace(desc, dev, fmt, args); va_end(args); } - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -734,7 +741,7 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - dynamic_printk(descriptor->flags, KERN_DEBUG "%s%pV", + dynamic_printk(descriptor, KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); @@ -745,7 +752,6 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, const char *fmt, ...) { struct va_format vaf; - unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -755,15 +761,14 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; - flags = descriptor->flags; if (!dev) { - dynamic_printk(flags, KERN_DEBUG "(NULL device *): %pV", + dynamic_printk(descriptor, KERN_DEBUG "(NULL device *): %pV", &vaf); } else { char buf[PREFIX_SIZE] = ""; - dynamic_dev_printk(flags, dev, "%s%s %s: %pV", + dynamic_dev_printk(descriptor, dev, "%s%s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(dev), dev_name(dev), &vaf); @@ -794,7 +799,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dynamic_dev_printk(flags, dev->dev.parent, + dynamic_dev_printk(descriptor, dev->dev.parent, "%s%s %s %s%s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(dev->dev.parent), @@ -802,10 +807,10 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, netdev_name(dev), netdev_reg_state(dev), &vaf); } else if (dev) { - dynamic_printk(flags, KERN_DEBUG "%s%s: %pV", - netdev_name(dev), netdev_reg_state(dev), &vaf); + dynamic_dev_printk(descriptor, &dev->dev, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - dynamic_printk(flags, KERN_DEBUG "(NULL net_device): %pV", + dynamic_printk(descriptor, KERN_DEBUG "(NULL net_device): %pV", &vaf); } @@ -833,7 +838,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dynamic_dev_printk(flags, ibdev->dev.parent, + dynamic_dev_printk(descriptor, ibdev->dev.parent, "%s%s %s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(ibdev->dev.parent), @@ -841,10 +846,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dev_name(&ibdev->dev), &vaf); } else if (ibdev) { - dynamic_printk(flags, KERN_DEBUG "%s%s: %pV", - dev_name(&ibdev->dev), &vaf); + dynamic_dev_printk(descriptor, &ibdev->dev, KERN_DEBUG "%s%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - dynamic_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", + dynamic_printk(descriptor, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } From patchwork Fri Jan 7 05:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706248 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 988BBC433F5 for ; Fri, 7 Jan 2022 05:30:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C48B113229; Fri, 7 Jan 2022 05:29:59 +0000 (UTC) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE5CD113220; Fri, 7 Jan 2022 05:29:56 +0000 (UTC) Received: by mail-io1-xd2b.google.com with SMTP id s6so5907439ioj.0; Thu, 06 Jan 2022 21:29:56 -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=e63T25IY0LrfOuX+XUbFrW7daTp0yjRBy27VA81f73c=; b=lrazqIvRI7nkcOWlxTYZ9i/W0BZLR+6pq9AkUgro+ggvyCEnHKGma1fZ9YSYg9sLXs t7BZGjrvTexU9tKlOt269njn3U2ieCQjxn3V0E4N2eAeb9iyPqe2sWWyYgK0Nfuor0Kj 7o8gVKi/QiHWa/zkHJSlpIbe+W1LFcV611bn1lba/8aTTOeI83SnxuUYqeOkhgc6fxis r+O2Hwht/mRN4l4ezOOBpeBeIejoXY9HrP/Tk+J5BH7NbzBXo4W18iiRxzUKlMX/9Qdf Q+RYhwObXjtRB9E85C74C9P6wIQKJ1j6GGz/BxLvSV3lqWyMnulc0/m7dOnhr0Pm/FNa maLA== 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=e63T25IY0LrfOuX+XUbFrW7daTp0yjRBy27VA81f73c=; b=3z7aTr3H1zukGY89l5ehwNEMpv1EYxTH73DRQeKMMAqEjMyFIOZ6ec2vXemo0sP84V NNzUoYafao+CfLyZmNeLCj9auvlaCVwzG7yIi2Xxq+V0E6ayo7xSwybLp3agQETyJTk5 yLkKFEMyG0ylHLz7XA+nFfz9gDRXUVXBf9WWbNkRvu9ZsrDnVdEnowX1aBUoz4tBcnfv 7APLR02mNus4xbe9kJBsDLwXVZZm4HYlX+NPJSjpTYBMjc6k7iniF4X4bvGYJeSM3aw2 8eg6ynQnJww4Gs2I8n13WuSveEEew5cBMnngwYfCSf3JEBELBVCKsyHTqjQaVAAavXEd GYfg== X-Gm-Message-State: AOAM533J4LNYZzM/XfMJvizD/z6cbo6Q4Koy8CYrP513KIzXaqYkxrdT lJ/YuV/CnfLiRtbirsUrdXU= X-Google-Smtp-Source: ABdhPJzCJ4a/OeMh5+Vd7ifGWNtNlzms8nsxPhCodTm0c6KSDOhbHpofTWUlQSognE0poa4IEhOEPg== X-Received: by 2002:a05:6638:2505:: with SMTP id v5mr31095831jat.250.1641533396065; Thu, 06 Jan 2022 21:29:56 -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 c18sm1843446iod.18.2022.01.06.21.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:55 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:28 -0700 Message-Id: <20220107052942.1349447-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 05/19] dyndbg: add desc, dev fields to event record X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" commit:HEAD~1 added pr_debug(), dev_dbg() params to the new events, but didn't actually capture the params. Do that now; add the other TP_* parts: __fields, fast-assign, and printk elements for the desccriptor and device params. The message capture part is copied from printk:console, it gets the whole message, including dyndbg's prefixing: the dev_name() etc, the optional module:function:line decorations, and the trailing newline (which is trimmed). dyndbg->trace-events must be enabled on both sides: in tracefs: echo 1 > /sys/kernel/tracing/events/dyndbg/enable in dyndbg: echo module drm +T > /proc/dynamic_debug/control This is good; it gives 2 orthogonal cuts at trace traffic, dyndbg can enable callsites indvidually, tracefs can (in principle) filter and trigger on the incoming event stream. ATM, TP_print adds "__entry->desc->{modname,function}", which is redundant with +Tmf enabled callsites. RFC Perhaps the whole decorations/prefix should be excluded from the event capture ? Vincent's skip-past-KERN_DEBUG trick could be extended to skip part or all of the prefix, and leave the "decorating" of events solely to TP_printk. Whats the right separation of concerns ? NB: __entry->desc is a pointer into kernel .data, a pretty stable reference, at least while the kernel is running. Signed-off-by: Jim Cromie --- include/trace/events/dyndbg.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h index 82620b10e968..2ac296cb451c 100644 --- a/include/trace/events/dyndbg.h +++ b/include/trace/events/dyndbg.h @@ -14,10 +14,12 @@ TRACE_EVENT(prdbg, TP_ARGS(desc, text, len), TP_STRUCT__entry( + __field(const struct _ddebug *, desc) __dynamic_array(char, msg, len + 1) ), TP_fast_assign( + __entry->desc = desc; /* * Each trace entry is printed in a new line. * If the msg finishes with '\n', cut it off @@ -30,8 +32,8 @@ TRACE_EVENT(prdbg, __get_str(msg)[len] = 0; ), - TP_printk("%s", __get_str(msg)) - + TP_printk("%s.%s %s", __entry->desc->modname, + __entry->desc->function, __get_str(msg)) ); /* capture dev_dbg() callsite descriptor, device, and message */ @@ -42,10 +44,14 @@ TRACE_EVENT(devdbg, TP_ARGS(desc, dev, text, len), TP_STRUCT__entry( + __field(const struct _ddebug *, desc) + __field(const struct device *, dev) __dynamic_array(char, msg, len + 1) ), TP_fast_assign( + __entry->desc = desc; + __entry->dev = (struct device *) dev; /* * Each trace entry is printed in a new line. * If the msg finishes with '\n', cut it off @@ -58,7 +64,8 @@ TRACE_EVENT(devdbg, __get_str(msg)[len] = 0; ), - TP_printk("%s", __get_str(msg)) + TP_printk("%s.%s %s", __entry->desc->modname, + __entry->desc->function, __get_str(msg)) ); #endif /* _TRACE_DYNDBG_H */ From patchwork Fri Jan 7 05:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706251 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AF05C433FE for ; Fri, 7 Jan 2022 05:30:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24050113246; Fri, 7 Jan 2022 05:30:04 +0000 (UTC) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E21D113229; Fri, 7 Jan 2022 05:29:58 +0000 (UTC) Received: by mail-il1-x129.google.com with SMTP id o1so3643591ilo.6; Thu, 06 Jan 2022 21:29: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=Hyui/9XEFQbqGCcGYlhpIzLPjJi33gkvYHXo74A0/3Q=; b=IU3vT52kge4VoDiJuwOsA8j+GKfxVgh5ey5XO3SiQoirl1BeyHVYMo3q9CdLNtpcrs SGcsf4M78LC6wtFBycVFPoB5fENHSmO4Vb/eBtGxCEDJc934TMbmZwW0crFlubOMlBf0 XY3zJUPST8ImY4vMCKatw4pF6DgsnMvhzgzhOJRpvM82Y3gvtScwll9A7sDQKM5RYxod 4ROxDZVJYThqdML5j3sjprkEa9EVX7AKYTfmLUXt6iNlLuJHTbCHz7/rEndJ5kagH2MD GiNBT/4z1uCWwd/ulQzeyx2L39/iZUWfZi7Vp9VwgSB1L06MzoIweOQSh2Q78XiPNc1A CcAw== 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=Hyui/9XEFQbqGCcGYlhpIzLPjJi33gkvYHXo74A0/3Q=; b=A1x9MpRr3RrB5nwxaiRveuoVE0MzUplf1y1JOLxWwQPnBQ0WwAjyeGNE+o475KdCur F8K7bsIgtDR9gobrFxI1QILE/jcjlYW2tO2HwPoeeUEH4xSfNg6MrmpGolZv3yWf4GFM BE+y9tpY5dPO60j5jq1q1RTl4MBxhER0Sla4KlvrQ8EemHs98WB0gOLX8KsiKcShjh+J FQoDHaTeHGZ9tDWEr42TYG1kI2jAIxFzFWQcCGD7iJzYkRenzk9GNzxlj/T74XHr83AK Lbeq2J6D6c6xth+v7d4fnoQhzxr7S7hEyGWCsmUhUT4TGVF1mH/aYSSg+owTijxE8VNL Op5Q== X-Gm-Message-State: AOAM530XnaDkuVkat7COKuAA2tQh5YcW75Wy+OOue/B4UUMgDWdg7J7f i4HDDqBuun2HvqB78aTf0qU= X-Google-Smtp-Source: ABdhPJzRNIRXh2SqL/+c3H8HIxlpBdAWgefXUkquh+C0fyO1fTdoZd3yCc+Z25Fbeh8t3hY83ngwJg== X-Received: by 2002:a05:6e02:18ce:: with SMTP id s14mr28271765ilu.0.1641533397322; Thu, 06 Jan 2022 21:29:57 -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 c18sm1843446iod.18.2022.01.06.21.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:56 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:29 -0700 Message-Id: <20220107052942.1349447-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 06/19] dyndbg: add class_id to callsites X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DRM defines/uses a 10 enum drm_debug_category to create exclusive classes of debug messages. To support this directly in dynamic-debug, add the following: - struct _ddebug.class_id 4 bits is enough for drm_debug_category and the query support: - struct _ddebug_query.class_id - ddebug_change - looks for "class" keyword - parse_class - accepts uint: 1-15, sets query->class_id - vpr_info_dq - displays new field - ddebug_proc_show - append column with "cls:%d" With this patch, the following cmd is accepted w/o error: #> echo module drm class 2 +p > /proc/dynamic_debug/control It currently does nothing, since no pr_debug callsites can yet be initialized with class_id != 0. Note that this is specifically an error: #> echo module drm class 0 +p > /proc/dynamic_debug/control parse_class() prohibits this, we reserve "class 0" as a non-category. This means that all good inputs are true, and 0 is special. NOTES: Patch extends DEFINE_DYNAMIC_DEBUG_METADATA() with a _CLS suffix, and a new cls param, and re-adds old name using extended name. Then, repeats those mods up through the Factory macros that use the METADATA* .data constructors, so as to actually supply the category into the initializer. CC: Rasmus Villemoes Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 11 +++++ include/linux/dynamic_debug.h | 41 +++++++++++++------ lib/dynamic_debug.c | 30 ++++++++++++-- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index 3c8f104a143f..7e1322660b10 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -35,6 +35,7 @@ Dynamic debug has even more useful features: - line number (including ranges of line numbers) - module name - format string + - class number:1-15 * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -143,6 +144,7 @@ against. Possible keywords are::: 'module' string | 'format' string | 'line' line-range + 'class' integer:[1-15] line-range ::= lineno | '-'lineno | @@ -217,6 +219,15 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file +class + This expects a single integer, in range: 1-15. + Using this specification constrains to exact class_id matches. + This is intended for DRM.debug enumerated categories, plus 1. + class_id = 0 is reserved, returns an error currently. + + This differs from the others primarily in that it is not displayed + in the control file currently, add later as an extra column. + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e0c2d7c0938b..e9483cd9ac1c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -20,6 +20,7 @@ struct _ddebug { const char *function; const char *filename; const char *format; + unsigned int class_id:4; unsigned int lineno:18; /* * The flags field controls the behaviour at the callsite. @@ -91,7 +92,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name = { \ .modname = KBUILD_MODNAME, \ @@ -100,9 +101,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ + .class_id = cls, \ _DPRINTK_KEY_INIT \ } +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, 0, fmt) + #ifdef CONFIG_JUMP_LABEL #ifdef DEBUG @@ -132,17 +137,21 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #endif /* CONFIG_JUMP_LABEL */ -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, 0, fmt, func, ##__VA_ARGS__) -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(id, 0, fmt, func, ##__VA_ARGS__) /* * "Factory macro" for generating a call to func, guarded by a @@ -152,15 +161,23 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__) #define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), 0, fmt, func, ##__VA_ARGS__) + /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc_cls(fmt, eCat, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), eCat, \ + fmt, func, ##__VA_ARGS__) + +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), 0, \ + fmt, func, ##__VA_ARGS__) #define dynamic_pr_debug(fmt, ...) \ _dynamic_func_call(fmt, __dynamic_pr_debug, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2efdc4f1553f..419d4664e724 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -58,6 +58,7 @@ struct ddebug_query { const char *function; const char *format; unsigned int first_lineno, last_lineno; + unsigned int class_id; }; struct ddebug_iter { @@ -138,13 +139,13 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) fmtlen--; } - v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n", + v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%u\n", msg, query->function ?: "", query->filename ?: "", query->module ?: "", fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno); + query->first_lineno, query->last_lineno, query->class_id); } /* @@ -174,6 +175,10 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; + /* match against the class_id, if > 0 */ + if (query->class_id && query->class_id != dp->class_id) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -310,6 +315,22 @@ static inline int parse_lineno(const char *str, unsigned int *val) } return 0; } +/* + * class_id is 0-15. 0 is default, is nonsense in active search + */ +static inline int parse_class(struct ddebug_query *query, const char *str) +{ + int rc; + unsigned int val; + + rc = kstrtouint(str, 10, &val); + if (rc < 0 || !val || val > 15) { + pr_err("expecting class:[1-15], not %s\n", str); + return -EINVAL; + } + query->class_id = val; + return 0; +} static int parse_linerange(struct ddebug_query *query, const char *first) { @@ -424,6 +445,9 @@ static int ddebug_parse_query(char *words[], int nwords, } else if (!strcmp(keyword, "line")) { if (parse_linerange(query, arg)) return -EINVAL; + } else if (!strcmp(keyword, "class")) { + if (parse_class(query, arg)) + return -EINVAL; } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -1007,7 +1031,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape(m, dp->format, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_printf(m, "\" cls:%u\n", dp->class_id); return 0; } From patchwork Fri Jan 7 05:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706250 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 443F3C433EF for ; Fri, 7 Jan 2022 05:30:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 860DB11323E; Fri, 7 Jan 2022 05:30:08 +0000 (UTC) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41EDC11321F; Fri, 7 Jan 2022 05:29:59 +0000 (UTC) Received: by mail-il1-x133.google.com with SMTP id e8so3768514ilm.13; Thu, 06 Jan 2022 21:29:59 -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=KuUpo8N7O6zfCcQlim8LLc328KIOMpVIHmOBAPahhn4=; b=bJ/n5Q/dPqC+YFPh92aeruYamwdqsuJZrluEKsrTDhwqmu8Fb4JTaPyRt5ppFFUgkJ +naYVaSeN+LIgNQsfRVtctMtWqzkwjq2WzzFqJ2qE/B91Y6WH3a1gVw7PtofKY+9/jKk HpuSX9xGFF3YYHcYpHzZkkXHQ8i6RFqifCkt6raVeU7hilf1KPsiARZKkm2pjgnt+fzg DtS6h+lnsUno5cNenvFVUBSx745HI3tL0Bbfg2E9KMDsfcvIYLSA4tiaIHUKZzW5Ciw9 yZH5W9pJ5bVQtZERKqmG6p9llU0RE8hgM4ymHzrKsH5TmcEfxPwjM940iF8HakEwvs60 amXQ== 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=KuUpo8N7O6zfCcQlim8LLc328KIOMpVIHmOBAPahhn4=; b=wmKIgipcW7xXKFDl3W6OHI47VQwX7TJenqXvlIKTdmie64JPxykH38PcGCzc04R8No 1eJJyziGfO5MA29VOmzrF+cC8czsL3GqOvE/azkSL5tnRr0Hub8Tg9JgQ1fct/8rN7tU dG/K1HGJiLvwW4Wtzy3q4048l9/+FXPjfdeSHcyfmSQ0uVdCiOEc+sh6lTKF2gLXgH2c ckkdCUhAyQrKCLM6bQjeRsvgfkvfa7IphQQSvi+js8TQOSIvUaURBqf8vikNWmfebA7V jK5MAeghksfdxyMiwPPVlPLbTmgp8FudVZlGtZmluNJNurMQSGmKq8wtBeQKVsZVrDqY qHRg== X-Gm-Message-State: AOAM530UDKxUwH70hI60dlKeWT2pq7kpApK0GK3adNxT8rzyWI9QHAKa 7yTEV4CLA6YVnp3eoc63chs= X-Google-Smtp-Source: ABdhPJy2rvSWBjxrv0s0L+Dd40rEcbOGWkDTDS7wEKky+oaA8kMgIOWAJ3OBBEACDrV+n0KZGzNJKA== X-Received: by 2002:a05:6e02:20c9:: with SMTP id 9mr29967785ilq.108.1641533398507; Thu, 06 Jan 2022 21:29:58 -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 c18sm1843446iod.18.2022.01.06.21.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:58 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:30 -0700 Message-Id: <20220107052942.1349447-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 07/19] drm_print: condense enum drm_debug_category X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" enum drm_debug_category has 10 hardcoded values, which could be "simplified" as sequential BIT(x)s. But lets take it one step further, removing the explicit initializations (other than starting at 1), and move the BIT() operation into drm_debug_enabled(). This gives us a more compact representation (4 bits), without loss of info; all DRM.debug api calls pass an enum parameter (and not a bit-OR of them), and the bitmask-iness of the enum's values is merely a micro-optimization to avoid doing BIT(category) at runtime. I doubt the extra bit-shift would be measurable here. And the 4-bit representation means it fits into struct _ddebug.class_id (commit:HEAD~1), setting up for further integration. The enum starts at 1, which respects the "reservation" of 0 as a special case; it is a non-category, and shouldn't get treated like one. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..b4355bfd7888 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -279,49 +279,49 @@ enum drm_debug_category { * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... */ - DRM_UT_CORE = 0x01, + DRM_UT_CORE = 1, /** * @DRM_UT_DRIVER: Used in the vendor specific part of the driver: i915, * radeon, ... macro. */ - DRM_UT_DRIVER = 0x02, + DRM_UT_DRIVER, /** * @DRM_UT_KMS: Used in the modesetting code. */ - DRM_UT_KMS = 0x04, + DRM_UT_KMS, /** * @DRM_UT_PRIME: Used in the prime code. */ - DRM_UT_PRIME = 0x08, + DRM_UT_PRIME, /** * @DRM_UT_ATOMIC: Used in the atomic code. */ - DRM_UT_ATOMIC = 0x10, + DRM_UT_ATOMIC, /** * @DRM_UT_VBL: Used for verbose debug message in the vblank code. */ - DRM_UT_VBL = 0x20, + DRM_UT_VBL, /** * @DRM_UT_STATE: Used for verbose atomic state debugging. */ - DRM_UT_STATE = 0x40, + DRM_UT_STATE, /** * @DRM_UT_LEASE: Used in the lease code. */ - DRM_UT_LEASE = 0x80, + DRM_UT_LEASE, /** * @DRM_UT_DP: Used in the DP code. */ - DRM_UT_DP = 0x100, + DRM_UT_DP, /** * @DRM_UT_DRMRES: Used in the drm managed resources code. */ - DRM_UT_DRMRES = 0x200, + DRM_UT_DRMRES }; static inline bool drm_debug_enabled(enum drm_debug_category category) { - return unlikely(__drm_debug & category); + return unlikely(__drm_debug & BIT(category)); } /* From patchwork Fri Jan 7 05:29:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706249 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26A08C433FE for ; Fri, 7 Jan 2022 05:30:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36E5C113232; Fri, 7 Jan 2022 05:30:06 +0000 (UTC) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27EBC113237; Fri, 7 Jan 2022 05:30:01 +0000 (UTC) Received: by mail-io1-xd2e.google.com with SMTP id x6so5757394iol.13; Thu, 06 Jan 2022 21:30:01 -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=z+whnRInE6RCe8IE0tc3gMQFft25woQ2FviIb/MiH/k=; b=JhenPuVwR+eU0uHEksqOulZpa5e3OJYhulnV6N9KN+XJWrge1y9oMhr8zH1rM8i7bX yZ5XoCvdfycAgkTiwWJwWmyAPQiqoUdzKlKLdTiNf0iY7KXdrlmgZRGOGGrhg5fW+i/w 9J08f903uSPuqbaLFBbQZKf7/8NOPYkfGt2rmhYlWOdUy2Z2HWACgt26Xg6E8Go6GFYu uAdUqTUZ2q9RJuBP4bt3GIzV4Bgk6Od8ysP/JsYrGluugD1ux+f9alWqtHmRywXi0sVE olvJcDp0zYC7jIY90t09WVT5gV84xPpp5Dk/B84fwFzsVMhuBlzK0e59aqIDMqNPPt9Q jPEQ== 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=z+whnRInE6RCe8IE0tc3gMQFft25woQ2FviIb/MiH/k=; b=zo21tDSmeL5IYZNc1euB6LZlNZLIvlS6L1+c7/iHgfCUjNKn6e454hIbCE60WN5Ia7 r1ysydouJcGIkNDkElOwAit0cOI3PAlYGM37b0W4aOFhJuUseEkqVzCVqlYE6DYa+LNG rDoAHiiXNIxJc5U6ELcFd6KGsec046GxMxMpFgqVjKrUDP7mznl9Qyw05E32GPVhw+8j Pd4NzjqYFtq7QZmR/ZYbtekn4PXcpS5AjGr79+76aCTd8fBP9o3rtCTARxftPHLEUsId X3RGJ6UIadOczw0jwGb0H8wUpNfpVZOV5vBOowYUGQjTi2fX7fHkFSsu/1Nr1jryxNgl nVKg== X-Gm-Message-State: AOAM533x7xJG6ehhC6zWOfozm/xF78nTdq/1hEQ0OD5olvB0HsPdC487 bkiSGlZwL+WCrFdH9jPdXt8= X-Google-Smtp-Source: ABdhPJzRsRX1nIT4M3s/esAkmWqVAyhco+gRzEgZ4Si1rvTVOGDW5wSP5pmalpqqsm5K7wxwZepWPw== X-Received: by 2002:a02:6289:: with SMTP id d131mr10292826jac.61.1641533399696; Thu, 06 Jan 2022 21:29:59 -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 c18sm1843446iod.18.2022.01.06.21.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:29:59 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:31 -0700 Message-Id: <20220107052942.1349447-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 08/19] drm_print: add trace_drm_dbg, trace_drm_devdbg events X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" __drm_debug() and __drm_dev_dbg() currently printk to syslog. These 2 underlay the vast bulk of DRM.debug api calls; they are a significant source of debugging info, and could add useful context to debug traces. Wire them to emit 2 new trace_*() events: drm_prdbg and drm_devdbg. These events keep the args of those 2 callers: - int/enum category, va_format *vaf - struct device *dev, int/enum category, va_format *vaf ISTM best to reflect args thru w/o altering; it is simple, least surprising, and preserves info for possible filtering/selecting events. NOTES: trace_*() additions are strictly redundant with printks to syslog, not properly placed to reduce overall work. Reuses trim-trailing-newline trick on vnsprintf TLDR: The event called by __drm_dev_dbg() depends upon !!dev; theres little value to storing a null in the trace. Yes, one could know that devdbg was called with a null, but is that worthwhile ? And if you really needed to know the call (not available from control-file format) the file:line gets you there. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 13 +++++-- include/trace/events/drm.h | 68 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 include/trace/events/drm.h diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..cfcb89ffd89d 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -36,6 +36,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + /* * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. @@ -269,13 +272,15 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, vaf.fmt = format; vaf.va = &args; - if (dev) + if (dev) { dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); - else + trace_drm_devdbg(dev, category, &vaf); + } else { printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); - + trace_drm_debug(category, &vaf); + } va_end(args); } EXPORT_SYMBOL(drm_dev_dbg); @@ -295,6 +300,8 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...) printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); + trace_drm_debug(category, &vaf); + va_end(args); } EXPORT_SYMBOL(__drm_dbg); diff --git a/include/trace/events/drm.h b/include/trace/events/drm.h new file mode 100644 index 000000000000..944aedaf6aa6 --- /dev/null +++ b/include/trace/events/drm.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM drm + +#if !defined(_TRACE_DRM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DRM_H + +#include + +/* drm_debug() was called, pass its args */ +TRACE_EVENT(drm_debug, + TP_PROTO(int drm_debug_category, struct va_format *vaf), + + TP_ARGS(drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(int, drm_debug_category) + __dynamic_array(char, msg, 256) + ), + + TP_fast_assign( + int len; + + __entry->drm_debug_category = drm_debug_category; + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + + len = strlen(__get_str(msg)); + if ((len > 0) && (__get_str(msg)[len-1] == '\n')) + len -= 1; + __get_str(msg)[len] = 0; + ), + + TP_printk("%s", __get_str(msg)) +); + +/* drm_devdbg() was called, pass its args, preserving order */ +TRACE_EVENT(drm_devdbg, + TP_PROTO(const struct device *dev, int drm_debug_category, struct va_format *vaf), + + TP_ARGS(dev, drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(const struct device*, dev) + __field(int, drm_debug_category) + __dynamic_array(char, msg, 256) + ), + + TP_fast_assign( + int len; + + __entry->drm_debug_category = drm_debug_category; + __entry->dev = dev; + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + + len = strlen(__get_str(msg)); + if ((len > 0) && (__get_str(msg)[len-1] == '\n')) + len -= 1; + __get_str(msg)[len] = 0; + ), + + TP_printk("cat:%d, %s %s", __entry->drm_debug_category, + dev_name(__entry->dev), __get_str(msg)) +); + +#endif /* _TRACE_DRM_H */ + +/* This part must be outside protection */ +#include From patchwork Fri Jan 7 05:29:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706252 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7DF1C433EF for ; Fri, 7 Jan 2022 05:30:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A33F211324B; Fri, 7 Jan 2022 05:30:05 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9029E11321F; Fri, 7 Jan 2022 05:30:01 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id o7so5795576ioo.9; Thu, 06 Jan 2022 21:30:01 -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=8b7+tL+cd3XDbB0bbZH5A7VjNPtmy29zZLwMyQWQkLE=; b=o9vQsJKvZk6S9XjC7kUDkR8bIThbqDoiVc/MFm8MmQEHbsaeMN/xcxudj9lZNEuDS2 eOakFvpgoWPfS98WTCBb2Mvx9Nd7zJfazbjcYzwDfvPeCikaTCIcVsHEM/f0dtg7U+r5 Mxy5tmew79fxiPkP+utkESzS6eBvJq/vl8vrgG6RKL49FeNdfg9Uva65T5kqWbmsT2RL UNvpE5oQgPEiKC/MA3wbsVtVNo5OeD9NWOGOgTt9of7BCQXgfnFaX08notkcyK4K3Xu8 NtgSn1MKeOW/hoNhyX+Rea60/xVtgItY1ByjzQXK8XrypaQ7LIDuzuSragynGLAcq/Aa S+Rg== 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=8b7+tL+cd3XDbB0bbZH5A7VjNPtmy29zZLwMyQWQkLE=; b=0Rxn6DXtpYHGHJQ5hu43LsWiw4RNy+Udr6GjlvovxnqV2sS9NsPuS7K0tKsADlTX1Q 6LGXgMwWDCgnYApJhHT5CLrIj1JWSLhxbow//ueBsdeGzy833Od6Jefnt/1fu5CwbNGn bn2pzI2vOIrBjLAHF3JNM25xcXo52whSZtu+hMAdQzW1i9dwvWPK33w6iek0rd9flC/4 8PxAzz7bSQAcfuNiXbPLK22JmS7cuCr0ejtvvNVBqYoMtSitYSaO9pjMLzbhbgDx4dup 8YMannnYxo4nL/m9JGlFqH05meDlI/d6SreentoAT33Q5qGgDx7wyJY+HKvR/+75DeA3 98/Q== X-Gm-Message-State: AOAM531jIIPEcwQPvXl9nwse+fBHuPL3xP89wT2tHKc4xi5IMXyVjxnj OEY+yQ/qscerwUSvD1L1A7Y= X-Google-Smtp-Source: ABdhPJwNprmy0e1y9wsTmFZ4pycxzUQNGEbLySOh1tCB6yThFteXTFSOZg2I004I2+XHF7Nzrqyh6A== X-Received: by 2002:a6b:f70e:: with SMTP id k14mr29152347iog.173.1641533400783; Thu, 06 Jan 2022 21:30:00 -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 c18sm1843446iod.18.2022.01.06.21.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:00 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:32 -0700 Message-Id: <20220107052942.1349447-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 09/19] drm_print: add CONFIG_DRM_USE_DYNAMIC_DEBUG X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DRM.debug API is used thousands of times in drivers/gpu/drm/*; when these are implemented using dynamic-debug, DYNAMIC_DEBUG_METADATA adds a struct _ddebug (56 bytes) per site. Since i915 will have ~2k callsites, and amdgpu ~4k, the memory costs are substantial, and thus made configurable. For a baseline: bash-5.1# drms_load [ 10.923093] dyndbg: 1 debug prints in module drm [ 10.928345] ACPI: bus type drm_connector registered [ 11.034012] dyndbg: 2 debug prints in module ttm [ 11.038188] dyndbg: 8 debug prints in module video [ 11.551064] dyndbg: 127 debug prints in module i915 [ 11.617106] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug. [ 12.084856] dyndbg: 2196 debug prints in module amdgpu [ 12.099040] [drm] amdgpu kernel modesetting enabled. [ 12.099790] amdgpu: CRAT table not found [ 12.100523] amdgpu: Virtual CRAT table created for CPU [ 12.100901] amdgpu: Topology: Add CPU node [ 12.165382] dyndbg: 3 debug prints in module wmi [ 12.356424] dyndbg: 3 debug prints in module nouveau i915/gvt has pr_debugs that show up here amdgpu has many pr_debugs from macro expansions Signed-off-by: Jim Cromie fixup-mk --- drivers/gpu/drm/Kconfig | 12 ++++++++++++ drivers/gpu/drm/Makefile | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 0039df26854b..4e7b865c3441 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -62,6 +62,18 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default y + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + Use dynamic-debug to avoid drm_debug_enabled() runtime overheads. + Due to callsite counts in DRM drivers (~4k in amdgpu) and 56 + bytes per callsite, the .data costs can be substantial, and + are therefore configurable. + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 0dff40bb863c..60f4d7bc27eb 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -3,6 +3,8 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. +CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE + drm-y := drm_aperture.o drm_auth.o drm_cache.o \ drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \ drm_drv.o \ From patchwork Fri Jan 7 05:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706253 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 677D9C43217 for ; Fri, 7 Jan 2022 05:30:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FF16113247; Fri, 7 Jan 2022 05:30:10 +0000 (UTC) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F1C811323C; Fri, 7 Jan 2022 05:30:03 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id q5so5820435ioj.7; Thu, 06 Jan 2022 21:30:02 -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=rhZr/5fj4D2TZDy+BWecHE7NyGhS8joUKN+lZK3t0TY=; b=K1cqGUH7tn5pqvS315M3pFn/EFgcikByySyyak0mzM8JxMmudF/Sy8JlBB45ADlq0Q h3CiSMrawE2whBb2mbSZHfWmdYLREJEPfTxr2b57R9R9ti6BcFDmuwPnfc30I6vac+uo 0jgJdiQfW3YX3b0jCY4Zedd3eZYKYcAy0/Ljpc7Ux/RDzjusBmBRulIh3mdm3kt/MeCh kgVrbYG5Wn+1Om+V/PAKYveiBwWwfF2yrt+J3KGHW7ZFrQVLbAs6kWOSTFyXYfFdf8S4 rnKX3cl1t4lBkgUwrXL0UnyIa6OAOygh6uNnNmKUmP8c3hKPDPzTiShoBKW0tJ00tVf6 fA+g== 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=rhZr/5fj4D2TZDy+BWecHE7NyGhS8joUKN+lZK3t0TY=; b=4nk4GBAlE3CiBYciyLUAngizmQp7A69EDjz8nELBpGJIIpESaFRIfjQwP1lFaeOTVx HJ2b0YzOCHTjcgoKSAVO0nNB7SegzCjKSloJ2r3eqD3zsxPeLdtWZCuRk+6Aai/ttbRE TtkYU/jAq0362znQg/WeY1QKsvyh24u+dKPF1vZBxzskAOLWsjs25rFTk2XbhWLMqx2Y ZgZc5XYhJSTxwIKN5PcTwi7tGcLx/IFNjqv2wIjP1U4ZnErGEF43SBp4ndz6y2Q4f5mU 7oIw4E64WDyi88fNhcH+yPxbxo7p0VYN0KOaifDbylY3Se6Gcj9kRivzyRPjZuVFHmme G/mw== X-Gm-Message-State: AOAM532euoPxuV5AT+Jzj2AhAxjmzdgftLI6MURP5yXFZcQKB9BzdVKV xSS+E5H5Vki5+9cd+AOgEq4= X-Google-Smtp-Source: ABdhPJzl4z5cci7KuMClhyTbFxtElPWbEhb9xNZirTd547D1CieexOjnCBEvzsszS6inI5KOM8xk0A== X-Received: by 2002:a05:6638:52e:: with SMTP id j14mr27122583jar.98.1641533402035; Thu, 06 Jan 2022 21:30:02 -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 c18sm1843446iod.18.2022.01.06.21.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:01 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:33 -0700 Message-Id: <20220107052942.1349447-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 10/19] drm_print: interpose drm_dev_dbg, __drm_dbg with forwarding macros X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_dev_dbg() & _drm_dbg() sit below the categorized layer of the DRM debug API, and thus implement most of it. These are good places to insert dynamic-debug jump-label mechanics, allowing DRM to avoid the runtime cost of drm_debug_enabled(). Set up for this by changing the func names by adding '__' prefixes, and define forwarding macros to the new names. no functional changes. memory cost baseline: (unchanged) bash-5.1# drms_load [ 9.220389] dyndbg: 1 debug prints in module drm [ 9.224426] ACPI: bus type drm_connector registered [ 9.302192] dyndbg: 2 debug prints in module ttm [ 9.305033] dyndbg: 8 debug prints in module video [ 9.627563] dyndbg: 127 debug prints in module i915 [ 9.721505] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug. [ 10.091345] dyndbg: 2196 debug prints in module amdgpu [ 10.106589] [drm] amdgpu kernel modesetting enabled. [ 10.107270] amdgpu: CRAT table not found [ 10.107926] amdgpu: Virtual CRAT table created for CPU [ 10.108398] amdgpu: Topology: Add CPU node [ 10.168507] dyndbg: 3 debug prints in module wmi [ 10.329587] dyndbg: 3 debug prints in module nouveau Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 10 +++++----- include/drm/drm_print.h | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cfcb89ffd89d..5dd6713c14f2 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -259,8 +259,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...) { struct va_format vaf; va_list args; @@ -283,9 +283,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -304,7 +304,7 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...) va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); void __drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b4355bfd7888..f8fa5af11310 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -334,7 +334,7 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, const char *format, ...); /** @@ -383,6 +383,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +#define drm_dev_dbg(dev, eCat, fmt, ...) \ + __drm_dev_dbg(dev, eCat, fmt, ##__VA_ARGS__) + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -484,10 +487,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, */ __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); +#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) + /* Macros to make printk easier */ #define _DRM_PRINTK(once, level, fmt, ...) \ From patchwork Fri Jan 7 05:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706256 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 600BBC433EF for ; Fri, 7 Jan 2022 05:30:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11BFE11324C; Fri, 7 Jan 2022 05:30:11 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15D11113245; Fri, 7 Jan 2022 05:30:04 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id e128so5859218iof.1; Thu, 06 Jan 2022 21:30:04 -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=agBSgkgkW/lOUa/a1e2VO231rW5BNQTBTfk7cJDbplk=; b=HAk3291JdByrBv+FlaCYSm7Og7Bv51IGb1/URK9sxt4hUoGrvKjKdIty96hALwR/56 hez4koMRHtjeS7rnGaNo6hBBnYB7M2baJcHRYh7mUipsSy2UXAENXWDvUWyAzZhodemo G+KsjM6aTfXFF2lCIyhxEjxyPXjVGvrKg/SXNvf7Xy0QWtieoBRZC5kWZX1ycVJwwxVc pV+JJQgTPFZpraYMQMqfpixURgyaJfQ38P/IMQU9z13yeIVMizzfKazBnAdAvJDxGWze EBJ0fniTa40LiDCC2M3o4sbSaBLDCVSksKcXd3oU/6WKoHmfR58b4Pxc5t15V75MJu6S kXAg== 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=agBSgkgkW/lOUa/a1e2VO231rW5BNQTBTfk7cJDbplk=; b=bKKm3k9iXNjkEhrgpbJJdzUkHQ0zQ2nUB22nmrHELZFVlZdZoXM1Mx8mGUmtLDtaPP hL5AE4UbxZfMUi3McKADKsC168QC6197YEGuUZ2Lf9uACLIDJUVqv5PpzxP5EWO+uJ8x fWbHFl5/5uBbLfWg1c/tPGnrjJ1bNp9SFlSKhg6HRQYVwSjcDtxnC7CnpUFmAb2MlrVJ VWqeyGhQ+FL6RtzvSwVFP/m8IgrZDs91oi+TtgYd18woaKZQBJ1w+8Cv2izDy6VGg+mG xe7nhFVbgV6uCnrESZVnxLg9Y0z1f0jmlsgKgw3FW5kUcRdfXKzR3C0jo51G1RHI6HP/ 7w8g== X-Gm-Message-State: AOAM530ATEQ9kQKAb57b1fpRF3P+d0RlshdcLkizXnWyPxb+DYJKS9vL fSlfQmE6L3kj3QDqlvcokIg= X-Google-Smtp-Source: ABdhPJz5Pwl1TXvRhFAHC/C/RtcA8HwmVdUMjfOUZVBgrqnxSM4Fa/HYaYOvHoAIy1tgjh4vXNkRfA== X-Received: by 2002:a05:6602:493:: with SMTP id y19mr29526904iov.126.1641533403267; Thu, 06 Jan 2022 21:30:03 -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 c18sm1843446iod.18.2022.01.06.21.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:02 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:34 -0700 Message-Id: <20220107052942.1349447-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 11/19] drm_print: wrap drm_dev_dbg in _dynamic_func_call_no_desc X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" make drm_dev_dbg() macro CONFIG_DRM_USE_DYNAMIC_DEBUG dependent: =N direct forwarding: drm_dev_dbg -> __drm_dev_dbg() =Y wrap __drm_dev_dbg in _dynamic_func_call_no_desc(). This adds the metadata which creates a /proc/dynamic_debug/control entry for each callsite, and exposes it for selective enablement. NB: include header in header so wrapper is available proof of function: bash-5.1# grep 'ring test' /proc/dynamic_debug/control drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:453 [amdgpu]amdgpu_ring_test_helper =xf "ring test on %s succeeded\012" less 452 else 453 DRM_DEV_DEBUG(adev->dev, "ring test on %s succeeded\n", 454 ring->name); drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c lines 417-454/458 byte 12536/12575 100% (press RETURN) new prdbg callsite counts: bash-5.1# drms_load [ 20.533990] dyndbg: 1 debug prints in module drm [ 20.535637] ACPI: bus type drm_connector registered [ 20.624951] dyndbg: 2 debug prints in module ttm [ 20.627853] dyndbg: 8 debug prints in module video [ 20.922442] dyndbg: 127 debug prints in module i915 [ 20.984159] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug. [ 21.310216] dyndbg: 2196 debug prints in module amdgpu [ 21.324537] [drm] amdgpu kernel modesetting enabled. [ 21.325092] amdgpu: CRAT table not found [ 21.325512] amdgpu: Virtual CRAT table created for CPU [ 21.326009] amdgpu: Topology: Add CPU node [ 21.401137] dyndbg: 3 debug prints in module wmi [ 21.532540] dyndbg: 3 debug prints in module nouveau Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index f8fa5af11310..1eef315a0a65 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -383,8 +383,14 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, eCat, fmt, ...) \ __drm_dev_dbg(dev, eCat, fmt, ##__VA_ARGS__) +#else +#define drm_dev_dbg(dev, eCat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ + dev, eCat, fmt, ##__VA_ARGS__) +#endif /** * DRM_DEV_DEBUG() - Debug output for generic drm code From patchwork Fri Jan 7 05:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706255 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DDF0C4332F for ; Fri, 7 Jan 2022 05:30:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DE6211324E; Fri, 7 Jan 2022 05:30:11 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52DA211321F; Fri, 7 Jan 2022 05:30:05 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id o7so5795728ioo.9; Thu, 06 Jan 2022 21:30:05 -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=g0urLO3I3y9RJ2BqZiVIn4AxdODRtFQ4HWGOlAS/PKA=; b=EdMk5S4qxg+IvtCJJesbywIliZbPLs1Ba2Zuk+Chr0N/6pldmZrHxH6ql2FlgEiiUH FnNeUPOZyS0SPx2vf9zfWWylETk2T9iQqUXxiMvluDJ4ZFx7HEzDy/6qR7VwTWegKFEQ EkYg+mpmf7s+rQP5bwZWzVaFSWCJ44//tSJ+Ay67a7gAMMZu41gsxIs/FfPdQzxw5nu6 o8b7YjJnM0VqQ6AI2zmZhsK12BCYNtAdMCgKDpkW5WUWpk7rMUwbq+Lpey9d7QKm/DI/ zvb+FPkSR7wGjIg4c6HdyhGMjQqHp4bN/Csfc2TnL94i3DQfEWZ/PQ/mNaXckduheRyG 7kEQ== 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=g0urLO3I3y9RJ2BqZiVIn4AxdODRtFQ4HWGOlAS/PKA=; b=1t0aKuski4k6hsKHftnIw68Yo/kkpy7b7+7Efui5C3hGbnRgQWbeMkP28rv6MbR0cE 0i0dn9D+nybrHn8AnGPReE3GsdeXEN6k1keuN2hPAmMtuTBH2xaHupgt+ou7ewO8dLMy FMO/8MjfxAE6cxhdcl4lGNKjsDNT+M/fIWDJcvnMqNgcNXKYoUC10xm8gmbW7FCwBskF nX+JdtTDTwCrwiTGLpBoQRxXRoGdcdxXQ5geUFiUctKtY2SNKDtIZhqr30h7xjXb6OLp 560AFJM27oWy7dX+yrcvYQSdJlzHhB/9LpufWSZ8c1fTdQf9ctm741JBkVLPitjaggBd Axsg== X-Gm-Message-State: AOAM53134oRj42JJ5iQZrcBJld7Car6HtVDLVj2VRwBNbwYS8LRLSttX ugBQkYF8IAICwGhNHDUtlWU= X-Google-Smtp-Source: ABdhPJxQ+uyoXwjAObJKgimGggABXHR+0a+JXdXUWplJy2XxxqeRTe3P3YMMZ4MRonvQBUhFbE6T8g== X-Received: by 2002:a05:6638:1442:: with SMTP id l2mr32029078jad.186.1641533404530; Thu, 06 Jan 2022 21:30:04 -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 c18sm1843446iod.18.2022.01.06.21.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:04 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:35 -0700 Message-Id: <20220107052942.1349447-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 12/19] drm_print: wrap drm_dbg in _dynamic_func_call_no_desc X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Change __drm_dbg() macro to be CONFIG_DRM_USE_DYNAMIC_DEBUG dependent: N- keep straight mapping to exported ___drm_dbg() Y- wrap ___drm_dbg() inside _dynamic_func_call_no_desc() This patch places ~1/2 of drm.debug API messages behind dyndbg's JUMP_LABEL/NOOP optimization. The CONFIG_DRM_USE_DYNAMIC_DEBUG dependence is due to the .data footprint cost of per-callsite control; 56 bytes/site * ~2k,3k callsites (for i915, amdgpu), which is significant enough to make optional. bash-5.1# drms_load [ 7.489844] dyndbg: 239 debug prints in module drm [ 7.494010] ACPI: bus type drm_connector registered [ 7.546076] dyndbg: 81 debug prints in module drm_kms_helper [ 7.555723] dyndbg: 2 debug prints in module ttm [ 7.558920] dyndbg: 8 debug prints in module video [ 8.074699] dyndbg: 431 debug prints in module i915 [ 8.158682] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug. [ 8.574456] dyndbg: 3817 debug prints in module amdgpu [ 8.589962] [drm] amdgpu kernel modesetting enabled. [ 8.590548] amdgpu: CRAT table not found [ 8.590998] amdgpu: Virtual CRAT table created for CPU [ 8.591634] amdgpu: Topology: Add CPU node [ 8.636446] dyndbg: 3 debug prints in module wmi [ 8.768667] dyndbg: 24 debug prints in module nouveau Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 1eef315a0a65..8d6b74270c50 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -319,10 +319,36 @@ 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 @@ -497,7 +523,13 @@ void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#else +#define __drm_dbg(eCat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ + eCat, fmt, ##__VA_ARGS__) +#endif /* Macros to make printk easier */ @@ -569,7 +601,7 @@ void __drm_err(const char *format, ...); static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);\ const struct drm_device *drm_ = (drm); \ \ - if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \ + if (__drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \ drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## __VA_ARGS__); \ }) From patchwork Fri Jan 7 05:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706254 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8619EC433FE for ; Fri, 7 Jan 2022 05:30:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8784511321F; Fri, 7 Jan 2022 05:30:11 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78082113237; Fri, 7 Jan 2022 05:30:06 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id x6so5757597iol.13; Thu, 06 Jan 2022 21:30:06 -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=O69jwEK6BGWuT7bxOYDKnQEBPlUpFxQn3cSq5pD/L6c=; b=kjIfxzNx9rucec9vax5OFMutL6FvvqBipuTamNE+LERXDRo6gx8l/eHFoPN6aT+3aN 839At6W/5jr7R8zFP3y1+IwGhQE39mEt7TDVl3kRBKxcuorV8/pxARug/hXVBmf569pS JrT3PgROyKCagtD+A6Gwn+Zi0Ha6/M1YNlHEvnWCqADuPkOrlo5g3V3KeXEu50IoqxNI VxzhW5roni2KOcI2LE+/afrWFB7QTwTKMr9s5K6OdYPK/lzQNU95S8l0TmNIsgmOCR4f 0MoIrxeICOcqDG3fniszaXgabKKQoGpnyxn6NaSlmPuvSP+XUpFOGumJBlcrv7/XAJfv jWMA== 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=O69jwEK6BGWuT7bxOYDKnQEBPlUpFxQn3cSq5pD/L6c=; b=I5lvRurycf+Nyox/hk8QPwUuYt0qU12lj1fOZ8MHSWbOBBOgDS31PU2mNaadhENpFX TIen7i1/LnY1qkybFj3ftttQxSBHwcm+lQPBRGTuHKY+tKOSJh7POIHxpAgWLx1Dj4LX GRNn2O6AvCTGQ/UW3EDJwfyiqPSrrx9LlZq7bumIPdyvwJqMv6T4yB4k60GKnX1nKho0 ZiHft3PvTeCH62YNdoFHFNY9KPolNnXIBY5Yl/XVi72rp7YSyiRmqSYOnNAxDs6IWgBe MOStsfctnARzFyR8d0SM1SMRF3+u7jUHaEH0q2w+1fWZvBmYGgD5yUwOTRYo0voZ1DPq urlg== X-Gm-Message-State: AOAM5313VqDQhA4K+5CnvZZRmnbtyl5391XuaHzUZq/lCdc0XyTb/2Yy EAxqgZ4rBa8rE9SLooxE5g0= X-Google-Smtp-Source: ABdhPJxTkXRmMBve2LtAb8XAmhR2+L3R66b7dP6c1YxaZdMVvWReyuf74i4hY6RdW4AdcGIW1ZI0lw== X-Received: by 2002:a05:6638:370c:: with SMTP id k12mr28932444jav.25.1641533405766; Thu, 06 Jan 2022 21:30:05 -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 c18sm1843446iod.18.2022.01.06.21.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:05 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:36 -0700 Message-Id: <20220107052942.1349447-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 13/19] drm_print: refine drm_debug_enabled for dyndbg+jump-label X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 the 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 5dd6713c14f2..aab29dd6cad1 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -265,7 +265,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); @@ -290,7 +290,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); From patchwork Fri Jan 7 05:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706257 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 482C2C433F5 for ; Fri, 7 Jan 2022 05:31:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B75F111325E; Fri, 7 Jan 2022 05:30:14 +0000 (UTC) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52A3211322E; Fri, 7 Jan 2022 05:30:08 +0000 (UTC) Received: by mail-io1-xd32.google.com with SMTP id u8so5832527iol.5; Thu, 06 Jan 2022 21:30:08 -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=fs9SXvpvEEnkA+pZj7l54+pYQd7M1OVNoq6NoKKp5pE=; b=BPvCeyaEsfkyYHJplLo278shtoIIb9ttoxvNbZHAmTThf0T7b3rtFx2a9vUqNjwfch nioeXn9/nQgokrJmOmYK7+lr0g8nICaJBJ3Q4VI6rRotAKLBeTIMbxum2W3CpjVblIYE M1NTdeWOTZn7ugu7aIsCs4JuwjgHyVnQTbaPdKo4G+cox7pD7igqayZaElp86ZUk496Q kL7oKgoL7MofSKtlH8pkHPDrmGVacnLJTs3AuN2KCdUUYu5tRSweIKgg7xAq1gdSJjnK JtZZ+tfuAwxsJ0/GoTVV2w7fUuyWt5NZSSib698HNisxorA4k54ln+rMEUBH9shuVVKj Ut6A== 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=fs9SXvpvEEnkA+pZj7l54+pYQd7M1OVNoq6NoKKp5pE=; b=sOsujmx9RmbV+wOQUgoLOgbwddh+l6AYFDArRd4CVj9mlpgWeHAgRvTjMAxTbYfCNY 61UH8m69XEoIW06d9THfJiPE37dBXpipzhGUc0uqQ6H6mp3li4aCjH/uXUKSL93ikO4v dNAoNlJHKwc9qThiJAT35wptKFYqSo9rRaZlyKQ9qFemJBxZpaVVSKoJcmW+d/p7Epno c5d5C/5YxHOTmOD+KAzcfCHi4VpmO4QKdZGxg5YVDBMYjfFI8sX0UEa2RWB4Ts+avVcG 2scDVg8xLILl4KtnRAcvygDpPE3+HFBxkjq6V+tEpfQJxs5YgDv7Sy3LUkgwaIRXihLK gt4g== X-Gm-Message-State: AOAM532zy9mBPeWI0NL0HCk0D294aBokzrHizUdWquJERk8E01AYPnmP DMqmUAQxNAgfQ7TY7TbcoGA= X-Google-Smtp-Source: ABdhPJx7+AElBptGJel+f8XWKrTSvq1aQzmSbXkyUTKq/TkWKsGnfjRusoZRcHuw2zq/ku/ipdX6lA== X-Received: by 2002:a05:6638:1244:: with SMTP id o4mr26844964jas.80.1641533406977; Thu, 06 Jan 2022 21:30:06 -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 c18sm1843446iod.18.2022.01.06.21.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:06 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:37 -0700 Message-Id: <20220107052942.1349447-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 14/19] drm_print: prefer bare printk KERN_DEBUG on generic fn X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_print.c calls pr_debug() just once, from __drm_printfn_debug(), which is a generic/service fn. The callsite is compile-time enabled by DEBUG in both DYNAMIC_DEBUG=y/n builds. For dyndbg builds, reverting this callsite back to bare printk is correcting a few anti-features: 1- callsite is generic, serves multiple drm users. its hardwired on currently could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading they describe only the generic site, not end users IOW, 1,2 are unhelpful at best, and possibly confusing. reverting yields a nominal data and text shrink: text data bss dec hex filename 462583 36604 54592 553779 87333 /lib/modules/5.16.0-rc4-lm1-00008-ged3eac8ceeea/kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 /lib/modules/5.16.0-rc4-lm1-00009-g6ce0b88d2539-dirty/kernel/drivers/gpu/drm/drm.ko NB: this was noticed using _drm_debug_enabled(), added earlier. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index aab29dd6cad1..b911f949af5b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -23,8 +23,6 @@ * Rob Clark */ -#define DEBUG /* for pr_debug() */ - #include #include @@ -165,7 +163,8 @@ EXPORT_SYMBOL(__drm_printfn_info); void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) { - pr_debug("%s %pV", p->prefix, vaf); + /* pr_debug callsite decorations are unhelpful here */ + printk(KERN_DEBUG "%s %pV", p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_debug); From patchwork Fri Jan 7 05:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706258 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52403C433EF for ; Fri, 7 Jan 2022 05:31:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 451D3113268; Fri, 7 Jan 2022 05:30:16 +0000 (UTC) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2630211323A; Fri, 7 Jan 2022 05:30:09 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id y70so5851472iof.2; Thu, 06 Jan 2022 21:30:09 -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=JbeTRv2Fyfg8UJiPWSnBwDsjkhtsGcD/brFxy1OI2So=; b=VK9Dj9vp/R6vihhAELn97CTPOQgU/Fn1YhQ4WuPOYiEBxoo0M5cBeUusxl5g7Ha4Ks WrSXQpzI9UTEbJuljMm74kc+SOYx4WA60VHSaWlMnqZLGSpzXGYHb5CjApMc8ayRHXdb WVxj63BzSSHT1ezgUPu83Zo54NGeKs9Zr8fg9VJ5Cce/XGIJIhdo3KaIQVI41J2/2Lf+ ih/u+bokNAuNDPcsOTLlcmCFeGVo1AadQJrR31RrPEgAU2ShgFfYB6nhOEK8TtKNUXzi 6mTbi2qAxMgfIuE5P3OOX5a39/63S/9+7gqCBnDd1OoaXvruf1pURBiPx2C3jbSLyZ5B 2b6w== 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=JbeTRv2Fyfg8UJiPWSnBwDsjkhtsGcD/brFxy1OI2So=; b=BmjDXqVH5ZYFNEDb6uFGF7C9pcX+8PMg7Y3daCc7MRBTysNqxRIrgDGbDSaUjX0CiV /R9cwJeaJ8PFVwLApaU42/RcdFNEytf2TH+5EjNvjP9Tx7Gpu5DoqNUa3x7a4lBqG8Ql sHj0vSZ3eW9XuHox3rw8clezYfcsjEwy5U1GjcDrN9YKUR1/pWGkQ/IOGjH4xZaOiN+O qKBds/AeEKKVOJliimH3fK3R1TXkkIEwhqi1F+pDS7ZZ/TnvwNMDO5mVNtm5CXrk/ztL bhi5XwhbQ0fsDwuz9jK7ARsHHa4eQ9fMJlgExsNaVXBIzVkp1XGtXFOgSk2S4lgp56q8 Hurg== X-Gm-Message-State: AOAM531O7QrAOnF832hEcFXtct8//pLNsOGHv17Azn96M563JyvrUQeP 55HN0NBGn8yyF+6GRtahjhg= X-Google-Smtp-Source: ABdhPJyyRxeOryfv21hSwrmrhXKwCfWI/bo+N4N54ntb26BYYZ7XqFH1lAI3RsHnWdKPEMsyhDvqMQ== X-Received: by 2002:a02:b603:: with SMTP id h3mr30604302jam.233.1641533408224; Thu, 06 Jan 2022 21:30:08 -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 c18sm1843446iod.18.2022.01.06.21.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:07 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:38 -0700 Message-Id: <20220107052942.1349447-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 15/19] drm_print: use _dynamic_func_call_no_desc_cls X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Upgrade the current use of _dynamic_func_call_no_desc(), adding the suffix and the category arg. The arg has been available via the macros implementing the drm.debug api, but dyndbg lacked a simple way to represent it and use it until recently. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 8d6b74270c50..0c704610c770 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -414,8 +415,8 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, __drm_dev_dbg(dev, eCat, fmt, ##__VA_ARGS__) #else #define drm_dev_dbg(dev, eCat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ - dev, eCat, fmt, ##__VA_ARGS__) + _dynamic_func_call_no_desc_cls(fmt, eCat, __drm_dev_dbg, \ + dev, eCat, fmt, ##__VA_ARGS__) #endif /** @@ -524,11 +525,11 @@ __printf(1, 2) void __drm_err(const char *format, ...); #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) #else #define __drm_dbg(eCat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ - eCat, fmt, ##__VA_ARGS__) + _dynamic_func_call_no_desc_cls(fmt, eCat, ___drm_dbg, \ + eCat, fmt, ##__VA_ARGS__) #endif /* Macros to make printk easier */ From patchwork Fri Jan 7 05:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706261 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58453C433FE for ; Fri, 7 Jan 2022 05:31:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 88424113271; Fri, 7 Jan 2022 05:30:18 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DEB111324D; Fri, 7 Jan 2022 05:30:11 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id e128so5859460iof.1; Thu, 06 Jan 2022 21:30:11 -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=qYyJ2gcl34AtG+ZwzeuT+zalv5tvCFacm4aJJ3L+PFU=; b=n5cDKpY/cS3ddfduU75FLd0mm/XG5Pm3C7omvy4wXv3FY5Ljt7Dn096WxhuV01V/uR agjlDHLToD0Cg8Tc+m/rD0aVxrP3mLxB2DCAHY6VKw3DlGhz6uOzIMJCFLkFg/Fk6fQa m9kieutSbD75E/lHgv7lCWlrz7p9i+Jqkz2sxDfcRXkdx83cO+prvc5LWdXNmJWfjeCK QnPA+yX6Y8dW0FOO1MGgT6XRj2b6FzA56X4/L1wM8wzyddIVlrUX8cICTROh6Xc5PHCS 2OhKsU+un9BbaB5LdDVwo5pAfJIOYGuGyHfic5lyoWk6pCAn/UGOkjfDYClncsTWpPd2 VZtg== 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=qYyJ2gcl34AtG+ZwzeuT+zalv5tvCFacm4aJJ3L+PFU=; b=6mqX1yvQpxl0tOf0PjnTQVdye7D+Yz+PxpCBCsnHTV9YEIIJTBPY9BFmqWKFrVgElB dc2FVXtVHnUHa2wCPk1OO5zvScaLH9bcqRRqiG+jpEnI/NH3icJujyyH864rT8l2OPj6 nEUhrbPTVZ1lN/T8OCGQWyRzQe/Xxu+cc90Y6Ih22E75vyS949Jr7ygjvNRNoldfPEWA 3j9XD2Z7s1SR9pANwiVa2INqF+1ios0vwoVV0pShLi1h7Zwaco7tfvtfIUz1330CNatL hj0LodrDq/5V3dZA0EhpWMOFfHKIa75+DxYLmf0omimsLSV631v68mcek3czTXz/9TKb 904Q== X-Gm-Message-State: AOAM530qBmRBfSl2ze5OUInWfMnaZn4l9cSUlpjolR6elxijYhgYgsf7 fL/7/1vjgbexUXiJ7NfbU4E= X-Google-Smtp-Source: ABdhPJyZ2DQ/f+275CIjKbX91nJCLDE4hjHieIEqtncwcYdaOvFghGTgMmBnVGaYwBuweKjCTTGK8A== X-Received: by 2002:a5d:8543:: with SMTP id b3mr29143476ios.11.1641533409455; Thu, 06 Jan 2022 21:30:09 -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 c18sm1843446iod.18.2022.01.06.21.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:09 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:39 -0700 Message-Id: <20220107052942.1349447-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 16/19] drm_print: add struct _ddebug desc to drm_*dbg X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" A recent commit adding trace-events to drm noted: trace_*() additions are strictly redundant with printks to syslog, not properly placed to reduce overall work. That was because it didn't have the struct _ddebug *descriptor, whose .flags specify TRACE and PRINTK actions on a controlled callsite. So it could only duplicate the stream (from the enabled callsites). To issue TRACE, PRINTK selectively: - add struct _ddebug * param to prototypes and functions: ___drm_dbg(), __drm_dev_dbg() add "struct _ddebug;" to name the ptr-type, to silence warning. - adjust the forwarding macros: drm_dbg, drm_dev_dbg to provide a descriptor, or NULL. basically this is dropping the _no_desc_, ie using _dynamic_func_call_cls(), since the callee can now accept it. - add if (desc->flags ...) TRACE / PRINTK actions. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 25 ++++++++++++++++--------- include/drm/drm_print.h | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index b911f949af5b..8c33302212fc 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -258,8 +258,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -267,24 +267,31 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, if (!__drm_debug_enabled(category)) return; + /* we know we are printing for either syslog, tracefs, or both */ va_start(args, format); vaf.fmt = format; vaf.va = &args; if (dev) { - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - trace_drm_devdbg(dev, category, &vaf); + if (desc->flags & _DPRINTK_FLAGS_PRINTK) + dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + + if (desc->flags & _DPRINTK_FLAGS_TRACE) + trace_drm_devdbg(dev, category, &vaf); } else { - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - trace_drm_debug(category, &vaf); + if (desc->flags & _DPRINTK_FLAGS_PRINTK) + printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + + if (desc->flags & _DPRINTK_FLAGS_TRACE) + trace_drm_debug(category, &vaf); } va_end(args); } EXPORT_SYMBOL(__drm_dev_dbg); -void ___drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 0c704610c770..6d43b81a0ee4 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -360,9 +360,9 @@ static inline bool drm_debug_enabled(enum drm_debug_category category) __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); -__printf(3, 4) -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...); +__printf(4, 5) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...); /** * DRM_DEV_ERROR() - Error output. @@ -412,11 +412,11 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, eCat, fmt, ...) \ - __drm_dev_dbg(dev, eCat, fmt, ##__VA_ARGS__) + __drm_dev_dbg(NULL, dev, eCat, fmt, ##__VA_ARGS__) #else #define drm_dev_dbg(dev, eCat, fmt, ...) \ - _dynamic_func_call_no_desc_cls(fmt, eCat, __drm_dev_dbg, \ - dev, eCat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(eCat, fmt, __drm_dev_dbg, \ + dev, eCat, fmt, ##__VA_ARGS__) #endif /** @@ -519,8 +519,8 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * Prefer drm_device based logging over device or prink based logging. */ -__printf(2, 3) -void ___drm_dbg(enum drm_debug_category category, const char *format, ...); +__printf(3, 4) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); @@ -528,8 +528,8 @@ void __drm_err(const char *format, ...); #define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) #else #define __drm_dbg(eCat, fmt, ...) \ - _dynamic_func_call_no_desc_cls(fmt, eCat, ___drm_dbg, \ - eCat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(eCat, fmt, ___drm_dbg, \ + eCat, fmt, ##__VA_ARGS__) #endif /* Macros to make printk easier */ From patchwork Fri Jan 7 05:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706260 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EE9BC4332F for ; Fri, 7 Jan 2022 05:31:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47C3A113276; Fri, 7 Jan 2022 05:30:19 +0000 (UTC) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD906113250; Fri, 7 Jan 2022 05:30:11 +0000 (UTC) Received: by mail-il1-x12b.google.com with SMTP id x15so3808841ilc.5; Thu, 06 Jan 2022 21:30:11 -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=MXP101OBKmlnLofCkQPbu2Mn+KOJTGfJ6b+NIiHZLS4=; b=D0dcLl/Cn+05vmbxEjZI4ubBfvPU4FZ8FgYhK/JyJWNyoH+7qZpiKJfVRL5ulKNTRy jFDcUxZ91EN16Ibemv9vUXdY1ReZQaflP4hcZQHEHRJOjkVNQ5W9khjmIANSER/NtbMP I4e1dlHmX0Z6WSZAvdoJ45Sber5oXYOi2xew3LlQ/9tbieVU8eWL59q2mMsc1wpwOtd1 khuF/ia6OakQnXTmlFRLOh0StIV+ANTNdh7eDyd44bVKYA02wrjMsxD16+I9JEcpjPHa 2Kwykx0kyqSEmt2NAzQrL+9zCN6drsk+OR194QbU7V6JD8Hd2GYg0XtH/YYP+ALyhuej BSgw== 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=MXP101OBKmlnLofCkQPbu2Mn+KOJTGfJ6b+NIiHZLS4=; b=zJqOQxljlVinyCAxyEzzM8lBbSl2AEyz1CgJTVk7c8KSRQxCEgX6xikQ1MpjNZaGdX VPT6Sq6GYakkAPZb8uW8K019ChBVSY8BwQNVLAuXcLVwkl9Tfg7a9yFZUioMeEeTOSkS WrjnAyyOh2t2W0KIMChDBP8hIjLNyI0FXfd+mJE28DCyRIt+4tm26UvsUe9AsCvvbj5K mWvUPzCmMsAuUxghd9he4Ys7giQXkqQ8gjoYe9lsJ/Zj0N56fN2O/0fRvsXfRW2gBiZb bzlirMKnf03eeVc/+jT8rNcyBjWgwfR5gBLosm4UHW/4tjJIPgawTnWCyMUQqmGfjYKJ swLA== X-Gm-Message-State: AOAM5334Xefsn1dMHQhdOfoqxXUSiXceH/JC1imcreHUu41wI6gXW1iW zNuefn2dA1/tRd/Bn9lnpkg= X-Google-Smtp-Source: ABdhPJyJV+ie8tIgRKUsxFge8djV88zEG6NNzur6iycvq7O0pB1HrKdK6LcPy9o+zi6LoQYAKFNbXA== X-Received: by 2002:a92:c685:: with SMTP id o5mr29675045ilg.152.1641533410743; Thu, 06 Jan 2022 21:30:10 -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 c18sm1843446iod.18.2022.01.06.21.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:10 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:40 -0700 Message-Id: <20220107052942.1349447-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 17/19] drm_print: add struct _ddebug *desc to trace-drm-*() params X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Replace trace-drm-*()s category param with struct _ddebug *desc; it has .classid field, which is the category. This brings the events closer in line with those added for dyndbg; at least the 1st param, and possibly the struct device (tb-checked). There are still differences in the tail of the prototypes; vaf vs text + len, which probably breaks CLASS sharing. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 6 +++--- include/trace/events/drm.h | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 8c33302212fc..0a15a4ec5ead 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -278,14 +278,14 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, __builtin_return_address(0), &vaf); if (desc->flags & _DPRINTK_FLAGS_TRACE) - trace_drm_devdbg(dev, category, &vaf); + trace_drm_devdbg(dev, desc, &vaf); } else { if (desc->flags & _DPRINTK_FLAGS_PRINTK) printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); if (desc->flags & _DPRINTK_FLAGS_TRACE) - trace_drm_debug(category, &vaf); + trace_drm_debug(desc, &vaf); } va_end(args); } @@ -306,7 +306,7 @@ void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const ch printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); - trace_drm_debug(category, &vaf); + trace_drm_debug(desc, &vaf); va_end(args); } diff --git a/include/trace/events/drm.h b/include/trace/events/drm.h index 944aedaf6aa6..bfe1fff923d8 100644 --- a/include/trace/events/drm.h +++ b/include/trace/events/drm.h @@ -9,25 +9,25 @@ /* drm_debug() was called, pass its args */ TRACE_EVENT(drm_debug, - TP_PROTO(int drm_debug_category, struct va_format *vaf), + TP_PROTO(struct _ddebug *desc, struct va_format *vaf), - TP_ARGS(drm_debug_category, vaf), + TP_ARGS(desc, vaf), TP_STRUCT__entry( - __field(int, drm_debug_category) + __field(struct _ddebug *, desc) __dynamic_array(char, msg, 256) ), TP_fast_assign( int len; + char *p = __get_str(msg); - __entry->drm_debug_category = drm_debug_category; - vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + __entry->desc = desc; + len = vsnprintf(p, 256, vaf->fmt, *vaf->va); - len = strlen(__get_str(msg)); - if ((len > 0) && (__get_str(msg)[len-1] == '\n')) + if ((len > 0) && (len < 256) && p[len-1] == '\n') len -= 1; - __get_str(msg)[len] = 0; + p[len] = 0; ), TP_printk("%s", __get_str(msg)) @@ -35,30 +35,30 @@ TRACE_EVENT(drm_debug, /* drm_devdbg() was called, pass its args, preserving order */ TRACE_EVENT(drm_devdbg, - TP_PROTO(const struct device *dev, int drm_debug_category, struct va_format *vaf), + TP_PROTO(const struct device *dev, struct _ddebug *desc, struct va_format *vaf), - TP_ARGS(dev, drm_debug_category, vaf), + TP_ARGS(dev, desc, vaf), TP_STRUCT__entry( - __field(const struct device*, dev) - __field(int, drm_debug_category) + __field(const struct device *, dev) + __field(struct _ddebug *, desc) __dynamic_array(char, msg, 256) ), TP_fast_assign( int len; + char *p = __get_str(msg); - __entry->drm_debug_category = drm_debug_category; + __entry->desc = desc; __entry->dev = dev; - vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + len = vsnprintf(p, 256, vaf->fmt, *vaf->va); - len = strlen(__get_str(msg)); - if ((len > 0) && (__get_str(msg)[len-1] == '\n')) + if ((len > 0) && (len < 256) && p[len-1] == '\n') len -= 1; - __get_str(msg)[len] = 0; + p[len] = 0; ), - TP_printk("cat:%d, %s %s", __entry->drm_debug_category, + TP_printk("cat:%d, %s %s", __entry->desc->class_id, dev_name(__entry->dev), __get_str(msg)) ); From patchwork Fri Jan 7 05:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706259 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0E63C433EF for ; Fri, 7 Jan 2022 05:31:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 012BC113275; Fri, 7 Jan 2022 05:30:19 +0000 (UTC) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id A11A2113251; Fri, 7 Jan 2022 05:30:12 +0000 (UTC) Received: by mail-il1-x12b.google.com with SMTP id v18so3782982ilm.11; Thu, 06 Jan 2022 21:30:12 -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=ZLyZe+zqEr28zNe4xKfsfPFT08eh4jYXBYI+HMn/i1o=; b=aab8Shi1gVQJ7GTizRPNRon73x/TgmPaLmEmERosCRUO/w2C47+MsLojqFv7cY2BFa dz5HB9pwP0blHrgSvuMI2wy7RyMqwfs6aUlSlThy85prA0y2QVNpw1OsgX1oJnA4nPpE 0Rha5Qx59HmnhO6hgvaYPqFFb0YYLyk2D373LCAf102S61Ol1E4y9C3saaaFCJ4/rUgj UcMKwydoScFgatDAK3PfF8Ker8hJLhX9aRI/Ci1k6u4Shbn7NaBp1FLjDcu+T5ucYuD8 POQZ6FGj+i22fW0G9pETJwbaQKhVXTVqIjUH0lU/e5ijkoeCCjVYidkGCqqWPjF/0oVy wXpw== 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=ZLyZe+zqEr28zNe4xKfsfPFT08eh4jYXBYI+HMn/i1o=; b=wTI4+qJvTqSmgSOr34e21y8ySZObZDkNEl6Gx8Gh/p6VlhC13/KvZ2AjNIhEiQK6BY KnwjJxxD9Ed+51Sc6Yta2rgh9IfSbqCTj5NdQ31OobnCWfsEfytc7bBpvAE7ad2YWbkB f1q0e1jfdb9Xkd0DjncY9XajlVy0gudug8ZIz+AXQRAbLV6nO3271uKMYtwfD7O0jFVM f17M/foMmtAV/2ipSzX7Kd2nn1TDZ3GyZqaxaPhrgOPD4NdWZgAS+cEt3EEU0sq3gB/d i4gS57AifPkEdzM5USSchTm0ZmDbtBhhQog1yz50tVqMyARiAyi6GK9E5wJjXJMisaJU YvEQ== X-Gm-Message-State: AOAM533lCwrtJjgM6wuHXRmNRcB48oRtYMPIVvg8fUST8AHtO/vWl6/Y PVYkvGnRlmX2ijtwgqkkixQ= X-Google-Smtp-Source: ABdhPJya09sR3zYcLyhJ2X2tUElbcml2PEfFZFC4rQHb+JD4zfRwDEJZy4pc64tj1n0Mr+SqKaRLug== X-Received: by 2002:a05:6e02:501:: with SMTP id d1mr28614110ils.285.1641533411913; Thu, 06 Jan 2022 21:30:11 -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 c18sm1843446iod.18.2022.01.06.21.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:11 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:41 -0700 Message-Id: <20220107052942.1349447-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 18/19] dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, var, bitmap_desc, classes..) allows users to create a drm.debug style (bitmap) sysfs interface, to control sets of pr_debug's according to their .class_id's 1st, due to a recent commit, this already works: echo "module drm class 1 +p ; module drm class 3 +p" >control With the macro, this is basically equivalent: # this also turns off all other classes. echo 0x05 > /sys/module/drm/parameters/debug To use: DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, "drm.debug - bits => categories:", /* vector of uint:4 symbols, ala enum drm_debug_category */ DRM_UT_CORE, DRM_UT_DRIVER, DRM_UT_KMS ... ); To support the macro, the patch includes: - int param_set_dyndbg_classbits() - int param_get_dyndbg_classbits() - struct kernel_param_ops param_ops_dyndbg_classbits Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. get/set use an augmented kernel_param; the arg refs a new struct dyndbg_bitmap_param containing: A- the vector of classes (drm.debug "categories") being controlled For CONFIG_DRM_USE_DYNDBG=y, enum drm_debug_category is initialized into (struct _ddebug).class_id, so its already available to select on. B- a pointer to the user module's ulong holding the bits/state. By sharing bit-state in __drm_debug, we coordinate with existing code that still uses drm_debug_enabled(), so they work unchanged. NOTES: param_set_dyndbg_classbits() compares new vs old bits, and only updates each class on changes. This maximally preserves the underlying state, which may have been customized via later `echo $cmd >control`. So if a user really wants to know that all prdbgs are set precisely, they must pre-clear then set. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 45 ++++++++++++++++++++- lib/dynamic_debug.c | 75 +++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e9483cd9ac1c..318ac44a0d4a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -20,7 +20,9 @@ struct _ddebug { const char *function; const char *filename; const char *format; - unsigned int class_id:4; +#define CLS_BITS 4 +#define DD_MAX_CLASSES (1 << CLS_BITS) + unsigned int class_id:CLS_BITS; unsigned int lineno:18; /* * The flags field controls the behaviour at the callsite. @@ -202,6 +204,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +struct kernel_param; +int param_set_dyndbg_classbits(const char *instr, const struct kernel_param *kp); +int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include @@ -248,6 +254,43 @@ static inline int dynamic_debug_exec_queries(const char *query, const char *modn return 0; } +struct kernel_param; +static inline int param_set_dyndbg_classbits(const char *instr, const struct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +struct dyndbg_classbits_param { + unsigned long *bits; /* ref to shared state */ + const int classes[]; /* indexed by bitpos */ +}; + +#if defined(CONFIG_DYNAMIC_DEBUG) || defined(CONFIG_DYNAMIC_DEBUG_CORE) +/** + * DEFINE_DYNAMIC_DEBUG_CLASSBITS() - bitmap control of classed pr_debugs + * @sysname: sysfs-node name + * @_var: C-identifier holding bit-vector (Bits 0-15 are usable) + * @desc: string summarizing the controls provided + * @classes: vector of callsite.class_id's (uint:4, 0 is reserved) + * + * This macro implements a DRM.debug API style bitmap, mapping bits + * 0-15 to classes of prdbg's, as initialized in their .class_id fields. + */ +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, _var, desc, ...) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_classbits_param ddcats_##_var = { \ + .bits = &(_var), .classes = { __VA_ARGS__, 0 } }; \ + module_param_cb(fsname, ¶m_ops_dyndbg_classbits, &ddcats_##_var, 0644) + +extern const struct kernel_param_ops param_ops_dyndbg_classbits; + +#else /* no dyndbg configured, throw error on macro use */ + +#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "CONFIG_DYNAMIC_DEBUG|_CORE && -DDYNAMIC_DEBUG_MODULE needed to use this macro: " #fsname #var) + +#endif + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 419d4664e724..40ca7973a0f8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -610,6 +610,81 @@ int dynamic_debug_exec_queries(const char *query, const char *modname) } EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); +#ifdef CONFIG_MODULES +#define KP_MOD_NAME kp->mod->name +#else +#define KP_MOD_NAME NULL /* wildcard */ +#endif +#define FMT_QUERY_SIZE 128 /* typically need <40 */ +/** + * param_set_dyndbg_classbits - bits => categories >control setter + * @instr: string echo>d to sysfs + * @kp: kp->arg has state: bits, map + * + * Enable/disable prdbgs by their "category", as specified in the + * DEFINE_DYNAMIC_DEBUG_BITGRPS.classbits argument. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classbits(const char *instr, const struct kernel_param *kp) +{ + unsigned long inbits; + int rc, i, matches = 0, totct = 0; + char query[FMT_QUERY_SIZE]; + const struct dyndbg_classbits_param *dcp = kp->arg; + + if (dcp) { + pr_err("set_dyndbg_classbits: no bits=>queries map\n"); + return -EINVAL; + } + rc = kstrtoul(instr, 0, &inbits); + if (rc) { + pr_err("set_dyndbg_classbits: expecting unsigned int\n"); + return rc; + } + vpr_info("set_dyndbg_classbits: new 0x%lx old 0x%lx\n", inbits, *dcp->bits); + + for (i = 0; i < DD_MAX_CLASSES && dcp->classes[i]; i++) { + if (test_bit(i, &inbits) == test_bit(i, dcp->bits)) + continue; + snprintf(query, FMT_QUERY_SIZE, "class %d %cT", dcp->classes[i], + test_bit(i, &inbits) ? '+' : '-'); + + matches = ddebug_exec_queries(query, KP_MOD_NAME); + + v2pr_info("bit-%d: %d matches on class:%u\n", i, + matches, dcp->classes[i]); + totct += matches; + } + *dcp->bits = inbits; + vpr_info("total matches: %d\n", totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg_classbits); + +/** + * param_get_dyndbg_classbits - classbits reader + * @buffer: string description of controlled bits -> classes + * @kp: kp->arg has state: bits, map + * + * Reads last written bits, underlying prdbg state may have changed since. + * Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classbits(char *buffer, const struct kernel_param *kp) +{ + const struct dyndbg_classbits_param *p = kp->arg; + unsigned long val = *p->bits; + + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", val); +} +EXPORT_SYMBOL(param_get_dyndbg_classbits); + +const struct kernel_param_ops param_ops_dyndbg_classbits = { + .set = param_set_dyndbg_classbits, + .get = param_get_dyndbg_classbits, +}; +EXPORT_SYMBOL(param_ops_dyndbg_classbits); + #define PREFIX_SIZE 64 static int remaining(int wrote) From patchwork Fri Jan 7 05:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12706262 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0197DC4332F for ; Fri, 7 Jan 2022 05:31:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B496113265; Fri, 7 Jan 2022 05:30:21 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id C50ED113257; Fri, 7 Jan 2022 05:30:13 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id y11so5825934iod.6; Thu, 06 Jan 2022 21:30:13 -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=WQJWjrpvTcrk4L61/TAk/KIkMk45wkVxi65EcBB2wtY=; b=d2IudHU+bG8/bgad7PeXNNcoFRsOkHVCShVHm/vs56LEwWSHNLuOiFpEy9DKP9l6Tr NRBxvirumd6cXxSnkNLyfQ8A+72NlcNsvL7hvZj4qmTJqiiF7Csdbvt56vxPZKgm+KVa LrSlrBhRhlCqqGdxdNHqwGpDCyTnA+YPYbfsQ7G96lw32cSPWQqyRz6ZiwfsJR6RI6by O/u4dN98TOOAoUCbAY7mPaIye9Ia4ZItYtBJMihh1+Ydm/s5SHgsKj5zmzh/47Sa491b AMMv+xW6DkrMNDF0c1KBxG7IMcy/cHwsIMDRlFUpK5z1bz9+nVuZCJuiiCAmG8ZEJ5nx Qodg== 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=WQJWjrpvTcrk4L61/TAk/KIkMk45wkVxi65EcBB2wtY=; b=apIvMQ2vnGgCsmgiVxVk0ZbYyosGw/22RAQomiwgh49lrthjZCHrrUFoeVPEFMXgZh H5Q7D/UNjkfB1tNkxqLubzOd8zX+vbH3aK0LceGe3v+vnSImLHlYd3S7feHiNqZLpAWA C6O3P/wOa7GkYaeqQsRvTE5UCqaoO+dHeAGAtiYTeMorVXdiSL1CQyHQbKsJ/rxdSAX6 2OoPnrmfPasHZZFsPOGcbrvCCcN1V4Fkva932N/NjzFt8ZnxbWMtOB+A5B3Y5f78CZFH wScCxTIFQNAlfYMdQOcMIY86FMD8FfqxwiR1zqv02DMl4QLSDUwFJyXqxjclgQDtYAa1 /BSg== X-Gm-Message-State: AOAM533AnTV4gW9j/kF3+upt8ap8/oeetkyPhzGpqyfTU1zSjvT5tXaQ wVB0A78KtkXk+gGA8ulNd/k= X-Google-Smtp-Source: ABdhPJyGlqD7G+Do4+iTOVF8S6gJU+ENiyjS7KIHnyFyCqamp+AFbBw5NgCHK7Jn+6e1D4PE8CKoHg== X-Received: by 2002:a05:6602:2218:: with SMTP id n24mr29175293ion.182.1641533413048; Thu, 06 Jan 2022 21:30:13 -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 c18sm1843446iod.18.2022.01.06.21.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 21:30:12 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, 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 Date: Thu, 6 Jan 2022 22:29:42 -0700 Message-Id: <20220107052942.1349447-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107052942.1349447-1-jim.cromie@gmail.com> References: <20220107052942.1349447-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v11 19/19] drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quic_saipraka@quicinc.com, arnd@arndb.de, jim.cromie@gmail.com, catalin.marinas@arm.com, linux-arm-msm@vger.kernel.org, mingo@redhat.com, quic_psodagud@quicinc.com, maz@kernel.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" if CONFIG_DRM_USE_DYNDBG=y, use new macro to create the sysfs bitmap to control drm.debug callsites. DEFINE_DYNAMIC_DEBUG_CLASSBITS( debug, __drm_debug, "drm.debug - control summary", /* inline vector of dyndbg.class_id (uint:4, 0 is reserved) */ DRM_UT_CORE, DRM_UT_DRIVER, DRM_UT_KMS, DRM_UT_PRIME, DRM_UT_ATOMIC, DRM_UT_VBL, DRM_UT_STATE, DRM_UT_LEASE, DRM_UT_DP, DRM_UT_DRMRES ); NOTES: dyndbg.class_id is uint:4, values 1-15 are valid. 0 is reserved primarily for non-classified callsites (aka: prdbgs), and is thus available to mark the end of the vector (and is added by the macro). RFC: how to fold this in, with multiple macro expansion ? Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 20 ++++++++++++++++++-- include/drm/drm_print.h | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 0a15a4ec5ead..0de562e5306a 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -41,7 +41,7 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned int __drm_debug; +unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" @@ -53,7 +53,23 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -module_param_named(debug, __drm_debug, int, 0600); + +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +module_param_named(debug, __drm_debug, ulong, 0600); +#else +DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, + "enable drm.debug categories - 1 bit per category", + DRM_UT_CORE, + DRM_UT_DRIVER, + DRM_UT_KMS, + DRM_UT_PRIME, + DRM_UT_ATOMIC, + DRM_UT_VBL, + DRM_UT_STATE, + DRM_UT_LEASE, + DRM_UT_DP, + DRM_UT_DRMRES); +#endif void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 6d43b81a0ee4..ebed5ba2dc24 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -36,7 +36,7 @@ #include /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; /** * DOC: print