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: 12706216 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A46E7C433EF for ; Fri, 7 Jan 2022 05:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SKZv7/ho0JJWAJ65HWtLtI8wJvcTW6nKjtgC/G4JSoE=; b=bU+g9bGyyQCGfU aC23T3xkAlJyZ8MkNzppfm7fL50HXzPA2hTdX9ui2psIz23gtqyQ586kJK/wtug4Nhx3adGTqF71A 8txrs8eiSjoqFN52ua6gPHL+LM/Z9G3kCZFRZVkRvbep/wBEtPJR36rZPWz2fp+DrF7h42SE6c6t+ jLl6BkvzYmh7w6J5cSY3qCxYBBKB7vc1w0TutRrqJwOr/513B6gjGeMZhxo8aJ+uAre6sNwwAxEV2 0i+RdGGsFAbuVqfjB8sq7CyE74Y0OhyDCa6LFFUa+If0UvuUflqwR3fzyxT0GOx7PuZ/YsHzaqMn7 fjlhDJvOOC+sjgu7eUpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpG-002NN6-Cu; Fri, 07 Jan 2022 05:30:06 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp1-002NGA-UV for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:29:53 +0000 Received: by mail-il1-x133.google.com with SMTP id r16so2097799ile.8 for ; 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=upCEDs65Vv9J1AXUz4J5boUTfqEJia2L1J/ErAXjjqhOiBc8lHLUJV09RgBXkXa3PO USafCksknL1Fx2DLVHeVelcrfXV7egnuCTCo6dBbZ6km7F2SS9PrV0R3Ah/52pM7n6if rQsX1WRYIQjhWUPrQ6NdhJQ4RfzJ+O6tdecG87I4wCSySvmp3ZkJB5x8z3mvQvOnCdxx 03bCJ5HicQ7kT6SOWtwjUB2S61oa+PhgameukDM5dh3VBCE0WPmZGozGX1N/ilig0oXE 22ZId3BE8TLRCiUE/4xFQu++ySGoahXc64Afk4oFgWQrcAGMtK4QB8Ve9mVLhwIC5Ic5 Vdlw== X-Gm-Message-State: AOAM533U+TFqIr/Ff033BqoHD8TbRRX6WAuYvTgVuphNS3h5iFzefRBp zjp47g5G0+zjtgdWMSXatKE= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v11 01/19] dyndbg: add _DPRINTK_FLAGS_ENABLED 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212952_005130_52029D50 X-CRM114-Status: GOOD ( 15.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706217 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F44FC433F5 for ; Fri, 7 Jan 2022 05:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mfa4U1/yGcwRIIhKbpz0cc6B5iNT173tzyegROTTEvY=; b=OB4fCmU9oi7aux d0v6UeZ+dhFmtZ04hlV27Etym4l1Wx+q2MbAiIYLZ0PBjdVZ2DdHLLJc08DNFPZbAdHFzvQhMANS1 YVlJCA4DXO86n1uo2cgriY1c437zzL1QQxdOArxN6HKU6VJeQDI90eiGt3ob43Z3Q11VoVyL08X2j QLVMlVxhbMsFeYJRONOAdjTJnlhTwq/+SGuzp/W1B0qWlNR8zGc6FfO1sKioY+T+xbQxlTkNxCLOt J85l159GYhZAQ1FlUB+chRMLrrgUk6IKkZh3Xp0fJ/JOLHubfreA5pMkcE99IQMewK6RhkjJLq+Jv srHds7e6TC/Ld91A+ODA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpR-002NSv-Cx; Fri, 07 Jan 2022 05:30:17 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp3-002NGn-52 for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:29:54 +0000 Received: by mail-il1-x136.google.com with SMTP id d14so3832326ila.1 for ; 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=7sKu3wz4uhdkx+HC6rm/VxHKUikC58aUbqV2JwMZQjJlQxqJFzpDtfGnatsj0W66q7 ac0QKWccXndOEU3BFzWfrIxcsIZBcnlOISPuMpVpTPHoREz7cziz6LlT4PaF1UhTwYqi i2w3/PqgxvQCRnGcq5N+zZQfEcB/z0zti2M/kR3aUjgG4wT7rIlyGD3EbTcoMSr+bWga pwhHEWstD37Mzre8W7LsalTMt9ivp/gNpcjOAOy0woefWxlrXGD1VLyXWQCZI6SFYUvt 6xHNbCdbqma275SyUD9SOXBLOJ5qCDrtSWFvTTQtjD5auwGXeu+tq5BcWf8eZrUXWarm B7zQ== X-Gm-Message-State: AOAM532mBr3Ow2zePH4RmmovoMUKAX66SXIGyR79vOP0D2w6TyBXYAhG x/vT+p6Fsqk0BsZMe9LKKW4= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v11 02/19] dyndbg: add _DPRINTK_FLAGS_TRACE 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212953_212842_EE9DA0E8 X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706219 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07483C433F5 for ; Fri, 7 Jan 2022 05:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7+xWpHxWE1oZyyGc8ezkjVEjU/iBCtKv3Wb+r1FRwf0=; b=ysUzHL78C9U6Qk 8+ggdIrsRLIaQhB11sC3A/CiThoP/W3Q6YYbG9VLZyNNABeKBFngqB+/XfrdN7ycT7CZ/ohRO6LBH UuimkI4RGTWrRlJesfhtmm3Fonf1V/himwJZea7KZlv6D366dj60fn6H+TVf/hWDJOGVOBaC6+5P6 FzXDW0rLdEeWE5xqUV6N3SdUrTg7Xx9kAhS0HdC8499R8iWVTEM4LhBOM4V9ERrte4KOj5BJ/dyNW ZP+kvApf5sS7g5P9yj9F0w8FIrBvAzLQ9qUFZ6Rzu94c6Gt12wwjPb/hos9BsVi00vwBzQUtifTiB LodRUwIJrQ1MUizil7gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpc-002NXC-9Y; Fri, 07 Jan 2022 05:30:28 +0000 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp4-002NHH-9z for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:29:56 +0000 Received: by mail-il1-x12b.google.com with SMTP id x15so3808442ilc.5 for ; Thu, 06 Jan 2022 21:29:53 -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=m63VM4Z2idkZSulKiNt2t8YvF829mAfeXHOJ5CxU+xT8U1WJJl6xElurNVvgGkUz5s r6M3Pwq8b9TawtNSH7EM7iQShKnmk7nIA/1HpbLh6+lOMtC+mjdXCGJ2CnqHmUhB9MZg UkPOVo8amVfeu0NGjfngWV7vMPYBSwnFqwyNYPxwOxYvYh11KTaLVXx12Ff9QZEIR1tB MHIG1UkzUsfTnGGFwYw6TD9XtzpaVmCQScqvi+7ltDvLD3KnNbpc4XQuRh4JByHcnCKC IoQlktMHiOXZ6pa2XxKywvimyBDqo2c3yl5Igp5v90kot1wxo48d06POqXVeMnbXyTYu ty/A== X-Gm-Message-State: AOAM532Eo3x/bquPAhHc3QfNHWjx1axMC3YPJ/X/u/U5JGFAaByFVi+c dCTYYPyqaZco9+j67/C6q9c= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v11 03/19] dyndbg: add write-to-tracefs code 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212954_379168_F4809D62 X-CRM114-Status: GOOD ( 21.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706220 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9038C433F5 for ; Fri, 7 Jan 2022 05:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=peoEpmwo/SwCboS2ouulzrR/69/p9tAY7i6yVUJ2GOw=; b=1klL+fFeR9FZVI lZohLdpRwe64zBOtCgbq/2gBkWrFimqZSpl7ieH2nS8NtZCku/a0VjK1dMm51Qhs4QAwXbToAX0Nf lDnj2paYOOs2EZpsos4+WTcJt9tFdWD9Auq0edvCj54qc8CfkzC+nGXBW6PQnfdhPS2H7H6OKULsl 2b08t0ejVgZCEMZcpFvAvpD0TpxYoU0c6/cFJ6E79BcKKtS2U1iPFzLSacgZz9nksxnxIKeCx8SYD XLpj4/0RD/fnOR0pTsraX8/j2pWSWp8dUstvosell85ZOYsAQehBAIr4jXNFGN2ohcksTer+vhsc8 NWel5SRhAQKl+8a6hvvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpr-002Nfp-U8; Fri, 07 Jan 2022 05:30:44 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp5-002NHq-Nv for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:29:57 +0000 Received: by mail-il1-x129.google.com with SMTP id r16so2097872ile.8 for ; 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=Jd1FTlMzD0y6jIO65HeSne5ot5C47HF8JOfa8tl2nDUXMgHLfpWLFaoPTqQ+zeWDmr tObzHeI0DYpbZjRUMUKkeDm2lKqY9EU8xr5hZVLv7l9IC2dbqTavY2JGFJjMJiU0d/3/ 21paqyWG76sTdXkBbS3LesVvvLNMIRNGTw6L+n6LYH2engvSeYI5xIH1lEjmiGqqRS9F HQq5TFXcUN8QNglShB9MCGVZSXo/Zjp4kzKdtGXYkKRslU5iphQJCm/SQRec0JLHm35+ g6xTwwsIyMwompTwxAprPUWeVm4P2ivRNUQQBInNaZGhtjJ9KEk1o6l66sT2pEDlmExw h5Aw== X-Gm-Message-State: AOAM531gAxQ925Kf+OSsc8UUq9JuIpvyB8ANIbTtmwqyuBXGxYKwUhRK /wZdDJssGijBN3ask2qFZps= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 04/19] dyndbg: add trace-events for pr_debug, dev_dbg 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212955_842986_4C2969B3 X-CRM114-Status: GOOD ( 25.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706221 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6668C433F5 for ; Fri, 7 Jan 2022 05:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=awfCf0qBjGgzPVX0JMf0vBZzi99tDOE+oVeGg5pE3yA=; b=ejjQij0L2UZC9t Bof5IV3rlsN1f5SDg1HuTC6pD5WwdRmcJyLHNshKUw6Fm/+RsowGBI76O4jaIll3Dd2S5ts26qyoZ vwXiRfNllpA8KD7mxncFfOPDtZMEIB4/Kke+ME4jg3TK4OcIb32Cb9qSNgUNANABLnSfJZmpJ+bwV HtMNqeYxnclXk5iAXpETxApxFrPAzGmt9D4IF/MSuEdJ34ZjRfOgWrN6SxL8VlqNe8aN+YVD9WcLv ITUArYVR6Rhurzjru6FPExlDnYFlV1Xf5mrBczoSZcb3FxdJi3YqvnI349VS+14u4KfQWq3Wpu4Wl gx70BhFf+F3zSTIChuyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hqN-002O3e-5t; Fri, 07 Jan 2022 05:31:15 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp7-002NID-0l for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:29:58 +0000 Received: by mail-io1-xd35.google.com with SMTP id o7so5795441ioo.9 for ; 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=8Erd0HC0EsSlRIHRELLB51qXHh9Cy2IlMKhduvOlUWLOzakSknkQ8sH8q1sD2tDman osmixkmDe7cU6WhWWFXip64N/EfSxGsM8ywnbWADm+skCq1KW/1NbudXw1PSvi8/0H39 I7IZxjl/JsaXTogTYBXUd1fqKY0+4MtrjEnY1SjHR7tzS7PtuoRySX/GF6prubpJ4yo4 lQqa75IWPuj6mIPiyf3n38Mcz2zcdlO+wQSN4fb1WJ7GDzjmjCqk1LlVn9DZy17eTJpu +PjNYg2EHCEmJE9z9gMajMsLG3uwK7S7u1LpqZrYAohHoW7p65noKWp5rZngRC4Ya8kc FlKw== X-Gm-Message-State: AOAM533GX6Vp8qBh2xgZHdpl3yDM63b93iyrGMXh0SS0Re0texH+gyuE FutDs7vk5YVqkS9L/ogVO8U= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 05/19] dyndbg: add desc, dev fields to event record 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212957_092102_98F1B1BC X-CRM114-Status: GOOD ( 17.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706222 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5243DC433F5 for ; Fri, 7 Jan 2022 05:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bjp1n6GfkHh6DJ8wqYYWfYjsjzBzo+rjNOFmZLD2baQ=; b=AE7k25BXHP5HiA g1Z9y9hXOZOWs01yfHQlgpfREsOkVmW2W3wAjmgyPKBIEROEev7oycHv5BhOyBLdTDVUUhv1WkfEv aPsogRiPk7KS2wFrT2PkxkB1RWANSjthRXGG1FKNketopZSMP25HwHtoSje0reApNUNL13kyFwu5P 8dMO4Ol+m98YGpnGBhAvp8+3yiYtJFMLxBkqm4eyk7Z7C0jxwKnBKm0bT+JIgokP85XlrIRhZqwAK 8oVH1+BFH3mm7EHoXBhXjDN3oKDuvJ7Pc0tJToWo8MMncjSmz8R7AdjF7Mn/o4N7Hplw/fv55f00f vVPshkvG651fl3CQDZDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hqi-002OGZ-B0; Fri, 07 Jan 2022 05:31:36 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp8-002NJW-8Z for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:00 +0000 Received: by mail-il1-x12a.google.com with SMTP id b1so3830611ilj.2 for ; Thu, 06 Jan 2022 21:29:57 -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=qQZ6bll+sN2y/TR/0ISZpeIjWHlyPFHZD7HqOTTB9QMJpTk0qI0gIezZ+ejXniNBO2 1b0N698pL08WcUkabPq48coioP41cRBkhpAYLDdr6LVZGF87NVuOJCc2eW+loOTprpI4 5zPH+jDB066esQgvGQ8At3NAhio/DXuTXhqU6idEeL6w1Vt9N8mTuKZFPurQ+qwC3EK+ AuMhzsmRlPMvINFear+nzvC6kHrH2wtNoRDr5E2J4dv70PjL91Lt1WrSC51T0ragzfoJ ncNkVZ+FV3rYIcPGdWohhiUMCyMT57NpOViFSGW/e8ADS1Gab8JYwaN7z6GAJaRLvqC7 yWRQ== X-Gm-Message-State: AOAM531khF5NGWyQv+jEfYHL91LY17uKXxhnv8pF/4ozTfNPq4d+5qvG zPtS0Fs4/mFKGRfjBmI5Aes= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 06/19] dyndbg: add class_id to callsites 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212958_343380_B16DC60B X-CRM114-Status: GOOD ( 27.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706283 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F415C433EF for ; Fri, 7 Jan 2022 05:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RAbNsFKU9VAGh8PY0ZKtAtboVr5/RG42dEXUvw0Z0G0=; b=CcS7Sn9uS3cjLD lowV2ujZ+FyW6FiytIp0R3tyLmh+fVrqfJtSuhkjm6vuFgd6EYqsNdKEl4/8seGmETe5JI9NKKD90 nYc9oRXndryLtvfpeOjDd4SYm1W0jiaLZSrmGGhdGaFF5PvPLW/z7pdmTctH7ea6hts6HWrhK80eF Ar8EZ2k8xG174Emu9DZ+4ubAcfPcBX2EdiIKoK7vj0I6qk+B3liFhpNWzI9yV1RTH5BXXqS4WZH3q FYL/pNSC8DnXb8OiWS5i0cuX9X5CGlrilt0QYUHsemotPQJYBXUor5SCxyTL3QnIbVLlNsMFYI9JL yJHY5vOEfGuniVeS7G6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hr5-002OU8-VK; Fri, 07 Jan 2022 05:32:00 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hp9-002NK5-4O for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:00 +0000 Received: by mail-il1-x136.google.com with SMTP id d3so3774464ilr.10 for ; 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=CHw41Xf/4bynYjTeBJuwt3OdqlBOtt/CoDAwyekqJKki5zgXs1sJ1oU5hoxsk6dLkm jHn+MMZsaZOJ33lVasLXORT9/eFJwSGNCqKivEYX93xAP81J3SKsYmtmlsAW7mzGgpja 8TKS+RIQqidritxs5JQ8Nf7RoXfbP+lBZxR9dE+7ZqYpn5FadIvpuPWDdqCAKzQi/ABZ x1Ve6q0FROFkrAY4DFgHOX1/BnV8ctCeYn4vbIsWGTdIEvOlcXRJl31iL1Rhzv7XbWVt cBksRpXDrhkaQLQWspU6w1h0ph/P3YvFTwMFaYpqDU+xNQI6mUcY8CyI7XJ9zdOj+J+y F75g== X-Gm-Message-State: AOAM531VuimlLAJpmvMVlOzJ0vm58CTEMQXmyOkqAnVu0T3LcEmTZ2pI bTJ3I4WMqiNuQgXPgkz5D30= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 07/19] drm_print: condense enum drm_debug_category 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_212959_242449_74872F51 X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706284 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E36E6C433F5 for ; Fri, 7 Jan 2022 05:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SB9eGgn+gY0i21UT6azCDOeFOCzf7VA2I5DO8c3v5HY=; b=mqKysb1+RlAR+7 nkIj55DILe3ibvhKiKDJ7mVmJhp312x8S6RhDKQvKsOuYpDtbzFhmDhbstH0brY3ZKx4XLtfElFTT GkLSZcBYd9oyHlNNXOzSQfI0a1k5guSowK6yP2hWktJEasFeTBIpvw8Fb9nh/nDbbT6yCldBayOhG dUl6CiVs9NwlslMdCCr77XUBjaJIK6IPO3FWwAzMsXBrjQ89m2hSN19G7WIwbZAvkG9pXKeanuLIf AE755pgeqS9SudIh9B73Qt9y7X8JXtMjgHGDmRdfxHKo7O3nRAvbjY1qLIKE1NjeOE639WksmQ68g onkA5tBUGcS8D55K244Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hrT-002Ogr-GY; Fri, 07 Jan 2022 05:32:23 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpA-002NKj-Lx for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:02 +0000 Received: by mail-io1-xd2b.google.com with SMTP id y18so5832169iob.8 for ; Thu, 06 Jan 2022 21:30:00 -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=rs8jHOwDEObeGNySwSH1pHnC/4PsI2xPUOYw3NzZXDHH7ULfWs5peoTev3FQbFItwm jkzAlQUSTttfjZsSlLDKDeiPFzNeo3yzDHhkH6BCqJ/Q2A0cfA+lm2BpClNvfQBkBjb+ ZsUGRA+DQ5Nx+v4Hx8pXCJpOPGR9LkDORx8NmJj7qEEkk+E3n97izecVf8DgZu02XtE2 mu7NlhkDM7w8BCg3kG+JJEXyC6sS0rhnNd47M00S2TV7CUtfR/F6gA6vTt/Rd7EU/L5+ jI0DMXsaHgWpdY8x7JfbQh/ycLfgMm85Hk5tdakQqsnGVXANJVIDGMq8/6htiNehTNCR QXgA== X-Gm-Message-State: AOAM531Kbw+RZFsCT/gE96v74EmkcXYKwC8uUH0eY/pqwy7WSN9jKgW4 Q/5YVWDeRRxJI11tGLmyOps= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 08/19] drm_print: add trace_drm_dbg, trace_drm_devdbg events 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213000_753083_3E411CB6 X-CRM114-Status: GOOD ( 19.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org __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: 12706285 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8291FC433EF for ; Fri, 7 Jan 2022 05:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c8PBw6zLqYityHyTZi53wRinN2A3Dw8B41tuJ0a5j/M=; b=OmaxwNmK4lHgij 3vVs8b7TrFrWZxeLUqO3G+y7skWoBW+r6sOatUlV463WMgsoHRyZBU1/dQKEWoaT381x7SRwSyGSF pzBu5mVTc4c/ux0/W5+cHiy83UGQLS4L8n77xzXjBd7VExlK2A8Jn0NYigbKx0EKc43MJGGYmfAdl 4XCBrw4f9WJoiIyEY4+yaucPxGnrooVe7gUujOG3US7EcbdHhgnioRQV1a0sqdpjfpRLUaciVsygs 2GLrwnVulp5Agnv/H5KNmb5g0yJf9S15sy6bYOe2Tx289UwQu43vtTZpv8XgF4LYNTYMywPm+PUWx F16eXTog50JqDeCib46g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hru-002Oub-8k; Fri, 07 Jan 2022 05:32:50 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpB-002NLE-M6 for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:03 +0000 Received: by mail-io1-xd2f.google.com with SMTP id u8so5832330iol.5 for ; 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=n66D0Iq6ck/PLo7lQeASW3P8BUCEHLiTDSN3y30pVCJY/qRPgnE7yrqfMnj8/TxRLJ HXV+zmWMi/RKarnhvjGHATDP3uGUiEWYDcy/NeNa+W1LiA+G+MREIS04UGtSRHHTFMkB OXnKCf7MnFtRduPMcYPC7j+pMPz4OU1v5Ta4A7HSjDJFeqwhHnFw0EOvSPMg0Brc4z/m IiVurt9ujuE6DO/BQ+TWa/85ef7aXE30/eZG851zm6b2o6N3L+jqGOjDYoB3hbD+Sw4Z UnG2MieV6eTYP3xrCX3yn5P7iDk9HSaVwu6QMCIbumLlCwfXantqXijo0nvV7NX8xaxu Sv0A== X-Gm-Message-State: AOAM532YKe60xBBGvF1S+4J8v8HYsBr8eGlyqEnVQwZWRcddwWeOdcJ7 40iOT0htFL8eIE64lGep6yg= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 09/19] drm_print: add CONFIG_DRM_USE_DYNAMIC_DEBUG 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213001_763342_AC985A75 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706286 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C214C433F5 for ; Fri, 7 Jan 2022 05:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2kr8/vFcJ8VhNbpPf+NraLeW6n9+Yt9whGEmcuobe5o=; b=vDbu517S0mYxdV ED7kYomENrP5m1DaAWhEXJaN1FxO0uUK0+kDUmectLdeuTazCWrT490cLmcwKNCkKpr1hG10cgp5x b3vY9CSlmMIT0KW+YrkKw6qgvsxUesWHfJ9bC6kzCWu1fEFL7R4cLOL7Lm4sJLXXnOnbWqdFFOOf2 C7/L66vdv7jFgq1VdRw88f6WacQtWc48wppXJalJnU93smHC6/wJokrIHo+B6PCnDtbj1aJ7HxO7N qtqxAeAhDB0AFVkrfo3GVv1wUugfeIoJNIoWXKPL2Slp7s+I+Fwot2USP/aEBg47AE82Iv2dDSwfY LWWGUBNPhnbv6q0e9W8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hsG-002P4L-HA; Fri, 07 Jan 2022 05:33:12 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpD-002NLu-NN for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:05 +0000 Received: by mail-io1-xd34.google.com with SMTP id l3so5788471iol.10 for ; 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=N8JM0SU/SEYZ9WEBAK1tqS9/v6lJq0JCb/UJO7Mxo105fbUEI02V9Oewi84euerjyZ IQegn6YlhFHHaAxqqKJgYB5WGqdcGsTiS3+g8mRmYhf+jdMlObi2t4jffPgttcvluVB5 Enfl2qFEH0LGa4Xr01Ciey9QItU+h6gNdy8pUUeOEwWiyQhGdy6YyHV5oQ0n7RjIV1hn tETzz39Pmjmnf5H8CB99VO2Kk8+cxnHYkKNewT7iknMQYqLiLlPDSrAN4YYD/cW2scA1 ex9rUSUjQ0u7vDtZxZyr5ULJpAfaWuBHjv9KxclnQ4yV7jZ7TI/b34VPQ35WgrrdbIJR pd9g== X-Gm-Message-State: AOAM532Go17BnJVivGnwVmV8V9qU4AN+W2Wx4QsIR2oN2NBYHC58NoHN V7qZgyXpsG5L5C6LyGgnnkw= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 10/19] drm_print: interpose drm_dev_dbg, __drm_dbg with forwarding macros 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213003_799974_556BBB25 X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706287 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C619C433EF for ; Fri, 7 Jan 2022 05:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ObhkOMhDL8hNLHEdICArEdmeHdtj3VDhKKttTZNiIdU=; b=fjE1Wg7yQ6Vg18 SLwfH4a7ds7ifyzs0vHPGI4chi61E/uivUoUyzzb3UbfAZqUUGEElkcXoJ0hmuyZh+dZGkvqCQobP 9y0wCHwvjk9AAepWrs9DaKBJCix0qk4GOoxGv/TZSpioPetkYnwOdBLrF24oDiq2NL16k74BhFlRI DXMhOXm8xB/sQ8suY+FuiLkZTViQhD9VyFnmF7TQ18jxw02UbOKxej4g3z0EOxNvlKHCcg+JIiYPK g4abWOvo3wJM6E1aXGY4h8he0faNAH2o0osETPq9mqm3mogptgzV/vv134FuQqw/GCyFj3JPqGPfB 8MkbXYKLh7QMIVLsDINg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hst-002PKU-Nc; Fri, 07 Jan 2022 05:33:52 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpE-002NMJ-Bu for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:06 +0000 Received: by mail-io1-xd31.google.com with SMTP id e128so5859222iof.1 for ; Thu, 06 Jan 2022 21:30:03 -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=iq1tW25LYfwS/kNkb3lbW3BlyNa93JDZpJrAxVQY0EZ8VOM0+HB6Bdi91CVdcdE5ER bmN9FoRUfa4SPqQ1YNAluwlBS5gbr9mgOK18SZOg46nKZqDytYcApPJEKA5p+WRqerIi Cn8B0M0FlAKtqvV2JVKnFcZG35RvFCdp3H6kZJF0szB/CyW+MdqhUb+FeII26EdE/GHi ZVkZxkWWiixqXZr3pSf6TaT3xIvlj/9nyh/1QABJ/2i7uRddzqRBKS2byvZuI7DqdGbu 1d8t89NfNZsVjGsQsQPC+2pErl66u806pVSD+ceH5GNLrKkRuk1mn3rfur/ro5v50/Cq CfoQ== X-Gm-Message-State: AOAM5306fbtm32ounPvRYbt/eYVgmH6oHD4fJPe+KKbtWFYVMiB83RlI 376lj1h74ORr49zD+BJQ0qI= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 11/19] drm_print: wrap drm_dev_dbg in _dynamic_func_call_no_desc 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213004_497073_FC354DA0 X-CRM114-Status: GOOD ( 11.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706288 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37901C433EF for ; Fri, 7 Jan 2022 05:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sXND661qfyssb8Wtr1EXtoPtyGePolaxC8q0Z1RnT6A=; b=owmkE4aLfnPnPJ cVNYCXtClMBtvy1ie1dWa8tLjOUtpqKFwb+7O3coemTwpc/du3VHT2hBsKTPqcIn6rMfrqnjUEdzE +lt1RwoVOl8/54yKXM1wXXZBW17bz9ghH8x5vAcjJQiADmodzal1E9qyp1TdR2C2iw8QE1D+bqFMf JrXHI65o3RAj6oO31Udy+3up0EzBmQS7X7gTAY32VIi62FgsBF6gg+Sh5oMOLWFjF5b8Vc9iOWDl6 xlu5J3e0tu5tnpIHsC/NpdOeQSxcKDaQN7Cfc1MpG2Crqpax0jSLYvIQdROtJaMWGciuxpXlcHWBk 1C51tLExnTNd+pZF1jow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hta-002Pdw-DW; Fri, 07 Jan 2022 05:34:35 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpF-002NN4-HL for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:07 +0000 Received: by mail-io1-xd32.google.com with SMTP id o7so5795732ioo.9 for ; 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=qkoxqzjfQR5GBTMsiJmfoBQ/xtHqA2J/f+7eZVvt28mfkw7uL+NU1hAXzGjIu0hoIa 3L1XRejfrIGUG+p0hJVl0A5c6UIMVV/iR1arE5fNZPaTMEEWWIKFM4qlEgHyHxNjfdgP tdwpcNIt9djfJnvjJ7pxb0YWece+gH2u3/CLB45vEjUmmGhlZI8Hz8vglN13KEaNiaJU 2I19l8Ig3C6WhKCIJXBgdPypW8ERAKnpxxOBbVT/s3FypPDokXPAg/2dgjgbCY2dTgN1 B3+FBvTFduQ/CWR3+B2p9NY2EIt2xYHW+zZX+dyJiHOFFakPCwyxh2Ma3IjZypsf7SQY 6cIA== X-Gm-Message-State: AOAM5332jr2MElVrXtkxpmD0wdN1rtcs/noSmz3uXyRYjA94D/jvZjR3 pJwixeNQ1g63rJ+cG0ZVdvk= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 12/19] drm_print: wrap drm_dbg in _dynamic_func_call_no_desc 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213005_614341_1DD247BF X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706289 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85741C433EF for ; Fri, 7 Jan 2022 05:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J+eNJevxQuLv55K22vYwyyMjKs3JoZbqNt+dZymHRSk=; b=d8jd2pXnAgVo7f KQIAxWF5LbImL9LjKJl+zoPK5+6cBbJ7IYa+q1gTEDl39pTyXm3Y9NUTL6H98XSSXI1SwSrzsLzwj PpYdI6YsZ1c5H+TX8U/eAnnU5yM02tdFv3tIB0bdFco1Nx+a3LSQoBmUc7sFz7M6qZ7pVXKSRAxGg mqxUndjVXYI9LmTFL3VTrJ1z1H0MpRhKVVCtduRAK1k/eCTDZYNWdDRU16Di/7flnqMZrAeCHdwwJ eWNGBlHlee7fke6yX2dFnJygOIqO9HtLM8z4KWmkMVHMvLFMURc+irQKPpgKaMX2yyY2Epbjl8qmW sej+MwWnwKFOyhJmScGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hu6-002Pqb-7K; Fri, 07 Jan 2022 05:35:07 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpG-002NNX-LR for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:08 +0000 Received: by mail-io1-xd2c.google.com with SMTP id l3so5788594iol.10 for ; 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=hbr65PI8jf6ZrPWZVuXCwJzcEEHj4b5kQbsc/domC7u0JWkermUE+WRjnCPUsHf008 3Li/GAgV4s3+JSxZWpyFLjewX0RrQkC4VB73fOdN4+0FSxA7a3zTziUHX7A82DcfJW9Y mjVHJ1xDLmz0auvag7DQrpdTC6tI3PQjslEgxm0jLf84wzawIEqmTcYZKHgxZq5wZTAs tnyE5WPNg/DxCzNg1Db31L1iZInXTfQZl6RFe3pZDTTpAUg3q5pkJ8u2ynlcC0grOJW3 2RDYJHD+Mp1FL5zJJVES+SWrDUSMuMzY5qe3EPcfYIfWJ8y/Y6RZX61uyzm/cmulvErm LVoQ== X-Gm-Message-State: AOAM5327JOicI32cZ2BqgmUkiz/8I3Zq3pGMuPbeFNboChFugYgnGuY3 nCogFWOVzS+O40EhPoTFr4iNuXPRMlo= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 13/19] drm_print: refine drm_debug_enabled for dyndbg+jump-label 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213006_748261_0BE32581 X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706290 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0886DC433F5 for ; Fri, 7 Jan 2022 05:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P/0iPbRtTQvJiyfFxphggl4YpBTwiYgwCTxEzV7qN/k=; b=2MvGEbQYe+2IIc U/3HsRxDqjvw5RpMhN75C/v/qOE8UuLLTQ/bsP67wmViD6yf1aC7TQanJGKUoeXGzsDOO5+5s58Qc 6uGLv/b4Fr0sgx2GCMxh32HnwHKtxkWqKG+PRZSdzq7PlpphpRqsE3pZaJ4wL7CxElmfaKnkL6xQQ KVMuerctOQNwRyBQkiELt3jYyHMMnvtLFsTr01vT369IsgmDZTVi8QLEMVK45czmHEQLdIfhmrhZE kEeuB7N7Mwq9JN0/+RYxubGfGBZntNximKM9bxQ+ytBGoQ2ZQN/b7LSQUI3IdtylFJxs6FSZL3y8g RwEHqKUffymqM7PmABOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hvE-002QHe-Gw; Fri, 07 Jan 2022 05:36:17 +0000 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpI-002NOi-1m for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:09 +0000 Received: by mail-io1-xd2e.google.com with SMTP id p65so5849447iof.3 for ; Thu, 06 Jan 2022 21:30:07 -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=50FisNcukX3tGskq1TQwxFAU1v/DwXLuOY4Bvtr/7htt1TBdtIe5HDHeK4UAnfGa0V w8TB6wVjk2T15ZnxnkHl4xBmvx/+2O7Ggk/hbCoklSqurwHT093i892a43UwO2oxdVa2 PNfHQdIZDk2c+1I3Vg2NSf+1sDYqVUfez268Yy+gaQ4KqRJ6cdhmdlnY7MH+zJTefIGs yB1Q1wp8ulGre+W5g820vgMF9zxop6AaCxJqd6vlwGXf43v355ZO8EREfDAOXT+got7e DL5x+T8RvKwzbBAYCDmtJZch731ujQxkje9XwiUsHN8DqzSwCTAno+Pg1PlflUysxkEb LXwA== X-Gm-Message-State: AOAM533aJoXRVr0uTi6iI9ZSUyyWT/q6IDezG3tE+Pbaw7OQPh5Rs3yf FuPdYopOsT/A6ShtId9Xhp0= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 14/19] drm_print: prefer bare printk KERN_DEBUG on generic fn 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213008_119365_D6042D4A X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706291 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9786CC433EF for ; Fri, 7 Jan 2022 05:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A56bdouHv3B8Vg5IDRBabUr4H4Zek05yr9lmC/tPnRM=; b=zDFQdrq7TIL9yu A8uPthSiS74l83BiB5GoCohrobwql62NuMkJIs7yUT+Pt0YlgLo0XBTMlY2GIyMvNDRClq3KUOzg0 8//u5zkNXUfObR9IS5x4Dac2pa9384JgLj7OyplyYIhJ0GQ2KRTa7byA/kItEMJIWd3scI6Ztvz2+ 5bn1OUTBtjJtmEQonfLkXOLbeJQwiS7kWD47v2WNRokeL6Yps8z/EVZjb6aCHQhpJ8U+8jMueoz5F c1hYkX9x3VhX0kvnA1zs0RDQ8GQD9k61qRRPDP5C5j2EjLDavAcZYgh9v65/KMbG2HAiVkLmBOHpx qeN9+cWEFKJN1oOlcrDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hwH-002Qi1-SG; Fri, 07 Jan 2022 05:37:23 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpJ-002NP4-3b for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:10 +0000 Received: by mail-io1-xd30.google.com with SMTP id x6so5757668iol.13 for ; 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=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=j3607ehmNjcCifYagTDCV1M189tNhaPOCEIwmsY+uyZWRuV156z/aS6ilfi+lH/lBl 0fyLZPsQdkRmsrL7YROFIx935BqrfLAxeFgWpP/VyCwaQxD8mpm+blX+XfWEtbRT6Fya CIhmtpUp6J1iuj7ku/EuB5yU7u1q5zF27HdvfpGBY19HWHhEXlNx24K/fpYylrgvTuTw YXHb26aSIaLvuNTXcKI2cuohYMGjHyOOfVYCDzpKw2Q3uwkhXth9jdYWyVLBEgCHjs7W J3SUajnad+jkBZD45aEy0Y6yb78NKHH1uEea7UkUGflE1uWNK5YUjAlXTSGcgtNJrhN8 GenA== X-Gm-Message-State: AOAM532GSNvm4pablyEKtCPBfpBHlml/ZdLFpUYv55l9D+02yLIOlPJr LtY6U9OXF1WEHhs5iBhXD9s= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 15/19] drm_print: use _dynamic_func_call_no_desc_cls 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213009_172666_C5AA50CC X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706292 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FBADC433F5 for ; Fri, 7 Jan 2022 05:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W2+DemDX5O0K1gdZkZZHFg42l9Ul/0FnfCWIbj8TJlM=; b=vNF/nkq3gZkcFi ElOp/XYZAKoeGCi5/mMNLJg0V1n01ityBskTVPZVf2Zs5l2zVArYIZgBr9azUWBgg3jOLVq/sh4rl JGJS0i4r2fehbQUza6Bq0tsElOSAh2IYh4/i+wUg909LMGrJlQooVF8cUxKWvhP5Xu7L06AgW5Pot J/oUjdwlbPLLSNPQqgK/2hFp6Mkgx8HrtV/Ej6xFWnM+L2ZTLfgW9a3TDsl3ZJ6rCwUOR1I1zl6iX tl+/9Iwe+JFGZM9sgYOL5A8c7QGQgiB6pC7xFymReANZeXO+5o5VtpGhUad9pxn3MHUR6JNGqeOEm goJgCowvip4+QT54DUoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hxQ-002RCt-On; Fri, 07 Jan 2022 05:38:33 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpK-002NPa-26 for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:11 +0000 Received: by mail-io1-xd2c.google.com with SMTP id h23so5776509iol.11 for ; Thu, 06 Jan 2022 21:30:10 -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=pHqXQujVEsCUk53Ogy7FWfRVvSAEqSXhmVzwIZEzoBd0uHJhodI/AapW8rpBGG3JUb dH78FPK2CJZ0gCc0CUOc1zHnshVeEDqnOE11pTutUY8sOFGg2wyHHNcR0NuakzG9qit7 d0zKUbb40PaaNEg6D999kY3+wtclqZmsnJSlVuaMBDNRrDZ4m4BiptlJ5umKntZwYYGY NK+XFlcquXmfLpLbQ5Y7SI0lvIlsCaz06mqy4UcYjiPONpSh5Pveoh4qNKSRswmvC4Gx twK05RS4/GSZcolqZh+on7U2M5TQ3snOdH74LDwDcghXLZSWwGOYCmxrD7Xa6UPmhj7j q19A== X-Gm-Message-State: AOAM531MZcS5L+nTgln05AmOZW7Aa4Qk/eB0DcccOZPjZ+/Zpk1INR4Z LDA1sKCBa+LFzuCaxaS/sBM= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 16/19] drm_print: add struct _ddebug desc to drm_*dbg 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213010_127263_8915A891 X-CRM114-Status: GOOD ( 14.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706293 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67E4BC433F5 for ; Fri, 7 Jan 2022 05:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GuEqSkDauIVbwTpUaqdJd1w36naKIEsQSvE/CoFfbfE=; b=CmIJNzr/E6XyE9 /uUH0PXPtr+L1vWFdxtOBOiu0SF9Dqj2oqSbDVv8ybzCg2SAHLtQbvJjDCJ5YthoQKBCD1vvex2Hm u0AVn1IheZ3B+u38Ddtow+aps0BbEFQll4lEuUo3oLmYYfQP87tqIkg/ht9ywuvEb8U6v7/+FZy7s 4YN9AbyczapI8fcNSrqiHA8rQ1oV/uQJgFlqIubFwqQD/iUV6XRAzFF15EX2xcyemUHbx3Z1vqL8P 4a+gy7O6ta36TdOSg6/+Z1dk1IhQ3d/faRQ8nuKjnKsut48Zzs90IyxK84njQS1iisIUxJhhC/JWz qqWBVlOFEbju2XWoQLBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hyX-002RZ7-83; Fri, 07 Jan 2022 05:39:42 +0000 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpL-002NQB-9u for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:12 +0000 Received: by mail-il1-x12b.google.com with SMTP id v18so3782957ilm.11 for ; 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=FS4UzJA4vGpqwaiY5kQFOhPaYTES2Al37DgJHLofA4hpJ8NVpsOoNaLycvNNTwOrO3 S30h9JF6NGb3+3c0CwZxn0WGHylXAnIVpYO08PpCrArQ77jqznVa5RmYIfOGDSV4FMW1 bqHvIQLDKeDFJhu3fuer2zq7iDTDSYooFpXULP24Fd5tRYbXG82QRcIgFu1tuTyO9qzw qFQ5WPXwgCmHZE6tBAF6bSpoUhsgB8Tvd96D+PL+DPA0j3yAn1EaHYFZUlQN4ZhM+oca gRQXfoNncVya2h3TO8ICHpwkpBrWCePE7eEgQk1K/uDeX7WQReDu8zTY6RguI9q+cJjN K1Hw== X-Gm-Message-State: AOAM533aLrg0pgLxehn+HyaX5KsZyIQ5YYJu0TqlbnEt+RdwdI7b+uKH 20vSHkqNnidd096cPjmBa2s= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 17/19] drm_print: add struct _ddebug *desc to trace-drm-*() params 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213011_378318_32517D84 X-CRM114-Status: GOOD ( 14.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706294 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55EB7C4332F for ; Fri, 7 Jan 2022 05:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cp1GNLDt65AVx45oUKtfLVo9iiwAZy3ntoMSB5nQDKE=; b=aubTLTJFM2Hp9J kmkEuiGZAaYwFYG4FlfTJ7WgA00c9Daxd6wl3a5C66e+dSoA7nDmPW9XnClZWJO/tfw+FbzGn6Bdo WnRkkdSq0Wu7wNbEhS0Ds3ytQcc2AEvR96XjR2Oeb478+SQ4k2wSvumLvIuwVNW3o43Xvf2XMUlTq jH+kYcTjVS8eDkJH/v5aEiAa6oz0CJA5rg2rTGXT3h8fk/wde5mAzikTalHNStzUJf1lgPdsOm9Rw jm4JqT0ecHznmv5cpBom3fa0znMj/j7W/Shq3mu9SDstsDsIgBmH1awjQWj0m5l70iabwQ6U/SZMB fJQ8PusFMdLrhz1el0BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hzj-002S32-9K; Fri, 07 Jan 2022 05:40:55 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpM-002NQo-SQ for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:14 +0000 Received: by mail-il1-x12f.google.com with SMTP id r16so2098230ile.8 for ; 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=Td4tI2Mb5n06iohWfEaKss3/jsAwFgP7e6iqufWoh8MLimVwqpSCxp5F8NHMj/oVsQ tU/Ej3CRKs8jkf3gkvruBg+vXBHS40X70KoLq7eyZoxiS/MqtGdtCcVa5/QoAKoBDwkT 0ccIzjDRJgvDdVfJbh9b9oTer7cFuwkgZxHo+0hM7rehnWFFwGRftUInwWkV2Fls9pjI aLE+H0SYw4POz6PJqIVmTKo47tmrrHJrGbOYUEKAio+4GA9WrAl2VYro4lGH0s5H6KcT sgEOGz4kFx7DkHsTXd5CE7mOJkXemUFKXMWenc8R53yEInCy3d5H7Whd92wt5Jgr9ihL 6vBA== X-Gm-Message-State: AOAM532nJu533wogxrkKpWMBeRk9WuowS+kJahZiewkhzov7xkzuUUiO nQwPtbtAktczH38GgQyZS0U= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 18/19] dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213012_997763_7076BD7B X-CRM114-Status: GOOD ( 23.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 12706295 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 750D1C433EF for ; Fri, 7 Jan 2022 05:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J6BM5DaA8KKgrFOuqc/S5i7UDStNZDhT2E5SVnVE7dY=; b=FrexxlV549vnk5 YDuEsSW803l1BAEu+b20OXkxCRTcJZ6WRc4cfcGhe5pmnxMTXhTbnLxCKly4rc+JYWYlqHOaOzyhA 9Y8tw0kqUUKdqklYhXmpbrtwL2XWgLL0UXXRe7nDEK0Ol9Ctr/J+x9GbpY9eBoJZcHhRDGC8cefjh OY8VP4ehmGQ/jrWPxVnOY+U9yLIKAPoAjt2eg5YQu4kd+3KPIu+5G/1eLyRkKQ00nK5/kyZoA6z/i lSUuTt2W5/ZeONOGM6I9/E+0xutsgEtw/9gs2r31Aq8xUrilCZeV12I+RQhuwDZWv5V4ZFa7K8hWG mSRsc16xePMGpWP0BZmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5i0z-002SSI-E2; Fri, 07 Jan 2022 05:42:15 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5hpN-002NRq-Lf for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 05:30:15 +0000 Received: by mail-io1-xd32.google.com with SMTP id y18so5832588iob.8 for ; 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=HfJnbsXO9UY+DJzq0AmLqzxS0qT0vSn5CdMhm49p24H/fmVIp+6XWLL2GldSlfhZrO Hw6D40DRN2cz/flPtDnhBP0samZSibTptGKRUE1dz2n9xG8gl6ELILArUZy2MNaYqGBV ElcGrL7u5NnnJmLPNn0GafBmjXlWqQAG6edMjQ2A54UP+0MkVJ8Vf1GVQU/l4PJtmkYO z6HfQThpC35qeSgWfyRo5VCz8XAz95lVUZpEgvu6btpgylWn2WNKkHeSa1v27IdMrAkT tGu7YE06OyebdN6HbKiIaIK+HYJOT+qn3h7S+7SCBzbgr4ppxh79pDzjEuA183tUeptD 9oHw== X-Gm-Message-State: AOAM5316TTl1TT/X8obLiR7D5j6CnhoLLyxqeU3mhDFnf8c7A9J2Nj/m vx/nKEu2jCdE/DcRMjMRXu8= 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 Cc: quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v11 19/19] drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_213013_755159_22EEC238 X-CRM114-Status: GOOD ( 13.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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