From patchwork Sun Sep 4 21:40: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: 12965268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA466C6FA82 for ; Sun, 4 Sep 2022 21:43:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4992510E13C; Sun, 4 Sep 2022 21:42:22 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4611210E010; Sun, 4 Sep 2022 21:42:07 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690239iof.1; Sun, 04 Sep 2022 14:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wU3a+NtnQXjoNN7rXOqrGTxjDahMgVmGQsWn0PV1P8M=; b=oqkgy1Lfx8/69RwJIe3zmzWJ5fKHCCfMExZbNN1eCUrtrvQvfE+1n1ok/9I/8qxcYJ V2Y5ovP3OXd3K2CAgS1BbVBtTfJUEdG+6tO5gfR37M2/5p6wJ7VN6X0nrZdJxzrfPg/O GkZXIIfX5vDFQr6/LJp0ofI0n6FCf/1AN3tsFeNZ25fi7xHd9VYOST2OyHqYWaGYzSlw QAv9HoibN19LRrRCQG9pGNe24p8W2DNmEf8nLDndfGLmEJnHDeMsDoQW6Zdu2pC0wkcY XlK7itax1DrgPu8UOaURRS4O0KdAKHHKQZ5pij8wgvGjblMAY0dpNFeQ9Bgy/4Pt7tCN CpYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wU3a+NtnQXjoNN7rXOqrGTxjDahMgVmGQsWn0PV1P8M=; b=qIjPKNmMiM1efCvMSoPENmlmUlyL/GU9xShsysq8mRtwfhcjn0ctD/oe/ysmQ7+NOu Os0yCeXjjTCQjcACPiKoLGsX5rtEpovFdPwqUDEjPdT7j1dM3pNTm7KtC2B4fEWbg2Df Ou1yzC97kH8YtpSxFQJ8hCz/y+v67VcF8+gbmjP1K9otxafKi4A6EBAyvHpM9y6K/wyE kV9Cpi10sko7d5O7SS+5EXK48067i4AUt8e5+k9pCp50a56G4YfUdhQqVZRZ8eYp+CF0 LOxwDAl+OSyBwQlDB4NsO9bobxKSy7CZBRwliIqmObwjBgTqhvjsUA/BFnZ7eo1wUaP9 yExQ== X-Gm-Message-State: ACgBeo2gkjQEWpGNaa0ZO22xZPONhLBecJ5PVWp9RwdutKso2bj/ZWXm dRq5/5hXerTicru6AjE187Q= X-Google-Smtp-Source: AA6agR6woh73WD6o0519OJbQFrJQIwWPKVm7AZf+Fo8tuX8h74mdDupZVosU1fX68Rvv18her7b2lQ== X-Received: by 2002:a05:6638:25ca:b0:351:1a2a:763d with SMTP id u10-20020a05663825ca00b003511a2a763dmr3305728jat.251.1662327726407; Sun, 04 Sep 2022 14:42:06 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:06 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:38 -0600 Message-Id: <20220904214134.408619-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 01/57] dyndbg: fix static_branch manipulation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, vincent.whitchurch@axis.com, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In https://lore.kernel.org/lkml/20211209150910.GA23668@axis.com/ Vincent's patch commented on, and worked around, a bug toggling static_branch's, when a 2nd PRINTK-ish flag was added. The bug results in a premature static_branch_disable when the 1st of 2 flags was disabled. The cited commit computed newflags, but then in the JUMP_LABEL block, failed to use that result, instead using just one of the terms in it. Using newflags instead made the code work properly. This is Vincents test-case, reduced. It needs the 2nd flag to demonstrate the bug, but it's explanatory here. pt_test() { echo 5 > /sys/module/dynamic_debug/verbose site="module tcp" # just one callsite echo " $site =_ " > /proc/dynamic_debug/control # clear it # A B ~A ~B for flg in +T +p "-T #broke here" -p; do echo " $site $flg " > /proc/dynamic_debug/control done; # A B ~B ~A for flg in +T +p "-p #broke here" -T; do echo " $site $flg " > /proc/dynamic_debug/control done } pt_test Fixes: 84da83a6ffc0 dyndbg: combine flags & mask into a struct, simplify with it CC: vincent.whitchurch@axis.com Acked-by: Jason Baron Signed-off-by: Jim Cromie --- .drop @stable, no exposed bug. .add jbaron ack --- lib/dynamic_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dd7f56af9aed..a56c1286ffa4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -211,10 +211,11 @@ static int ddebug_change(const struct ddebug_query *query, continue; #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + if (!(newflags & _DPRINTK_FLAGS_PRINT)) static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + } else if (newflags & _DPRINTK_FLAGS_PRINT) { static_branch_enable(&dp->key.dd_key_true); + } #endif dp->flags = newflags; v4pr_info("changed %s:%d [%s]%s =%s\n", From patchwork Sun Sep 4 21:40: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: 12965270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65A8CC6FA86 for ; Sun, 4 Sep 2022 21:43:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B0F910E188; Sun, 4 Sep 2022 21:42:32 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86C4E10E12F; Sun, 4 Sep 2022 21:42:13 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id h78so5628051iof.13; Sun, 04 Sep 2022 14:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uH+4PavI6tAvpP/bjllSxBrsqqx6lF8VrU02FESH7jw=; b=KSguwditGP/8FfWJ8QbYlUiwq8c5izqFVOSRXyhmdm05P40z31yyLERnx/4KMPZ18U yGQR/CcjnDmULO16vw9EZu863miip8Q4Ywm4OktFjjZNUdUqH0muQK6Hts5AQIQFY6EB Gnd8tvXDTP4gJcju+NDHoa6XhCzxcDglfVGpQH0OUqyXe+AwXj6MR3J0j7QIftZAI5mj aaAjnkm2GGxbLWKdhe9FWSpkC220hHqlwQNKss4GdfYbEiEqODGTAqXksS6qf8YV6XOx K+5l+OjHWI7q3CG8hiEA7+JF714yQmdURuxM/WmEm8lMmPJufYDfmHmioTV5V0ZMKzak OMig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=uH+4PavI6tAvpP/bjllSxBrsqqx6lF8VrU02FESH7jw=; b=GXqvhABD/jZoIL5+7NTzjFJdyFFcypNsYVsNr+00tzzIq898u9Z/E1gnVuz8fXQvpZ BmWYcwk6sNZJu0pcSoGS+dGKhfJZCDnt9tYHBuassbCdH77j5Lf2Jf064djI9p3LQR4r ma3OAEGqzQQc7YnnEgI6ZVzDmdRKZhH0hCD/WiKTib5euD5hJBo5c2jgucxK5JlB/puE JZbnGXXmIYsp/CHdXUcjGG6VSVH5ktPbBUFcGrrPmilFhpn4jTmed4es5sn7DuQBCjYI qH59K0Alj/SPG3/TEKLozdxSPIleoJk3O470KXHmZZU8XEoOvXRmjn+ntSZNlw5T3YwV dCyQ== X-Gm-Message-State: ACgBeo35sgMykxe7liW6rwRF96jCl2f7+tvSswHjzIwHK5NpUWIbeGAx +vnzK9QpJMabspeGCENDWis= X-Google-Smtp-Source: AA6agR47srkJpi3DXb58PnE0nCQCRP4+fmezLwneAZEvxkrMVJGtdvwOuDoiXOHxF1d7qDgzdSj+Lg== X-Received: by 2002:a05:6602:140d:b0:68b:1bd1:1c54 with SMTP id t13-20020a056602140d00b0068b1bd11c54mr18562369iov.9.1662327731887; Sun, 04 Sep 2022 14:42:11 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:11 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:39 -0600 Message-Id: <20220904214134.408619-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 02/57] dyndbg: fix module.dyndbg handling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" For CONFIG_DYNAMIC_DEBUG=N, the ddebug_dyndbg_module_param_cb() stub-fn is too permissive: bash-5.1# modprobe drm JUNKdyndbg bash-5.1# modprobe drm dyndbgJUNK [ 42.933220] dyndbg param is supported only in CONFIG_DYNAMIC_DEBUG builds [ 42.937484] ACPI: bus type drm_connector registered This caused no ill effects, because unknown parameters are either ignored by default with an "unknown parameter" warning, or ignored because dyndbg allows its no-effect use on non-dyndbg builds. But since the code has an explicit feedback message, it should be issued accurately. Fix with strcmp for exact param-name match. Reported-by: Rasmus Villemoes Fixes: b48420c1d301 dynamic_debug: make dynamic-debug work for module initialization Acked-by: Jason Baron Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..f30b01aa9fa4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -201,7 +201,7 @@ static inline int ddebug_remove_module(const char *mod) static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *modname) { - if (strstr(param, "dyndbg")) { + if (!strcmp(param, "dyndbg")) { /* avoid pr_warn(), which wants pr_fmt() fully defined */ printk(KERN_WARNING "dyndbg param is supported only in " "CONFIG_DYNAMIC_DEBUG builds\n"); From patchwork Sun Sep 4 21:40: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: 12965273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A6D1C6FA86 for ; Sun, 4 Sep 2022 21:44:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D71AA10E1C3; Sun, 4 Sep 2022 21:42:35 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id E56D710E134; Sun, 4 Sep 2022 21:42:13 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id c4so5673061iof.3; Sun, 04 Sep 2022 14:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=PbqFdyxSi0Pp6DU3HKsSvwhQJYj8Q2VNhxZwCrpnF6M=; b=VsDvR0vs9q2FKCQfOJtjIj8FHz9/Z3bqLVP6coIdC18//1aR2LaIbaZwWf9Z6tEGfl 5LATbVVqKiBlBcSVvzROupFX7UszhsGWDUy+bmPT1qGZcI1Zqa5qU39Qb2kqg4sRO0kw fgQxDQpiLWZ85LuT4smVr3O+O5zuSTuXZnwG3Rv/A16MfL6bVIcM4HNldOSP2KESU/gT V20+cxV8kGInvZOnWna6gEYV1K+GBUIItJpcmPhCpXQ4cyszHg26A0WRN3M3WtAN/wBm medsQTQakd/d2p87LqtCTlPg3npIOQkOQZQTqCeT1ibwK4SGN1YC/clvc4rCKuFX7YAD 0pxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=PbqFdyxSi0Pp6DU3HKsSvwhQJYj8Q2VNhxZwCrpnF6M=; b=HY40IgpXerJiE61XL2fafyrwIwJWYmmPJOcG+1SFuYYJ7lH5wf4HpRIiy4peQBqWJN 4d/K13pOs21qaIqr3YPiQXFTZFkVCNE+yWVEDPevaGkGn8m2QqXNc4ZO2oUpXS1IxANh Dww1j/8aQkGqjCPdZWyFbKdpL0H5y6dDGy/l1Vw67FdCB5FCIgqUSG7zSB7WEx0IkQSL AbM+cUCUsqoBhbe9KTLOcyWHtnxEApQUYtOsAOW9O38/YAT+qxA8VuloRTVikHwVFz5u VY5o3CN/xODOI6DXaYRG5DzAqlEv4PGtGI9jGxa/gmszDB2CdOXje/1qBau9RZxUjtPt Sotg== X-Gm-Message-State: ACgBeo0atqoXRP7cND5q6ZxogqgXDjnbXsRzQtzPajkkGHJheIHigEJG f3Javx6UoBF6QJy7192G6OM= X-Google-Smtp-Source: AA6agR7fSTOVCWKQ249DqThxtdMK6mWi8uoaxMmg3jSWwtFYYJA/nulJNENKG3FHhy/TNLExju0ubQ== X-Received: by 2002:a05:6638:3385:b0:339:ea59:a31f with SMTP id h5-20020a056638338500b00339ea59a31fmr23089435jav.55.1662327732789; Sun, 04 Sep 2022 14:42:12 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:12 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:40 -0600 Message-Id: <20220904214134.408619-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 03/57] dyndbg: show both old and new in change-info X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" print "old => new" flag values to the info("change") message. no functional change. Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a56c1286ffa4..8faf584f2f4b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -156,7 +156,7 @@ static int ddebug_change(const struct ddebug_query *query, struct ddebug_table *dt; unsigned int newflags; unsigned int nfound = 0; - struct flagsbuf fbuf; + struct flagsbuf fbuf, nbuf; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -217,11 +217,12 @@ static int ddebug_change(const struct ddebug_query *query, static_branch_enable(&dp->key.dd_key_true); } #endif + v4pr_info("changed %s:%d [%s]%s %s => %s\n", + trim_prefix(dp->filename), dp->lineno, + dt->mod_name, dp->function, + ddebug_describe_flags(dp->flags, &fbuf), + ddebug_describe_flags(newflags, &nbuf)); dp->flags = newflags; - v4pr_info("changed %s:%d [%s]%s =%s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &fbuf)); } } mutex_unlock(&ddebug_lock); From patchwork Sun Sep 4 21:40: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: 12965269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7DD7C6FA86 for ; Sun, 4 Sep 2022 21:43:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8E0B10E168; Sun, 4 Sep 2022 21:42:24 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E38A10E136; Sun, 4 Sep 2022 21:42:14 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id r141so5678247iod.4; Sun, 04 Sep 2022 14:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lfSfy0OiU9ae6zZc6r/YuzMWOjdJ0UjQGjJ43pXzmPk=; b=KcesxilWXRdWpOhaJNS8hSdNzO2vJhvPIX8XFE/aZuuFFV/+3fkufo6o6ElznrbWN1 hoQZPHbfdOcz8L6sXkvFrKKZliazt6a4HKb0p79Fa2Zhrdr6HDCcI0KK/H9P9yVDZ0Y1 XOoaExBg1xHhuXs3yHeI8R5l5GWskuW3Z+FVRjyUb653F8P0zqYTLWJiVIDzJ2NhKKTd sAM2TckvvjW2cAHdzhkzl7UYgmcQlxp7qgTNOjT2XZzRsRWDv8h0wvTVgRljyvneh0q1 9N5+8G6XjIRe/5YLV+HiKEXVas9ltjJefKy4f23RAvj1+gQWPwzMCaVO52+Z4MXYdv5k T+pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lfSfy0OiU9ae6zZc6r/YuzMWOjdJ0UjQGjJ43pXzmPk=; b=7p/9yq9xpezZ3uBSRHr2tWpmnh9NOiLc6yrAiiAAbyR/oo6vPLdz69JYEBG/bHBdii u/znIG/aJ5up40GNa/gUtcG6b99UNi3qQMHtO1TSMXV03gLZp6sfabvoJowi+HbdPzJj L+cVonl3uDdxH3PjK7DB/Zzk1mxx1CZJQlQkH7i8BVJ2DFv2/3dep+1zQhJR3pyJrB90 6FtLO/0hyBqOe2RbYhCQbCWTkZECajBx92GFLLkJFdYJ/RHnhzdI/Wih1Sc/BZHeXtJp sYi9zepxydxMCYU+k48f3ha5LybXbGzWAO76JRDDhPKcSzZl/T5kNtZBHz5/oy5yJpBR fs7w== X-Gm-Message-State: ACgBeo08d1AcooztRepr/Txseo3XRciiksOSMFQ3EZ+du+na7BPIbXFV e81Hwusj5YcsB8T/OmiIw9s= X-Google-Smtp-Source: AA6agR52gEm4o8C36a4sLU4vrMjIM3u6oGZjtYr9bqiC4iAeliEnkHdid9H5R34pPZS4s09WvEyVEg== X-Received: by 2002:a5e:a70f:0:b0:684:d596:b7e7 with SMTP id b15-20020a5ea70f000000b00684d596b7e7mr20134222iod.84.1662327733775; Sun, 04 Sep 2022 14:42:13 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:13 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:41 -0600 Message-Id: <20220904214134.408619-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 04/57] dyndbg: reverse module walk in cat control X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" /proc/dynamic_debug/control walks the prdbg catalog in "reverse", fix this by adding new ddebug_tables to tail of list. This puts init/main.c entries 1st, which looks more than coincidental. no functional changes. Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8faf584f2f4b..7fb99492c16f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -970,7 +970,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, dt->ddebugs = tab; mutex_lock(&ddebug_lock); - list_add(&dt->link, &ddebug_tables); + list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); From patchwork Sun Sep 4 21:40: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: 12965281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3FF2ECAAD5 for ; Sun, 4 Sep 2022 21:45:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 809C210E27F; Sun, 4 Sep 2022 21:42:57 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9A7E10E135; Sun, 4 Sep 2022 21:42:15 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id 10so5685068iou.2; Sun, 04 Sep 2022 14:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=86ewCwjQW9i1kYjMVzcHXeBvyH4rTaXf6X7Uwlu5n+M=; b=GXl1s6xju+1eOoRqJRl5q8cmU4AqdZG79xuy+4LJGCEiw/Hpm6hcED/kqRFHo3q+gu qamuPL9FDFXp54vbLn1D/b404KlO7XolhPIJPAhLWpnmuPX+sSGTlZLE8h+zZqYnQIrO WQv5lca1ZofQjJIzLmrQTtiUPEYKCY216cU1ZnpHg+6ZUjNnIOjcVxlqwiL58RevVO8D pGUHsa6tvLQW+hC5jGjp1KE581rAtx4OqvJE4X3qwKJoz1fNkj+HyJpZ/66sdZUCD24D Mz7y6TAL9Xr3pr/ZW5qptrtm61mPi57w9KyBOC6mMX4UYP+bimaAR2CSopw3oHJTZyoA VPjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=86ewCwjQW9i1kYjMVzcHXeBvyH4rTaXf6X7Uwlu5n+M=; b=Bx1Lor4eUSlER3ZAJnCUd2rGH7NkMMjjpa4aVqnnJfLl2GjVISEmVN+d2yjOpRVxQz qMDl8tjfo6dhwj5xDgKsWj5wcchMnJqYW1ZVitEGsZ9czOKsOeT+fKl67gobkVaX5/uo 84jVaDzZSB4BBMLZJI+CR8v11tn/GgpMq1M8WnOWS0UoSq+9iaFQ9TTkE7jvvHORrn6+ i2ChJhwuGTpgwwR9sTfEK2IbBQCQXqRtXYANdnB4o/qWQtWrwMhgsvblJ2sYHA8p36Ey hJgnSv74laxQo8DCAEifSMrbKqPVwzJoGZZ0vrnd83+W90mGn/mGLFhUx4n2Ag/WRF+T FSwQ== X-Gm-Message-State: ACgBeo0cQm065/jTywIMn9uhylLsI6wavHukszHz5UYvFlDVqpOHtRz2 lJY41PsacCsz1yXfgHDlJRA= X-Google-Smtp-Source: AA6agR6667/lK+w05CI7BYagBtCSm/gCmvjQy5HHxRwHWCtcxf7YniB8McshMO9sqao4Jd/ymXysNA== X-Received: by 2002:a05:6638:1607:b0:34a:105c:7204 with SMTP id x7-20020a056638160700b0034a105c7204mr24730394jas.216.1662327734786; Sun, 04 Sep 2022 14:42:14 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:14 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:42 -0600 Message-Id: <20220904214134.408619-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 05/57] dyndbg: reverse module.callsite walk in cat control X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Walk the module's vector of callsites backwards; ie N..0. This "corrects" the backwards appearance of a module's prdbg vector when walked 0..N. I think this is due to linker mechanics, which I'm inclined to treat as immutable, and the order is fixable in display. No functional changes. Combined with previous commit, which reversed tables-list, we get: :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012" init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" init/main.c:1424 [main]run_init_process =_ " with arguments:\012" init/main.c:1426 [main]run_init_process =_ " %s\012" init/main.c:1427 [main]run_init_process =_ " with environment:\012" init/main.c:1429 [main]run_init_process =_ " %s\012" Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 7fb99492c16f..8ff11977b8bd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -59,7 +59,7 @@ struct ddebug_query { struct ddebug_iter { struct ddebug_table *table; - unsigned int idx; + int idx; }; struct flag_settings { @@ -805,13 +805,12 @@ static struct _ddebug *ddebug_iter_first(struct ddebug_iter *iter) { if (list_empty(&ddebug_tables)) { iter->table = NULL; - iter->idx = 0; return NULL; } iter->table = list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx = 0; - return &iter->table->ddebugs[iter->idx]; + iter->idx = iter->table->num_ddebugs; + return &iter->table->ddebugs[--iter->idx]; } /* @@ -824,15 +823,16 @@ static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter) { if (iter->table == NULL) return NULL; - if (++iter->idx == iter->table->num_ddebugs) { + if (--iter->idx < 0) { /* iterate to next table */ - iter->idx = 0; if (list_is_last(&iter->table->link, &ddebug_tables)) { iter->table = NULL; return NULL; } iter->table = list_entry(iter->table->link.next, struct ddebug_table, link); + iter->idx = iter->table->num_ddebugs; + --iter->idx; } return &iter->table->ddebugs[iter->idx]; } From patchwork Sun Sep 4 21:40:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7965BC6FA82 for ; Sun, 4 Sep 2022 21:44:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AC3410E265; Sun, 4 Sep 2022 21:42:51 +0000 (UTC) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DF6210E13C; Sun, 4 Sep 2022 21:42:17 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id b142so5642068iof.10; Sun, 04 Sep 2022 14:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ysIiIQDuG3NPX9ftczW4ZGg58gUBI4jeSANScS140gM=; b=APgxhuRWpHrA5EiAcM6bPTAJX5sVjnKO8ZXN2+OQbTnNZthJ6+91rd6qMlpfQu96tK kU7buxw62MArc4SqmHlqi7ZnRepiJzi2ZjfY0l2reZS4c+bENNXL+q4MBcG6kmRIBJDg zjOTRGcunIJUea9k7GCkxnFakIoXTx5p4Q3YZsvD2JZKGgVLIqCxlvTVr6lLWopOQ5jg tM6aObbyHfQt4hKC15wVu4dtKTl7xSjSAHhGJrPEG7cERNokHi0L0ifYgGVAskmds7W2 JuY57ATFtM+4aknCtkIxF/AXoHBg+QwEAv3LIU8kjqNqvJGhCXZbCxBDuxpyjqad4Plp 4+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ysIiIQDuG3NPX9ftczW4ZGg58gUBI4jeSANScS140gM=; b=xxAh/p4UZJBypJZqqY73gzFANse80LflCsSkIrGHz1qL8U4cp5wnl8bUt1E1kiGV6y A1jifzp7w17bodu9KiRao1VV9WZQKfJUpyeiHrbMtA79kZrFlc7O5YO2KxNficVSO2Uz /j4dJGycKHNyGQf80NQWqcKXyH+ahUrHYYmrvjWV7xm3kpeyhHd+ZyElvZHSufstD3N5 euXn9H7Q/Z6kskf/1aT2GFZ0AuRiNy5hb+M1VrPEgzuXkdvc80m4+bj6ytbr92j+NYjo Z9PfXEZEpaCGCj7IZLDzJ2pdztM/KVjy7o9XZiqeb4sP/SzRbK2wh7EnSMEs8qyvmB7F ZJmQ== X-Gm-Message-State: ACgBeo1ZmE9n0Ohegy9JTFlPTNbiYVMJIO9ZQBccJ9RKoI146+YuoBui vYQVoyhHcBwH2OVXp5Lw+nDH5E9qb5M= X-Google-Smtp-Source: AA6agR6afjzcErCVofVv8IgSNBB83b3vDq9Bdzagkl5cWOw7B+80htmvEYKRocJbPU12He1vQEZnCg== X-Received: by 2002:a05:6602:2b81:b0:688:b897:13b8 with SMTP id r1-20020a0566022b8100b00688b89713b8mr21276933iov.43.1662327735766; Sun, 04 Sep 2022 14:42:15 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:15 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:43 -0600 Message-Id: <20220904214134.408619-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 06/57] dyndbg: use ESCAPE_SPACE for cat control X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" `cat control` currently does octal escape, so '\n' becomes "\012". Change this to display as "\n" instead, which reads much cleaner. :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\n" init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\n" init/main.c:1424 [main]run_init_process =_ " with arguments:\n" init/main.c:1426 [main]run_init_process =_ " %s\n" init/main.c:1427 [main]run_init_process =_ " with environment:\n" init/main.c:1429 [main]run_init_process =_ " %s\n" Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8ff11977b8bd..e5cbe603000c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -900,7 +900,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) trim_prefix(dp->filename), dp->lineno, iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); - seq_escape(m, dp->format, "\t\r\n\""); + seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\"\n"); return 0; From patchwork Sun Sep 4 21:40:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0B30ECAAD5 for ; Sun, 4 Sep 2022 21:45:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0AE110E289; Sun, 4 Sep 2022 21:42:58 +0000 (UTC) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by gabe.freedesktop.org (Postfix) with ESMTPS id A509310E136; Sun, 4 Sep 2022 21:42:17 +0000 (UTC) Received: by mail-io1-xd30.google.com with SMTP id q81so5653590iod.9; Sun, 04 Sep 2022 14:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nL64tgfR3yuX9RW4VuAbZjo3bVMvuFZk7zY8MVD5bOI=; b=MCERlmgtJae24BInitcbNWrvVsK4E28qygPVO0EI6bkancXMheS04Tjo59+IeITlng jf5a49doi5XUUhgQrgt0RmWEG3xEjEu3z6ICYcIoTvGgQxKN8UUHK2ER+0LYVRq3FV20 WucDDDHNaHkRRVFc33rm6kG1+UsezVvy9A3pW29Mq1niKl9lIkT8agZdaeX87NAWjUS1 MYunE/FL5qWQueHrE71Nebq3OiS0fnNs9Cl3zzOr1/GBkEIemuvUKXl1uWUTCi/CRp7Y yFRVweG/UcdYXA9YY+/xnyx11VcNoG2ZRCFkTug07yb1tarb7cX3rZ4pliWCDznewiHQ YFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=nL64tgfR3yuX9RW4VuAbZjo3bVMvuFZk7zY8MVD5bOI=; b=E2fnTGHeOWHazwEJcmnuRK/jxnZbxhxzvXEwOFQgtqcaj0I6GQSdfazbbT0cYeMJ2E bJr+264LosdHj+4kC2XBpdvmKAfjxdqXZonSNzXkbv8GbFmkuImQr+KzZBUBJR6Qz7CI hvYRJB4P3Z8ldNDUdTQ+tVh0Tg2WjFWW8Nb8XmH+Y25eEqn6pcFsAb5shX8p3+oVwgpB BlYBCujnLqnYyCKwpOOAVIGG3S7KIEamiZhN2Uc4hmTXPBS6EY2bvCUo9jZnbz8TNOJB FZqz0hznhyJnUYmmaIbLgR/NJWB02qTjsDR4kCpfZlp9yMkwes0WNnsxGQjWkVOKyUrb p2bg== X-Gm-Message-State: ACgBeo0c8pN9+KmYS5+Sv2RXb+Sp4QLQFZ7+ZmPgGi24gnehAv6zJpEJ 4WjoW4f/antesxR2Rq8axo4= X-Google-Smtp-Source: AA6agR6mvknJtV6TiNBzpnOFVHbpLslD1LC4cvqoUjepqIcY8t7Gx+7cGEaleIov3kTIKLX0n/BTLQ== X-Received: by 2002:a05:6602:13c8:b0:68a:db5d:269d with SMTP id o8-20020a05660213c800b0068adb5d269dmr20950589iov.209.1662327736752; Sun, 04 Sep 2022 14:42:16 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:16 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:44 -0600 Message-Id: <20220904214134.408619-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 07/57] dyndbg: let query-modname override actual module name X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" dyndbg's control-parser: ddebug_parse_query(), requires that search terms: module, func, file, lineno, are used only once in a query; a thing cannot be named both foo and bar. The cited commit added an overriding module modname, taken from the module loader, which is authoritative. So it set query.module 1st, which disallowed its use in the query-string. But now, its useful to allow a module-load to enable classes across a whole (or part of) a subsystem at once. # enable (dynamic-debug in) drm only modprobe drm dyndbg="class DRM_UT_CORE +p" # get drm_helper too modprobe drm dyndbg="class DRM_UT_CORE module drm* +p" # get everything that knows DRM_UT_CORE modprobe drm dyndbg="class DRM_UT_CORE module * +p" # also for boot-args: drm.dyndbg="class DRM_UT_CORE module * +p" So convert the override into a default, by filling it only when/after the query-string omitted the module. NB: the query class FOO handling is forthcoming. Fixes: 8e59b5cfb9a6 dynamic_debug: add modname arg to exec_query callchain Acked-by: Jason Baron Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e5cbe603000c..5a849716220a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -385,10 +385,6 @@ static int ddebug_parse_query(char *words[], int nwords, return -EINVAL; } - if (modname) - /* support $modname.dyndbg= */ - query->module = modname; - for (i = 0; i < nwords; i += 2) { char *keyword = words[i]; char *arg = words[i+1]; @@ -429,6 +425,13 @@ static int ddebug_parse_query(char *words[], int nwords, if (rc) return rc; } + if (!query->module && modname) + /* + * support $modname.dyndbg=, when + * not given in the query itself + */ + query->module = modname; + vpr_info_dq(query, "parsed"); return 0; } From patchwork Sun Sep 4 21:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0383ECAAD5 for ; Sun, 4 Sep 2022 21:44:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0FDC10E1A3; Sun, 4 Sep 2022 21:42:34 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 66A0E10E140; Sun, 4 Sep 2022 21:42:18 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id s3so1910938ilv.4; Sun, 04 Sep 2022 14:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=a7DZCtJXdhSHu/g5l+Gfz3Grwf1u1lU78G+9NH5FV+4=; b=Jkkv7Uh7bMpbU+r6NlVBVYvbcfasFu4S18WrtPiOTovRP/fBU0eokGYClnWQb7wddC DJ2DbVzsV7l0UCuqjr+/R6KQlSzLD5J92WNj7XSoVVY8gqVI9s5+LywRHe/BNZ0ZDJCc DBl/2kKsA3D/oCquCqonuGQe5CgfatnSAtbCiKvVrFPbB6oGvCcBuFm2/uYygIQIwATx /9hnZoDjFPUZ988quw0t0Q6f4uHxj8Y7bfuMSk0/m2vgl7WvaETEtWFom2mBW8A8JJcp dzHb6d84REzzsRPCW3uadJ6MxO4TQxHz/Xw5lgx7Ma3qC+o1NzDn+smeH30H24e+PkJ2 LgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=a7DZCtJXdhSHu/g5l+Gfz3Grwf1u1lU78G+9NH5FV+4=; b=7Yd6MdY9SyhBayB5zsxy1M56DH3c5LQ/I3q+YBW2yjYjzMlmonfXHaQU9YTGq0+y7T hy/luOgAhHf9764iobubPsypHscCtruM33duHOF02eDuX1hWS2szVhf91g71zK9uffwq 1MzF14MMq/teNPfp5/Vq5o8z62e6e1BBIG2w94j5nYb2CKwzZWlceQFjMkBd/QHb9P6W WmsvJfQdasF7RoclxD+oLTyQ1Aofi6uFeNGAj7MJJ3FLngfipFGOx3qHRbDb8ts1Wp5G 3hcWVfy+4xaIykYJsMatRrVRBNekW0s+5BT+Qns/2Ok8GOAAOsg+MsbfkBDtaxLY9fKy lpiA== X-Gm-Message-State: ACgBeo2nNfei7qrPCFb6Et6ihxlZEoTqYAD4ZcjijhMfqv+1Rogb9Qu4 MC/4EH/23RKDoFvxUWpgdhb61v3Q9V4= X-Google-Smtp-Source: AA6agR7hw62bgxem2HOBZn5lz7k1Ka/rS42TkERRx352o8pyZNwU2vSuXFqs3ENfjD7w6M0xKnvuiQ== X-Received: by 2002:a92:cdae:0:b0:2f1:8d4e:403e with SMTP id g14-20020a92cdae000000b002f18d4e403emr4891ild.129.1662327737641; Sun, 04 Sep 2022 14:42:17 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:17 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:45 -0600 Message-Id: <20220904214134.408619-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 08/57] dyndbg: add test_dynamic_debug module X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Provide a simple module to allow testing DYNAMIC_DEBUG behavior. It calls do_prints() from module-init, and with a sysfs-node. dmesg -C dmesg -w & modprobe test_dynamic_debug dyndbg=+p echo 1 > /sys/module/dynamic_debug/parameters/verbose cat /sys/module/test_dynamic_debug/parameters/do_prints echo module test_dynamic_debug +mftl > /proc/dynamic_debug/control echo junk > /sys/module/test_dynamic_debug/parameters/do_prints Acked-by: Jason Baron Signed-off-by: Jim Cromie --- MAINTAINERS | 2 ++ lib/Kconfig.debug | 10 ++++++ lib/Makefile | 1 + lib/test_dynamic_debug.c | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lib/test_dynamic_debug.c diff --git a/MAINTAINERS b/MAINTAINERS index 41762df1be0c..c4465981df31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7222,6 +7222,8 @@ M: Jason Baron S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +M: Jim Cromie +F: lib/test_dynamic_debug.c DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 183c37502119..5bf7897d9095 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2587,6 +2587,16 @@ config TEST_STATIC_KEYS If unsure, say N. +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on DYNAMIC_DEBUG + help + This module registers a tracer callback to count enabled + pr_debugs in a 'do_debugging' function, then alters their + enablements, calls the function, and compares counts. + + If unsure, say N. + config TEST_KMOD tristate "kmod stress tester" depends on m diff --git a/lib/Makefile b/lib/Makefile index f0a855eed891..c893114029b8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o obj-$(CONFIG_TEST_SCANF) += test_scanf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c new file mode 100644 index 000000000000..ba3882ca3e48 --- /dev/null +++ b/lib/test_dynamic_debug.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +#define pr_fmt(fmt) "test_dd: " fmt + +#include + +static void do_prints(void); /* device under test */ + +/* run tests by reading or writing sysfs node */ + +static int param_set_do_prints(const char *instr, const struct kernel_param *kp) +{ + do_prints(); + return 0; +} + +static int param_get_do_prints(char *buffer, const struct kernel_param *kp) +{ + do_prints(); + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); +} + +static const struct kernel_param_ops param_ops_do_prints = { + .set = param_set_do_prints, + .get = param_get_do_prints, +}; + +module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); + +static void do_alpha(void) +{ + pr_debug("do alpha\n"); +} +static void do_beta(void) +{ + pr_debug("do beta\n"); +} + +static void do_prints(void) +{ + do_alpha(); + do_beta(); +} + +static int __init test_dynamic_debug_init(void) +{ + pr_debug("init start\n"); + + do_prints(); + + pr_debug("init done\n"); + return 0; +} + +static void __exit test_dynamic_debug_exit(void) +{ + pr_debug("exiting\n"); +} + +module_init(test_dynamic_debug_init); +module_exit(test_dynamic_debug_exit); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); From patchwork Sun Sep 4 21:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 322DCECAAD5 for ; Sun, 4 Sep 2022 21:46:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10F5910E1C4; Sun, 4 Sep 2022 21:42:55 +0000 (UTC) Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5473310E135; Sun, 4 Sep 2022 21:42:19 +0000 (UTC) Received: by mail-il1-x12a.google.com with SMTP id a9so3885278ilh.1; Sun, 04 Sep 2022 14:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=774vPkNjj+tHobVK7wxTpiFngzuHiOZuQGU68liCSfs=; b=C7K+Yu8rS5CfqjlNHPHnOaD4zxwfuunfcvyOT5g9f9rMen9a6bVHcvqbwXA2+Y+9Kz RKQbD2pNaDWCYN70iNH05lkOWO4RBz/bQ8/cRwN6WEZcEvurKwq1+mOrxYFqPOqFAgqc jTojshygRsAzBiQhplkoP1HY15Ecq9/KjZAyKP3dmiszNKFO5leOY1ZvfEMxlgqXIOZd dYRX5/7LlkpgOOE5bEoz36HFy0JsAvZ+ng4hTn9uDioPYMM7Bu0T/tVRPEgpDqQID6iV nipB6JonPPNto+aq00YwjoQiAFGv/V/8G9n0DURSqGi4XiyI78KNHcGZM6RuJDkxs46Z 26bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=774vPkNjj+tHobVK7wxTpiFngzuHiOZuQGU68liCSfs=; b=R2SoRJgSUlpl4QRrVWuV7ldF9UIQG4Z2TeOqAkDu6f0cD8aYkbzRF3LBFpK1hm/pC4 +mwYbSZT96ebqajyPEpJ4UFoBZccDEm7Tp8nF6E2S85fHYYoD/8kFdQfwMA3uSL/6+fp iffQkFFQCAICGBKr/rR6tnHbgpfW22pmDKKPE6+KLxx4m8A5CWj4givl8jsoZT7m96J1 nUWamMmDz51rR+NuLJbGoHFYYsb6fKaTWPG15OgV4no4p475URgFWKz6TTcxkZ/ETt2q GMUZxPM2BxiG8nTfszBOj7CRGZlQ0tIiWdfxc9hj3foy4IpC6wweyZaXWYK2gNcjPh4k 2P+Q== X-Gm-Message-State: ACgBeo0PfsByV8MLt2m3TrjcvY10AHV9EMrgLfsLryJ5bi4X5GacSQZO 2a50DQ+4mvUbzV1ZhI2eTS4= X-Google-Smtp-Source: AA6agR5dk7sIC47F0zJwtTKZLwCG1OGpPQGC5vGCcEQBykOFT3Gx9Uw/vzxF/89YxMKOB4dB9YkQUQ== X-Received: by 2002:a05:6e02:148d:b0:2ee:82e:63fc with SMTP id n13-20020a056e02148d00b002ee082e63fcmr7362054ilk.289.1662327738560; Sun, 04 Sep 2022 14:42:18 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:18 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:46 -0600 Message-Id: <20220904214134.408619-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 09/57] dyndbg: drop EXPORTed dynamic_debug_exec_queries X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This exported fn is unused, and will not be needed. Lets dump it. The export was added to let drm control pr_debugs, as part of using them to avoid drm_debug_enabled overheads. But its better to just implement the drm.debug bitmap interface, then its available for everyone. Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()") Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") Acked-by: Jason Baron Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 9 --------- lib/dynamic_debug.c | 29 ----------------------------- 2 files changed, 38 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f30b01aa9fa4..8d9eec5f6d8b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -55,9 +55,6 @@ struct _ddebug { #if defined(CONFIG_DYNAMIC_DEBUG_CORE) -/* exported for module authors to exercise >control */ -int dynamic_debug_exec_queries(const char *query, const char *modname); - int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); extern int ddebug_remove_module(const char *mod_name); @@ -221,12 +218,6 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) -static inline int dynamic_debug_exec_queries(const char *query, const char *modname) -{ - pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); - return 0; -} - #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a849716220a..e96dc216463b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -558,35 +558,6 @@ static int ddebug_exec_queries(char *query, const char *modname) return nfound; } -/** - * dynamic_debug_exec_queries - select and change dynamic-debug prints - * @query: query-string described in admin-guide/dynamic-debug-howto - * @modname: string containing module name, usually &module.mod_name - * - * This uses the >/proc/dynamic_debug/control reader, allowing module - * authors to modify their dynamic-debug callsites. The modname is - * canonically struct module.mod_name, but can also be null or a - * module-wildcard, for example: "drm*". - */ -int dynamic_debug_exec_queries(const char *query, const char *modname) -{ - int rc; - char *qry; /* writable copy of query */ - - if (!query) { - pr_err("non-null query/command string expected\n"); - return -EINVAL; - } - qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); - if (!qry) - return -ENOMEM; - - rc = ddebug_exec_queries(qry, modname); - kfree(qry); - return rc; -} -EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); - #define PREFIX_SIZE 64 static int remaining(int wrote) From patchwork Sun Sep 4 21:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63831C6FA82 for ; Sun, 4 Sep 2022 21:43:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BE1810E197; Sun, 4 Sep 2022 21:42:32 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3479510E134; Sun, 4 Sep 2022 21:42:21 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id d68so5628836iof.11; Sun, 04 Sep 2022 14:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=JzdXJQgZbXW3FjxRfc8LeNnI2jIQsEPwZbCx/pElNeM=; b=FUv8NBMgLulwhhEoMyLnxfYB3+uPNeLFEo5/TLMiSZjR94roddKbiqTTG31unDiBV2 koej5AIOTpgc4Fj75xhV1jWGKl/5CM8q7EieivOlV5/b+BYdXa9pALtMLQe6QZEuohs8 uc4jHbPW01pKLaccj4L/SBD9SF3hrWMDpeLoGgRrvCEUQKX8JmTlITp0J8QvdPavHfqS KpCN89/psw628tV7ylJY71laqV2x/K4y1PPoettY5lY6Kg7pmI05/DzTkiDbBqcz1dnc NsgFPB4IEgajS8Toc7/PVXqE2pPIC6p3Ibe6XKVfl3deYBS708mMbxWmh4z8Z7N8CYIi UccQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=JzdXJQgZbXW3FjxRfc8LeNnI2jIQsEPwZbCx/pElNeM=; b=d4S2pnbdzUOoPKcZncPHOSSHUvWo/+KbanleMYrdWSW3P8zHEdmkgxQDlTyvuTQHqf vLM+4Sj+rGPPnAIr/mUb95gdKrF7c/AZmdSI1G5f0ZfFZRpK3Pd+87AQLb3/1ol8YCgx OsfQypMtJ4nGvq72mB0Kbr0QsjgS3HwyL3kSxN0lQMadm+/0iAd99QkxX5Xe9AH7yUGy xcT9wt0V3fLlGRPheLYMaGXfWw05nbytSfuuSMRgkz+iMHZKk5lmxCXdq5AYmw1KmA3n 5AtkrZ/hdISL5/8whQiq0bUyB2Q6c/yivW/NehlswPW0VqZOiMpK5bIhOqePoDp4EtNd 9WUg== X-Gm-Message-State: ACgBeo0VeZ0v5MFjtI36CfpUbPk4o/v0icWZCu3XhV+P7TH/QciNaNek /V4+or3JAl41IGqDHTNASYQ= X-Google-Smtp-Source: AA6agR69LwdoHmp66Z3rxXxBJJ0Vec0ZLNH/n+zC6VNVydFgIRnTRHkjqAX0L8kf28KEk70mHqw2jw== X-Received: by 2002:a5e:8414:0:b0:689:e3c:308a with SMTP id h20-20020a5e8414000000b006890e3c308amr21338651ioj.29.1662327739611; Sun, 04 Sep 2022 14:42:19 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:19 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:47 -0600 Message-Id: <20220904214134.408619-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 10/57] dyndbg: cleanup auto vars in dynamic_debug_init X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" rework var-names for clarity, regularity rename variables - n to mod_sites - it counts sites-per-module - entries to i - display only - iter_start to iter_mod_start - marks start of each module's subrange - modct to mod_ct - stylistic new iterator var: - site - cursor parallel to iter 1st step towards 'demotion' of iter->site, for removal later treat vars as iters: - drop init at top init just above for-loop, in a textual block Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e96dc216463b..2e8ebef3bd0d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1059,11 +1059,10 @@ static int __init dynamic_debug_init_control(void) static int __init dynamic_debug_init(void) { - struct _ddebug *iter, *iter_start; - const char *modname = NULL; + struct _ddebug *iter, *iter_mod_start; + int ret, i, mod_sites, mod_ct; + const char *modname; char *cmdline; - int ret = 0; - int n = 0, entries = 0, modct = 0; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1074,30 +1073,32 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; return 0; } - iter = __start___dyndbg; + + iter = iter_mod_start = __start___dyndbg; modname = iter->modname; - iter_start = iter; - for (; iter < __stop___dyndbg; iter++) { - entries++; + i = mod_sites = mod_ct = 0; + + for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + if (strcmp(modname, iter->modname)) { - modct++; - ret = ddebug_add_module(iter_start, n, modname); + mod_ct++; + ret = ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; - n = 0; + + mod_sites = 0; modname = iter->modname; - iter_start = iter; + iter_mod_start = iter; } - n++; } - ret = ddebug_add_module(iter_start, n, modname); + ret = ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; ddebug_init_success = 1; vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", - entries, modct, (int)((modct * sizeof(struct ddebug_table)) >> 10), - (int)((entries * sizeof(struct _ddebug)) >> 10)); + i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), + (int)((i * sizeof(struct _ddebug)) >> 10)); /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. From patchwork Sun Sep 4 21:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68FEEC6FA89 for ; Sun, 4 Sep 2022 21:44:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC13A10E23C; Sun, 4 Sep 2022 21:42:49 +0000 (UTC) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 805B110E163; Sun, 4 Sep 2022 21:42:23 +0000 (UTC) Received: by mail-il1-x133.google.com with SMTP id k9so701019ils.12; Sun, 04 Sep 2022 14:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=UryXZ8MRQvm9M8ywPbYKJOd9IzaI7xdASsleEmdDI64=; b=muSWjLs7x00fb34NXmJsZan+xUhIQRfkeBRQvGNO6EFtSqDV4gjF1KMkI8Bqak2VBg M+SglSeYYC0OIZzXmOEj02FMTLSgdMYfMKEdDLaaJuUeMzg1y8KursXgroBhEJhRXtPE ES3Dwgi1AQvCREt4K2pjDPVYOugleYpu5qaUw9tS2HWryERwvYXOQYwsEa82WRrrUjO/ yp7b0DPlePFOgcmNGO1FDSg1nPI3ICuWkKnZ9YbEBpQ3YvU6cljVk8CuOS4yIAP4Zg5S dnOYXunWEY24yxfgLxp+iCfDjBKFKOLqcksfSprGowZrq59RNyZHdmnZQ7ThwtBHf/Qg N9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=UryXZ8MRQvm9M8ywPbYKJOd9IzaI7xdASsleEmdDI64=; b=VSSB3w8FllE86Ogs8WRG3kN8jJHoE1Vo/7txnaOKJiWJRsDznnL1U8BTICKfs0VT4g 8w0fDRcfAXO9LMMRoawPkOeH3qdFY07V8A7oAHKXiPvPR9WrPhUdcQzDPpqzD3u011q1 Gsl5zj/b0N7MMPHvSR4fmbmRCzNyJYG7Jrh4xtFxRDSl9sFG1LnXEbS0ZpXmrQc+X8B2 bcg2hBMGRhFkekQI6Qn6loyckJUotUUzGDB2HlMILX71KDOgSWwJZrYWYh1Bt9bc20UZ H5JJmSBvvh2GlrfRJSYz+Q5SGvvJPRmPmSXWaLnRfgXRAtIEnevFeILXG1QZYOUTbzG2 OTrg== X-Gm-Message-State: ACgBeo2b6Db5npWcBmZtXbSie5zYpNKZjvvqHzRIqpTikicy8TLRrPpz S54L8F5bfqcWmV08oSjz55Y= X-Google-Smtp-Source: AA6agR4xCBLCNJuB54OnGN7VtAxvyEt+vNDQxb7qX+QcTnPDx6k921Txd/smbqxpe7ugLH91cljdjg== X-Received: by 2002:a05:6e02:15c4:b0:2e1:986c:91a1 with SMTP id q4-20020a056e0215c400b002e1986c91a1mr24412890ilu.22.1662327740646; Sun, 04 Sep 2022 14:42:20 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:20 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:48 -0600 Message-Id: <20220904214134.408619-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 11/57] dyndbg: gather __dyndbg[] state into struct _ddebug_info X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, Luis Chamberlain , seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This new struct composes the linker provided (vector,len) section, and provides a place to add other __dyndbg[] state-data later: descs - the vector of descriptors in __dyndbg section. num_descs - length of the data/section. Use it, in several different ways, as follows: In lib/dynamic_debug.c: ddebug_add_module(): Alter params-list, replacing 2 args (array,index) with a struct _ddebug_info * containing them both, with room for expansion. This helps future-proof the function prototype against the looming addition of class-map info into the dyndbg-state, by providing a place to add more member fields later. NB: later add static struct _ddebug_info builtins_state declaration, not needed yet. ddebug_add_module() is called in 2 contexts: In dynamic_debug_init(), declare, init a struct _ddebug_info di auto-var to use as a cursor. Then iterate over the prdbg blocks of the builtin modules, and update the di cursor before calling _add_module for each. Its called from kernel/module/main.c:load_info() for each loaded module: In internal.h, alter struct load_info, replacing the dyndbg array,len fields with an embedded _ddebug_info containing them both; and populate its members in find_module_sections(). The 2 calling contexts differ in that _init deals with contiguous subranges of __dyndbgs[] section, packed together, while loadable modules are added one at a time. So rename ddebug_add_module() into outer/__inner fns, call __inner from _init, and provide the offset into the builtin __dyndbgs[] where the module's prdbgs reside. The cursor provides start, len of the subrange for each. The offset will be used later to pack the results of builtin __dyndbg_sites[] de-duplication, and is 0 and unneeded for loadable modules, Note: kernel/module/main.c includes for struct _ddeubg_info. This might be prone to include loops, since its also included by printk.h. Nothing has broken in robot-land on this. cc: Luis Chamberlain Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 13 +++++++----- kernel/module/internal.h | 4 ++-- kernel/module/main.c | 18 ++++++++-------- lib/dynamic_debug.c | 40 +++++++++++++++++++++++++++-------- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8d9eec5f6d8b..6a2001250da1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -51,12 +51,16 @@ struct _ddebug { #endif } __attribute__((aligned(8))); - +/* encapsulate linker provided built-in (or module) dyndbg data */ +struct _ddebug_info { + struct _ddebug *descs; + unsigned int num_descs; +}; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname); +int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); + extern int ddebug_remove_module(const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -184,8 +188,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include -static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname) +static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char *modname) { return 0; } diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 680d980a4fb2..2e2bf236f558 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -53,6 +53,7 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const s32 __start___kcrctab[]; extern const s32 __start___kcrctab_gpl[]; +#include struct load_info { const char *name; /* pointer to module in temporary copy, freed at end of load_module() */ @@ -62,8 +63,7 @@ struct load_info { Elf_Shdr *sechdrs; char *secstrings, *strtab; unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; - struct _ddebug *debug; - unsigned int num_debug; + struct _ddebug_info dyndbg; bool sig_ok; #ifdef CONFIG_KALLSYMS unsigned long mod_kallsyms_init_off; diff --git a/kernel/module/main.c b/kernel/module/main.c index a4e4d84b6f4e..4c20bc3ff203 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1598,16 +1598,16 @@ static void free_modinfo(struct module *mod) } } -static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num) +static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *dyndbg) { - if (!debug) + if (!dyndbg->num_descs) return; - ddebug_add_module(debug, num, mod->name); + ddebug_add_module(dyndbg, mod->name); } -static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) +static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *dyndbg) { - if (debug) + if (dyndbg->num_descs) ddebug_remove_module(mod->name); } @@ -2111,8 +2111,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) if (section_addr(info, "__obsparm")) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); - info->debug = section_objs(info, "__dyndbg", - sizeof(*info->debug), &info->num_debug); + info->dyndbg.descs = section_objs(info, "__dyndbg", + sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); return 0; } @@ -2807,7 +2807,7 @@ static int load_module(struct load_info *info, const char __user *uargs, } init_build_id(mod, info); - dynamic_debug_setup(mod, info->debug, info->num_debug); + dynamic_debug_setup(mod, &info->dyndbg); /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init(mod); @@ -2871,7 +2871,7 @@ static int load_module(struct load_info *info, const char __user *uargs, ddebug_cleanup: ftrace_release_mod(mod); - dynamic_debug_remove(mod, info->debug); + dynamic_debug_remove(mod, &info->dyndbg); synchronize_rcu(); kfree(mod->args); free_arch_cleanup: diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2e8ebef3bd0d..c358ccdf4a39 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -923,14 +923,20 @@ static const struct proc_ops proc_fops = { * Allocate a new ddebug_table for the given module * and add it to the global list. */ -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *name) +static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, + const char *modname) { struct ddebug_table *dt; + v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + if (!di->num_descs) { + v3pr_info(" skip %s\n", modname); + return 0; + } + dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) { - pr_err("error adding module: %s\n", name); + pr_err("error adding module: %s\n", modname); return -ENOMEM; } /* @@ -939,18 +945,25 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, * member of struct module, which lives at least as long as * this struct ddebug_table. */ - dt->mod_name = name; - dt->num_ddebugs = n; - dt->ddebugs = tab; + dt->mod_name = modname; + dt->ddebugs = di->descs; + dt->num_ddebugs = di->num_descs; + + INIT_LIST_HEAD(&dt->link); mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); - vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); + vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); return 0; } +int ddebug_add_module(struct _ddebug_info *di, const char *modname) +{ + return __ddebug_add_module(di, 0, modname); +} + /* helper for ddebug_dyndbg_(boot|module)_param_cb */ static int ddebug_dyndbg_param_cb(char *param, char *val, const char *modname, int on_err) @@ -1064,6 +1077,11 @@ static int __init dynamic_debug_init(void) const char *modname; char *cmdline; + struct _ddebug_info di = { + .descs = __start___dyndbg, + .num_descs = __stop___dyndbg - __start___dyndbg, + }; + if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); @@ -1082,7 +1100,9 @@ static int __init dynamic_debug_init(void) if (strcmp(modname, iter->modname)) { mod_ct++; - ret = ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs = mod_sites; + di.descs = iter_mod_start; + ret = __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; @@ -1091,7 +1111,9 @@ static int __init dynamic_debug_init(void) iter_mod_start = iter; } } - ret = ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs = mod_sites; + di.descs = iter_mod_start; + ret = __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; From patchwork Sun Sep 4 21:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D98DECAAD5 for ; Sun, 4 Sep 2022 21:47:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8716D10E252; Sun, 4 Sep 2022 21:43:23 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8AAEF10E135; Sun, 4 Sep 2022 21:42:23 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868035ilt.7; Sun, 04 Sep 2022 14:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xIjcpB1yObanMGjMFeMKYjIQWCM49hxUe0Q+YC489GU=; b=MLaOUG1eQyDNFysR3kFQ1CuvqHjhT0aQXApMqF4gTtmKSNtSjX/I5UlLfKj7GXM5dJ ERh08+wfPW/pY1uDfq/mQRn9W4pI+ZknWQk0O9BgR5Mk9AjPJWG5zDfHLcpmenzVQTzo 579HyQFoNP2ls47VGJ5G3weYDitOixMG/+//9S/xiAYoLVVWBuJc+DV/rYYNjDLyRLfb HNDjMkbf5rFexzATxXpZ556L2eM2E51BpzYlMdQx5ufJQGJ8cauf0lUEASuflYmkRnFq wm3CJLRAjYbtQSKbcHHo9KjCQC9bF3ISuBv6sJ+vPDbFd2H4Yl4b8qIqAqmbssefUuAQ LhwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xIjcpB1yObanMGjMFeMKYjIQWCM49hxUe0Q+YC489GU=; b=dnyMjdQi4CDVcB0bDokE1qY0QNKe0Hx5/Q3cwNIUpaoORwakQh9sBdFrVirKxWnuop b/QVYh3xw4X9ewj/SpZxQSH83hFV1lFKNAZAr7OlDZa152ULGN0n2DTapG3Pg7CbjOui xKfZZZa7kZn8ERdtf37HIo0BaBswXQQhNr9g6qBPlSoP7uYGM1KAkKv6nYa5OvJjCLZq WjuMv3jmHxv3HTd/btM1UK55LT6vqaodsTsUQdMklH53o3b3c0SaJOBVZdVMAMFA6/do ZN3It2tIys9UssHYV+ehFMZkWetZUKeLMZbycURQ5MSsf8d/JnpxliWGDj7TW4dxRRA3 964g== X-Gm-Message-State: ACgBeo2XKk06gCAQUkiDztQKyWOONyEwouZAdccgcNv3mifxw9T/IGjr 5fwCXss9vVfv5j8altTQRts= X-Google-Smtp-Source: AA6agR67iR6BYXhMU24o7aSNMqzyMctDSZZTQcZ/yxizOCzV0f4LJSYbYSri4MSdNRuTGB/KPRJVfw== X-Received: by 2002:a05:6e02:15c9:b0:2e1:a5b6:7e25 with SMTP id q9-20020a056e0215c900b002e1a5b67e25mr23241731ilu.185.1662327741691; Sun, 04 Sep 2022 14:42:21 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:21 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:49 -0600 Message-Id: <20220904214134.408619-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 12/57] dyndbg: add class_id to pr_debug callsites X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rasmus Villemoes , Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DRM issues ~10 exclusive categories of debug messages; to represent this directly in dyndbg, add a new 6-bit field: struct _ddebug.class_id. This gives us 64 classes, which should be more than enough. #> echo 0x012345678 > /sys/module/drm/parameters/debug All existing callsites are initialized with _DPRINTK_CLASS_DFLT, which is 2^6-1. This reserves 0-62 for use in new categorized/class'd pr_debugs, which fits perfectly with natural enums (ints: 0..N). Thats done by extending the init macro: DEFINE_DYNAMIC_DEBUG_METADATA() with _CLS(cls, ...) suffix, and redefing old name using extended name. Then extend the factory macro callchain with _cls() versions to provide the callsite.class_id, with old-names passing _DPRINTK_CLASS_DFLT. This sets us up to create class'd prdebug callsites (class'd callsites are those with .class_id != _DPRINTK_CLASS_DFLT). No behavior change. cc: Rasmus Villemoes Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 71 +++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 6a2001250da1..633f4e463766 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -6,6 +6,8 @@ #include #endif +#include + /* * An instance of this structure is created in a special * ELF section at every dynamic debug callsite. At runtime, @@ -21,6 +23,9 @@ struct _ddebug { const char *filename; const char *format; unsigned int lineno:18; +#define CLS_BITS 6 + unsigned int class_id:CLS_BITS; +#define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -88,7 +93,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, \ @@ -97,8 +102,14 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ + .class_id = cls, \ _DPRINTK_KEY_INIT \ - } + }; \ + BUILD_BUG_ON_MSG(cls > _DPRINTK_CLASS_DFLT, \ + "classid value overflow") + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) #ifdef CONFIG_JUMP_LABEL @@ -129,17 +140,34 @@ 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__); \ -} while (0) - -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ +/* + * Factory macros: ($prefix)dynamic_func_call($suffix) + * + * Lower layer (with __ prefix) gets the callsite metadata, and wraps + * the func inside a debug-branch/static-key construct. Upper layer + * (with _ prefix) does the UNIQUE_ID once, so that lower can ref the + * name/label multiple times, and tie the elements together. + * Multiple flavors: + * (|_cls): adds in _DPRINT_CLASS_DFLT as needed + * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) + */ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ + func(&id, ##__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define __dynamic_func_call_cls_no_desc(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_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) /* * "Factory macro" for generating a call to func, guarded by a @@ -149,22 +177,33 @@ 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(_DPRINTK_CLASS_DFLT, 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_cls_no_desc(cls, fmt, func, ...) \ + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ + func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define dynamic_pr_debug_cls(cls, fmt, ...) \ + _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \ + pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_pr_debug(fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_pr_debug, \ + _dynamic_func_call(fmt, __dynamic_pr_debug, \ pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_dev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ + _dynamic_func_call(fmt, __dynamic_dev_dbg, \ dev, fmt, ##__VA_ARGS__) #define dynamic_netdev_dbg(dev, fmt, ...) \ From patchwork Sun Sep 4 21:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EFF6C6FA82 for ; Sun, 4 Sep 2022 21:44:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 92E5710E248; Sun, 4 Sep 2022 21:42:47 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED28A10E140; Sun, 4 Sep 2022 21:42:22 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690458iof.1; Sun, 04 Sep 2022 14:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9SzKct1HE2F9SFFHU0qV3d4yTS+Vy3tZKPhpRiWkMoE=; b=keVbDAqmRl0RyYCgYBZ9vpqCQmkMyk7el0JhW316fk9lzXS1Qp8s1NvY5dl+0KhmSp ibqXTnOnHqVsgbVNxEqbtv43vgYRsJvWCMIHnYD2MdOnweaxtJ/6lJmRUKioxtauNnK3 MAOa5YY5NhAaVnZUHf9WjVTMmFZFR8zfXvqsn6ug0qyuxgGFFgrtJhQLojNKtMyGeGVu +yc9Lpue47auQ2O1yq9JKZ+AL+lsysQCM4CP52NRtG4YNpaMNSOR2BmwDKNu/vEgwcNy CzChZLaOzOawknlDJ4jxM+ihj0KwR+efhIg2T10h1eobX6skVdqLap7sQsWzIfHZi9ST UvOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9SzKct1HE2F9SFFHU0qV3d4yTS+Vy3tZKPhpRiWkMoE=; b=MJqOY3vUCTIeirzHwFXaYmcvYDeo2kaKFQkPCgr6IxA9KYbxj1yTHGvoYvDQXVXicH O2OBwLt4HVLvKKecAy4tlP6UotjtxervYfH79QIG4kC6s5qN+pj9p0KTk/C4Zkp3Khc2 HBMWaVqYpmT3Xn8xomjOmbZ8aRODLb4swQsIdec98bVRqlMs0ua02azLiyIL0uufpYA4 sb4v2boSQak0JaGSPc/nnI23xn0SJy5lNjw09/1VPRh6FIiSI/HvklWnuF/bkUfmG6zJ GOeALwzjBcFlBH/LOZxxZu8xVSpTsnmLtxXtRlCgKabSsevWyEaEe6dNbuEEpoXpdI1N qOxg== X-Gm-Message-State: ACgBeo3rCDzaEDobkh5nsxUUrdiZyFqtVzoufTE4BAf8D0NJmmXNVChy LcNJmaRUCVgnMea7RkIxGYw= X-Google-Smtp-Source: AA6agR6jMolGXndfzGgA0ZvJd/LMfHAfLgpxQDVqtziCymaTm3c0Mj4mJvOTk/aEeCbTagH4y5NkEA== X-Received: by 2002:a5e:8407:0:b0:689:ff32:84d3 with SMTP id h7-20020a5e8407000000b00689ff3284d3mr21836771ioj.180.1662327742655; Sun, 04 Sep 2022 14:42:22 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:22 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:50 -0600 Message-Id: <20220904214134.408619-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 13/57] dyndbg: add __pr_debug_cls for testing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" For selftest purposes, add __pr_debug_cls(class, fmt, ...) I didn't think we'd need to define this, since DRM effectively has it already in drm_dbg, drm_devdbg. But test_dynamic_debug needs it in order to demonstrate all the moving parts. Note the __ prefix; its not intended for general use, at least until a need emerges. ISTM the drm.debug model (macro wrappers inserting enum const 1st arg) is the baseline approach. That said, nouveau might want it for easy use in its debug macros. TBD. NB: it does require a builtin-constant class, __pr_debug_cls(i++, ...) is disallowed by compiler. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 633f4e463766..3c9690da44d9 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -221,6 +221,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +/* for test only, generally expect drm.debug style macro wrappers */ +#define __pr_debug_cls(cls, fmt, ...) do { \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ + "expecting constant class int/enum"); \ + dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ + } while (0) + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include From patchwork Sun Sep 4 21:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15D82C6FA86 for ; Sun, 4 Sep 2022 21:45:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93D1010E24A; Sun, 4 Sep 2022 21:43:06 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0058910E134; Sun, 4 Sep 2022 21:42:23 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id r141so5678375iod.4; Sun, 04 Sep 2022 14:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5Pcy7SEXmziNMuvuaPrrGzNbNpmap+iXZUcd2i8OvCY=; b=GB9PW2F6Q86MU59eDr4MyMDq35GvNA/Jg6eGCzAQ+7KsoRzAAGQZzPwH/dw5FsI2O2 3lRJv+1hZh1L7J0X5r+/gJmZ/p+S01FMLMk12jtIdbQdXgJQ5HUhVxyOwaVdwGYVI3Oz yjqdX503u6uH34EL0ic6GiF8HRbIhCOXLCJO9nVVYQl1dCp+lnEx6muhaf01/usDbzPU ZZzM26A2bAzM2xcI/xnYhnCbRLdj88A3HAOOSNyOx2yCAv4FEaJnA3vSTNlpS3Zj1ziY Be6DgpqOnB5C2e1LiZ39wPFC92RfVb0RqUf1pyPHHTI99OqApEkJoA3tEi/tTJOeGG06 rZsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=5Pcy7SEXmziNMuvuaPrrGzNbNpmap+iXZUcd2i8OvCY=; b=FU2It+lwikCQdF7ESHCyxO+QG1jc9NfDT8PwDfXVv0+lEwps4jYaSqHuh0ngGaWViA zuAXclATMETG8SuTxEu5b1O96+HCcdthayl1v0yhX1ePaNqEnwX/GMGuK2LBdejJeAMX tcXm21evR284orb/Y8jTI9U092uwyPrBfSs/0TDV2tYciM0xor83W88eDZWT06fsXf/r 5M2sEknRXTIDBpXh0uZr3pq0V7JhzY+10jQU6YA7U3XcfBl02WV4gvvRI29PaMKvAHk4 0E1GNxDQWrQUiBEcO6iBlsiVrXBwwKV8JMcVL8UGyDOXxi0lSQLsPgBA5O6JFZB9li5Q CVdw== X-Gm-Message-State: ACgBeo3bmN+Xd+xR9aVqfcqZ+4GS73GchX4sCowTtC+/7clbK65uO4OL 4jDbNa9lvK3vUQp5I0l6FWw= X-Google-Smtp-Source: AA6agR6EECGaIhMrD6/ftIKIMo5ApfTHYgvzkKs19vbQldr38XY5/ivWSJIIjhhS6BH5Fg18Gldhsw== X-Received: by 2002:a6b:e816:0:b0:688:c999:d08c with SMTP id f22-20020a6be816000000b00688c999d08cmr22221392ioh.100.1662327743569; Sun, 04 Sep 2022 14:42:23 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:23 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:51 -0600 Message-Id: <20220904214134.408619-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 14/57] dyndbg: add DECLARE_DYNDBG_CLASSMAP macro X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Using DECLARE_DYNDBG_CLASSMAP, modules can declare up to 31 classnames. By doing so, they authorize dyndbg to manipulate class'd prdbgs (ie: __pr_debug_cls, and soon drm_*dbg), ala:: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control The macro declares and initializes a static struct ddebug_class_map:: - maps approved class-names to class_ids used in module, by array order. forex: DRM_UT_* - class-name vals allow validation of "class FOO" queries using macro is opt-in - enum class_map_type - determines interface, behavior Each module has its own class-type and class_id space, and only known class-names will be authorized for a manipulation. Only DRM modules should know and respont to this: :#> echo class DRM_UT_CORE +p > control # across all modules pr_debugs (with default class_id) are still controllable as before. DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, classes...) is:: _var: name of the static struct var. user passes to module_param_cb() if they want a sysfs node. _maptype: this is hard-coded to DD_CLASS_TYPE_DISJOINT_BITS for now. _base: usually 0, it allows splitting 31 classes into subranges, so that multiple classes / sysfs-nodes can share the module's class-id space. classes: list of class_name strings, these are mapped to class-ids starting at _base. This class-names list must have a corresponding ENUM, with SYMBOLS that match the literals, and 1st enum val = _base. enum class_map_type has 4 values, on 2 factors:: - classes are disjoint/independent vs relative/xcontrol interface doesn't enforce the LEVELS relationship, so you could confusingly have V3 enabled, but V1 disabled. OTOH, the control iface already allows infinite tweaking of the underlying callsites; sysfs node readback can only tell the user what they previously wrote. 2. All dyndbg >control reduces to a query/command, includes +/-, which is at-root a kernel patching operation with +/- semantics. And the _NAMES handling exposes it to the user, making it API-adjacent. And its not just >control where +/- gets used (which is settled), the new place is with sysfs-nodes exposing _*_NAMES classes, and here its subtly different. _DISJOINT_NAMES: is simple, independent _LEVEL_NAMES: masks-on bits 0 .. N-1, N..max off # turn on L3,L2,L1 others off echo +L3 > /sys/module/test_dynamic_debug/parameters/p_level_names # turn on L2,L1 others off echo -L3 > /sys/module/test_dynamic_debug/parameters/p_level_names IOW, the - changes the threshold-on bitpos by 1. Alternatively, we could treat the +/- as half-duplex, where -L3 turns off L>2 (and ignores L1), and +L2 would turn on L<=2 (and ignore others). Signed-off-by: Jim Cromie --- . revised DD_CLASS_TYPE_{DISJOINT,LEVEL}_* names . reorder-enum - _NAMES feature is extra. --- include/linux/dynamic_debug.h | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 3c9690da44d9..98dbf1d49984 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -56,6 +56,61 @@ struct _ddebug { #endif } __attribute__((aligned(8))); +enum class_map_type { + DD_CLASS_TYPE_DISJOINT_BITS, + /** + * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit. + * expecting hex input. Built for drm.debug, basis for other types. + */ + DD_CLASS_TYPE_LEVEL_NUM, + /** + * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N. + * N turns on just bits N-1 .. 0, so N=0 turns all bits off. + */ + DD_CLASS_TYPE_DISJOINT_NAMES, + /** + * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES, + * classes are independent, like _DISJOINT_BITS. + */ + DD_CLASS_TYPE_LEVEL_NAMES, + /** + * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES, + * intended for names like: INFO,DEBUG,TRACE, with a module prefix + * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug + */ +}; + +struct ddebug_class_map { + struct list_head link; + struct module *mod; + const char *mod_name; /* needed for builtins */ + const char **class_names; + const int length; + const int base; /* index of 1st .class_id, allows split/shared space */ + enum class_map_type map_type; +}; + +/** + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module + * @_var: a struct ddebug_class_map, passed to module_param_cb + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names used to control class'd prdbgs + */ +#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ + static const char *_var##_classnames[] = { __VA_ARGS__ }; \ + static struct ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_classes") _var = { \ + .mod = THIS_MODULE, \ + .mod_name = KBUILD_MODNAME, \ + .base = _base, \ + .map_type = _maptype, \ + .length = NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .class_names = _var##_classnames, \ + } +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) + /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; From patchwork Sun Sep 4 21:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EFA6ECAAD5 for ; Sun, 4 Sep 2022 21:46:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C8A710E2F8; Sun, 4 Sep 2022 21:43:14 +0000 (UTC) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5621F10E16D; Sun, 4 Sep 2022 21:42:25 +0000 (UTC) Received: by mail-io1-xd2e.google.com with SMTP id p187so5652771iod.8; Sun, 04 Sep 2022 14:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ygTuajbmVKRymZcTR8l4AYG1vTV31KkFalfQRqvEO70=; b=qb+eXUS2FeGvpVtJ7v+DpOZwxGybLXxNLvokvSQTdNFeUtdY8CsheY5eB/SHmPx4O9 huSEsSDTQKrSj+0Puiw+lGBf49Y4J1xWJgf6Ap2MJoyUCbw2fAY5nQAAJERXo7vJ7beG uEy7TG4owjT8onLbXW0wMRyVFiQeDhNfDDdJsyJhbLqVj3VikXMuVtM2AfKuFTkruuIT ZEtn5PQ+tih96gGXNgsH2cVDPtvjPYgq/XfBF5eBzbkWlcn29wqz/HPJB8mdX0xxRHTF eqZ20NxASPafvwnESXcu++44WdfCGPEIGsJqdmjGZ4Ebkk3JbphMGW8Ilt+BN7LlYeLQ RQIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ygTuajbmVKRymZcTR8l4AYG1vTV31KkFalfQRqvEO70=; b=wqyswgqSS+xjxhGFgvJszBg+HlA73UKzKlDubqKST3aa2GcfrSxGUyVPbJM8ELYkty zDiRUy3ZzFtvddHO1aHNwQzyZ9yzHqszranMyOCaNsBvrAsBNOGrDg1mtjq49SufJwa/ Gi4IIn4K07Ro7GV8DFG2fMEMM1ySJWfIGkxZph2YzPoXn1d02uNlJTlQocom/QqomJT0 u0yc3YWLypTLNweEICsH7G2+r+OFW5JuJS+5on2SkIOX2UqktQkQQs9GJ79UlZkLsomj 7eiXP8eHwNu3KmdRtZ2eYeOIfzNMhlv26hXD1CKclxIvH2Xx+BQNdvZKMR903AqpJ2sc 4i/w== X-Gm-Message-State: ACgBeo1XsD8v5gJMF8LxRX/lxYzdJNh6/hAFelEYRgjq08/OvgjcURqr SRh2pLPzwgSVgahrgx72aj8= X-Google-Smtp-Source: AA6agR6i2bEKl1Cs2088Bgc9CVI77OTinqvJI0IWGolf9NIA7tDBAIrKIIWBixVDBMgcEhK2nR9WNg== X-Received: by 2002:a05:6638:4091:b0:342:e406:45d8 with SMTP id m17-20020a056638409100b00342e40645d8mr25310655jam.130.1662327744496; Sun, 04 Sep 2022 14:42:24 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:24 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:52 -0600 Message-Id: <20220904214134.408619-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 15/57] kernel/module: add __dyndbg_classes section X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add __dyndbg_classes section, using __dyndbg as a model. Use it: vmlinux.lds.h: KEEP the new section, which also silences orphan section warning on loadable modules. Add (__start_/__stop_)__dyndbg_classes linker symbols for the c externs (below). kernel/module/main.c: - fill new fields in find_module_sections(), using section_objs() - extend callchain prototypes to pass classes, length load_module(): pass new info to dynamic_debug_setup() dynamic_debug_setup(): new params, pass through to ddebug_add_module() dynamic_debug.c: - add externs to the linker symbols. ddebug_add_module(): - It currently builds a debug_table, and *will* find and attach classes. dynamic_debug_init(): - add class fields to the _ddebug_info cursor var: di. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 2 ++ kernel/module/main.c | 2 ++ lib/dynamic_debug.c | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 7515a465ec03..9b8bd5504ad9 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -345,6 +345,9 @@ *(__tracepoints) \ /* implement dynamic printk debug */ \ . = ALIGN(8); \ + __start___dyndbg_classes = .; \ + KEEP(*(__dyndbg_classes)) \ + __stop___dyndbg_classes = .; \ __start___dyndbg = .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg = .; \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 98dbf1d49984..9073a43a2039 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -114,7 +114,9 @@ struct ddebug_class_map { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct ddebug_class_map *classes; unsigned int num_descs; + unsigned int num_classes; }; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) diff --git a/kernel/module/main.c b/kernel/module/main.c index 4c20bc3ff203..6aa6153aa6e0 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2113,6 +2113,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) info->dyndbg.descs = section_objs(info, "__dyndbg", sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); + info->dyndbg.classes = section_objs(info, "__dyndbg_classes", + sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); return 0; } diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c358ccdf4a39..fb31a1a2fc3f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -41,6 +41,8 @@ extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct ddebug_class_map __start___dyndbg_classes[]; +extern struct ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { struct list_head link; @@ -1079,7 +1081,9 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di = { .descs = __start___dyndbg, + .classes = __start___dyndbg_classes, .num_descs = __stop___dyndbg - __start___dyndbg, + .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, }; if (&__start___dyndbg == &__stop___dyndbg) { @@ -1122,6 +1126,9 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); + if (di.num_classes) + v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. * While this has already been done for known boot params, it From patchwork Sun Sep 4 21:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB524ECAAD5 for ; Sun, 4 Sep 2022 21:45:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16A5B10E22E; Sun, 4 Sep 2022 21:42:46 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2A3910E140; Sun, 4 Sep 2022 21:42:25 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id r141so5678400iod.4; Sun, 04 Sep 2022 14:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bV2pbi1NEnXBIYceq2iCnojYvMw47Sm5P0bDatZE/qY=; b=DRCAFhL8qizXn9QBOsMZO6CWk737/iorbRJ4AxHGEgMlW1XjBcP+vkmFKNoyTUK0Mj RgDgR2Ync4KORGyKwN45XuxZ3LCgDHh7aM7gIcdOLcttBFR6Un79bJyvT2V/T+t1uwET tHeAl0kEFnMLN5umqFTSN7rOVhAj0XWVzl/y6lz8DsbMtgZKngpwCHlWQPaVdjC6LyHL qSLUkoUXTZ6m9J5MpZDXz12M3aHFBVeTnL/qP7lUD45vpjehf2aOfxyxGF8UMp8S8D8U hKvmKb7U5FALDSB3abvwTeqDsOg4bgbNnzuU9E1pJLb4XrIdrdIzUyRn++u3pSGOKqBq 6ETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bV2pbi1NEnXBIYceq2iCnojYvMw47Sm5P0bDatZE/qY=; b=yMlJ5eaqZCr1helUhuL3NXet4g6Ua8XMvah6x4I9G5zSYMoRQLoxLSj5mnsTsyuhDK cqwclGqbovebeO8qBE/STq+EWTz+cqEaz9GVfoFgVhpAUTkVUGmnqEz9pf1JyowWAp5F RnBSkjGU7aqMdW6mEzHcWz3wzFb5dfc29V1aIcJC934gPzwo38FQk+jFpVFclA+x1Knu NrUBvKUWj/8T43Zhy/sT0W+ChR+VWp0+6gOIjvgCCoxJ+gcN1lR5W5mR9U8iCltel7cJ AioWNNdgGDiShdRPMSXzBcaHl0fsiY0ZMNr6Si7y9zagsBHXHVY+p3wrJLAXJ37j+0Mk 1RnQ== X-Gm-Message-State: ACgBeo2fstDQJzouGUFMUXEj6DvPzmI2pQoCq2pvHZQxdmVtsWlVgPza lO38VMFCNbmPIP8yKJJv0qs= X-Google-Smtp-Source: AA6agR4Eiudl3FZhHqIH1u+1kjDcwObHAsibzo+7iq3K3aAIOXK9LPSM3GGiI3JaBRbAwyq3KZU0rA== X-Received: by 2002:a6b:3e06:0:b0:68b:7524:f342 with SMTP id l6-20020a6b3e06000000b0068b7524f342mr15398868ioa.149.1662327745421; Sun, 04 Sep 2022 14:42:25 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:25 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:53 -0600 Message-Id: <20220904214134.408619-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 16/57] dyndbg: add ddebug_attach_module_classes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add ddebug_attach_module_classes(), call it from ddebug_add_module(). It scans the classes/section its given, finds records where the module-name matches the module being added, and adds them to the module's maps list. No locking here, since the record isn't yet linked into the ddebug_tables list. It is called indirectly from 2 sources: - from load_module(), where it scans the module's __dyndbg_classes section, which contains DYNAMIC_DEBUG_CLASSES definitions from just the module. - from dynamic_debug_init(), where all DYNAMIC_DEBUG_CLASSES definitions of each builtin module have been packed together. This is why ddebug_attach_module_classes() checks module-name. NOTES Its (highly) likely that builtin classes will be ordered by module name (just like prdbg descriptors are in the __dyndbg section). So the list can be replaced by a vector (ptr + length), which will work for loaded modules too. This would imitate whats currently done for the _ddebug descriptors. That said, converting to vector,len is close to pointless; a small minority of modules will ever define a class-map, and almost all of them will have only 1 or 2 class-maps, so theres only a couple dozen pointers to save. TODO: re-evaluate for lines removable. Signed-off-by: Jim Cromie --- v6 . fix compile err due to reorderd commits, and missed lkp report. . init dt->maps in ddebug_add_module, prior to ddebug_attach_module_classes --- lib/dynamic_debug.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fb31a1a2fc3f..b71efd0b491d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,7 +45,7 @@ extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { - struct list_head link; + struct list_head link, maps; const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; @@ -921,6 +921,32 @@ static const struct proc_ops proc_fops = { .proc_write = ddebug_proc_write }; +static void ddebug_attach_module_classes(struct ddebug_table *dt, + struct ddebug_class_map *classes, + int num_classes) +{ + struct ddebug_class_map *cm; + int i, j, ct = 0; + + for (cm = classes, i = 0; i < num_classes; i++, cm++) { + + if (!strcmp(cm->mod_name, dt->mod_name)) { + + v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, + cm->mod_name, cm->base, cm->length, cm->map_type); + + for (j = 0; j < cm->length; j++) + v3pr_info(" %d: %d %s\n", j + cm->base, j, + cm->class_names[j]); + + list_add(&cm->link, &dt->maps); + ct++; + } + } + if (ct) + vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -952,6 +978,10 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, dt->num_ddebugs = di->num_descs; INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->maps); + + if (di->classes && di->num_classes) + ddebug_attach_module_classes(dt, di->classes, di->num_classes); mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); From patchwork Sun Sep 4 21:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7381DC6FA86 for ; Sun, 4 Sep 2022 21:46:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C52110E271; Sun, 4 Sep 2022 21:42:54 +0000 (UTC) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1626610E174; Sun, 4 Sep 2022 21:42:27 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id 62so5673969iov.5; Sun, 04 Sep 2022 14:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VxE+CjvPcbwZBKtBtewU/pc49ydYdwD1bemh/z2C+cc=; b=h1uXArjcpOcsplR1a7ck5hMfB0jipK7wuQb7G44QWNwGjgEBu1Xr0G94cXBoKzCxfl 1vjqE5xplO6F9Ls21RTEGvLbk74OohelrHNWo/7jTzO5+gDicgi/Bhw7sy4kErWVx22u 02PfdOEn6NyoxKvro1zgilAxVQfYygibBFevXKY43frFl8LZo4SEX9VknH94NYm2QeTv ntOmxRNJPekmmY2SfXOh/Mtv93hcpIqsrWvRjureF0LbQUIqNg5XmgRMuOe2/qExVrJY FsBtgrOyxi+4w3laqUtR4Qlj95NLv5TTt4NuboZT5tsRTKmXXBS6ekBqAFZ/3n+DSo0a el+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VxE+CjvPcbwZBKtBtewU/pc49ydYdwD1bemh/z2C+cc=; b=G2dNMSqWUFW1IvTMPyOOsJcIbOFEgJ6n+INP+ULpfkKzFBco2ZjgUT+mMIKGYYYOoc KZx4/PfGLRUeo8T3yYhIuVDBKNvXDbgtNmwguWqxX3t9G2NBBMNvWpd079tOkrr/j919 LCGFbI13evY1R6TfFm+rj5tv6KrS9yGgfp52RwbbRUwqOZtMkZd2bae2eS48rRaUOTAy O7I1mnSg25vhkhuE2qocGncnOHKA4vh/TW++/TYMqICweEfZ3mxlN31oZNWUZqG6SgWi V4YR5oVYzkp0i04xitV+wOEze0nxf80sJBDJsb0+qVuM9P24wvRZT01W8pDlaKzy1he0 gjjg== X-Gm-Message-State: ACgBeo1bZJcTKs1srCAMhqQJqbXMq1KC+t7SEK9Oekb1c5h/MD/DxVN6 ceeieTuaodj1Noi/EIjzems= X-Google-Smtp-Source: AA6agR4/STeszDaNnHQOAo3k0NzkOuMgD+5y52Td5RoIs4nkonSkpoIupcmrwQAe7iVGrvlZT5LJ6A== X-Received: by 2002:a02:c487:0:b0:34f:3b8b:6ba1 with SMTP id t7-20020a02c487000000b0034f3b8b6ba1mr6323054jam.291.1662327746302; Sun, 04 Sep 2022 14:42:26 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:26 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:54 -0600 Message-Id: <20220904214134.408619-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 17/57] dyndbg: validate class FOO by checking with module X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add module-to-class validation: #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control If a query has "class FOO", then ddebug_find_valid_class(), called from ddebug_change(), requires that FOO is known to module X, otherwize the query is skipped entirely for X. This protects each module's class-space, other than the default:31. The authors' choice of FOO is highly selective, giving isolation and/or coordinated sharing of FOOs. For example, only DRM modules should know and respond to DRM_UT_KMS. So this, combined with module's opt-in declaration of known classes, effectively privatizes the .class_id space for each module (or coordinated set of modules). Notes: For all "class FOO" queries, ddebug_find_valid_class() is called, it returns the map matching the query, and sets valid_class via an *outvar). If no "class FOO" is supplied, valid_class = _CLASS_DFLT. This insures that legacy queries do not trample on new class'd callsites, as they get added. Also add a new column to control-file output, displaying non-default class-name (when found) or the "unknown _id:", if it has not been (correctly) declared with one of the declarator macros. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 76 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b71efd0b491d..db96ded78c3f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -56,6 +56,7 @@ struct ddebug_query { const char *module; const char *function; const char *format; + const char *class_string; unsigned int first_lineno, last_lineno; }; @@ -136,15 +137,33 @@ 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", - msg, - query->function ?: "", - query->filename ?: "", - query->module ?: "", - fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno); + v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s\n", + msg, + query->function ?: "", + query->filename ?: "", + query->module ?: "", + fmtlen, query->format ?: "", + query->first_lineno, query->last_lineno, query->class_string); } +static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, + const char *class_string, int *class_id) +{ + struct ddebug_class_map *map; + int idx; + + list_for_each_entry(map, &dt->maps, link) { + idx = match_string(map->class_names, map->length, class_string); + if (idx >= 0) { + *class_id = idx + map->base; + return map; + } + } + *class_id = -ENOENT; + return NULL; +} + +#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -159,6 +178,8 @@ static int ddebug_change(const struct ddebug_query *query, unsigned int newflags; unsigned int nfound = 0; struct flagsbuf fbuf, nbuf; + struct ddebug_class_map *map = NULL; + int __outvar valid_class; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -169,9 +190,22 @@ static int ddebug_change(const struct ddebug_query *query, !match_wildcard(query->module, dt->mod_name)) continue; + if (query->class_string) { + map = ddebug_find_valid_class(dt, query->class_string, &valid_class); + if (!map) + continue; + } else { + /* constrain query, do not touch class'd callsites */ + valid_class = _DPRINTK_CLASS_DFLT; + } + for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; + /* match site against query-class */ + if (dp->class_id != valid_class) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -420,6 +454,8 @@ 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")) { + rc = check_set(&query->class_string, arg, "class"); } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -854,6 +890,20 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) return dp; } +#define class_in_range(class_id, map) \ + (class_id >= map->base && class_id < map->base + map->length) + +static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) +{ + struct ddebug_class_map *map; + + list_for_each_entry(map, &iter->table->maps, link) + if (class_in_range(dp->class_id, map)) + return map->class_names[dp->class_id - map->base]; + + return NULL; +} + /* * Seq_ops show method. Called several times within a read() * call from userspace, with ddebug_lock held. Formats the @@ -865,6 +915,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) struct ddebug_iter *iter = m->private; struct _ddebug *dp = p; struct flagsbuf flags; + char const *class; if (p == SEQ_START_TOKEN) { seq_puts(m, @@ -877,7 +928,16 @@ 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_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id != _DPRINTK_CLASS_DFLT) { + class = ddebug_class_name(iter, dp); + if (class) + seq_printf(m, " class:%s", class); + else + seq_printf(m, " class unknown, _id:%d", dp->class_id); + } + seq_puts(m, "\n"); return 0; } From patchwork Sun Sep 4 21:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72991ECAAD5 for ; Sun, 4 Sep 2022 21:46:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1ADD10E272; Sun, 4 Sep 2022 21:42:54 +0000 (UTC) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by gabe.freedesktop.org (Postfix) with ESMTPS id A24CB10E12F; Sun, 4 Sep 2022 21:42:27 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id 62so5673985iov.5; Sun, 04 Sep 2022 14:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ka8KRcp96RIs3WOVwaYMps+w4bs0E4mB3tU6nT4x+Cw=; b=GxYiBhtnCCLvIcjhtx8t6SNtIL7IN9FTRLpFWPEgQwmEChr7Li1YPuQJ9uzL52Yj6A cgqwOnKPTkhyNLE0ZRZ71TysRmVMnqOnOuIZy+W7qyW1e5LLWRS5QYdy3aifvqzwysH4 6lBOaERL6zccFDJfBmPhlj41W7qOzgatR/sLszHd+5qrcHenG/kiPqGelWghMXTumLSf wFRbcjMRbogjvc9bqHIzD2/qSvsiQjcw0SYznzSLJ7jTTu+kn1HauuURN6n5y/Y3xzEP XBYr4ufLmOy1cM38/VKtTZMrK2mJrrVShrlX+MdWlctqxmtxNnUASO0irSsXn081Wpp/ hmlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ka8KRcp96RIs3WOVwaYMps+w4bs0E4mB3tU6nT4x+Cw=; b=gt/ZyEjc+0qs5vVFhShBDgaVAl+wy+FrRCyFKwhrxVvMD8cfx/JyGjU0Q/ATWkJf6t HEJLk6N0okIBdXS9L9BPYAznT/ACtUxSwLhH5hU14/83MRj1SoTbjbXMNred5HdaoCAR fMB4slgo1lyypjgTaVqCv4Io4ozYZ7e0p8779ZYvGV7Hlexo70ONOtVTWeLpz/KSr7j3 hc5ypeMFXWIzbQ/oRL5zC1tSGwX66h53sfYh1Ri5LtTOxlV5SgACMIUZByTZiaKW/SZ6 yvzF/K5SV1hffS4gtjREZ4AT3oyiNSBgRmqHgNMZcn4NtjbKf7HAIE25bP4fktIccQ1+ k7mA== X-Gm-Message-State: ACgBeo1gt/kXnJ+DTeKIGd5hVj9VSJD6vMehyS5WKqtZKQAc7G87DXjL rs9X7BXAv43yPAJ/GM4jDr4= X-Google-Smtp-Source: AA6agR5AUEVpUfSPOxmk4wGZ/zK2tirYmhJ7zb9Jqld8zfrr8gDhVIB8ywXi+kyB8PgF4y+5mK88yQ== X-Received: by 2002:a6b:5f19:0:b0:688:2173:1ae3 with SMTP id t25-20020a6b5f19000000b0068821731ae3mr21256805iob.12.1662327747322; Sun, 04 Sep 2022 14:42:27 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:27 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:55 -0600 Message-Id: <20220904214134.408619-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 18/57] doc-dyndbg: describe "class CLASS_NAME" query support X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add an explanation of the new "class CLASS_NAME" syntax and meaning, noting that the module determines if CLASS_NAME applies to it. Signed-off-by: Jim Cromie --- Documentation/admin-guide/dynamic-debug-howto.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index a89cfa083155..d8954ab05c7b 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 name (as known/declared by each module) * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -142,6 +143,7 @@ against. Possible keywords are::: 'file' string | 'module' string | 'format' string | + 'class' string | 'line' line-range line-range ::= lineno | @@ -203,6 +205,15 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitespace +class + The given class_name is validated against each module, which may + have declared a list of known class_names. If the class_name is + found for a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a DRM.debug category + class JUNK # silent non-match + line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single From patchwork Sun Sep 4 21:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 684E1ECAAD5 for ; Sun, 4 Sep 2022 21:45:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A01E410E2A2; Sun, 4 Sep 2022 21:43:02 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE55610E133; Sun, 4 Sep 2022 21:42:28 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690551iof.1; Sun, 04 Sep 2022 14:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=CX6qv1cFIAak2H7Dm87W0kPuSMznCRZBjCF+tQ4X600=; b=Q3cfmH2LyzD2M1ZLD1pNAYsFedbjIhzATxm909rJnzqncgvkGEna14g3zmelu6oNst yGRhbYN/jRA+ojsvvywLPGWaCcX47VMRUnKRP92jnlsGfo1gGsS/0pX+v8XIDy5+K1wv hcfhFf3zOBj2FBQR39ZiBbHIk3gixOCnKUR2CMrawaeq1wqnvitFf/VGPNqkBkPIpnls 56wnzrcfUPLjZXmU8QQUnd4C5IE+42uE+JPwWFrONI+gkyiM0SOy/zS4gmQQTKnJrSEh AmFmI41xFzMh/EU0bL2Kwgx3PqC/fsLN3iAS+RAov2KWCcsxbl/Ax9pu0IhieIAi3uwK Zk8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=CX6qv1cFIAak2H7Dm87W0kPuSMznCRZBjCF+tQ4X600=; b=Otxeed0nn20MyKkmhAu5eOaYiPqKDYDsKNLS7B3IDgTY7U17oKqKJwBSY8YIP8Qu1v +DD4+qIqkkl4gI1964Dp59rWFLCQnXBz8epZq72jpvwrvKGReTBBwsrNySuGohmn2YAS 5V5n9SBJJ5ZJUMYrgquw7+75iA0Ou04GtMZJQLBOavBOzrSkJ2d+L4framURc2PEN0SA SL1YhKQJnFkWB88lpV+xsdhnIa2tdnHh7tskXj1hhcpDNuN5S7ketd7lj08F/zPNw4hL kGt0HPQnp8zRSWbww5jYYfZePrSuxwOFm4Ceg4883aZDS/CBSI9bSWHpcSL90UCp0TJL eG9Q== X-Gm-Message-State: ACgBeo0/0tino0LTnv8syzGYAWiXXAAT7BbfIe4d7NKLoX6ahy43CnzK xtSEdf0K+MXdmnLV+bTPXAw= X-Google-Smtp-Source: AA6agR6FDmbgVlOi+VH2xD/wJEH/An47KuIR8rJmhUndQnxcZqdaaNF4vm3Z/VHoIzRdq/aFbHaolw== X-Received: by 2002:a02:cb57:0:b0:34c:b847:d5fb with SMTP id k23-20020a02cb57000000b0034cb847d5fbmr9181329jap.32.1662327748378; Sun, 04 Sep 2022 14:42:28 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:27 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:56 -0600 Message-Id: <20220904214134.408619-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 19/57] doc-dyndbg: edit dynamic-debug-howto for brevity, audience X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Rework/modernize docs: - use /proc/dynamic_debug/control in examples its *always* there (when dyndbg is config'd), even when is not. drop talk, its a distraction here. - alias ddcmd='echo $* > /proc/dynamic_debug/control focus on args: declutter, hide boilerplate, make pwd independent. - swap sections: Viewing before Controlling. control file as Catalog. - focus on use by a system administrator add an alias to make examples more readable drop grep-101 lessons, admins know this. - use init/main.c as 1st example, thread it thru doc where useful. everybodys kernel boots, runs these. - add *prdbg* api section to the bottom of the file, its for developers more than admins. move list of api functions there. - simplify - drop extra words, phrases, sentences. - add "decorator" flags line to unify "prefix", trim fmlt descriptions CC: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- fixup-doc: trailing colons for block headers, trim fedora numbers. Bagas --- .../admin-guide/dynamic-debug-howto.rst | 235 +++++++++--------- 1 file changed, 117 insertions(+), 118 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index d8954ab05c7b..faa22f77847a 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -5,30 +5,19 @@ Dynamic debug Introduction ============ -This document describes how to use the dynamic debug (dyndbg) feature. +Dynamic debug allows you to dynamically enable/disable kernel +debug-print code to obtain additional kernel information. -Dynamic debug is designed to allow you to dynamically enable/disable -kernel code to obtain additional kernel information. Currently, if -``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and -``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically -enabled per-callsite. +If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic +debug. You'll need root access (sudo su) to use this. -If you do not want to enable dynamic debug globally (i.e. in some embedded -system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic -debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any -modules which you'd like to dynamically debug later. +Dynamic debug provides: -If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just -shortcut for ``print_hex_dump(KERN_DEBUG)``. + * a Catalog of all *prdbgs* in your kernel. + ``cat /proc/dynamic_debug/control`` to see them. -For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is -its ``prefix_str`` argument, if it is constant string; or ``hexdump`` -in case ``prefix_str`` is built dynamically. - -Dynamic debug has even more useful features: - - * Simple query language allows turning on and off debugging - statements by matching any combination of 0 or 1 of: + * a Simple query/command language to alter *prdbgs* by selecting on + any combination of 0 or 1 of: - source filename - function name @@ -37,107 +26,88 @@ Dynamic debug has even more useful features: - format string - class name (as known/declared by each module) - * Provides a debugfs control file: ``/dynamic_debug/control`` - which can be read to display the complete list of known debug - statements, to help guide you - -Controlling dynamic debug Behaviour -=================================== - -The behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a -control file in the 'debugfs' filesystem. Thus, you must first mount -the debugfs filesystem, in order to make use of this feature. -Subsequently, we refer to the control file as: -``/dynamic_debug/control``. For example, if you want to enable -printing from source file ``svcsock.c``, line 1603 you simply do:: - - nullarbor:~ # echo 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - -If you make a mistake with the syntax, the write will fail thus:: - - nullarbor:~ # echo 'file svcsock.c wtf 1 +p' > - /dynamic_debug/control - -bash: echo: write error: Invalid argument - -Note, for systems without 'debugfs' enabled, the control file can be -found in ``/proc/dynamic_debug/control``. - Viewing Dynamic Debug Behaviour =============================== -You can view the currently configured behaviour of all the debug -statements via:: +You can view the currently configured behaviour in the *prdbg* catalog:: - nullarbor:~ # cat /dynamic_debug/control + :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format - net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012" - net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012" - net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth : %d\012" - net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests : %d\012" - ... + init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012 + init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" + init/main.c:1424 [main]run_init_process =_ " with arguments:\012" + init/main.c:1426 [main]run_init_process =_ " %s\012" + init/main.c:1427 [main]run_init_process =_ " with environment:\012" + init/main.c:1429 [main]run_init_process =_ " %s\012" +The 3rd space-delimited column shows the current flags, preceded by +a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites. -You can also apply standard Unix text manipulation filters to this -data, e.g.:: +Controlling dynamic debug Behaviour +=================================== - nullarbor:~ # grep -i rdma /dynamic_debug/control | wc -l - 62 +The behaviour of *prdbg* sites are controlled by writing +query/commands to the control file. Example:: - nullarbor:~ # grep -i tcp /dynamic_debug/control | wc -l - 42 + # grease the interface + :#> alias ddcmd='echo $* > /proc/dynamic_debug/control' -The third column shows the currently enabled flags for each debug -statement callsite (see below for definitions of the flags). The -default value, with no flags enabled, is ``=_``. So you can view all -the debug statement callsites with any non-default flags:: + :#> ddcmd '-p; module main func run* +p' + :#> grep =p /proc/dynamic_debug/control + init/main.c:1424 [main]run_init_process =p " with arguments:\012" + init/main.c:1426 [main]run_init_process =p " %s\012" + init/main.c:1427 [main]run_init_process =p " with environment:\012" + init/main.c:1429 [main]run_init_process =p " %s\012" - nullarbor:~ # awk '$3 != "=_"' /dynamic_debug/control - # filename:lineno [module]function flags format - net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" +Error messages go to console/syslog:: + + :#> ddcmd mode foo +p + dyndbg: unknown keyword "mode" + dyndbg: query parse failed + bash: echo: write error: Invalid argument + +If debugfs is also enabled and mounted, ``dynamic_debug/control`` is +also under the mount-dir, typically ``/sys/kernel/debug/``. Command Language Reference ========================== -At the lexical level, a command comprises a sequence of words separated +At the basic lexical level, a command is a sequence of words separated by spaces or tabs. So these are all equivalent:: - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' > - /dynamic_debug/control - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd file svcsock.c line 1603 +p + :#> ddcmd "file svcsock.c line 1603 +p" + :#> ddcmd ' file svcsock.c line 1603 +p ' Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: - ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \ - > /dynamic_debug/control - -If your query set is big, you can batch them too:: - - ~# cat query-batch-file > /dynamic_debug/control + :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd <<"EOC" + func pnpacpi_get_resources +p + func pnp_assign_mem +p + EOC + :#> cat query-batch-file > /proc/dynamic_debug/control -Another way is to use wildcards. The match rule supports ``*`` (matches -zero or more characters) and ``?`` (matches exactly one character). For -example, you can match all usb drivers:: +You can also use wildcards in each query term. The match rule supports +``*`` (matches zero or more characters) and ``?`` (matches exactly one +character). For example, you can match all usb drivers:: - ~# echo "file drivers/usb/* +p" > /dynamic_debug/control + :#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion -At the syntactical level, a command comprises a sequence of match -specifications, followed by a flags change specification:: +Syntactically, a command is pairs of keyword values, followed by a +flags change or setting:: command ::= match-spec* flags-spec -The match-spec's are used to choose a subset of the known pr_debug() -callsites to which to apply the flags-spec. Think of them as a query -with implicit ANDs between each pair. Note that an empty list of -match-specs will select all debug statement callsites. +The match-spec's select *prdbgs* from the catalog, upon which to apply +the flags-spec, all constraints are ANDed together. An absent keyword +is the same as keyword "*". -A match specification comprises a keyword, which controls the -attribute of the callsite to be compared, and a value to compare -against. Possible keywords are::: + +A match specification is a keyword, which selects the attribute of +the callsite to be compared, and a value to compare against. Possible +keywords are::: match-spec ::= 'func' string | 'file' string | @@ -213,6 +183,7 @@ class class DRM_UT_KMS # a DRM.debug category class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names line The given line number or range of line numbers is compared @@ -239,17 +210,16 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. - 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 - t Include thread ID in messages not generated from interrupt context - _ No flags are set. (Or'd with others on input) + _ enables no flags. -For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag -have meaning, other flags ignored. + Decorator flags add to the message-prefix, in order: + t Include thread ID, or + m Include module name + f Include the function name + l Include line number -For display, the flags are preceded by ``=`` -(mnemonic: what the flags are currently equal to). +For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only +the ``p`` flag has meaning, other flags are ignored. Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. To clear all flags at once, use ``=_`` or ``-flmpt``. @@ -324,7 +294,7 @@ For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or enabled by ``-DDEBUG`` flag during compilation) can be disabled later via the debugfs interface if the debug messages are no longer needed:: - echo "module module_name -p" > /dynamic_debug/control + echo "module module_name -p" > /proc/dynamic_debug/control Examples ======== @@ -332,37 +302,31 @@ Examples :: // enable the message at line 1603 of file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c line 1603 +p' // enable all the messages in file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c +p' // enable all the messages in the NFS server module - nullarbor:~ # echo -n 'module nfsd +p' > - /dynamic_debug/control + :#> ddcmd 'module nfsd +p' // enable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process +p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process +p' // disable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process -p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process -p' // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. - nullarbor:~ # echo -n 'format "nfsd: READ" +p' > - /dynamic_debug/control + :#> ddcmd 'format "nfsd: READ" +p' // enable messages in files of which the paths include string "usb" - nullarbor:~ # echo -n 'file *usb* +p' > /dynamic_debug/control + :#> ddcmd 'file *usb* +p' > /proc/dynamic_debug/control // enable all messages - nullarbor:~ # echo -n '+p' > /dynamic_debug/control + :#> ddcmd '+p' > /proc/dynamic_debug/control // add module, function to all enabled messages - nullarbor:~ # echo -n '+mf' > /dynamic_debug/control + :#> ddcmd '+mf' > /proc/dynamic_debug/control // boot-args example, with newlines and comments for readability Kernel command line: ... @@ -375,3 +339,38 @@ Examples dyndbg="file init/* +p #cmt ; func parse_one +p" // enable pr_debugs in 2 functions in a module loaded later pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p" + +Kernel Configuration +==================== + +Dynamic Debug is enabled via kernel config items:: + + CONFIG_DYNAMIC_DEBUG=y # build catalog, enables CORE + CONFIG_DYNAMIC_DEBUG_CORE=y # enable mechanics only, skip catalog + +If you do not want to enable dynamic debug globally (i.e. in some embedded +system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic +debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any +modules which you'd like to dynamically debug later. + + +Kernel *prdbg* API +================== + +The following functions are cataloged and controllable when dynamic +debug is enabled:: + + pr_debug() + dev_dbg() + print_hex_dump_debug() + print_hex_dump_bytes() + +Otherwise, they are off by default; ``ccflags += -DDEBUG`` or +``#define DEBUG`` in a source file will enable them appropriately. + +If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is +just a shortcut for ``print_hex_dump(KERN_DEBUG)``. + +For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is +its ``prefix_str`` argument, if it is constant string; or ``hexdump`` +in case ``prefix_str`` is built dynamically. From patchwork Sun Sep 4 21:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88892ECAAD5 for ; Sun, 4 Sep 2022 21:48:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EAC0A10E38E; Sun, 4 Sep 2022 21:43:47 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id D46F110E163; Sun, 4 Sep 2022 21:42:29 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868108ilt.7; Sun, 04 Sep 2022 14:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ER34tpiRxpxrqbyeNfK9kTxedh1cey5Wd7+bTMMeAt0=; b=gUiSZYP/k1pFS83DqE+EmB82be55p+NVZac494a9x4xvG65y6FIZ6bn2Dug8vAHY9q qzJdTJ0xaj0Tydn2YUrikCBWFQcFjSz5g9K7vIAtbjGAnIZi4K/jJs2sHNZBJ+baoA8l URtbxytNiVq1d9Gu6B/r7QOd6vTqF0GZqhWye1MbM7fFBWlQFQAJXor/wBXat4Nk7Et/ pEIU7EQnt5M5neYGmrgk6SH/GT1IUmqsTEaBMUPKKfJBHtQW3Zxu7sdHRGllR577eVYj MSfDzcicu+qbF1uZp/QhiDLJS0y/yQR5YspuuKz5kZ2xpPb3n6kFqaSM4iSEEbLHVncg ltBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ER34tpiRxpxrqbyeNfK9kTxedh1cey5Wd7+bTMMeAt0=; b=Ms/hYuY3s3IdUKrfA5eCvB1j6J2LzRsgu/rS9Jta2V81XDKBFJRungciE6007ckQEz 52pSIsBwnH0F/KgpTA08hfY2Jy/k45ulHF/oguvXRXlArNNynbto+9ke4mXIiU1PFNqX yDfPzQOU/5mrDz0hlBlub4CVN9bP+wzYKxsvweumA0svRCww2XSFm/vEozboXRfekNCp sWeywDtR3tarXFRqmql+e/eZils8dEo8ZcVbS4mu4U6jtwgeLaL4eP3IIcfwi2FVEtG3 83W0L3P3GpAOe63d92tAFZ6VT8UTvV5zXC0Lr58XSfzTtpMC0gGhjNEvvTrx6a7kt0X4 TBLA== X-Gm-Message-State: ACgBeo1iXc0A/p6TcE8f/M5azp6h0zSGykQHOFkJjwPBu5NQ4Yrgqcw/ Z/ZtYdny5Ll1LXmiuzlXLkA= X-Google-Smtp-Source: AA6agR58q6IyXd9WZ12hKcbIiqtMN6VqpqX1EWImJSjgdussO16aRw1Y1NKPghl79c/vNyaNEGfwGw== X-Received: by 2002:a92:2c0e:0:b0:2ea:c3b8:433c with SMTP id t14-20020a922c0e000000b002eac3b8433cmr19399396ile.107.1662327749404; Sun, 04 Sep 2022 14:42:29 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:29 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:57 -0600 Message-Id: <20220904214134.408619-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 20/57] dyndbg: add drm.debug style (drm/parameters/debug) bitmap support X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add kernel_param_ops and callbacks to use a class-map to validate and apply input to a sysfs-node, which allows users to control classes defined in that class-map. This supports uses like: echo 0x3 > /sys/module/drm/parameters/debug IE add these: - int param_set_dyndbg_classes() - int param_get_dyndbg_classes() - struct kernel_param_ops param_ops_dyndbg_classes Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. This might be unnecessary here. get/set use an augmented kernel_param; the arg refs a new struct ddebug_class_param, which contains: - A ptr to user's state-store; a union of &ulong for drm.debug, &int for nouveau level debug. By ref'g the client's bit-state _var, code coordinates with existing code (like drm_debug_enabled) which uses it, so existing/remaining calls can work unchanged. Changing drm.debug to a ulong allows use of BIT() etc. - FLAGS: dyndbg.flags toggled by changes to bitmap. Usually just "p". - MAP: a pointer to struct ddebug_classes_map, which maps those class-names to .class_ids 0..N that the module is using. This class-map is declared & initialized by DECLARE_DYNDBG_CLASSMAP. - map-type: 4 enums DD_CLASS_TYPE_* select 2 input forms and 2 meanings. numeric input: DD_CLASS_TYPE_DISJOINT_BITS integer input, independent bits. ie: drm.debug DD_CLASS_TYPE_LEVEL_NUM integer input, 0..N levels classnames-list (comma separated) input: DD_CLASS_TYPE_DISJOINT_NAMES each name affects a bit, others preserved DD_CLASS_TYPE_LEVEL_NAMES names have level meanings, like kern_levels.h _NAMES - comma-separated classnames (with optional +-) _NUM - numeric input, 0-N expected _BITS - numeric input, 0x1F bitmap form expected _DISJOINT - bits are independent _LEVEL - (x /sys/module/drm/parameters/debug_catnames A naive _LEVEL_NAMES use, with one class, that sets all in the class-map according to (x /sys/module/test_dynamic_debug/parameters/p_level_names : problem solved echo -L1 > /sys/module/test_dynamic_debug/parameters/p_level_names Note this artifact: : this is same as prev cmd (due to +/-) echo L0 > /sys/module/test_dynamic_debug/parameters/p_level_names : this is "even-more" off, but same wo __pr_debug_class(L0, ".."). echo -L0 > /sys/module/test_dynamic_debug/parameters/p_level_names A stress-test/make-work usage (kid toggling a light switch): echo +L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7 \ > /sys/module/test_dynamic_debug/parameters/p_level_names ddebug_apply_class_bitmap(): inside-fn, works on bitmaps, receives new-bits, finds diffs vs client-bitvector holding "current" state, and issues exec_query to commit the adjustment. param_set_dyndbg_classes(): interface fn, sends _NAMES to param_set_dyndbg_classnames() and returns, falls thru to handle _BITS, _NUM internally, and calls ddebug_apply_class_bitmap(). Finishes by updating state. param_set_dyndbg_classnames(): handles classnames-list in loop, calls ddebug_apply_class_bitmap for each, then updates state. NOTES: _LEVEL_ is overlay on _DISJOINT_; inputs are converted to a bitmask, by the callbacks. IOW this is possible, and possibly confusing: echo class V3 +p > control echo class V1 -p > control IMO thats ok, relative verbosity is an interface property. _LEVEL_NUM maps still need class-names, even though the names are not usable at the sysfs interface (unlike with _NAMES style). The names are the only way to >control the classes. - It must have a "V0" name, something below "V1" to turn "V1" off. __pr_debug_cls(V0,..) is printk, don't do that. - "class names" is required at the >control interface. - relative levels are not enforced at >control _LEVEL_NAMES bear +/- signs, which alters the on-bit-pos by 1. IOW, +L2 means L0,L1,L2, and -L2 means just L0,L1. This kinda spoils the readback fidelity, since the L0 bit gets turned on by any use of any L*, except "-L0". All the interface uncertainty here pertains to the _NAMES features. Nobody has actually asked for this, so its practical (if a little tedious) to split it out. Signed-off-by: Jim Cromie --- . drop kp->mod->name as unneeded (build-dependent) . param_set_dyndbg_classnames, not _class_strings . DD_CLASS_TYPE_* name changes, per Jason . callbacks: extend comments on DD_CLASS_TYPE_* handling, flow notes varname changes . kdoc tweaks . add stub macro: #define KP_NAME(kp) kp->name later, add "$module." prefix when config doesn't do it . s/struct ddebug_classes_bitmap_param/struct ddebug_class_param/ . fix levels state handling v4 had trouble where level-type's state was fouled by conversion to bitmap form given to apply-bitmap. fix by: (simplify/clarify) add old-bits, new-bits to sysfs-iface&support use CLASSMAP_BITMASK more in param_set_dyndbg_class{es,names}(): move state-saving inside switches, and tailor it to type. this preserves lvl-state, vs -v4 which didnt. I could "hack" in an offset, but the problem feels deeper. The root-problem may be the ambiguity wrt 0x0 > knob; per a input-is-assert-bitpos interpretation, it turns on bit 0. Thus far, code has avoided this ambiguity, by recommending against coding pr_dbg_cls(V0|L0, ""), which makes "+L0" & "-L0" equivalent, and "0" silent. That might be "too clever by 1/2"; accepting an int, so -1 means all-bits-off as well as verbosity-off, might be the better way. fix-lvl-sz --- include/linux/dynamic_debug.h | 21 ++++ lib/dynamic_debug.c | 212 ++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 9073a43a2039..41682278d2e8 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -119,6 +119,15 @@ struct _ddebug_info { unsigned int num_classes; }; +struct ddebug_class_param { + union { + unsigned long *bits; + unsigned int *lvl; + }; + char flags[8]; + const struct ddebug_class_map *map; +}; + #if defined(CONFIG_DYNAMIC_DEBUG_CORE) int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); @@ -278,6 +287,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_classes(const char *instr, const struct kernel_param *kp); +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp); + /* for test only, generally expect drm.debug style macro wrappers */ #define __pr_debug_cls(cls, fmt, ...) do { \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ @@ -324,6 +337,14 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) +struct kernel_param; +static inline int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +extern const struct kernel_param_ops param_ops_dyndbg_classes; + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index db96ded78c3f..009f2ead09c1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -596,6 +596,218 @@ static int ddebug_exec_queries(char *query, const char *modname) return nfound; } +/* apply a new bitmap to the sys-knob's current bit-state */ +static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, + unsigned long *new_bits, unsigned long *old_bits) +{ +#define QUERY_SIZE 128 + char query[QUERY_SIZE]; + const struct ddebug_class_map *map = dcp->map; + int matches = 0; + int bi, ct; + + v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + + for (bi = 0; bi < map->length; bi++) { + if (test_bit(bi, new_bits) == test_bit(bi, old_bits)) + continue; + + snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], + test_bit(bi, new_bits) ? '+' : '-', dcp->flags); + + ct = ddebug_exec_queries(query, NULL); + matches += ct; + + v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, + ct, map->class_names[bi], *new_bits); + } + return matches; +} + +/* stub to later conditionally add "$module." prefix where not already done */ +#define KP_NAME(kp) kp->name + +#define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) + +/* accept comma-separated-list of [+-] classnames */ +static int param_set_dyndbg_classnames(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + unsigned long curr_bits, old_bits; + char *cl_str, *p, *tmp; + int cls_id, totct = 0; + bool wanted; + + cl_str = tmp = kstrdup(instr, GFP_KERNEL); + p = strchr(cl_str, '\n'); + if (p) + *p = '\0'; + + /* start with previously set state-bits, then modify */ + curr_bits = old_bits = *dcp->bits; + vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); + + for (; cl_str; cl_str = p) { + p = strchr(cl_str, ','); + if (p) + *p++ = '\0'; + + if (*cl_str == '-') { + wanted = false; + cl_str++; + } else { + wanted = true; + if (*cl_str == '+') + cl_str++; + } + cls_id = match_string(map->class_names, map->length, cl_str); + if (cls_id < 0) { + pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); + continue; + } + + /* have one or more valid class_ids of one *_NAMES type */ + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_NAMES: + /* the +/- pertains to a single bit */ + if (test_bit(cls_id, &curr_bits) == wanted) { + v3pr_info("no change on %s\n", cl_str); + continue; + } + curr_bits ^= BIT(cls_id); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + *dcp->bits = curr_bits; + v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, + map->class_names[cls_id]); + break; + case DD_CLASS_TYPE_LEVEL_NAMES: + /* cls_id = N in 0..max. wanted +/- determines N or N-1 */ + old_bits = CLASSMAP_BITMASK(*dcp->lvl); + curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); + + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + *dcp->lvl = (cls_id + (wanted ? 1 : 0)); + v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, + map->class_names[cls_id], old_bits, curr_bits); + break; + default: + pr_err("illegal map-type value %d\n", map->map_type); + } + } + kfree(tmp); + vpr_info("total matches: %d\n", totct); + return 0; +} + +/** + * param_set_dyndbg_classes - class FOO >control + * @instr: string echo>d to sysfs, input depends on map_type + * @kp: kp->arg has state: bits/lvl, map, map_type + * + * Enable/disable prdbgs by their class, as given in the arguments to + * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative + * levels by bitpos. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + unsigned long inrep, new_bits, old_bits; + int rc, totct = 0; + + switch (map->map_type) { + + case DD_CLASS_TYPE_DISJOINT_NAMES: + case DD_CLASS_TYPE_LEVEL_NAMES: + /* handle [+-]classnames list separately, we are done here */ + return param_set_dyndbg_classnames(instr, kp); + + case DD_CLASS_TYPE_DISJOINT_BITS: + case DD_CLASS_TYPE_LEVEL_NUM: + /* numeric input, accept and fall-thru */ + rc = kstrtoul(instr, 0, &inrep); + if (rc) { + pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); + return -EINVAL; + } + break; + default: + pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + return -EINVAL; + } + + /* only _BITS,_NUM (numeric) map-types get here */ + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + /* expect bits. mask and warn if too many */ + if (inrep & ~CLASSMAP_BITMASK(map->length)) { + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", + KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); + inrep &= CLASSMAP_BITMASK(map->length); + } + v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); + totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + *dcp->bits = inrep; + break; + case DD_CLASS_TYPE_LEVEL_NUM: + /* input is bitpos, of highest verbosity to be enabled */ + if (inrep > map->length) { + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", + KP_NAME(kp), inrep, map->length); + inrep = map->length; + } + old_bits = CLASSMAP_BITMASK(*dcp->lvl); + new_bits = CLASSMAP_BITMASK(inrep); + v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); + totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + *dcp->lvl = inrep; + break; + default: + pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + } + vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg_classes); + +/** + * param_get_dyndbg_classes - classes reader + * @buffer: string description of controlled bits -> classes + * @kp: kp->arg has state: bits, map + * + * Reads last written state, underlying prdbg state may have been + * altered by direct >control. Displays 0x for DISJOINT, 0-N for + * LEVEL Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + + switch (map->map_type) { + + case DD_CLASS_TYPE_DISJOINT_NAMES: + case DD_CLASS_TYPE_DISJOINT_BITS: + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); + + case DD_CLASS_TYPE_LEVEL_NAMES: + case DD_CLASS_TYPE_LEVEL_NUM: + return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + default: + return -1; + } +} +EXPORT_SYMBOL(param_get_dyndbg_classes); + +const struct kernel_param_ops param_ops_dyndbg_classes = { + .set = param_set_dyndbg_classes, + .get = param_get_dyndbg_classes, +}; +EXPORT_SYMBOL(param_ops_dyndbg_classes); + #define PREFIX_SIZE 64 static int remaining(int wrote) From patchwork Sun Sep 4 21:40:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05BA7C6FA89 for ; Sun, 4 Sep 2022 21:45:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4E1D10E280; Sun, 4 Sep 2022 21:42:57 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98ECD10E183; Sun, 4 Sep 2022 21:42:30 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id d68so5628987iof.11; Sun, 04 Sep 2022 14:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=SWtn3j+X9Qv4/8jm3akSHIAKz6ptgqW0K3O3Ay77qY0=; b=kdD+2APgzWur66T/Yw0JAUha2OIBdQGSWr5pcgqmIKcw9t0P0ExtxJ+wCGmYlifBWY jx4J02H6x5y7Jghzq1hjlLd3x+JlLb3u/xHIEvdFLXebvyF7FseT8Um/rfOTT8sRqkHS Kwn5kYLnvRsaaJvK8r60GbVBm4z23vlSxPpIWmtoTyoxwEUVg3LWqMUsG2Yi6iDLoOmG BEzbio/nlWqLK6FIxJogNbut2lE5Za4JjbwBPh5poTqO7XvQoIMgS1PV8gDVCvH69rhU ccmuPpHwqKxPNGqKrdl4oLgloCvbIqvr5bIuq/7NKCEFQ+QaUBDxXUj6ZrVzTpP227xS 4kDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=SWtn3j+X9Qv4/8jm3akSHIAKz6ptgqW0K3O3Ay77qY0=; b=shV9RVbaac1mW7D1yqMVhdeNBP9nY08a3eO6/qInFyCpNtyT5P8DUNFgVqQqYA45X7 DhVncxJ0mFBg9e3Wns5/iqjboSBBumW1RW39b2L3Jpi9UpdbgBOS7g2CRCsjBEwZE0B8 qdxoUBsh6J6DsEkEA0EnaHuXJKJLlm6vNMC51vHCy2h+jfw2tcs3HFcfAvkW6KKR7uEe 9jCAz4vONT5FBdUqW3IRNR36Y51rBPOvyxzFGgoZtwDipAyl8yNtSmjdkWk3Q9jwCq10 8RlU4ohHIX9uQeF9cPOXCFjErh6RqFzuH5w/NznmfZWmBCR/KGnCjKenQfC3kGgr24ia /3EA== X-Gm-Message-State: ACgBeo0wwQSNS9tOaDaDS5tgyw5AoKio0eUITmGEbwVf3Iz391iLzZs9 tYRfzvC375UEfyp8jVXeLDI= X-Google-Smtp-Source: AA6agR41XH/DfG2wtMg0P4XixHVW9m5d5cJuou6QXxyrDYjIbsET4TcIXXSM7OxtuZdeXgbZ6EA6Xg== X-Received: by 2002:a6b:610c:0:b0:688:820d:bd14 with SMTP id v12-20020a6b610c000000b00688820dbd14mr20274946iob.205.1662327750268; Sun, 04 Sep 2022 14:42:30 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:29 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:58 -0600 Message-Id: <20220904214134.408619-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 21/57] dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Demonstrate use of DECLARE_DYNDBG_CLASSMAP macro, and expose them as sysfs-nodes for testing. For each of the 4 class-map-types: - declare a class-map of that type, - declare the enum corresponding to those class-names - share _base across 0..30 range - add a __pr_debug_cls() call for each class-name - declare 2 sysnodes for each class-map for 'p' flag, and future 'T' flag These declarations create the following sysfs parameter interface: :#> pwd /sys/module/test_dynamic_debug/parameters :#> ls T_disjoint_bits T_disjoint_names T_level_names T_level_num do_prints p_disjoint_bits p_disjoint_names p_level_names p_level_num NOTES: The local wrapper macro is an api candidate, but there are already too many parameters. OTOH, maybe related enum should be in there too, since it has _base inter-dependencies. The T_* params control the (future) T flag on the same class'd pr_debug callsites as their p* counterparts. Using them will fail, until the dyndbg-trace patches are added in. :#> echo 1 > T_disjoint [ 28.792489] dyndbg: disjoint: 0x1 > test_dynamic_debug.T_D2 [ 28.793848] dyndbg: query 0: "class D2_CORE +T" mod:* [ 28.795086] dyndbg: split into words: "class" "D2_CORE" "+T" [ 28.796467] dyndbg: op='+' [ 28.797148] dyndbg: unknown flag 'T' [ 28.798021] dyndbg: flags parse failed [ 28.798947] dyndbg: processed 1 queries, with 0 matches, 1 errs [ 28.800378] dyndbg: bit_0: -22 matches on class: D2_CORE -> 0x1 [ 28.801959] dyndbg: test_dynamic_debug.T_D2: updated 0x0 -> 0x1 [ 28.803974] dyndbg: total matches: -22 Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 125 ++++++++++++++++++++++++++++++++++----- 1 file changed, 110 insertions(+), 15 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index ba3882ca3e48..8dd250ad022b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -10,57 +10,152 @@ #include -static void do_prints(void); /* device under test */ - -/* run tests by reading or writing sysfs node */ +/* run tests by reading or writing sysfs node: do_prints */ +static void do_prints(void); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_param *kp) { do_prints(); return 0; } - static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { do_prints(); return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); } - static const struct kernel_param_ops param_ops_do_prints = { .set = param_set_do_prints, .get = param_get_do_prints, }; - module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); -static void do_alpha(void) +/* + * Using the CLASSMAP api: + * - classmaps must have corresponding enum + * - enum symbols must match/correlate with class-name strings in the map. + * - base must equal enum's 1st value + * - multiple maps must set their base to share the 0-30 class_id space !! + * (build-bug-on tips welcome) + * Additionally, here: + * - tie together sysname, mapname, bitsname, flagsname + */ +#define DD_SYS_WRAP(_model, _flags) \ + static unsigned long bits_##_model; \ + static struct ddebug_class_param _flags##_model = { \ + .bits = &bits_##_model, \ + .flags = #_flags, \ + .map = &map_##_model, \ + }; \ + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_model, 0600) + +/* numeric input, independent bits */ +enum cat_disjoint_bits { + D2_CORE = 0, + D2_DRIVER, + D2_KMS, + D2_PRIME, + D2_ATOMIC, + D2_VBL, + D2_STATE, + D2_LEASE, + D2_DP, + D2_DRMRES }; +DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); +DD_SYS_WRAP(disjoint_bits, p); +DD_SYS_WRAP(disjoint_bits, T); + +/* symbolic input, independent bits */ +enum cat_disjoint_names { LOW = 11, MID, HI }; +DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10, + "LOW", "MID", "HI"); +DD_SYS_WRAP(disjoint_names, p); +DD_SYS_WRAP(disjoint_names, T); + +/* numeric verbosity, V2 > V1 related */ +enum cat_level_num { V0 = 14, V1, V2, V3, V4, V5, V6, V7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, + "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); +DD_SYS_WRAP(level_num, p); +DD_SYS_WRAP(level_num, T); + +/* symbolic verbosity */ +enum cat_level_names { L0 = 22, L1, L2, L3, L4, L5, L6, L7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, + "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); +DD_SYS_WRAP(level_names, p); +DD_SYS_WRAP(level_names, T); + +/* stand-in for all pr_debug etc */ +#define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") + +static void do_cats(void) { - pr_debug("do alpha\n"); + pr_debug("doing categories\n"); + + prdbg(LOW); + prdbg(MID); + prdbg(HI); + + prdbg(D2_CORE); + prdbg(D2_DRIVER); + prdbg(D2_KMS); + prdbg(D2_PRIME); + prdbg(D2_ATOMIC); + prdbg(D2_VBL); + prdbg(D2_STATE); + prdbg(D2_LEASE); + prdbg(D2_DP); + prdbg(D2_DRMRES); } -static void do_beta(void) + +static void do_levels(void) { - pr_debug("do beta\n"); + pr_debug("doing levels\n"); + + prdbg(V1); + prdbg(V2); + prdbg(V3); + prdbg(V4); + prdbg(V5); + prdbg(V6); + prdbg(V7); + + prdbg(L1); + prdbg(L2); + prdbg(L3); + prdbg(L4); + prdbg(L5); + prdbg(L6); + prdbg(L7); } static void do_prints(void) { - do_alpha(); - do_beta(); + do_cats(); + do_levels(); } static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); - pr_debug("init done\n"); return 0; } static void __exit test_dynamic_debug_exit(void) { - pr_debug("exiting\n"); + pr_debug("exited\n"); } module_init(test_dynamic_debug_init); From patchwork Sun Sep 4 21:40:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC2ABC6FA82 for ; Sun, 4 Sep 2022 21:46:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C8E9E10E2A6; Sun, 4 Sep 2022 21:43:02 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8742310E184; Sun, 4 Sep 2022 21:42:31 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id h78so5628307iof.13; Sun, 04 Sep 2022 14:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4JXdBl/0qOwV/A52QqNijcawUGjQl7evE5vQaPe8I/Q=; b=Q6wDNH7ni+pezhZQtqZpJ97lJZANkr1r1w8Q0HIYBSFAhwljRqOGh9Iv19Gf64+llB frZm5l9a2D6+RrKMDxtJrGMvuFtfct+nV7wpbjJBApGvgbR/UCdA+edFFEWQV3yW5xZt Abl341qIlvY+ti5hONgL6a+0BiJXwAUlG16pl8y98ByU4SwhFvt6k2mPawMY8CGIW+5o XyF4e1Ssr9Pgjhu7rCIp5wA50OjjlhqxJNYWrilP5bH59brlOnduXsjVgJiJlrcuk94w aC5b1ZZDeZyRlOAFIdmJz1af5ykZ0tqCvavdXbRILxmEHXgITfMxjOp5/9nTnIUykGr1 jaiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=4JXdBl/0qOwV/A52QqNijcawUGjQl7evE5vQaPe8I/Q=; b=7+gf0kl1xJaddSc95nfdoiTyR2GmNwBUnUKBtFT/HBWKLe90lwlXLq1qrsqR1Al5Ym VBG+eEuFwpWDmsjvTXAnp23vg6c133EvjpgaHi/vi//55TrDBz0rgW/OrVLNhC99MQO3 1+t7RkVNHyZdOqn/75+gYzGDB2yV4NVxySA1ZN2c0++GR8qCfYPnTVDMrLO4JoOnLyzH Ysi8n2DQA8/gyCQSIWnRlGEvJYeZaCuFVBH8+oRZvOZMw3EetbMaa8Z6imqbiKXG0oV6 67VIfXf88cQk6717aeUYdfNYS5mqUEntL86n4TOVFUVTmjdOHZiLPA553MD1E0OEyfNd BgbQ== X-Gm-Message-State: ACgBeo3oGQebLplhmUKPx0pwUtAhO6+crPX0nWHnDUc/wH0FxMIeYV1q B57woIS4YFy4x8RuuSNRtm4= X-Google-Smtp-Source: AA6agR4RtFxm49IqbK2hc+ajeSg5bxr0q7Z7xZNKzxnPnzjA/QHoeK8+UuSlF8s2NBv4jPh+uCHATQ== X-Received: by 2002:a02:9a16:0:b0:350:636f:af9a with SMTP id b22-20020a029a16000000b00350636faf9amr4392137jal.191.1662327751171; Sun, 04 Sep 2022 14:42:31 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:30 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:40:59 -0600 Message-Id: <20220904214134.408619-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 22/57] drm_print: condense enum drm_debug_category X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" enum drm_debug_category has 10 categories, but is initialized with bitmasks which require 10 bits of underlying storage. By using natural enumeration, and moving the BIT(cat) into drm_debug_enabled(), the enum fits in 4 bits, allowing the category to be represented directly in pr_debug callsites, via the ddebug.class_id field. While this slightly pessimizes the bit-test in drm_debug_enabled(), using dyndbg with JUMP_LABEL will avoid the function entirely. NOTE: this change forecloses the possibility of doing: drm_dbg(DRM_UT_CORE|DRM_UT_KMS, "weird 2-cat experiment") but thats already strongly implied by the use of the enum itself; its not a normal enum if it can be 2 values simultaneously. Signed-off-by: Jim Cromie Reviewed-by: Daniel Vetter --- 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..b3b470440e46 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, /** * @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 Sun Sep 4 21:41:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BA92C6FA86 for ; Sun, 4 Sep 2022 21:45:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67C6D10E298; Sun, 4 Sep 2022 21:43:00 +0000 (UTC) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by gabe.freedesktop.org (Postfix) with ESMTPS id C08B610E133; Sun, 4 Sep 2022 21:42:34 +0000 (UTC) Received: by mail-il1-x129.google.com with SMTP id l16so3889010ilj.2; Sun, 04 Sep 2022 14:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yb6CWV+TDDmM9onUuCxvFgBnmtmfnm46mq8t0HXB9jg=; b=lHCcfKuE75YvbApb3Q3ZrFKS/VLaGwoG8AzIOt7lRvkN6SBFDFxisWcCRiGMiVWTmH Kt63m7En4yLxNz7W7gTVWvhHgavhPV4rIN/E8gjWDoz36fXVQ8TufnV5YiPONZdg0wA9 PSC+3lVcstXByssTzg5qYKmlsp30bseonqBYHx7jAS4+G7wvrNp/c/1zAFFPf+Zb+I+C bM52a0v8IgrcQsDr4+T74tV0XI154yB2HOw02ZrUn321+0Geo88H4CTT7pj1lgDKjIx/ lz/D5+FWjXkDEy4M7lN8ydHYZ3SpeaGHxvF6OeZEhZdGSQrj5iVYVDwQgerulqIfnVFo NX1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yb6CWV+TDDmM9onUuCxvFgBnmtmfnm46mq8t0HXB9jg=; b=VV+h+iCxcnMtU4hjwqnYkNPpjh1QYOTa7mGMTk2lCPFyBeqYJtowAwSaQ2LnvWXD2c Jn8XOBuqeSlraEiBF/k2tjVMBj72Mm2Jt17Hy5P8OdCMjVwhgC3qJ4ADjNozWd/jEXsH DEKvuP7lOtXSlmTlz9Y5hx/3rye1xNSAPxO92t9aN+ST4eJb1EimfZxASU0t505QYIW1 emx8gH7Repsp9+D2zxKQqJuVZKZxPvf3rG/lpjdYETIhopYknAYpsN6ApNXonSGeciJT ViQX+Z9UHGJIZSN0vnOQCCNvv3x6dFuf6x9HoH2AIx+W09F81agKu6UDUdlJfBSBSnyU +GYA== X-Gm-Message-State: ACgBeo13KEwzmOF2ay+lr4W2dU78TFUXDidCB0QE7nEGm4BAXkPCn0Rg RHBJDdeT3Adro+xVoqpBOpc= X-Google-Smtp-Source: AA6agR5Cx+ajN8UUSivj7N6vamViDhkJkE8U1oCqTJYgtKCcaD95EUgEYEoUpvP503z2jlMiKd37Xg== X-Received: by 2002:a92:6a0d:0:b0:2e5:afe7:8d95 with SMTP id f13-20020a926a0d000000b002e5afe78d95mr24687711ilc.262.1662327752155; Sun, 04 Sep 2022 14:42:32 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:31 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:00 -0600 Message-Id: <20220904214134.408619-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 23/57] drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use DECLARE_DYNDBG_CLASSMAP across DRM: - in .c files, since macro defines/initializes a record - in drivers, $mod_{drv,drm,param}.c ie where param setup is done, since a classmap is param related - in drm/drm_print.c since existing __drm_debug param is defined there, and we ifdef it, and provide an elaborated alternative. - in drm_*_helper modules: dp/drm_dp - 1st item in makefile target drivers/gpu/drm/drm_crtc_helper.c - random pick iirc. Since these modules all use identical CLASSMAP declarations (ie: names and .class_id's) they will all respond together to "class DRM_UT_*" query-commands: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: This changes __drm_debug from int to ulong, so BIT() is usable on it. DRM's enum drm_debug_category values need to sync with the index of their respective class-names here. Then .class_id == category, and dyndbg's class FOO mechanisms will enable drm_dbg(DRM_UT_KMS, ...). Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie a different NAME => class_id mapping), changes are made according to each module's private class-map. No callsites are actually selected by this patch, since none are class'd yet. Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++ drivers/gpu/drm/display/drm_dp_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_crtc_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_print.c | 27 +++++++++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 12 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 13 ++++++++++++ include/drm/drm_print.h | 3 ++- 7 files changed, 92 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index de7144b06e93..97e184f44a52 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "amdgpu.h" #include "amdgpu_irq.h" @@ -185,6 +187,18 @@ int amdgpu_vcnfw_log; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + struct amdgpu_mgpu_info mgpu_info = { .mutex = __MUTEX_INITIALIZER(mgpu_info.mutex), .delayed_reset_work = __DELAYED_WORK_INITIALIZER( diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index 92990a3d577a..cbb9c4d6d8f2 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,18 @@ #include "drm_dp_helper_internal.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + struct dp_aux_backlight { struct backlight_device *base; struct drm_dp_aux *aux; diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 457448cc60f7..7d86020b5244 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,18 @@ #include "drm_crtc_helper_internal.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + /** * DOC: overview * diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..ec32df35a3e3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -40,7 +40,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" @@ -52,7 +52,30 @@ 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 +/* classnames must match vals of enum drm_debug_category */ +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + +static struct ddebug_class_param drm_debug_bitmap = { + .bits = &__drm_debug, + .flags = "p", + .map = &drm_debug_classes, +}; +module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); +#endif void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 6fc475a5db61..d1e4d528cb17 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -29,6 +29,18 @@ #include "i915_params.h" #include "i915_drv.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + #define i915_param_named(name, T, perm, desc) \ module_param_named(name, i915_modparams.name, T, perm); \ MODULE_PARM_DESC(name, desc) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 561309d447e0..fd99ec0f4257 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,18 @@ #include "nouveau_svm.h" #include "nouveau_dmem.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "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"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b3b470440e46..668273e36c2c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -35,7 +35,7 @@ #include /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; /** * DOC: print @@ -275,6 +275,7 @@ static inline struct drm_printer drm_err_printer(const char *prefix) * */ enum drm_debug_category { + /* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... From patchwork Sun Sep 4 21:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DC49C6FA82 for ; Sun, 4 Sep 2022 21:48:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E55C10E3BD; Sun, 4 Sep 2022 21:43:54 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BC1910E1C5; Sun, 4 Sep 2022 21:42:36 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id i77so5661068ioa.7; Sun, 04 Sep 2022 14:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=AsutXgMDAJiXYIziQgoUHz04vuwS74Ufjn18RboeZlU=; b=Qw5u5kHlAuCdVRdp5boFr8w9l56DpQmLytG5X7x/gapi8SNDYyfHxGQ865EixG1rDF w+qm25s4Qx7V+r1LIT4Yojr69wswh53LgdFjuv5u8ss4N7Y3M6OvvXRH+gSQtLhrl51K 8MA7vqh1hp2ucRb7mbZmSegCHdgHh45ZtNYeJv2RuaJEfVrE7xjijSClBWTNNcJBAAfv QJ9VxUtPDKNoU59NHhpkj4z/UKL9NQ5pTTXZdMEXqLoRbGLT/+iXx3JIGAlyabOc3HOS z4XZEA/jjk7trB7VNHK/xQkhJcQcINVffpR5ej+XDbn5uk/XFMlCTA04L/CLoqDiCira /Okw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=AsutXgMDAJiXYIziQgoUHz04vuwS74Ufjn18RboeZlU=; b=sFWWZjI0HXNSu+i6lF0+hLYiDKjqTFQTcqHD60ys9ioqPkjwlkZXIUu88MRppn5t2h pClzqToViw2nhWpNJJTDCn/sRZKbAQLGXvOt0mQtW9qX6B0VaNRuqZa2q83Q6zcrA2IH tVYNay414TihItQv5i9TbVanArDrdX9c+aDAh3LMwlPHZ44dQoB3xjMjWDHMlent2BaE 6PRnAa25XPtqdEn6qKNYoCWfG17Tk9rcYAy0jXFBo8ntcwBFDOyJlV8jEeTqa1WAaU6l VwFIxJvTtuERrwvEt6m9yUkyb5Xd3GOmjJIh2UoZr1KXf2Ip3KQJDITMsAEs+/ehCluX udqQ== X-Gm-Message-State: ACgBeo06XFKCvuKt1y1p261/1kqxSXogaT4WDOpRb002VrQSwQTIw2zo iT9WcGyw3Nd1BEjDBollKAE= X-Google-Smtp-Source: AA6agR4XUVL8R/sQ1zC2uzGX3CzIouq5JH8v/iId7txQSE5EgJyUlziUe0GD5gnf+dO0fl8HHWQm8g== X-Received: by 2002:a02:740b:0:b0:349:bcdd:ca20 with SMTP id o11-20020a02740b000000b00349bcddca20mr25953249jac.110.1662327753065; Sun, 04 Sep 2022 14:42:33 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:32 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:01 -0600 Message-Id: <20220904214134.408619-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 24/57] drm_print: interpose drm_*dbg with forwarding macros X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" change drm_dev_dbg & drm_dbg to macros, which forward to the renamed functions (with __ prefix added). Those functions sit below the categorized layer of macros implementing the DRM debug.category API, and implement most of it. These are good places to insert dynamic-debug jump-label mechanics, which will allow DRM to avoid the runtime cost of drm_debug_enabled(). 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 ec32df35a3e3..29a29949ad0b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -279,8 +279,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; @@ -301,9 +301,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; @@ -320,7 +320,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 668273e36c2c..c429c258c957 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -335,7 +335,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, ...); /** @@ -384,6 +384,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +#define drm_dev_dbg(dev, cat, fmt, ...) \ + __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -485,10 +488,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 Sun Sep 4 21:41:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CE79C6FA82 for ; Sun, 4 Sep 2022 21:46:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A24010E2D5; Sun, 4 Sep 2022 21:43:08 +0000 (UTC) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0757610E1CE; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: by mail-il1-x131.google.com with SMTP id e7so3873185ilc.5; Sun, 04 Sep 2022 14:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=U1e/PDiTaqhNlqhWklmksFO85pXyEBvT7LYXXx9lRsc=; b=Dx9MBKpykNOjC760F4pFLwFUkOoBmF/4z7wBX2mc5AIweU/3t3yi4wF+532OcszVdM fJS+kbBgoRInPWQA6RJ24UEiO6RyYqvxzwnizY/OXlGjDTiAte5Jy7Wgkyh+ej2dw7mp 8ah+0F5F3ut30swO8Jl6e2dH2RtgR7VodKDNux7pE967WR0SeE/u428cUqvwN8xe2OmV ay3wjVmLVzY5WIqtJ/VBzchbZ+9NV5ny/h5+U6aR4pyOmNjuCxZNrwhA78HFQY997wef fNMxXUBdIylIsoA4g3Yk7C70N55L4Qb/lJbN8V6hoNbx4nWhOh8w8GsOeIFiw0QPvj7b zvqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=U1e/PDiTaqhNlqhWklmksFO85pXyEBvT7LYXXx9lRsc=; b=f3e8FERhe0+9GnSoG90tTP2QrQUYs9LIE24BQLiqs2Ry16vQ+I65AuEDeHSIdMoH38 99bWXM3tDxrwKEol7jlA9oxLWukrezdCQ5MgmDYrPvGcZezwmvYoA0jA+9LbySqU/9pX h2zEisnbY3Gje+VbngT7Vf86Gf/r/mQcVmvNXtE0J98tWGkQb5VZa425bJ5xm6nOPRwd Q0JVNkaxyDXpcf0lq91Kts7Ry8nk20FyZZBaMXQFK+HeEyLM9USFfTpd+PK/uz0HHaKc SlqpRz+EsEFgjwDwcsNZ9cc0IgcoTtg6UwSLzSfpuph/GgxRyus479wvs9mT9XuRmrVH Jm4Q== X-Gm-Message-State: ACgBeo09REmJRf4q48ZnQKV3jhXROLGc6PbuZqHClGw+vgrIGreEs16X jFJDXoRFjKnxZW1MpChPD8k= X-Google-Smtp-Source: AA6agR4QIlOxxpmNgt7Mmv0IK9vaV2J3UNUt+wMqkJN9PXiw35wmcxQf7MVn0gpUR78DsbgyvTivGg== X-Received: by 2002:a05:6e02:1d07:b0:2eb:1792:5468 with SMTP id i7-20020a056e021d0700b002eb17925468mr15883450ila.60.1662327753969; Sun, 04 Sep 2022 14:42:33 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:33 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:02 -0600 Message-Id: <20220904214134.408619-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 25/57] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" For CONFIG_DRM_USE_DYNAMIC_DEBUG=y, wrap __drm_dbg() & __drm_dev_dbg() in one of dyndbg's Factory macros: _dynamic_func_call_no_desc(). This adds the callsite descriptor into the code, and an entry for each into /proc/dynamic_debug/control. #> echo class DRM_UT_ATOMIC +p > /proc/dynamic_debug/control CONFIG_DRM_USE_DYNAMIC_DEBUG=y/n is configurable because of the .data footprint cost of per-callsite control; 56 bytes/site * ~2k for i915, ~4k callsites for amdgpu. This is large enough that a kernel builder might not want it. Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 12 ++++++++++++ drivers/gpu/drm/Makefile | 2 ++ include/drm/drm_print.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 2f52e8941074..3b75c286f14f 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -51,6 +51,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_KUNIT_TEST tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS depends on DRM && KUNIT diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 25d0ba310509..0b283e46f28b 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_drv.o \ diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index c429c258c957..2d2cef76b5c1 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -384,8 +384,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, cat, fmt, ...) \ __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) +#else +#define drm_dev_dbg(dev, cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) +#endif /** * DRM_DEV_DEBUG() - Debug output for generic drm code @@ -492,7 +498,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(cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) +#endif /* Macros to make printk easier */ From patchwork Sun Sep 4 21:41:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4722C6FA89 for ; Sun, 4 Sep 2022 21:46:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 988C310E332; Sun, 4 Sep 2022 21:43:17 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 67D3110E1BE; Sun, 4 Sep 2022 21:42:35 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id h78so5628349iof.13; Sun, 04 Sep 2022 14:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6ZAp0SLSNepdkM6caeO4skWDicbHMA8OFY8bo87a1Nc=; b=DfX4/ghpRrLMvEAxpwWwPbtD5a1dkzxKOUPp2TD6F2q29vGGj/18IHkmJJpqNGED84 ReA0JJE5AA9AlXq8pGzPQjVUBQcsMR8EpnSbOuKD6tojGRRoX3dI2Ud0v22DsMUX8opI d3JQlwkymuNoAqrccLE9gDUMCmRsZkunqKR2XFWr2KptUsf2TiLlIieQnWztzPo6ZUgh MiQCOt2dHNm9l4z5HrlM5ImqTPv0SubrVLnrEYTh/r1aKOa0fhVY5VE/iog4DwbkB60l BBQjI90yzoxv+hYSTdUZRg31WO5JZtO0Ko4fDN3r4WVdZF42swnnS3An562cNwwtMv5i lx7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6ZAp0SLSNepdkM6caeO4skWDicbHMA8OFY8bo87a1Nc=; b=cNjaPVvd2wPXIYN6p/YWUlDA/jhmBuURdiZjiNpoQl6hTnEP+AA+u5BZBjQdlKalFz S9qBxe8zJBkOD/Vbx4vSamjDtkMb+MiXQaWIbhzTHLYTGxU//468Ka2V3tS/nnTj6JJk Etj9uxLzfnJxnbaOucylVC5+iFxndsngkWGZZzjBy7ZNzrA/1ugH0OD7sNXdl2fJZOYl vHThDAXexabGtmtdyNeRhdU52eGoAX9eSdBnBRaGTx0+jQ1VzlEyXPLTmGI73bCd+oJH o54vGMAXa+ktaKAMSWj6QJ0seHp9mTHI+95/lugVu5hnZK3vFX475g+xiGatBFo6kE7J 4rmA== X-Gm-Message-State: ACgBeo21uExkBWbQsR9KozchOjm7eHQ9Yxgrt5MbqG/gx0aWSRn4nsyH ojnd5HEC6FSzpjJShGJBwEo= X-Google-Smtp-Source: AA6agR7xT5UcbaaPMupHq74aD54OF9ftmAPlIhpkXGE6kw4lTSCQlvdL0+PZQyRTjzyip0WI8xfCIg== X-Received: by 2002:a02:3f20:0:b0:342:c96d:2f8 with SMTP id d32-20020a023f20000000b00342c96d02f8mr25501456jaa.74.1662327754895; Sun, 04 Sep 2022 14:42:34 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:34 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:03 -0600 Message-Id: <20220904214134.408619-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 26/57] drm-print.h: include dyndbg header X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" lkp robot told me: >> drivers/gpu/drm/drm_ioc32.c:989:2: error: call to undeclared function '_dynamic_func_call_cls'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] DRM_DEBUG("comm=\"%s\", pid=%d, dev=0x%lx, auth=%d, %s\n", Since that macro is defined in drm_print.h, and under DRM_USE_DYN*=y configs, invokes dyndbg-factory macros, include dynamic_debug.h from there too, so that those configs have the definitions of all the macros in the callchain. This is done as a separate patch mostly to see how lkp sorts it. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 2d2cef76b5c1..f8bb3e7158c6 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include #include From patchwork Sun Sep 4 21:41:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C45FECAAD5 for ; Sun, 4 Sep 2022 21:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D627F10E181; Sun, 4 Sep 2022 21:43:41 +0000 (UTC) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by gabe.freedesktop.org (Postfix) with ESMTPS id 221A610E163; Sun, 4 Sep 2022 21:42:36 +0000 (UTC) Received: by mail-io1-xd30.google.com with SMTP id q81so5653842iod.9; Sun, 04 Sep 2022 14:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=JJmkd9QkaZyaFdemWU+lkrR5661ckSN9S5LOBM0abWI=; b=Ekp5LSqCs4NIcDItFljM2WjOwt/efnWVaMW3yCqrqsUihOs5E0jY1gRnas7XeEnwXQ mJczoHE301+UhR2sdrk2Z8XMrus7OmPoIHzPLx9pOfthkP14wtWEMeSmcVDFGWB/CtdJ QoGwdbXBIatuJbFnjhsoLD7HBBwTwthzbbd/ephKZj4F869SAIYstaCw9X5XldSmfsj5 425BY3FM/yceTIl0QRHpBbqSrZ3pLSgxz0QvSfOSxR2x3onovMe0LjQXpUS5rZwJQTDD f0EEtc2lmFOrlMPRrbL5XtYdvoUv6FfCFWPMR8AZBn6i4YQ82dbzn0YVDauHfrda6dbp qmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=JJmkd9QkaZyaFdemWU+lkrR5661ckSN9S5LOBM0abWI=; b=7LYv/A3jHQI3iUfUepe58WbM44skBeBGRz7HqdPLwY6uaxVemy078FU2I7exh5Pxuy 5GkLErj1XrjtW6v9LNcarzLXP3GkyTuqug85jSWPY9lfk0ioGWs2gk9uV5Sr0WS7er/Q tcAKLkyVBCAjrR62BwQqGP54mi7zbL2f3NeGxupvlnum84dV/7hK5VsS+cuTl/PUSo3q MdpZKG4WR9LkhXXJoQUEs+e4L3dUhZ+Wqs1xPn8ZY2Zs7ilUggHq61kTYOiMEEjwy88n qgFpoVelJhwS3BWdyj/q73Q65BtMt4RShxLQYfG4vBNntKKKJIdBCXV0Eq1/hyMG8XDG t3vA== X-Gm-Message-State: ACgBeo0wSxbc3Ad/JVRsKS9fTtKE/NF49wYniqNgaBS7EqTC9NBA1erq IxhcnIBA2DYVN686adqpLXka5yPLk5E= X-Google-Smtp-Source: AA6agR6Y58eeN88K8D4OKhkCxT/e0VQuWiJ6m00+40bBTPAFdN9SV1gHrr39O9uhC7t16UdJ5cZYpQ== X-Received: by 2002:a05:6638:224:b0:350:6e7b:8e59 with SMTP id f4-20020a056638022400b003506e7b8e59mr4269174jaq.237.1662327755824; Sun, 04 Sep 2022 14:42:35 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:35 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:04 -0600 Message-Id: <20220904214134.408619-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 27/57] drm-print: add drm_dbg_driver to improve namespace symmetry X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_print defines all of these: drm_dbg_{core,kms,prime,atomic,vbl,lease,_dp,_drmres} but not drm_dbg_driver itself, since it was the original drm_dbg. To improve namespace symmetry, change the drm_dbg defn to drm_dbg_driver, and redef grandfathered name to symmetric one. This will help with nouveau, which uses its own stack of macros to construct calls to dev_info, dev_dbg, etc, for which adaptation means drm_dbg_##driver constructs. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index f8bb3e7158c6..dfdd81c3287c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -468,7 +468,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_core(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) -#define drm_dbg(drm, fmt, ...) \ +#define drm_dbg_driver(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) @@ -487,6 +487,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) +#define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__) /* * printk based logging From patchwork Sun Sep 4 21:41:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E757C6FA86 for ; Sun, 4 Sep 2022 21:45:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E32F910E2C1; Sun, 4 Sep 2022 21:43:03 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59D4610E1DA; Sun, 4 Sep 2022 21:42:37 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868182ilt.7; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=AK+43dpGRirTw4nNfvr173iCsOdOocOg1R4PrjXeYFMuE6BHzNx4/JyS2/Hs12JMwR arAb0AoFD3lLvnp+XMkj+nWBX4byPR8fWvDR9CUjvDV5RC/AcQEP8uncq985GYHJU6ZV Y1NZeglyoj+4PmVpyOb5acskIwIX7OJWl0g7dKKda3S5vGjIzl3tKiY/y8lQr42zk5mL 0kqpDAV5CIhV4bkqTSSNFO+cqJYPRqlUFUEUtUB21hy9TbrmlNQfyn3Yfv+pNchiW5lP omQ1D670173DGSz8AJfJF3mWC72dET7qdHGew94KumgAoocW1dkvnKB5l0zMBDpdb6qQ wgxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yz1nHWqmg1d//jI5WL7ehO+9XBH0wkH/Bsd6VUk2Nqk=; b=ZWIiJgo6z8EnI+7dI1ZQzNMp0CNkvvlf3FRsDpxY0lYxUdxzYnNRFWnBjgAVYOKwsi y0GOwyFh8iroqpY1q8SO/11RzFor2DpX30dDhw4CSspPJ/PMJFVD2AqLIw1GOZz+3pFJ RcVUI2Y6Ae0WXGqyU2wW2WORZmkDrR0s2ZKd74wO0lYZ8L2kShlJmRey9n3hOJ/OPpZr 0fqPgqiOL0ScSap078YpUiszKTrdI0uUWnr0B7hZEVleN4MLPq+zxo042WthPfMK9dSJ XMAPDgPRFpAfy+zuRXztzb3aINKiffIEM48LpWwAB/q5Xpw2aWIx7MH+49/MnOs7Wm1t w6hg== X-Gm-Message-State: ACgBeo0Riq3x5VgqkkCwQwFkSpiwGtla2WLPMW0YvzhsiQ2i79BjLUn8 JaRW9msVbnI7gUNrpzUvoB4= X-Google-Smtp-Source: AA6agR7r6U93/s1yKE4uP9xLO0qO4rTXytRbBRYsXbjE4vP4auvFXzNw8l/Z1/hxoQSGO8wQE4MxOA== X-Received: by 2002:a92:d708:0:b0:2eb:603a:f6fc with SMTP id m8-20020a92d708000000b002eb603af6fcmr12394161iln.225.1662327757031; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:36 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:05 -0600 Message-Id: <20220904214134.408619-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled. 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 an inline function. When plugged into 1, 3 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 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,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); @@ -308,7 +308,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); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ 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 * From patchwork Sun Sep 4 21:41:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965348 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF111ECAAD5 for ; Sun, 4 Sep 2022 21:49:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70BD910E7FB; Sun, 4 Sep 2022 21:43:59 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 401C010E204; Sun, 4 Sep 2022 21:42:38 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id r141so5678554iod.4; Sun, 04 Sep 2022 14:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0Id8r2vYLmajWhF+0Lsomg5sSzhIk/Fv798x/2NCQJ8=; b=nMgcsqv10t0jNSou/ChM9aj4Oe2Z78Qyt3lMIFBuZ+lquITOKuL5RF792lnxd7UxJ8 qpp+DhMKR6rD8Oc8zSCbZeoe0h9QjbpOO0YVftf9vHqXoRe8XPNetD5weW3YMiDh/hpz X9RMWx9bzPZKcOgMLConc2T+c/6pPJAtaa/JQl2Ee4JRD9rij46vnjQIlGRlSmKUKYKq Bepfrnuvr4KbA0CMM4R2ttIK4x2CvNrggANC7Rg2YtNXHsSx94pjtZ8bFBhm7X0MlxoT SxodpVFGmtdB1b6dU/Q2eNKDiZA6RGYLKeiZvHON/fhARPCby/xRuXS2G7hj7UBtB+21 GNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=0Id8r2vYLmajWhF+0Lsomg5sSzhIk/Fv798x/2NCQJ8=; b=BFmNrREv3OArjjjh/9NJbXnXe0OvKPtip9LGTGm5VGeQQsf54RgLu9DXg8A3arjGxF W01Y7rw7pRfxuhNN2twxQcg91RvbOyIeJSiEnmAwWTd4sE8m4DDNmbNeDW9fH6tCIFi7 hKBFkCgVhomLbhHY5vkAPq9hJ5iNpy/6JhyVu1lkc1+tQuVkrjnX7DHa9NWEulEFrh/0 UtVNZPNTK6iKzF8OhE5bkr0Bpgn72itgy0JB29GqCiKXKia+UcdQsxo0ecLZQNXs5n7Q 5r67A9xGIARFw29RtWtTdb1Y1aK7PpvodwBtgOJRmE1EkcXQvFwFAGsxSO+zZU7aB5Z4 FJcw== X-Gm-Message-State: ACgBeo1Ut+FLT86HoWnRLtXpkBTFqVIv980CL9aoOlL5KXPj5c2A0VGO p3pMuDrzzR0W4FtJNg5btxo= X-Google-Smtp-Source: AA6agR6b4AaEEfOSIKL24Lu0tIv0q3qOCsBl00MyhLWPv9u8tITL7jjngdAbr9/9HEHOPy1kJLcPuw== X-Received: by 2002:a02:cc76:0:b0:34c:13cf:efc9 with SMTP id j22-20020a02cc76000000b0034c13cfefc9mr10073340jaq.152.1662327757907; Sun, 04 Sep 2022 14:42:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:37 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:06 -0600 Message-Id: <20220904214134.408619-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 29/57] drm_print: prefer bare printk KERN_DEBUG on generic fn X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_print.c calls pr_debug() just once, from __drm_printfn_debug(), which is a generic/service fn. The callsite is compile-time enabled by DEBUG in both DYNAMIC_DEBUG=y/n builds. For dyndbg builds, reverting this callsite back to bare printk is correcting a few anti-features: 1- callsite is generic, serves multiple drm users. it is soft-wired on currently by #define DEBUG could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading here, 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 /kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 -dirty/kernel/drivers/gpu/drm/drm.ko 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 cb203d63b286..ec477c44a784 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 @@ -185,7 +183,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 Sun Sep 4 21:41:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1405DC6FA86 for ; Sun, 4 Sep 2022 21:46:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 699DF10E2F2; Sun, 4 Sep 2022 21:43:12 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33DD510E22E; Sun, 4 Sep 2022 21:42:39 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690681iof.1; Sun, 04 Sep 2022 14:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tmR8ChrylisxKKWzjN/Li/odfvtNSLNzyjwd4uQokF0=; b=YA6JGiqu4qnXHVqjxeqktp9+r4L0ElOdnkT68N+xlzo9ovLmKCzEp0/6pi8K8SxiDU KwjNYzCmK6I94RrfiBdEEofeg4VWstkfQy+pNcJcE38TAL+pwdl46PNNCBJq9ZaPrn+M 33ZbFTernPGN1s7PslLH1V5BQcLd2PMYBAL+EoFjllsHeR8xFZK5WLR46dTOAwP0TnT8 bt/FsSKVUbEDbMrLCkfwGdCNAWH8Ln1DNUBpcBawBvltIsAyilsUMDBqwiHRMVwbxjna NuT9XG9QpeIHCXfM3q7C9UUlbZKFIiyTINWnv7+ybnDtbVtD6WNa+Zzsrjxap3WT1/h0 5ZDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=tmR8ChrylisxKKWzjN/Li/odfvtNSLNzyjwd4uQokF0=; b=Ag/piAL88ffMIYQEIdFTBcZJoGdiX9bkeLH/CcsN6AFFI8sHvxAAPduiyNluBpIKwK qY7dqdsdWUAY9+0ApIRBZTsoXTILdpDMZo4N64eMiaNgwOWsyny2M/BhNCWtzkGr2UMx mE2MWt7DdOm71HpES1Xdd5OpwYHurDpalxneOtGhFuQ7CraW5CxoQM7I68ehqpuozlR7 /eoaKSezgnZ6Fk88ExlIjAL80cZD0m+R0N8XCUK/tI77DXRd/w1o+vzpb2LQDxZ7Ce3T vHOJdLwWMZYwKZqLedEGN2ovTMQih9tj6qcgTU96J0wTnbd9zmuyxklUvkPH9/1EPKzt 8lWg== X-Gm-Message-State: ACgBeo1c4DOROZVRZlr4J2Khn1gtIFa3L6GU6kEwkoZK8vK/B3CMM/l3 16GqaNmp0P7+1tNAdH3C8SEdpU7yMVc= X-Google-Smtp-Source: AA6agR67W0JwMKVjGZ0XAZCtblPF2QCqY+yVd4ipB10+ywZ/x6+YYkZcz6CmYFni52Q8uttRgXx7og== X-Received: by 2002:a05:6638:488a:b0:342:6d75:dfa6 with SMTP id ct10-20020a056638488a00b003426d75dfa6mr23007148jab.319.1662327758805; Sun, 04 Sep 2022 14:42:38 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:38 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:07 -0600 Message-Id: <20220904214134.408619-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 30/57] drm_print: add _ddebug descriptor to drm_*dbg prototypes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" upgrade the callchain to drm_dbg() and drm_dev_dbg(); add a struct _ddebug ptr parameter to them, and supply that additional param by replacing the '_no_desc' flavor of dyndbg Factory macro currently used with the flavor that supplies the descriptor. NOTES: The descriptor gives these fns access to the decorator flags, but does none of the dynamic-prefixing done by __dynamic_emit_prefix(). DRM already has conventions for logging/messaging; just tossing optional decorations on top may not help. Instead, existing flags (or new ones) can be used to make current conventions optional. For CONFIG_DRM_USE_DYNAMIC_DEBUG=N, just pass null. Note: desc->class_id is redundant with category parameter, but its availability is dependent on desc. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 8 +++++--- include/drm/drm_print.h | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec477c44a784..5b93c11895bb 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -278,8 +279,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; @@ -287,6 +288,7 @@ 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; @@ -302,7 +304,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } 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 7631b5fb669e..46f14cfb401e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -363,9 +363,10 @@ 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, ...); +struct _ddebug; +__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. @@ -415,11 +416,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, cat, fmt, ...) \ - __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__) #else #define drm_dev_dbg(dev, cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ - dev, cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) #endif /** @@ -523,17 +524,17 @@ 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, ...); #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(cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ - cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) #endif /* Macros to make printk easier */ From patchwork Sun Sep 4 21:41:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F811C6FA82 for ; Sun, 4 Sep 2022 21:48:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1DE5010E388; Sun, 4 Sep 2022 21:43:46 +0000 (UTC) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by gabe.freedesktop.org (Postfix) with ESMTPS id 82DCC10E23C; Sun, 4 Sep 2022 21:42:40 +0000 (UTC) Received: by mail-il1-x132.google.com with SMTP id l6so3864134ilk.13; Sun, 04 Sep 2022 14:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LAElKATTm6r2TIe9HchZuJ0iTvp0tkidaAAlkqZf57g=; b=ioFXEtAboLLUIN/kNyc61L0HOu8/6UCEVPrRpVK/iZqDkjSxhy1lokEax7skm4mwOF mCdRRCoU7224D2s+eeI9bmOsLLpeqbAXpSoc5ewN3Vnu4++5Y8MjvC45CARQ2eSUmtPM vq67RMmjwELCYQ5rsDgJHAwkUX47ytKixYLVLxiRln+UZzGGvAk+2JB+Sw0belDPO48F qDmzIHF6L9eAsm4bEnMCzLrXaEJmVUloL5mpLRJ14V94PQCg5aoimHZKHASnmIAq31fh i6l/G06rgbvOyZ/eJK8nqcrZ4A1qC4+YiBem4FdzmsbXjDz5e2YWLpntsHdBPAZvrPbS m72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=LAElKATTm6r2TIe9HchZuJ0iTvp0tkidaAAlkqZf57g=; b=GDfycPn8+yINvKjuUGdJnHs54/rla4Cu2hKhoGxSUs/Dbt3ksFaiEKei6aAr0xDxEX Mx006BZDlQgijFgtlNY2qji6OcUh7wVWPxk1Q9QJdCMv/0CcR5hbqxTNDEE3ICZQLxuI 1nJAJqIvUD7NWrbiYKhgZeuthkZwI4zkYLLm9d3kRIPvZ+9JnEnLF91/IHiq8RPi71N2 qiBd2+AKCtUg6fmg27GDKyngZYh09PLl6ZNMjAt9IpWZOdhkAxT+dpSwuomj59XgiU9e hotrAorg8v/r1e+BSdzvJSnxCACkh2PnL6SCUd1p/3s1BSByic/5EdO0Zwk/TCihAA6b y34A== X-Gm-Message-State: ACgBeo39fiStQG1VowHi1IXVd0r9xCCOGbAPx09cgg4F/SJEQZTiLZ2R gTj8g/HEGQVCV5hoMl5OwGU= X-Google-Smtp-Source: AA6agR4JZnvP+IfSOvpE/ZnPHvuTyE3m/D+cXn8a4t+7sZ/c+tnbIR9Wi8DqdENHAxq6VZVKf3h3Ew== X-Received: by 2002:a05:6e02:20c1:b0:2e9:f747:ad54 with SMTP id 1-20020a056e0220c100b002e9f747ad54mr25614470ilq.144.1662327759838; Sun, 04 Sep 2022 14:42:39 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:39 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:08 -0600 Message-Id: <20220904214134.408619-32-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 31/57] nouveau: change nvkm_debug/trace to use dev_dbg POC X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" These 2 macros formerly used dev_info, and they still check subdev->debug to gate the printing. So dyndbg control is redundant ATM (and possibly confusing, since its off by default). prdbg count is up from 3, or from 65 (with VMM_DEBUG here) [ 7.765379] dyndbg: 516 debug prints in module nouveau Its possible to control error, warn, info callsites too, but they're usually on, and the .data overheads on ~450 more callsites (56 bytes each) would just be wasted. $ for l in fatal error warn info debug trace spam; do echo $l; ack nvkm_$l drivers/gpu |wc; done fatal 3 19 335 error 289 1956 30651 warn 84 513 8860 info 14 88 1502 debug 387 2339 40844 trace 31 219 3368 spam 1 7 123 bash-5.1# echo $(( 516-65-387-31-1 )) 32 Thats approximate; not accounting #defines and doc/comment mentions. NOTE: this patch changes the log-level of the macro-issued messages from KERN_INFO to KERN_DEBUG. Adding a .kern_lvl field to struct _ddebug could fix that. RFC: dyndbg & subdev->debug Separate class-maps for each subdev are possible; except for the coordinated use of _base, each is independent, including choice of DISJOINT or LEVELS, as long as class-names don't conflict. So theres some flexibility. Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h index 96113c8bee8c..065d07ccea87 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -59,8 +59,8 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a) +#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) #define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a) From patchwork Sun Sep 4 21:41:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCF93C6FA86 for ; Sun, 4 Sep 2022 21:46:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F4A310E2E4; Sun, 4 Sep 2022 21:43:10 +0000 (UTC) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CDA610E1BE; Sun, 4 Sep 2022 21:42:41 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id b142so5642372iof.10; Sun, 04 Sep 2022 14:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8gwyhoydIHSfwTTFYi0xd/UEVRo5zT1WMZJS4KZ9ukE=; b=Oj7Ixl6oj9kg3JhT5hX2YNpqFWBWrRAemLR9ZyRiH8YKxlEL1JbyYUePKaIrZAL5jf 1WolreEcW4UQ85oE8rIFcQKM9Y8DgXov3VdkOuxIChkt3b8QQ86vavL7yfZdfnG1GXrG DieSrzFFZkksP5SG7xHoU2NUtwtLwxXiHtZdjYdGp0A0SfFIYvtv5K3SHQproh7ZaK9g fFJF5WVYv4z4A9NBf1N+h/WwX6chGYIEj2Ni0q0zS2lPBsAWNrYRKNiDRgERv8ZCLA+5 CocXeZEZ1Rn3EM+S6VnFtLemc62uByDMdXXT71Ilig4RAz83otTF0UG6qgEF5wkzDQpI 548g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=8gwyhoydIHSfwTTFYi0xd/UEVRo5zT1WMZJS4KZ9ukE=; b=lrv9lbQfZIm95JGLjvFVRIlUvKmMlxbADfT8f0t62rBx+GRBIPMh3SAyNZzgVoKYNr NWH6camU1Qfvf44nQOaougVEs7ncZdISqwNoTbDg5UrzBD1xo/FY131nUawf7ZqBajGu VXkleJnMl5LYq4TqWY8TsTf55Hfwtr4VZOo0DvpyhlnCrVRbEIAAuR1vZgxiO3T1YLDo eztw+ZbPrQoXsavyzZBcgm4xCACiI9YMAYcqiB3WMkSJMXKdqZNJizY2jhtZoAmHIzWs JHQQIyVLQNexPMjwRcV4E7NkzL2fhbjk8XcjTNCoPoIezRWwSOiAXDvltUwU8thbWk0x UjzQ== X-Gm-Message-State: ACgBeo0Kxp+i8r74aO10F9kLwXU6yv79IhECPEcTwG5FGryCbNngj9SC fBdUe3KsVMG8ZSI6jb+UDoY= X-Google-Smtp-Source: AA6agR7YcRBN9eLsdX3bzp79/kQqCn5Cue7Lw5y+W0FC6PDyqlsmvwF4ziOCRLDCU+BO8di3xE1W6A== X-Received: by 2002:a05:6638:d06:b0:350:a613:f7ec with SMTP id q6-20020a0566380d0600b00350a613f7ecmr3859829jaj.169.1662327760724; Sun, 04 Sep 2022 14:42:40 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:40 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:09 -0600 Message-Id: <20220904214134.408619-33-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC} respectively, replace those with drm_dbg_##cat invocations. this results in new class'd prdbg callsites: :#> grep nouveau /proc/dynamic_debug/control | grep class | wc 116 1130 15584 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc 74 704 9709 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc 31 307 4237 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc 11 119 1638 the KMS entries are due to existing uses of drm_dbg_kms(). Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/nouveau_drv.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 84df5ddae4d0..3b8a76004b57 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -39,6 +39,7 @@ */ #include +#include #include #include @@ -263,13 +264,16 @@ void nouveau_drm_device_remove(struct drm_device *dev); #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a) #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a) -#define NV_DEBUG(drm,f,a...) do { \ - if (drm_debug_enabled(DRM_UT_DRIVER)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ +#define NV_DRMDBG(cat,c,f,a...) do { \ + struct nouveau_cli *_cli = (c); \ + drm_dbg_##cat(_cli->drm->dev, "%s: "f, _cli->name, ##a); \ } while(0) -#define NV_ATOMIC(drm,f,a...) do { \ - if (drm_debug_enabled(DRM_UT_ATOMIC)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ + +#define NV_DEBUG(drm,f,a...) do { \ + NV_DRMDBG(driver, &(drm)->client, f, ##a); \ +} while(0) +#define NV_ATOMIC(drm,f,a...) do { \ + NV_DRMDBG(atomic, &(drm)->client, f, ##a); \ } while(0) #define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a) From patchwork Sun Sep 4 21:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEF62ECAAD5 for ; Sun, 4 Sep 2022 21:47:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E705D10E17A; Sun, 4 Sep 2022 21:43:22 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5CFC310E23F; Sun, 4 Sep 2022 21:42:42 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id m16so861477ilg.3; Sun, 04 Sep 2022 14:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jC4v9G/jhIkV0IQnbp5Uklfh57U7QHhGGd6NNp2oJCQ=; b=JArjEmrzGNVVldZMbJ5jrf44JYpBIstZSf/RikgwsjBwJH+il6AO3P1IV8DJwWsj01 wjyu3J9Voml6ApRZ9BbFJ9M9k7fiqw10KqjikCPJe1ZZgvidWnhx5sJWFvV6+ACmKVLG 04lpCLgNFAvsSYE1SjofxinrRx7C40uUtSYlD0/U1rAvxGK3g49Gp7iVxPuuo1UN1koT pE+CL1wi/k0+XzIAs5uudPeEblnnR/mJkz43hOcjYDEU+8Vb57yY9NqVAbA3oEUNEnUK b8swAPOctxMUkIWBM3RbRCtpkGuO1hVdC7f8myhppY8uQYK3DxWRAN3ZApquu4AfNZfN 3Law== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jC4v9G/jhIkV0IQnbp5Uklfh57U7QHhGGd6NNp2oJCQ=; b=d2wzXWSvPhFl0gnT21pA/RIrf1Vl8lPzmJkwUZyfNRSvN2piQdJTuHiQophaETAtO9 X8eLhOgmhfHOlwdzjWkTxwIk3t/vSHPi5i+5mzh96dWc1Q7l+JU7B2s0TgXELqkPAbm1 yMniV/ixT6buCRK4XjppVoZfx6NjXk/z4xpw++cmNPsvEinn9Bqv2P6WwB/Wm+OGtCPL 8rn/tUHxauOFUrEAfHyxrc7QC6mdQZF7vHel2CcnL3+xSw2LJFYjDUE5YbZtvF6bZtwE 3w3fL/5tgM68eaMrxBOhxdRS9gh2Q6uIQ5cw8faUXIIM73EXV5GM4EHQ+xYPRrVKY8tI wCzA== X-Gm-Message-State: ACgBeo3oMdlqp7w5gpelZI9LVTz+evgX46E+TMi9FTHy0MYIMT+EdCTr sFSw8ppU4MRGpg0sK1QtwoSicRut4hY= X-Google-Smtp-Source: AA6agR5aUJRUan3rD6naJWTJ2nKGrD7fI4wCyu4cKP7ShkwvcE9ugvvmti6Sq7eCe3uNSIs9c/N8tg== X-Received: by 2002:a05:6e02:dc3:b0:2ea:d7a4:a5f with SMTP id l3-20020a056e020dc300b002ead7a40a5fmr18266464ilj.308.1662327761570; Sun, 04 Sep 2022 14:42:41 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:41 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:10 -0600 Message-Id: <20220904214134.408619-34-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 33/57] nouveau: WIP add 2 LEVEL_NUM classmaps for CLI, SUBDEV X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" clone the nvkm_printk,_,__ macro ladder into nvkm_drmdbg,_,__. And alter the debug, trace, spam macros to use the renamed ladder. This *sets-up* (not done yet) to remove the _subdev->debug >= (l) condition, once the bitmap-param is wired up correctly, and figured into dyndbg's jump-label enablement. WIP. Then undo the 1-line change that reduced count of prdbgs from 632 to 119. ie: s/NV_SUBDEV_DBG_##l/NV_DBG_##l/ So heres what happened: new symbol is 15 (or 10), and fails this macro test, so gets compiled out, and the dev_dbg is excluded. if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \ I could hack this, by doing (l + base), but base is pretty distant. OTOH, the whole CONFIG_NOUVEAU_DEBUG check could be reworked; given that trace is minumum recommended, theres not that many callsites elided (SPAM only iirc) at compile-time, and dyndbg means keeping them has "zero" run-cost (and 56 bytes per callsite). So this config item doesnt do much when DRM_USE_DYNAMIC_DEBUG=y. So this is a useful place to stop and look around, try to guess which trail to take.. nouveau has additional debug variables to consider: drivers/gpu/drm/nouveau/include/nvkm/core/device.h 131: if (_device->debug >= (l)) \ drivers/gpu/drm/nouveau/include/nvkm/core/client.h 39: if (_client->debug >= NV_DBG_##l) \ drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h 54: if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ This is another baby-step, that seems not to break, so lets get a snapshot. whats done here: In nouveau_drm.c, do DECLARE_DYNDBG_CLASSMAP(LEVEL_NUM type) 2x more, for cli and subdev, right after the drm DECLARE. Adjust base for each, to share the 0..30 classid-space. These declare class-names: NV_CLI_DBG_* NV_SUBDEV_DBG_* accordingly. Note: class-name-space is flat and wide, so super-generic names like INFO should be prefixed; who could predict what a generic V3 does across all modules. s should be included adjusting the base to avoid each other, and the 0-10 already mapped to drm-debug-categorys (just above this addition). In nvkm/core/debug.h, add enums to match the names, with initial values to match the bases. In nvkm/core/subdev.h, alter (recently added) nvkm_drmdbg_() to use NV_SUBDEV_DBG_* instead of NV_DBG_*. NB: in both classmaps, Ive left FATAL..WARN out, they're not really optional the way INFO..SPAM are; dyndbg shouldn't be able to turn them off. bash-5.1# modprobe nouveau [ 966.107833] dyndbg: 3 debug prints in module wmi [ 966.342188] dyndbg: class[0]: module:nouveau base:15 len:5 ty:1 [ 966.342873] dyndbg: 15: 0 NV_SUBDEV_DBG_OFF [ 966.343352] dyndbg: 16: 1 NV_SUBDEV_DBG_INFO [ 966.343912] dyndbg: 17: 2 NV_SUBDEV_DBG_DEBUG [ 966.344443] dyndbg: 18: 3 NV_SUBDEV_DBG_TRACE [ 966.344938] dyndbg: 19: 4 NV_SUBDEV_DBG_SPAM [ 966.345402] dyndbg: class[1]: module:nouveau base:10 len:5 ty:1 [ 966.346011] dyndbg: 10: 0 NV_CLI_DBG_OFF [ 966.346477] dyndbg: 11: 1 NV_CLI_DBG_INFO [ 966.346989] dyndbg: 12: 2 NV_CLI_DBG_DEBUG [ 966.347442] dyndbg: 13: 3 NV_CLI_DBG_TRACE [ 966.347875] dyndbg: 14: 4 NV_CLI_DBG_SPAM [ 966.348284] dyndbg: class[2]: module:nouveau base:0 len:10 ty:0 [ 966.348888] dyndbg: 0: 0 DRM_UT_CORE [ 966.349310] dyndbg: 1: 1 DRM_UT_DRIVER [ 966.349694] dyndbg: 2: 2 DRM_UT_KMS [ 966.350083] dyndbg: 3: 3 DRM_UT_PRIME [ 966.350482] dyndbg: 4: 4 DRM_UT_ATOMIC [ 966.351016] dyndbg: 5: 5 DRM_UT_VBL [ 966.351475] dyndbg: 6: 6 DRM_UT_STATE [ 966.351899] dyndbg: 7: 7 DRM_UT_LEASE [ 966.352309] dyndbg: 8: 8 DRM_UT_DP [ 966.352678] dyndbg: 9: 9 DRM_UT_DRMRES [ 966.353104] dyndbg: module:nouveau attached 3 classes [ 966.353759] dyndbg: 119 debug prints in module nouveau NOTE: it was 632 with previous commit, switching NV_DEBUG to use NV_SUBDEV_DBG_DEBUG instead of NV_DBG_DEBUG may be the cause. Signed-off-by: Jim Cromie --- .../gpu/drm/nouveau/include/nvkm/core/debug.h | 16 +++++++++++++ .../drm/nouveau/include/nvkm/core/subdev.h | 17 ++++++++++---- drivers/gpu/drm/nouveau/nouveau_drm.c | 7 ++++++ drivers/gpu/drm/nouveau/nvkm/core/subdev.c | 23 +++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h index b4a9c7d991ca..6a155a23a3d1 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h @@ -9,4 +9,20 @@ #define NV_DBG_TRACE 5 #define NV_DBG_PARANOIA 6 #define NV_DBG_SPAM 7 + +enum nv_cli_dbg_verbose { + NV_CLI_DBG_OFF = 10, + NV_CLI_DBG_INFO, + NV_CLI_DBG_DEBUG, + NV_CLI_DBG_TRACE, + NV_CLI_DBG_SPAM +}; +enum nv_subdev_dbg_verbose { + NV_SUBDEV_DBG_OFF = 15, + NV_SUBDEV_DBG_INFO, + NV_SUBDEV_DBG_DEBUG, + NV_SUBDEV_DBG_TRACE, + NV_SUBDEV_DBG_SPAM +}; + #endif diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h index 065d07ccea87..ce33c82e5c75 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -2,6 +2,7 @@ #ifndef __NVKM_SUBDEV_H__ #define __NVKM_SUBDEV_H__ #include +#include enum nvkm_subdev_type { #define NVKM_LAYOUT_ONCE(t,s,p,...) t, @@ -18,7 +19,7 @@ struct nvkm_subdev { enum nvkm_subdev_type type; int inst; char name[16]; - u32 debug; + unsigned long debug; struct list_head head; void **pself; @@ -59,9 +60,17 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) -#define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) + +#define nvkm_drmdbg__(s,l,p,f,a...) do { \ + const struct nvkm_subdev *_subdev = (s); \ + if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ + dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \ +} while(0) +#define nvkm_drmdbg_(s,l,f,a...) nvkm_drmdbg__((s), NV_SUBDEV_DBG_##l, dbg, f, ##a) +#define nvkm_debug(s,f,a...) nvkm_drmdbg_((s), DEBUG, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_drmdbg_((s), TRACE, f, ##a) +#define nvkm_spam(s,f,a...) nvkm_drmdbg_((s), SPAM, f, ##a) #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a) + #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index fd99ec0f4257..864750451dc8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -83,6 +83,13 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, "DRM_UT_DP", "DRM_UT_DRMRES"); +DECLARE_DYNDBG_CLASSMAP(nv_cli_debug_verbose, DD_CLASS_TYPE_LEVEL_NUM, 10, + "NV_CLI_DBG_OFF", + "NV_CLI_DBG_INFO", + "NV_CLI_DBG_DEBUG", + "NV_CLI_DBG_TRACE", + "NV_CLI_DBG_SPAM"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c index a74b7acb6832..20cd99cce2a4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c @@ -26,6 +26,27 @@ #include #include +#include +#include + +#define DEBUG + +DECLARE_DYNDBG_CLASSMAP(nv_subdev_debug_verbose, DD_CLASS_TYPE_LEVEL_NAMES, 15, + "NV_SUBDEV_DBG_OFF", + "NV_SUBDEV_DBG_INFO", + "NV_SUBDEV_DBG_DEBUG", + "NV_SUBDEV_DBG_TRACE", + "NV_SUBDEV_DBG_SPAM"); + +static struct ddebug_class_param nv_subdev_verbose = { + .bits = NULL, // wants &_subdev->debug + .flags = "p", + .map = &nv_subdev_debug_verbose, +}; +module_param_cb(debug_subdev, ¶m_ops_dyndbg_classes, &nv_subdev_verbose, 0600); + + + const char * nvkm_subdev_type[NVKM_SUBDEV_NR] = { #define NVKM_LAYOUT_ONCE(type,data,ptr,...) [type] = #ptr, @@ -180,6 +201,8 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func, struct nvkm_device *device else strscpy(subdev->name, nvkm_subdev_type[type], sizeof(subdev->name)); subdev->debug = nvkm_dbgopt(device->dbgopt, subdev->name); + nv_subdev_verbose.bits = &subdev->debug; + pr_debug("updated bitmap: %px\n", &nv_subdev_verbose.bits); list_add_tail(&subdev->head, &device->subdev); } From patchwork Sun Sep 4 21:41:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F84FC6FA82 for ; Sun, 4 Sep 2022 21:46:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 173E910E273; Sun, 4 Sep 2022 21:43:23 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE38710E1C5; Sun, 4 Sep 2022 21:42:42 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690736iof.1; Sun, 04 Sep 2022 14:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=yB0p6m1pbFn82PaaCe9bX0Com85Je0ESfO84kw+YqGQ=; b=UQ8KTpkUZuUjPBlMxj/1xzitRYQINMPQpY3Hd7AH9zV7Ub4knjfNFZVsDZcPlumg6D RVvYcS9KlYeVAl2ypb4nyaXZuZp4hKLEPCUJULeth+dw9XjB7AZUphJjVMw77uQvbwIP F74jHiu1hanUG/lW7nkcHVm36JEUcgagI5taL7R0dabNs3eanVGIGy30Bz+y4yv7YaJg uJQDYEHEOVxa0h3AynNMElY1UV5uwXtZvaejV0B8nW90gt5D3JzxCo087m/HxCJPbM3P OmgAgxgRkcofaDF0Os9F+y60Rz4cN4ndRv4xMNT9b4kOQ3TXaSKJIqrX2mX1Xky6pPdt OYJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=yB0p6m1pbFn82PaaCe9bX0Com85Je0ESfO84kw+YqGQ=; b=g/z26cCJqKHx4bIGC3LIPOXrHfctO6Qa9qt/Cuskyl+yQDIiLlGVzJFzjsrwkV6o1H iuARW4rZ6rOCQH+HF6qv5IPROCY5nomcnfK+zWIhatddqbN9vn7sWiu5r98TRBwwzp6a 8mmQnAjxgnXesdttlNr9C/g+XwNGc94y/rF6FtIl7olmKesUW/EvWUjZLnISH7pfAuT2 dobMWgT62AH20QLSW5LL6hKMVfVBpnN21DeGxwbAXP6k1EizQ2FqNM3TJTU2uFBNpdVn 8lr+jIonNJqsMw1SIxTvgygFYgLJBAbOaBDpLmIn06WWIQDo9uhF1cr3UlGBUo6lsWcU WYmg== X-Gm-Message-State: ACgBeo2RbYHMdvL8s1fwG+BTs2oMvb66BjxKQCYj3G/+7A7JvQ+zzTcf hlKc96NZni+fBpNScGCpPr4= X-Google-Smtp-Source: AA6agR5hyoFODwyMk2f+k/6+4G4cl6nFZCnCNI0y+wxYxmE+qgJlFbiwfQMvoxjNj4fTWX0cU6fXrg== X-Received: by 2002:a05:6638:3712:b0:34a:31f:b80 with SMTP id k18-20020a056638371200b0034a031f0b80mr24360396jav.84.1662327762569; Sun, 04 Sep 2022 14:42:42 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:42 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:11 -0600 Message-Id: <20220904214134.408619-35-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 34/57] dyndbg: add _DPRINTK_FLAGS_ENABLED X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, vincent.whitchurch@axis.com, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Distinguish the condition: _DPRINTK_FLAGS_ENABLED from the bit: _DPRINTK_FLAGS_PRINT, and re-define former in terms of latter, in preparation to add a 2nd bit: _DPRINTK_FLAGS_TRACE Update JUMP_LABEL code block to check _DPRINTK_FLAGS_ENABLED symbol. Also add a 'K' to get new symbol _DPRINTK_FLAGS_PRINTK, in order to break any stale uses. 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 41682278d2e8..ecd3379090c4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,7 +32,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) @@ -42,8 +42,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 @@ -198,10 +200,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 009f2ead09c1..1e9d0124a0e9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -89,7 +89,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' }, @@ -246,10 +246,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 (!(newflags & _DPRINTK_FLAGS_PRINT)) + if (dp->flags & _DPRINTK_FLAGS_ENABLED) { + if (!(newflags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (newflags & _DPRINTK_FLAGS_PRINT) { + } else if (newflags & _DPRINTK_FLAGS_ENABLED) { static_branch_enable(&dp->key.dd_key_true); } #endif From patchwork Sun Sep 4 21:41:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D1E2C6FA82 for ; Sun, 4 Sep 2022 21:47:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E581710E1C5; Sun, 4 Sep 2022 21:43:30 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id C86A810E1C4; Sun, 4 Sep 2022 21:42:43 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868244ilt.7; Sun, 04 Sep 2022 14:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TAwV35ZWZLIKqOElwfkhFfIbRXseVOLIKBiUUUQjUVQ=; b=YQSF24Us+VgO6MmkwBVVohgShZMcax7Tlk2S3GvdeKpX8+kDOiSv3UtwHdryBa/MfZ MVJvIEFu2ceZYdrJvC7LCgaG6cEGWWOo9rPDcMnnD+bMW23GiPRN5wZw8EBRiwT0rE4D tyIORau8tjxdkTvurYsJa1KKbPC7Xw24bYyvtnAHFUTaVJyVUi4XMOenzHqGO8vAeZLz IykguT8g4g+lANiwbVQH2BC/Z9FWb7/vEYDvWbQ9K6c9NLNB3P6ZPkHEEo1aJnLu/3DP so/ytamyrgwlaVUiFuKwgSUCvGgReaF3szmlQpVggMMm6ySVIhuDBYvRb9VRu2wy021f mxrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=TAwV35ZWZLIKqOElwfkhFfIbRXseVOLIKBiUUUQjUVQ=; b=GXnssqtqRnAF3GHkQWsyxXYaHG2kQ5OPiCWi7qXYHs9ADMxQkstc63Gpl6ksN4vDRU C3nMqV5EyeyM9azu4GyXVPdSTHYcrXskwy5+1vubqWxkc9grOC0LDoqFgZ9ePUb2gIhY yulCTtOQXQ62weE6LoxgqSKhih1JbvXQI9WS9DMsx/R/ZNpgaR1d0BNGdDRpi2XmR4xS TUTaaD1xCad9WIgtoSvVqYFkOwiJdus/zisB7mzcciLOPQy1GkqMSmRGFBlrwi3rJtM4 ZZ/4K+LfWntWb6mpUXaVO0RdUpsw03Lyhe0b0gAUkHcS4n/9yg/CXGoqjQftynEAjlCW 3Wxg== X-Gm-Message-State: ACgBeo0xyQL6wrWRIKpox+rDp6Y5ETJWt40kRX7q1cpiCojJcut805Jq fla9S2MK1fz0gNVekuKBoo4= X-Google-Smtp-Source: AA6agR5dlZ+2mbjYaiVo07B1ri+ETbudxxDzknKKyObWsKY9ZVDTd1RmO8d48xns2r12tpVnSs9bbw== X-Received: by 2002:a05:6e02:12ed:b0:2eb:753e:cfb with SMTP id l13-20020a056e0212ed00b002eb753e0cfbmr12322927iln.14.1662327763512; Sun, 04 Sep 2022 14:42:43 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:43 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:12 -0600 Message-Id: <20220904214134.408619-36-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 35/57] dyndbg: add _DPRINTK_FLAGS_TRACE X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, vincent.whitchurch@axis.com, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" add new flag, and OR it into _DPRINTK_FLAGS_ENABLED definition CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index ecd3379090c4..04f49df308a7 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -42,7 +42,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 Sun Sep 4 21:41:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE5AEC6FA82 for ; Sun, 4 Sep 2022 21:47:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78E5E10E279; Sun, 4 Sep 2022 21:43:28 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id D112E10E183; Sun, 4 Sep 2022 21:42:44 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868252ilt.7; Sun, 04 Sep 2022 14:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hLX0vmxfE2cNoXxW+pxt5dZIDGNJfmOeoJDSMO1hano=; b=ZpQL1fgEKB26ROGXg3bIaSFjutqwzthCJGLTsOMm82G/WKNEV7RaSc1HgHH+4EYBBS I4kKHN3sYKUpq6oxtDqQ1rCKWqBdgYhjSyRVZjcy2kkCKt36zUM2J/ACsEbogd/hT1/4 424RgMlqSajD+0g+5qs3goYOHny/cd7TJJkRA/BMgzHJmFhr2Q29luzQuKVFVIgObj69 m8/YXI9TBy0MBh8wQ/bAntqEfcQ5RhKh7RL9djNRQrRx1PcKpAkktrHMphwSX2m7oEaQ uSJsFu2GqUMeiXnT8ItzwB1PI1sTsJRhpbzjAcUWmn/b2uQrxhPmWUibRuhMD2GPNPqm PVKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hLX0vmxfE2cNoXxW+pxt5dZIDGNJfmOeoJDSMO1hano=; b=iQF1uvIPCR6D0kYP7Il3cbLSE97NBxOGuHps0YuV4QwnASBlj+sYHciRenmDAIRinD 4TIl1jRunISFcBzfmfgTik8d1J8BmJ9lUmACT4R4lsALsMdfdji77pmgD4MRvQ12HQ2D qDBc5e6/FK3TPCvHTNMH9vTTS7/jZ6sGXjpIOaatQA7kW/TP7FHdmWxAKvVCrXLCMEXN GyIqworL1ioDKOvwlh0VlsiYQfaY2zbFrFCHhhr1WtYmAX7STVlh/QohNs3Zba+q+ZyO UVqu8+omkmBf4WgO9Q6vR0yHghsySsBDKv2pSNbRTJTBLtuxXIcF2oPmFyTzQXaxflkj BpDg== X-Gm-Message-State: ACgBeo2v+9YFo3IMA+j0EZA1WGC1bvNQ8pDBZHInsrmLq2HCC2mN9gEK se4znNlrDH0nN4mPG4a+JYU= X-Google-Smtp-Source: AA6agR6D4aeYAw5/pzfOTRxYtiGWHhCcgKpGfv2afQnTmQdaB6TE6PRIg59M3lVF8/S7qM7IzEmgCg== X-Received: by 2002:a05:6e02:1a6c:b0:2f1:5a6e:93c6 with SMTP id w12-20020a056e021a6c00b002f15a6e93c6mr1815104ilv.175.1662327764441; Sun, 04 Sep 2022 14:42:44 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:44 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:13 -0600 Message-Id: <20220904214134.408619-37-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 36/57] dyndbg: add write-events-to-tracefs code X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, vincent.whitchurch@axis.com, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" adds: ddebug_trace() uses trace_console() temporarily to issue printk:console event uses internal-ish __ftrace_trace_stack code: 4-context buffer stack, barriers per Steve Rostedt call it from new funcs: ddebug_printk() - print to both syslog/tracefs ddebug_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: __ddebug_{pr_debug,{,net,ib}dev_dbg}, replacing printk and dev_printk with the new funcs above. The _DPRINTK_FLAGS_TRACE flag character is 'T', so the following finds all callsites enabled for tracing: grep -P =p?T /proc/dynamic_debug/control This patch,~1,~2 are basically copies of: https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com/ with a few differences: - s/dynamic_/ddebug_/ on Vincent's additions - __printf attrs on the _printk funcs - reuses trace_console() event, not adding a new "printk:dyndbg" event. next patch replaces this with 2 new events CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 5 +- lib/dynamic_debug.c | 156 +++++++++++++++--- 2 files changed, 133 insertions(+), 28 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index faa22f77847a..45b6e5697c89 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -209,8 +209,9 @@ of the characters:: The flags are:: - p enables the pr_debug() callsite. - _ enables no flags. + p callsite prints to syslog + T callsite issues a dyndbg:* trace-event + _ enables no flags Decorator flags add to the message-prefix, in order: t Include thread ID, or diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1e9d0124a0e9..3c6c18f13889 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -90,6 +91,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' }, @@ -854,6 +856,98 @@ 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 ddebug_trace_buf { + char buf[256]; +}; + +struct ddebug_trace_bufs { + struct ddebug_trace_buf bufs[DYNAMIC_TRACE_NESTING]; +}; + +static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); +static DEFINE_PER_CPU(int, ddebug_trace_reserve); + +static void ddebug_trace(const char *fmt, va_list args) +{ + struct ddebug_trace_buf *buf; + int bufidx; + int len; + + preempt_disable_notrace(); + + bufidx = __this_cpu_inc_return(ddebug_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(ddebug_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(ddebug_trace_reserve); + preempt_enable_notrace(); +} + +__printf(2, 3) +static void ddebug_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. + */ + ddebug_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); + } +} + +__printf(3, 4) +static void ddebug_dev_printk(unsigned int flags, const struct device *dev, + const char *fmt, ...) +{ + + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + ddebug_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; @@ -868,16 +962,18 @@ 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); + ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); } EXPORT_SYMBOL(__dynamic_pr_debug); void __dynamic_dev_dbg(struct _ddebug *descriptor, - const struct device *dev, const char *fmt, ...) + const struct device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -887,16 +983,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); + ddebug_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); + ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev), dev_name(dev), + &vaf); } va_end(args); @@ -909,6 +1007,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); @@ -918,22 +1017,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); + ddebug_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); + ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", + &vaf); } va_end(args); @@ -949,26 +1050,29 @@ 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); + ddebug_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); + ddebug_printk(flags, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } va_end(args); From patchwork Sun Sep 4 21:41:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09EDCC6FA82 for ; Sun, 4 Sep 2022 21:46:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2BFD10E204; Sun, 4 Sep 2022 21:43:10 +0000 (UTC) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA36A10E1D3; Sun, 4 Sep 2022 21:42:45 +0000 (UTC) Received: by mail-io1-xd30.google.com with SMTP id q81so5653963iod.9; Sun, 04 Sep 2022 14:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=A2zndOeDRPgGOvwAIBa0JaD1rifqqeyYUM4/f4LglP8=; b=Dx7ob9YDExsS8kTSLfJMyPG66UA0U31lxKW3FyZ0OB7RnX+eTy24lpN15BN0uRCHgK iYRtls7LairgGBqQuWjOWGt5yV/5sReWPL8tJcxGLve+LNOB7TeMPm6iwWvkuf+Gq8oK Jg00USMN4Sx6FBVhr4RDt6XK444pORZc4ArmQjXr5Hi+BWDooYO/+r75wEMcyKAvmeXv ITokxmZrLFKj9FfRabOmhj5kw4y0bEhW59aTj3Y2WyYkmh3QI84/qPuQpnu2EEilo0M9 03YBBWYjSQ9xaDCSkgVNC8OmCZZsemz9X0cEsj/0x82tX7xElqTn8iPg31QwPj3XtjyW ewQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=A2zndOeDRPgGOvwAIBa0JaD1rifqqeyYUM4/f4LglP8=; b=h+6z9Lk7BwTzBANgKRGhY5L5pJrXyKBx5cplOIzviLdFi6yzEpjRDypfewJ98vssuV 0xDpJT23nR9itAyULb7zx37vZnNyNklMFDajlbOFqUya/J1dmv5B5uyCnT1mmkCvLyfB AgI+TSQKP7hlGg5e9EELjSMqgXEUlyDdJ0D8gDrHHcrg6A/qPnSlXiPX5YXQIjXVQjs0 XdejrndvOmBsWNre4NydHogZxcaNcHkiHDp8/k0nk4yqb3Roeiu/eZHgaLzZ3xDmLn0Z S105vvTY3hYNUXjiRZOnspwV7wZ9DFob/pZu0SVVvDQTlVM45xbIgiBERU1y7uUoWA8z jT3w== X-Gm-Message-State: ACgBeo1iocDhYrjSBodp5hQX0IRdD5lbLszGrpqAaWogoE2tzOfkTJGF nkkaJ4Dl3UUNdP1Lo8yJ3LY= X-Google-Smtp-Source: AA6agR5zZ3MpxOCe1Gv6PL9bbcItO9JKVZB4ZP+mJzEw4KEVnlCu6qXDvhLhCGEBE1WfgmU3fBenrw== X-Received: by 2002:a05:6638:d10:b0:34c:10d8:4f7 with SMTP id q16-20020a0566380d1000b0034c10d804f7mr10894388jaj.246.1662327765640; Sun, 04 Sep 2022 14:42:45 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:45 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:14 -0600 Message-Id: <20220904214134.408619-38-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 37/57] dyndbg: add 2 trace-events: drm_debug, drm_devdbg X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Recently added ddebug_trace() issues a single printk:console event. Replace that event with 2 new ones, defined in a new header: include/trace/events/dyndbg.h - dyndbg:prdbg - from trace_prdbg() - if !dev - dyndbg:devdbg - from trace_devdbg() - if !!dev This links the legacy pr_debug API to tracefs, so pr_debug() and dev_dbg() calls can add more debug context into the trace-logs, and then at users option, less into syslog. The new events allow enabling by event-type in tracefs, and dyndbg allows individual enablement of prdbg callsites (via +T flag). Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 25 ++++++++++++----- include/trace/events/drm.h | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 7 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 5b93c11895bb..c50edbf443d3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -35,6 +35,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. @@ -293,13 +296,19 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, vaf.fmt = format; vaf.va = &args; - if (dev) - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - else - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - + if (dev) { + 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 { + 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); @@ -319,6 +328,8 @@ 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); + 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..589fa1e1f2c2 --- /dev/null +++ b/include/trace/events/drm.h @@ -0,0 +1,54 @@ +/* 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) + __vstring(msg, vaf->fmt, vaf->va) + ), + + TP_fast_assign( + __entry->drm_debug_category = drm_debug_category; + __assign_vstr(msg, vaf->fmt, vaf->va); + ), + + 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) + __vstring(msg, vaf->fmt, vaf->va) + ), + + TP_fast_assign( + __entry->drm_debug_category = drm_debug_category; + __entry->dev = dev; + __assign_vstr(msg, vaf->fmt, vaf->va); + ), + + 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 Sun Sep 4 21:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 532D1C6FA86 for ; Sun, 4 Sep 2022 21:47:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AFCF10E2BB; Sun, 4 Sep 2022 21:43:32 +0000 (UTC) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C84910E1DA; Sun, 4 Sep 2022 21:42:47 +0000 (UTC) Received: by mail-il1-x12f.google.com with SMTP id b17so3907019ilh.0; Sun, 04 Sep 2022 14:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=MkO54h6RbL6AorJv6VQNVgmDkIVAXQk+J2K+rcA8Q74=; b=T3ioRoJuy8MAjM1fBChZi1K/OJxDzDdQQqCdKzjffCvU/X3SlWWIpnYLeQ03GsbxIu 5yy9VpNkonyO/kzNDY+IHHlpvMoDhr7TUxSwbaOTSQBjRTpMXELmW2qMxlS7zOBqTtAk LSywTJwn2v8eW8UIn/wC7G6bCUzFxHHA19DEPZ8Tb2eK8Ygwpx3NOvYhqhDhsSTuNblU uwascp+YyeS1UKoece2GHDMTMny2l3Gzr8HP/GirCcvXoswIOyRKsLSKaPSnP7DDTIOQ S5fNQreonTFjeF77CvhSPd4peuR9kXy9/Fs/m/E3iM7Ab+itlCiZck+Wtnigj5rqVSw+ Eh/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=MkO54h6RbL6AorJv6VQNVgmDkIVAXQk+J2K+rcA8Q74=; b=mLSlgP/W56hHIm5heaeAwoO8T0/dPJZEz29zdERrSrni/KR1XoUOuv4cOXVT8VkYzl 6HpRyDewAn/kg9DCe4G+U8bC66++/lE19S5gnkoz3NVKnLF3ju6X836Pmpc2f9Gic3Zp vQVjFBFP7iGIMqzFAz5Havhf0ogn11QNDk6jmuN/VM0hKsZdD2K2nLjms1t8MjZleumO 6qa78TPhQoJTpjiwu2wZoD4PhP9W4EnjXONIXZEFKekI7icI0jJkUWZ5kA9Jiu4YIYhv iyHKvkROWpbsEFFQiWJuda0OItNr75OVeXpI3L2mmMUcVj2v3sWJrcpqSwsp2lOLk9gw gagA== X-Gm-Message-State: ACgBeo3GyqE/cZPQttEDOWWNpNncFlNtxyEynY6xKwwI9Rnwdw0bh0Ay hN3E0ThUtCEiDMRQv2Ta/tc= X-Google-Smtp-Source: AA6agR6NnQrYXo22ArhDnzgxL+0DpouWFgKRVUKYMPOBl25l0DqdASsseYFz8k/hKpmJXQxvRG2mmg== X-Received: by 2002:a92:6903:0:b0:2e5:8f47:22e0 with SMTP id e3-20020a926903000000b002e58f4722e0mr24549638ilc.97.1662327766575; Sun, 04 Sep 2022 14:42:46 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:46 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:15 -0600 Message-Id: <20220904214134.408619-39-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 38/57] dyndbg: add 2 more trace-events: pr_debug, dev_dbg X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" ddebug_trace() currently issues a single printk:console event. Replace that, adding include/trace/events/dyndbg.h, which defines 2 new events: - dyndbg:prdbg - from trace_prdbg() - if !dev - dyndbg:devdbg - from trace_devdbg() - if !!dev This links the legacy 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 new trace_*() calls accept their caller's args respectively, keeping the available info w/o alteration; we can't improve on transparency. The args: 1- struct _ddebug *descriptor, giving tracefs all of dyndbg's info. 2- struct device *dev, used by trace_devdbg(), if !!dev The trace_*() calls need the descriptor arg, the callchain prototypes above them are extended to provide it. The existing category param in this callchain is partially redundant; when descriptor is available, it has the class_id. dev_dbg(desc, dev...), if dev is true, issues a trace_devdbg(), otherwise trace_prdbg(). This way we dont consume buffer space storing nulls. Otherwise the events are equivalent. Also add include/trace/events/drm.h, to create 2 events for use in drm_dbg() and drm_devdbg(), and call them. This recapitulates the changes described above, connecting 3-10K drm.debug callsites to tracefs. Signed-off-by: Jim Cromie --- include/trace/events/dyndbg.h | 74 +++++++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 73 +++++++++++++++++----------------- 2 files changed, 111 insertions(+), 36 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..e19fcb56566c --- /dev/null +++ b/include/trace/events/dyndbg.h @@ -0,0 +1,74 @@ +/* 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( + __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 + * 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.%s %s", __entry->desc->modname, + __entry->desc->function, __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( + __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 + * 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.%s %s", __entry->desc->modname, + __entry->desc->function, __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 3c6c18f13889..0870e939f255 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 @@ -874,7 +876,9 @@ struct ddebug_trace_bufs { static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); static DEFINE_PER_CPU(int, ddebug_trace_reserve); -static void ddebug_trace(const char *fmt, va_list args) +__printf(3, 0) +static void ddebug_trace(struct _ddebug *desc, const struct device *dev, + const char *fmt, va_list args) { struct ddebug_trace_buf *buf; int bufidx; @@ -893,7 +897,11 @@ static void ddebug_trace(const char *fmt, va_list args) buf = this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); - trace_console(buf->buf, len); + + if (!dev) + trace_prdbg(desc, buf->buf, len); + else + trace_devdbg(desc, dev, buf->buf, len); out: /* As above. */ @@ -903,9 +911,9 @@ static void ddebug_trace(const char *fmt, va_list args) } __printf(2, 3) -static void ddebug_printk(unsigned int flags, const char *fmt, ...) +static void ddebug_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); @@ -913,11 +921,11 @@ static void ddebug_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. */ - ddebug_trace(fmt + strlen(KERN_DEBUG), args); + ddebug_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); @@ -927,19 +935,19 @@ static void ddebug_printk(unsigned int flags, const char *fmt, ...) } __printf(3, 4) -static void ddebug_dev_printk(unsigned int flags, const struct device *dev, +static void ddebug_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); - ddebug_trace(fmt, args); + ddebug_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); @@ -962,7 +970,7 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + ddebug_printk(descriptor, KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); @@ -973,7 +981,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); @@ -983,15 +990,14 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; - flags = descriptor->flags; if (!dev) { - ddebug_printk(flags, KERN_DEBUG "(NULL device *): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL device *): %pV", + &vaf); } else { char buf[PREFIX_SIZE] = ""; - ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + ddebug_dev_printk(descriptor, dev, "%s%s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(dev), dev_name(dev), &vaf); @@ -1007,7 +1013,6 @@ 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); @@ -1017,24 +1022,22 @@ 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] = ""; - ddebug_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); + ddebug_dev_printk(descriptor, 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) { - ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", - netdev_name(dev), netdev_reg_state(dev), &vaf); + ddebug_dev_printk(descriptor, &dev->dev, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL net_device): %pV", &vaf); } va_end(args); @@ -1050,18 +1053,16 @@ 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] = ""; - ddebug_dev_printk(flags, ibdev->dev.parent, + ddebug_dev_printk(descriptor, ibdev->dev.parent, "%s%s %s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(ibdev->dev.parent), @@ -1069,10 +1070,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dev_name(&ibdev->dev), &vaf); } else if (ibdev) { - ddebug_printk(flags, KERN_DEBUG "%s: %pV", - dev_name(&ibdev->dev), &vaf); + ddebug_dev_printk(descriptor, &ibdev->dev, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } va_end(args); From patchwork Sun Sep 4 21:41:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85294C6FA82 for ; Sun, 4 Sep 2022 21:47:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08C5A10E2D6; Sun, 4 Sep 2022 21:43:34 +0000 (UTC) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8D6110E249; Sun, 4 Sep 2022 21:42:47 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id b142so5642444iof.10; Sun, 04 Sep 2022 14:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=F+IqvxQINaymRL+MafidUTbGzpHBkq2RsFapBWAQydg=; b=N0zhsOBdmXSpqdVIM7Dax53vYiJTKsqF6x9qw6PLO/aFCYoOS0opwP1W/5aTypbefh thcPTdmgHjCwAVeFNHFjBjHzjInzGS+YiXXOrz8p9PMclYRxe1LfcB0y1XUcNo/5BytA YEnLhw/gfAr8rG8KozwOaV+lYe7NXyUjy4JmDGJ94WvqWQr15EnP0FR45EtCb9sixA2H 5PVujoc2/62tw2Rf6QVixL1umMf0g4g0KWpbNPggi2SaHbsUt9ALitBx9exeU1qkh3CT vHElW8wRlXwjNWiUeoUytlqPPgsAovjsIKN3Z9gCGdsWoXgjj0apzjKHP7jxrbSbW8d4 SIYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=F+IqvxQINaymRL+MafidUTbGzpHBkq2RsFapBWAQydg=; b=KBhhIppzZLDDBhZp4G1PdJD6bUrHPaes7J1V9U+k8qA2nWTsJvKjGCgwZz3YjqZbid WWpqTvnUAI3tXZLqo1pruFWgMviB/B8g0752Z8wygT0D3D6ZjP23hYAgaj9zjFEAKfev BnkKMO2olp2zI6xNSHyqCQ/ZjmeX8J/v0y3E28W3w4pQA65VcvciNK2Ku2W5LXEVFnei Pjr5nBmlV073T0XrvQ8buzS2ltTTQezZMNgj2fozKLszcyIPY4WzKyGeYIDxFK9dSkVN a/WsRJDwYU709Raz13Nr4ic91jzqziV2pMpy3YyOqRYLNGJJ1j711Qw1/n2015RwdIFQ /ORw== X-Gm-Message-State: ACgBeo2X5TQojNJ/pBaldW9GHEnZoxr9GLjmguvnZLWvFTTLYJFuZyMj gZ69EV8CaUlAcunip8CpXy0= X-Google-Smtp-Source: AA6agR6wneRG7yCu0WnhzdrmY46L82HWUk9b8e+ZYvtbU/eRsNK3PLQqrk215dPJggzpSd7jRHChZQ== X-Received: by 2002:a5e:c319:0:b0:68b:2683:8e26 with SMTP id a25-20020a5ec319000000b0068b26838e26mr17614839iok.129.1662327767546; Sun, 04 Sep 2022 14:42:47 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:47 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:16 -0600 Message-Id: <20220904214134.408619-40-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 39/57] dyndbg/drm: POC add tracebits sysfs-knob X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" clone DRM.debug interface to DRM.tracebits: ie map bits to drm-debug-categories, except this interface enables messages to tracefs, not to syslog. 1- we reuse the class-map added previously. this reflects the single source of both syslog/trace events 2- add a 2nd struct ddebug_classes_bitmap_param refs 1, reusing it. flags = "T", to enable trace-events on this callsite. 3- module_param_cb([2]) - does the sysfs part Signed-off-by: Jim Cromie Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_print.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index c50edbf443d3..75d0cecd7e86 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -45,6 +45,9 @@ unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); +unsigned long __drm_trace; +EXPORT_SYMBOL(__drm_trace); + MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" "\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n" "\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n" @@ -77,6 +80,13 @@ static struct ddebug_class_param drm_debug_bitmap = { .map = &drm_debug_classes, }; module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); + +static struct ddebug_class_param drm_trace_bitmap = { + .bits = &__drm_trace, + .flags = "T", + .map = &drm_debug_classes, +}; +module_param_cb(tracecats, ¶m_ops_dyndbg_classes, &drm_trace_bitmap, 0600); #endif void __drm_puts_coredump(struct drm_printer *p, const char *str) From patchwork Sun Sep 4 21:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D31DECAAD5 for ; Sun, 4 Sep 2022 21:48:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 15C6510E37A; Sun, 4 Sep 2022 21:43:45 +0000 (UTC) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF40810E252; Sun, 4 Sep 2022 21:42:48 +0000 (UTC) Received: by mail-il1-x129.google.com with SMTP id l16so3889171ilj.2; Sun, 04 Sep 2022 14:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Rm4xzfpSQrPPtx8VSoa62A66wbCtcyyvqJRRKDZL61w=; b=Ztu8i1PzYXrrBIVkF2DTluW99gf/zMexybwuV049ePkV9na4V8i7w1QCN6zxYTzykr gWJHK2OLUi+Boeahy3lUbVhZndOD18gcDpF5to3yTILayNYKZ4bgsx/ilM5F1cusady1 0detNR1/ZaP4mXE3QDeOJN3Ua6Em4qgA+SRN1gU8L2pJeKLHb8ULMMjczUSsBwLn+TZH Fl7fIusVg1NIux1kE9DvOselusKgLkhoeoH81jzxT3c3JfNvfJFAW9TRgtjIQDm0ayCV KSsA2K0pqsDfZfpv6h3kPC2JEitI9SjrLzqxJmiXXq4ZsLTfwXk71OymdVL0+ct6JMQE 1v3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Rm4xzfpSQrPPtx8VSoa62A66wbCtcyyvqJRRKDZL61w=; b=dgq5/+UDGlMz4laV8b7orThFS0M73/fcZ2Ba9Zw0+bKhOiBVLebeONyzOoggppwf+a +TRcZ+94cuAa6VKt4QM91vlbO22izXDBf5oOOmgDBYcWJ35IJB8poA5KnrBKTNnwnHyH dgPtGT77mlNsU/XsNpSyT6i/xWA+zmFFY/Qt9YGtUMUQb4MyDe/yh0nh9ekQlMDLlKvh KZY6RCb5/rwORzJvGHqvvuYP/w9Lzrllg9MpDQM6ArR1wIqjVbsVn/+dst1TRIEMkWwz ZYKhhnhu7FFuVyZ/txJoy/11mNEEk9GTnvdyBdkZhfc+C3LqlWBcXtqLaWnk1CIKBZAe ueDA== X-Gm-Message-State: ACgBeo3IXJmK/q0RTxr98+wAQT2qLUi+jSZIBIKB9rS2yJgasBf+yPh0 xP5w9zXBoiWVtGkcBkwRGjY= X-Google-Smtp-Source: AA6agR7t0GY+1q5uTZb5We3a9PhT8Nv5YKHpftI6ooRy+sYIdJ0LN14CtXVDeZuK1HJNkFdvbQHENw== X-Received: by 2002:a92:dc8c:0:b0:2e9:469f:e5a3 with SMTP id c12-20020a92dc8c000000b002e9469fe5a3mr23264515iln.251.1662327768480; Sun, 04 Sep 2022 14:42:48 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:17 -0600 Message-Id: <20220904214134.408619-41-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 40/57] dyndbg: abstraction macros for modname, function, filename fields X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The .data table built of struct _ddebug[]s has about 40% repetition in the "decorator" fields: modname, function, filename. The real fix is to "normalize the db", but 1st we need a layer of accessor macros, giving us just one field deref to alter later. So: define 3 field-abstraction macros: desc_{modname,function,filename}(desc). replace all raw field refs in lib/dynamic_debug.c with them. The macros protect against NULL pointer derefs, substituting "_na_" otherwise. This provides a generic guard, opening options to drop the contents of __dyndbg_sites[] opportunistically, and trim kernel/module data. DRM, which could use only .class_id to control drm.debug, could drop them. The 3 macros use a common foundation: _ddebug_map_site(), which will adapt to follow the coming table-split. Also change field names; adding '_' prefix to insure that bare field-refs are found and fixed. Most field uses get the macros, except for dynamic_debug_init(), which will need to follow the rearrangements. NOTE: macros are private, not currently for general use. trace/events/dyndbg.h was a candidate to use these macros, for which I included the header. On rethink, these macros are wrong abstraction for tracing; better to expose a dynamic_prefix_emit(1) flavor, and use it in TP_printk to "decorate" enabled trace-logs like it does for sys-logs. So this patch removes the raw field-refs rather than use the macros. I left the include to mark the intention to use privatish interfaces, see if it draws objections or compile errs. [1] fills caller provided char-buffer, perhaps not ideal for tracefs. A fixed max-size-possible per-callsite (or globally) is practical, but the struct _ddebug_site * val is probably best; it refs a prdbg's site-rec of a builtin or loadable module, which is unique over the pertinent lifetime, and has all the info. WAG,TLDR: "decorating" could be defered until `cat trace`, modulo loadable sites[] data being needed to render after module is unloaded. no functional changes. Signed-off-by: Jim Cromie TP-print-dont-use-desc-foo --- include/linux/dynamic_debug.h | 12 ++++++------ include/trace/events/dyndbg.h | 7 +++---- lib/dynamic_debug.c | 37 ++++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 04f49df308a7..e04f5b0a31e2 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -18,9 +18,9 @@ struct _ddebug { * These fields are used to drive the user interface * for selecting and displaying debug callsites. */ - const char *modname; - const char *function; - const char *filename; + const char *_modname; + const char *_function; + const char *_filename; const char *format; unsigned int lineno:18; #define CLS_BITS 6 @@ -166,9 +166,9 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name = { \ - .modname = KBUILD_MODNAME, \ - .function = __func__, \ - .filename = __FILE__, \ + ._modname = KBUILD_MODNAME, \ + ._function = __func__, \ + ._filename = __FILE__, \ .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h index e19fcb56566c..2997289c0e3f 100644 --- a/include/trace/events/dyndbg.h +++ b/include/trace/events/dyndbg.h @@ -6,6 +6,7 @@ #define _TRACE_DYNDBG_H #include +#include /* capture pr_debug() callsite descriptor and message */ TRACE_EVENT(prdbg, @@ -32,8 +33,7 @@ TRACE_EVENT(prdbg, __get_str(msg)[len] = 0; ), - TP_printk("%s.%s %s", __entry->desc->modname, - __entry->desc->function, __get_str(msg)) + TP_printk("%s", __get_str(msg)) ); /* capture dev_dbg() callsite descriptor, device, and message */ @@ -64,8 +64,7 @@ TRACE_EVENT(devdbg, __get_str(msg)[len] = 0; ), - TP_printk("%s.%s %s", __entry->desc->modname, - __entry->desc->function, __get_str(msg)) + TP_printk("%s", __get_str(msg)) ); #endif /* _TRACE_DYNDBG_H */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0870e939f255..5a22708679a7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -167,6 +167,15 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons return NULL; } +static inline struct _ddebug_site * _ddebug_map_site(const struct _ddebug *desc) +{ + return desc->site; +} +#define _desc_field(desc, _fld) (desc ? (_ddebug_map_site(desc)->_fld) : "_na_") +#define desc_modname(desc) _desc_field(desc, _modname) +#define desc_function(desc) _desc_field(desc, _function) +#define desc_filename(desc) _desc_field(desc, _filename) + #define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and @@ -212,16 +221,16 @@ static int ddebug_change(const struct ddebug_query *query, /* match against the source filename */ if (query->filename && - !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, desc_filename(dp)) && !match_wildcard(query->filename, - kbasename(dp->filename)) && + kbasename(desc_filename(dp))) && !match_wildcard(query->filename, - trim_prefix(dp->filename))) + trim_prefix(desc_filename(dp)))) continue; /* match against the function */ if (query->function && - !match_wildcard(query->function, dp->function)) + !match_wildcard(query->function, desc_function(dp))) continue; /* match against the format */ @@ -257,9 +266,9 @@ static int ddebug_change(const struct ddebug_query *query, static_branch_enable(&dp->key.dd_key_true); } #endif - v4pr_info("changed %s:%d [%s]%s %s => %s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + v4pr_info("changed %s:%d [%s]%s %s to %s\n", + trim_prefix(desc_filename(dp)), dp->lineno, + dt->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags = newflags; @@ -836,10 +845,10 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) pos_after_tid = pos; if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->modname); + desc_modname(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->function); + desc_function(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); @@ -1241,8 +1250,8 @@ static int ddebug_proc_show(struct seq_file *m, void *p) } seq_printf(m, "%s:%u [%s]%s =%s \"", - trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + trim_prefix(desc_filename(dp)), dp->lineno, + iter->table->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\""); @@ -1504,12 +1513,12 @@ static int __init dynamic_debug_init(void) } iter = iter_mod_start = __start___dyndbg; - modname = iter->modname; + modname = iter->_modname; i = mod_sites = mod_ct = 0; for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { - if (strcmp(modname, iter->modname)) { + if (strcmp(modname, iter->_modname)) { mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; @@ -1518,7 +1527,7 @@ static int __init dynamic_debug_init(void) goto out_err; mod_sites = 0; - modname = iter->modname; + modname = iter->_modname; iter_mod_start = iter; } } From patchwork Sun Sep 4 21:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCB22ECAAD5 for ; Sun, 4 Sep 2022 21:48:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5750F10E3C3; Sun, 4 Sep 2022 21:43:55 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id C36F810E255; Sun, 4 Sep 2022 21:42:49 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id r141so5678705iod.4; Sun, 04 Sep 2022 14:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=PMiB8rnsUQPju8onoOnVuDb8slfA1llOhn686i4QNvM=; b=DhIMTIMuvABAe+Hzd9rSSdXTPFxO/+q5Cm+yD63nUFOoFZNB03XM5qcqbF65z2kAOS pOUh728z1/u5qw1UKGnSRJFv2eNFfmUNZA9Pr33CoridKkhzO3KHRwUivKPaXWPPvzes FIn2lGCuNdFOJuALDBDiHixeO3RwF3TScUe2Ec35/WnTE4/rWPnUBReM+TT+MGZi7UiP 8A62RK0snL+KInTqxx0ss+pLhLEPD3uKBa3QC0t9/c7eRXT2KH3ogGVGBr2JOf5Y5Y/C 0o98zKU/C2FCWYR/3SSsXNl5sS/BSOlPYUBKDAmomW9+bzVniS+aWFgMzIAaLAguaPjr OsXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=PMiB8rnsUQPju8onoOnVuDb8slfA1llOhn686i4QNvM=; b=Wnevqfh/GiQOMsA/kIrhUR7zDJxFtKkdCZCVaOSZas/kzdEL2Drb7mIVvR7rcHNuzr 3OkbjoxGSmibOBsppUsEnSRh8Towh9VzxvV5kgzH17/bn/9ibtPUU/krZ7pA8D316bqY Os+HXav8qG6BhG+dRBYq+NUrfiIWgPd4rTv2tsrdaZCYajYlcbsMG5IZzOBe/eA2SE6y xMGzPONgoYpnloz3SarsfT3rYwndR9SSRNZu+Pb5Nn/ozCbQ9nOqCdJjTIE9yKDQRw3J juBeL/P7SPsXE2+HbXilYyRY4//Ho9O5DjUpMMnzvCZtGanjGSCh41A5bGRsKcfFZEKe QWzw== X-Gm-Message-State: ACgBeo07CCZiuZpASJexZMtqV6pMdaC4T3CqNyb31rxYNKMP5z4RPFcB Hz3cALXcaZwvrAhCCBy9Azc= X-Google-Smtp-Source: AA6agR6INbA193jAVbdMDiyXOsWP4jHkkUZzNXaQ1TrC3Xmxtj8ovg2eyPEHbVIhKzd3D9P88Hc01A== X-Received: by 2002:a6b:7b41:0:b0:689:2648:9ce9 with SMTP id m1-20020a6b7b41000000b0068926489ce9mr21451384iop.185.1662327769373; Sun, 04 Sep 2022 14:42:49 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:49 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:18 -0600 Message-Id: <20220904214134.408619-42-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 41/57] dyndbg: split repeating columns to new struct _ddebug_site X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Struct _ddebug has 3 RO-data fields: _module, _file, _function, which have significant repetition in the builtins: 4222 unique records / 8920 callsites on a recent laptop build. Thats just 47% unique, on 24/56 of the unitary record. The quick path to excising this redundancy is: 1- split the table in 2, link 1st to 2nd (done here) 2- de-duplicate the 2nd table. (soon) So split struct _ddebug, move the 3 fields to a new struct _ddebug_site, and add a pointer from _ddebug to _debug_sites. The lineno field stays in _ddebug, so all _sites in a fn are identical. The new ptr from _ddebug -> _ddebug_site increases memory footprint, until step 2 is completed, at which point: old = 56 * 8920 new = (56-24+8) * 8920 + 24 * 4222 IE: DB<2> p 56 * 8920 499520 DB<3> p 40*8920 + 24 * 4222 458128 Thats 41392 saved, or ~8.3% Further, the site pointer is just temporary scaffolding: - descriptors are in a vector. - new desc._idx field (from spare bits) can get us to 0. set during _init, not by linker - add a header record in front of vector (.gnu.linkonce.dyndbg*) point it up to struct dyndbg_info - dyndbg_info has .sites - same desc._idx gets us sites[._idx] - new desc._map field, gives sites[._map] this allows de-duplication and packing. Once that is done, the savings increases: DB<7> p (56 * 8920) - (((56-24) *8920) + 24*4222) 112752 saved, or 22% STEP 1: dynamic_debug.h: This cuts struct _ddebug in half, renames the top-half to _ddebug_site, keeps __align(8) for both halves. Adds a forward decl for a unified comment for both halves, and added _ddebug.site field to point at a site record. Rework DEFINE_DYNAMIC_DEBUG_METADATA_CLS macro to declare & initialize the 2 static/private struct vars together, and link them together. It places each struct into its own section, so the linker packs 2 parallel arrays, and links them like a ladder. struct _ddebug_info is extended to track _ddebug_site[] just like it does for _ddebug[] and _ddebug_classes[]. The accessor macros desc_{module,filename,function} follow the field-moves with added '->site->' references, and return "_nope_" or "_na_" if the desc or site are null. This makes those ptrs nullable, and their referents recoverable (nothing tries to use this yet). NB: the "_na_" is undone temporarily later, for dev shortcut. Also add const to lineno field. It is set by compiler. In struct ddebug_table, add struct _ddebug_site *sites, to treat new vector just like the module's _ddebug[]s (its __dyndbg section, for loadable mods). While we don't need it now, we will need it to de-scaffold (drop the _ddebug.site). dynamic_debug.c: extern declarations of the section start/end symbols named and initialized in vmlinux.lds.h dynamic_debug_init(): Initialize global builtin_state from initialized cursor var. Trying to do so statically gave: "error: initializer element is not computable at load time" Check (num-descs == num-sites), and quit early otherwise. This is an important precondition, w/o it, we cannot really continue confidently. I inadvertently created the situation by having __used on 1/2 of the _ddebug{,_site} pair created by DECLARE_DYNAMIC_DEBUG_METADATA; this created ~70/ extra site records. This "worked", but was unnerving until I tracked it down. Add site iterator & site_mod_start marker, recapping iter/_mod_start. Inside the main loop, validate (site == iter->site). This is the full/proper precondition for the expected section contents and inter-linkage; the (num-descs == num-sites) check is just a quick necessary-but-not-sufficient version of this. NOTE: this check could be a BUG_ON, esp as any mismatch should have been caught by the quick-check. ATM it is just a pr_err; Id prefer to see errors rather than crashes. Demotes iter->site by replacing iter->site->_module by site->_module. This is a small step towards dropping it entirely. vmlinux.lds.h: add __dyndbg_sites section and start/end symbols, with the same align(8) and KEEP as used in the __dyndbg section. kernel/module/main.c:load_info(): Initialize _ddebug_info.sites with new section address. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 37 +++++++++++++++++++++--------- kernel/module/main.c | 2 ++ lib/dynamic_debug.c | 38 +++++++++++++++++++++++-------- 4 files changed, 60 insertions(+), 20 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 9b8bd5504ad9..1e7ee65e8591 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -351,6 +351,9 @@ __start___dyndbg = .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg = .; \ + __start___dyndbg_sites = .; \ + KEEP(*(__dyndbg_sites)) \ + __stop___dyndbg_sites = .; \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e04f5b0a31e2..dcc0e8cc2ef0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -9,20 +9,28 @@ #include /* - * An instance of this structure is created in a special - * ELF section at every dynamic debug callsite. At runtime, - * the special section is treated as an array of these. + * A pair of these structs are created in 2 special ELF sections + * (__dyndbg, __dyndbg_sites) for every dynamic debug callsite. + * At runtime, the sections are treated as arrays. */ -struct _ddebug { +struct _ddebug; +struct _ddebug_site { /* - * These fields are used to drive the user interface - * for selecting and displaying debug callsites. + * These fields (and lineno) are used to: + * - decorate log messages per _ddebug.flags + * - select callsites for modification via >control + * - display callsites & settings in `cat control` */ const char *_modname; const char *_function; const char *_filename; +} __aligned(8); + +struct _ddebug { + struct _ddebug_site *site; + /* format is always needed, lineno shares word with flags */ const char *format; - unsigned int lineno:18; + const unsigned lineno:18; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) @@ -58,7 +66,7 @@ struct _ddebug { struct static_key_false dd_key_false; } key; #endif -} __attribute__((aligned(8))); +} __aligned(8); enum class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, @@ -118,8 +126,10 @@ struct ddebug_class_map { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct _ddebug_site *sites; struct ddebug_class_map *classes; unsigned int num_descs; + unsigned int num_sites; unsigned int num_classes; }; @@ -137,6 +147,7 @@ struct ddebug_class_param { int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); extern int ddebug_remove_module(const char *mod_name); + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -164,11 +175,15 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const char *fmt, ...); #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ - static struct _ddebug __aligned(8) \ - __section("__dyndbg") name = { \ + static struct _ddebug_site __aligned(8) \ + __section("__dyndbg_sites") name##_site = { \ ._modname = KBUILD_MODNAME, \ - ._function = __func__, \ ._filename = __FILE__, \ + ._function = __func__, \ + }; \ + static struct _ddebug __aligned(8) \ + __section("__dyndbg") name = { \ + .site = &name##_site, \ .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ diff --git a/kernel/module/main.c b/kernel/module/main.c index 6aa6153aa6e0..5a80f18f8e4a 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2113,6 +2113,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) info->dyndbg.descs = section_objs(info, "__dyndbg", sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); + info->dyndbg.sites = section_objs(info, "__dyndbg_sites", + sizeof(*info->dyndbg.sites), &info->dyndbg.num_sites); info->dyndbg.classes = section_objs(info, "__dyndbg_classes", sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a22708679a7..f1f354efed5a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -44,6 +44,8 @@ extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct _ddebug_site __start___dyndbg_sites[]; +extern struct _ddebug_site __stop___dyndbg_sites[]; extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; @@ -52,6 +54,7 @@ struct ddebug_table { const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct _ddebug_site *sites; }; struct ddebug_query { @@ -1487,20 +1490,27 @@ static int __init dynamic_debug_init_control(void) return 0; } +fs_initcall(dynamic_debug_init_control); + +static struct _ddebug_info builtin_state; static int __init dynamic_debug_init(void) { struct _ddebug *iter, *iter_mod_start; + struct _ddebug_site *site, *site_mod_start; int ret, i, mod_sites, mod_ct; const char *modname; char *cmdline; struct _ddebug_info di = { .descs = __start___dyndbg, + .sites = __start___dyndbg_sites, .classes = __start___dyndbg_classes, - .num_descs = __stop___dyndbg - __start___dyndbg, - .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, + .num_descs = __stop___dyndbg - __start___dyndbg, + .num_sites = __stop___dyndbg_sites - __start___dyndbg_sites, + .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, }; + builtin_state = di; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1511,28 +1521,40 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; return 0; } - + if (di.num_descs != di.num_sites) { + /* cant happen, unless site section has __used, desc does not */ + pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_sites); + return 1; + } iter = iter_mod_start = __start___dyndbg; - modname = iter->_modname; + site = site_mod_start = __start___dyndbg_sites; + modname = iter->site->_modname; i = mod_sites = mod_ct = 0; - for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { + + if (site != iter->site) + /* XXX: also cant happen, but lets see how it plays */ + pr_err("linkage problem: site != iter->site\n"); - if (strcmp(modname, iter->_modname)) { + if (strcmp(modname, site->_modname)) { mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; + di.sites = site_mod_start; ret = __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; mod_sites = 0; - modname = iter->_modname; + modname = site->_modname; iter_mod_start = iter; + site_mod_start = site; } } di.num_descs = mod_sites; di.descs = iter_mod_start; + di.sites = site_mod_start; ret = __ddebug_add_module(&di, i - mod_sites, modname); if (ret) goto out_err; @@ -1566,5 +1588,3 @@ static int __init dynamic_debug_init(void) /* Allow early initialization for boot messages via boot param */ early_initcall(dynamic_debug_init); -/* Debugfs setup must be done later */ -fs_initcall(dynamic_debug_init_control); From patchwork Sun Sep 4 21:41:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21BBEECAAD5 for ; Sun, 4 Sep 2022 21:49:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A35FD10E790; Sun, 4 Sep 2022 21:43:58 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6AA310E25B; Sun, 4 Sep 2022 21:42:50 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id s3so1911241ilv.4; Sun, 04 Sep 2022 14:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=FwCkCkIuXLu91UbfHdZYDrwIlB+NdbMmm6xvFEQjyUU=; b=RYCkLD0FCIpFqOKsWlElNLu5l8dGxBEngWLZ18ylxy41NG+Qaj5BZrfDLn5uvMF2xo VwhlrGgEcVvma9ILcXWr/GE6ZBBnf6OlwUb6biRCydxCUq3oKWxUcQ2J/MNFVAYtgIqI Xb9AS9cv7UVTnWGcrEevePRMFxuCn/ulpHIE9HVRP/TdyoUsfjS6AF5uOoRVUuWr8vqg 4VPmeMzC0eaHliSJUHUrAHWH8r+EM3TH96DE9T2refzCG1P0lmBG3updh9CAqjc0qY/W hrGlSxiGyrArtn+T2krt991mxFZxt+CbQR1NKOfrS5F4tEvIbplkb8gHJGHTFjrzcpA+ KgHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=FwCkCkIuXLu91UbfHdZYDrwIlB+NdbMmm6xvFEQjyUU=; b=1fRxhGI4H96blfyMW/2Egsruq480QTYpsUtUrP1eWGfCk7dH2E4gp+kXnWu8yNIxIR oFyCJcPxw+9JNFmgCuU3feXGDc26fVjSyTsTkRGVfq1DbDafmIHVW5kJUXe9EzMH3Ny8 qicWoZXMqwGDUGA5bPTczHL8ImSbQAYgbH6PRV26a+r3wtZ2lOQNYAnW04eTiXx602O4 VtTgVE+R++JCfzRbMSYH2/6hT1565UwUts5XdWWiIzsHj5aGaZDmJipwy2ppQpuLw2Zi cSPl26rvdm2+hLNqBqOmBOnSqnNBRhSXgsSojZ0LU0K/5941Yvcwjoolsu5IHjPVkKZE u5ow== X-Gm-Message-State: ACgBeo0uwgynqQpPIUF68iGdu1c6WJjm6ZWwRSgMBz2Xjoo1w803ZoRb YgsGDdFKSVAzaJXeBKIhpfw= X-Google-Smtp-Source: AA6agR6xgn/MlYOoGIi2AaB+WdvqdQ5gYdviqjuZlblXZSMV6/iv7FJf6NsVsV/Y3NPrVDl1/Xe7dA== X-Received: by 2002:a05:6e02:1909:b0:2f0:a558:7113 with SMTP id w9-20020a056e02190900b002f0a5587113mr4717553ilu.55.1662327770538; Sun, 04 Sep 2022 14:42:50 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:50 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:19 -0600 Message-Id: <20220904214134.408619-43-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 42/57] dyndbg: shrink lineno field by 2 bits X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" struct _ddebug.lineno int:18 is bigger than we need: git ls-files | grep -P '\.c$' | xargs wc -l | sort -n | tail -n20 ... 22553 drivers/scsi/lpfc/lpfc_sli.c 28593 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c 46300 drivers/net/wireless/realtek/rtw88/rtw8822c_table.c 48725 drivers/net/wireless/realtek/rtw89/rtw8852a_table.c 1386670 total ... All but one of the biggest of these are just .data tables, and have no code, so would never need a pr_debug(). drivers/scsi/lpfc/lpfc_sli.c, at ~22k lines, would be encodable with 15 bits, but lets just shrink to 16 bits for now. RFC: Is this tantamout to a "don't write files with >64kloc" policy ? Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dcc0e8cc2ef0..c05148dab367 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -30,7 +30,7 @@ struct _ddebug { struct _ddebug_site *site; /* format is always needed, lineno shares word with flags */ const char *format; - const unsigned lineno:18; + const unsigned lineno:16; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) From patchwork Sun Sep 4 21:41:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0D5EC6FA86 for ; Sun, 4 Sep 2022 21:49:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE73F10EA55; Sun, 4 Sep 2022 21:44:12 +0000 (UTC) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49CC310E266; Sun, 4 Sep 2022 21:42:52 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id y187so5724068iof.0; Sun, 04 Sep 2022 14:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NJv9roPGKnaMDb9Znbql4uMkywSuYywvt+PY8YTJJ6Q=; b=HhTTMF5cOvfQxdSZmrczdsrS6DcF+dXJ4prb+yfBwfEsbsV/l8CegD6fvYMQv45pnL Lf3KTZjPRQvn2olpOHp+kmaJ4oJHgCOfWsY3FUgvHVffh1+zc352thh9xXYlfcfH2jPd WHUvSV9qo/7iWc+93e5dgxNXp0BN7YD7iPq5mLd4Lp375zL2U7/g25FtP4jW0poI3Xy1 BVe/2TTcrNFKPS3ucVYZJTTlomYi+IjWKzHykbLWJSIGsDYsRKCTeZerO4ouyzRs9apT ceUwHG+xksDXgJwO4SLD6ULb2vBG1qGluX6Fx9greabj7IG3dRz5uT820IrbROFlv4PW vTYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NJv9roPGKnaMDb9Znbql4uMkywSuYywvt+PY8YTJJ6Q=; b=Oqz6/PZLld5NHvrUkEHmwZcGvTlOMDHXFonM6HQC1gv2GGcWAIUrBFDweP9Wc1ekJ0 KLS+sWBL/Tm4bQI4RcrpkpEKqHpZxGXLOlkGpp+N1CK9yoshpnvLxUxd3uTNSn1PNiPf h7pQbjVw4mHf0xYZVZMCywtuUv+AAV4zE7klzBT9JMXswGYAbw4ldY69LVERU/4hT6/y t/grv1f/SmyqMPKmbEItFFhN5vYUwlUOZAs3mfif+IzM9CSJkz6yU/6WqbomMW1JevyG VP/IdL3r4v9d2NO5MvmbUkf9OwBAlPNNPVGR523Uux4kURQQ/3ztQnE13h2ff1aF4ddg 4hlw== X-Gm-Message-State: ACgBeo0IeSEal/J7jvQVLWh5Rx6cTQ0/wEbHJ/L2OTJL6KO3GhVZTVBK Zuk44yOgrwp/LFYXn3W2lYw= X-Google-Smtp-Source: AA6agR4MY52KR1Bw1Ot+iK3sIpDRwZTCG1xc7RrkCdtaGzSPJBBL/OV4txxLoofl2HiIy/rTScLO/A== X-Received: by 2002:a6b:1543:0:b0:688:6fcb:fa76 with SMTP id 64-20020a6b1543000000b006886fcbfa76mr21261370iov.60.1662327771514; Sun, 04 Sep 2022 14:42:51 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:51 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:20 -0600 Message-Id: <20220904214134.408619-44-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 43/57] dyndbg: add _index, _map to struct _ddebug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We now have 2 vectors of data: (__dyndbg, __dyndbg_sites), known to be equal-length, with _ddebug.site connecting them, like rungs on a ladder. In order to drop _ddebug.site, we need to replace the absolute ptr with a cheap relative-address computation: struct _ddebug_site *site = _ddebug_map_site(desc); 1st step: (done here) add ._index, ._map fields, and initialize them in __debug_add_module() to N (and = each other), where N is each element's position in the builtins (or loaded-module). Then _ddebug_map_site(desc) can compute &descs[0], and then use container_of() to go up 1 struct. RFC: Next steps: (outlined here, not done): 1. UPLINK: Define 2 new header structs, with _uplink fields, pointing at _ddebug_info: struct _ddebug_site_hdr { union { struct _ddebug_info _uplink*; struct _ddebug_site __; // sizeof this }; }; struct _ddebug_hdr { union { struct _ddebug_info _uplink*; struct _ddebug __; // sizeof this }; }; the union forces the allocation to be the bigger of the 2, with the expectation that the pointer will always fit. 2. Reserve a record in front of the __dyndbg* sections. can be done in {module,vmlinux}.lds.h, something like: SECTIONS { __dyndbg_sites : ALIGN(8) { *(.gnu.linkonce.dyndbg_site) *(__dyndbg_sites) } __dyndbg : ALIGN(8) { *(.gnu.linkonce.dyndbg) *(__dyndbg) } } KEEP( *(.gnu.linkonce.__dyndbg_site) *(__dyndbg_sites)) 3. specialize DYNAMIC_DEBUG_METADATA_CLS as DYNAMIC_DEBUG_TABLE. This special macro version creates header records, and puts them into .gnu.linkonce section. Unusually (uniquely?), it is tacitly invoked by dynamic_debug.h on behalf of all printk.h includers. This can result in multiple "declarations" in the same scope, so macro uses __weak and/or __unused to suppress linkage & errors. This created mumble-RELATIVE linkage errors in a few parts of the kernel, I worked around this by just suppressing the declaration if cflags includes -DDYNDBG_NO_TABLE. The up-link is init'd in 2 cases: The file static struct _ddebug_info builtins is initialized by dynamic_debug_init(), with the 3 ELF sections addresses+lengths composing the builtin dyndbg-state. It will be able to also initialize the header.UPLINK fields, as long as the storage space is available. Then rel_map() can rely upon it to provide the &site ref for a callsite's desc*, if it is enabled. Then at runtime (assuming initialization is correct): - use _index to get &descs[0] - container-of gets .UPLINK to &dyndbg_info - info->sites[_index] - replaces .sites - info->sites[_map] - allows de-duplicated vector position. M --- include/linux/dynamic_debug.h | 3 +++ lib/dynamic_debug.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index c05148dab367..268e903b7c4e 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -31,6 +31,8 @@ struct _ddebug { /* format is always needed, lineno shares word with flags */ const char *format; const unsigned lineno:16; + unsigned _index:14; + unsigned _map:14; #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) @@ -60,6 +62,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_DEFAULT 0 #endif unsigned int flags:8; + #ifdef CONFIG_JUMP_LABEL union { struct static_key_true dd_key_true; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f1f354efed5a..506a7e2e59d6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1344,6 +1344,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, const char *modname) { struct ddebug_table *dt; + int i; v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); if (!di->num_descs) { @@ -1364,6 +1365,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, */ dt->mod_name = modname; dt->ddebugs = di->descs; + dt->sites = di->sites; dt->num_ddebugs = di->num_descs; INIT_LIST_HEAD(&dt->link); @@ -1372,6 +1374,12 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, if (di->classes && di->num_classes) ddebug_attach_module_classes(dt, di->classes, di->num_classes); + for (i = 0; i < di->num_descs; i++) { + di->descs[i]._index = base + i; + v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, + di->descs[i].site->_function, di->descs[i].lineno); + } + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); From patchwork Sun Sep 4 21:41:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D75B4C6FA82 for ; Sun, 4 Sep 2022 21:48:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36FDD10E3C1; Sun, 4 Sep 2022 21:43:54 +0000 (UTC) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4219E10E269; Sun, 4 Sep 2022 21:42:53 +0000 (UTC) Received: by mail-il1-x136.google.com with SMTP id h14so3863974ilh.10; Sun, 04 Sep 2022 14:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=XI+lDDMQn1sJTAtsYXCSCZllHbtd6NOelDveTu16Um2gjNpYLeMWEPdHoroi+WJR56 k3PgFGFfbCQMOWVL4snzUZdVG+0cVnNUbfzxIKDLpC2iJQFgtJDx0CvxlhMkm+BuNHYM JOpIUa7zmX68L2U/aSqdB7PBn6ttAlQuheS/8IeqXuRiGsnhj+Lnu52QEV+kNwnXaeJD afRgsXfC7uf0JeApZ0fm2iin8GGl0CcHiwA1rJtoEcVABdqcneG5T6RL110N966WpM0o k1FblDutKG52QhJ9j7imv5ETtSUwiKKH84KtJRukZEMY244luC3ugPo7akWliqMbT+Gf LhEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=fQFt+Q4dHKQgvnoSVAYteGUN9CYax16Q8acu9lpmfc4weWjQn2clhGIPE2XkJlbfNe P+llX3ckq11T38iNobA1lBffgtlWtyn1c+FNvDVMW/O8wmTT+lZHVrSqpSB/fXX+uauF Y4KOOSpHzpnvOanc2ACbCvSOXpBcNOpa+jRwJ5s9mz9tXWSyBsF1na+gfdacr3Opk4/f a4j4S7VOSt3907TIlY78yACAFv5SCef1Psjvt09iL/uSxuqDvhIN+hck/t5fkylefwDv dCt3l3q7+uQ5jvbF5dgVm4GxiHfFv+Jw4VTCMc84fxTW8PZEjRawAm/C9o9HanlRyoiP 1+8w== X-Gm-Message-State: ACgBeo1T/HESEO2dzt02xMhiH5NvwOwrmLEV2hIBrQdQg04bB8dW9aOo Vowk0d6AS+9/4X3wqxP52gI= X-Google-Smtp-Source: AA6agR6GJ3545nMVzxW2kytCo0sZT1XkmI6FXzQ5bdXfVdq6vQh7IQ0VQLKX9DkPjjjN1oLgs/PH0w== X-Received: by 2002:a92:dcc2:0:b0:2e4:38f2:a9f6 with SMTP id b2-20020a92dcc2000000b002e438f2a9f6mr24500432ilr.130.1662327772508; Sun, 04 Sep 2022 14:42:52 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:52 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:21 -0600 Message-Id: <20220904214134.408619-45-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 44/57] dyndbg: extend __ddebug_add_module proto to allow packing sites X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In order to actually reclaim useful blocks of memory, we need to repack the vector of redundant site recs, not just detect the duplicates. To allow this, extend __ddebug_add_module()s prototype by adding: struct _ddebug_site *packed_sites - address of empty "stack" unsigned int *packed_base - index of Top-of-Stack This allows dynamic_debug_init() to tell __ddebug_add_module() where to push the unique site recs it finds while de-duplicating, and to communicate the new TOS back for the next iteration. Since we know we are shrinking data, we can overwrite _ddebug_sites[], for both builtins, and loadable modules, via ddebug_add_module(). For ddebug_add_module(), which is called from kernel/module/main, the 2 args: reuse the module.sites vector, with a 0 offset. This will allow de-duplication of the local vector. No de-duplication is done yet, so no use of the stack. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 506a7e2e59d6..1b57e43e9c31 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1341,7 +1341,8 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, * and add it to the global list. */ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, - const char *modname) + const char *modname, struct _ddebug_site *packed_sites, + unsigned int *packed_base) { struct ddebug_table *dt; int i; @@ -1390,7 +1391,8 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, int ddebug_add_module(struct _ddebug_info *di, const char *modname) { - return __ddebug_add_module(di, 0, modname); + unsigned int packed_base = 0; + return __ddebug_add_module(di, 0, modname, di->sites, &packed_base); } /* helper for ddebug_dyndbg_(boot|module)_param_cb */ @@ -1506,7 +1508,7 @@ static int __init dynamic_debug_init(void) { struct _ddebug *iter, *iter_mod_start; struct _ddebug_site *site, *site_mod_start; - int ret, i, mod_sites, mod_ct; + int ret, i, mod_sites, mod_ct, site_base; const char *modname; char *cmdline; @@ -1550,7 +1552,8 @@ static int __init dynamic_debug_init(void) di.num_descs = mod_sites; di.descs = iter_mod_start; di.sites = site_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; @@ -1563,11 +1566,13 @@ static int __init dynamic_debug_init(void) di.num_descs = mod_sites; di.descs = iter_mod_start; di.sites = site_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; ddebug_init_success = 1; + vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); From patchwork Sun Sep 4 21:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30B3BC6FA86 for ; Sun, 4 Sep 2022 21:49:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75A0C10E973; Sun, 4 Sep 2022 21:44:05 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE70710E26D; Sun, 4 Sep 2022 21:42:53 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id m16so861593ilg.3; Sun, 04 Sep 2022 14:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=2DUNNF4TyZPmUhIDyquoFTYgxu+2+I569ry9sz7h+V8=; b=mQmCZeXOpRyxBBvjbWVrCXsXx7gHTM8N/UQTvxQw6KuXSPexo1h3FD1ucxeyNJT+xH FCrl38VbY4XTggjAdID94f6qwWEzanDmr/mM2z9ppbD2bi++cdR0KFPdSDwIzMEdviuE T7rb8LW++Dfbale5om0KJkTeWydx42PLJzEbIaIRUShArRNRdH3N5bm567jsKFUoVvyE yNkTMgfq+82gXrYwwjc07JfVO8XbjrtDoDwJo5YA9vGk40vjd+duz80CzMwmFoM7NXkY 5BL2wv2zhIlR6b9Vj7PAu5z7gJVid5GmJmcNvK4vsfDXHVxr7IqKWTFLJl2NVdYInAfp DlOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=2DUNNF4TyZPmUhIDyquoFTYgxu+2+I569ry9sz7h+V8=; b=P9UxYs+vdSRaDLgDMePw14aG49ApFnpkoZH047gxjVPTOYlmH9fPIHjjhOzWMHgUU6 39r30woLq9JGhIpDDl2pumg9fNMhSsX4VQO0TmXtyiOGVny9M2qwV0JQENUvkYJSBV9v 2fRkojIdmoZ8++TvgE9x2LVuqFzy8t4XMQYgokixj9PePcUkU0HJi53AfDVoE5NK5M+V sOM22xLBWpQtZIG8AALI2qAHscuMCIZN3PCL3u+xwTwGFdElpieGC2u+BwmjfBdxMPuE ZqBbgrSuMNP+AVeXk63CUzs8KdoTcXn6U+UXtT+nQz97FFePrw6orv/9cJQ3NUGgar0D 5VHg== X-Gm-Message-State: ACgBeo1UM2ej9AQ1r/cYAEQvzuZt0x1m5xk6M7AX+vJn8GXzyCGfCrn0 PLAlxLc742leoyScudY8Yqk= X-Google-Smtp-Source: AA6agR7R7ppBFr3r3vC4WEGb4c102hUehmHvwf5LRPNlvppZUrjQH2NK84HPqLyTxmmaZ5tAXemtqA== X-Received: by 2002:a05:6e02:b2d:b0:2ec:b5eb:cd63 with SMTP id e13-20020a056e020b2d00b002ecb5ebcd63mr9305275ilu.291.1662327773546; Sun, 04 Sep 2022 14:42:53 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:53 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:22 -0600 Message-Id: <20220904214134.408619-46-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 45/57] dyndbg: de-duplicate sites X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In __ddebug_add_module(), detect repeated site records (by function name changes), and push changes onto the stack/vector passed in from dynamic_debug_init(). For ddebug_add_module(), this transparently de-duplicates the local sites vector (passed in recently added stack-base, and offset 0). Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1b57e43e9c31..41c23ec979f4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1347,7 +1347,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, struct ddebug_table *dt; int i; - v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + v3pr_info("add-module: %s.%d sites, start: %d\n", modname, di->num_descs, base); if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1376,11 +1376,19 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, ddebug_attach_module_classes(dt, di->classes, di->num_classes); for (i = 0; i < di->num_descs; i++) { - di->descs[i]._index = base + i; - v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, - di->descs[i].site->_function, di->descs[i].lineno); - } + if (di->descs[i].site->_function != packed_sites[(*packed_base)]._function) + memcpy((void *) &packed_sites[++(*packed_base)], + (void *) di->descs[i].site, sizeof(struct _ddebug_site)); + else + di->descs[i].site = &packed_sites[(*packed_base)]; + + di->descs[i]._index = i + base; + di->descs[i]._map = *packed_base; + + v3pr_info(" %d %d %s.%s.%d - %d\n", i, *packed_base, modname, + di->descs[i].site->_function, di->descs[i].lineno, *packed_base); + } mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1539,7 +1547,7 @@ static int __init dynamic_debug_init(void) iter = iter_mod_start = __start___dyndbg; site = site_mod_start = __start___dyndbg_sites; modname = iter->site->_modname; - i = mod_sites = mod_ct = 0; + i = mod_sites = mod_ct = site_base = 0; for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { From patchwork Sun Sep 4 21:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12965338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5A18C6FA82 for ; Sun, 4 Sep 2022 21:48:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E8CA10E389; Sun, 4 Sep 2022 21:43:46 +0000 (UTC) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2F4E10E273; Sun, 4 Sep 2022 21:42:54 +0000 (UTC) Received: by mail-il1-x131.google.com with SMTP id e7so3873386ilc.5; Sun, 04 Sep 2022 14:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=H201e8MxjjTWEZ5tX/zGuFZYDJJzszurQVKd2l3pA3I=; b=D5hVd8nWFbqRRkXkdpXZg4jOmNIfneov3THSYEMdUbvWnNl8Ne1nblV6QviWBWEGUg 2zMyuA7+zIirnNTNheDbR8jO4BMAl558jaE/EZxKR7+4koCB4I8+25Qe/kL8kQDF2Sho 9kDP0guazA6Lb4dxbqmjP5mGHurmuwBcuEMnuT3go1J7kq5fY3n584tb1fc7uABf1zin bHRRoPHY51s4kfci15ECF8xV6cBQQdgXuN4xECAP+d7JlGSq0KHUrs/nvlXcdLRTejSg qoOn5DPm1HXTaLGGK4GTAQmXYSy4e+uxehju05I6ClOoAcojZ1q7+CbFrz/rCbP0Qb06 zY5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H201e8MxjjTWEZ5tX/zGuFZYDJJzszurQVKd2l3pA3I=; b=XZkW/1LH0a8PA4OD7L5L1wCd8v+fbA0eo/ZHwjYlUcqm+7rWXs3LBfog9gAqSGl9lC LGmso6HwhKIorGzNGSGUbvOWEShFZf4y6TxftNfQw1JhpWOPeN4lY6aKCZloZAmjwRJA x4MdfLRAC61VDQR9e6YDML3l0yITQ4D2/6yisPjLxinQOFF0HpJhABcDGZ6iyhVn7Q0k FpP7nHHRb27dsZFPj14kXf9yKeKORqZH5H4WXdbfD59V8ZKIek6BybX7vPxn4UcOPh4C YJYjdyRc5x7/t7w0A8fvdvfxcwUW3hFhrEgvuQhZ5yPqISv1X11MLEgz105P+c+RpCpT 1Nyw== X-Gm-Message-State: ACgBeo0gTa1asBKdAAnv8dvnnavyII5dLOIbVdVeMu0H3cznC8PV4E+8 AhLTXF/lSPjirpjUQ8pT9Y/dOXWRcZY= X-Google-Smtp-Source: AA6agR6fMqZIkP1YOEGKlykQp2j5uHw/5o/cVx4vJBZLBlUDQYIi3bLhanGx4QpvBqJmpIkwB4O4Nw== X-Received: by 2002:a05:6e02:19ca:b0:2df:68c:4a6d with SMTP id r10-20020a056e0219ca00b002df068c4a6dmr24133939ill.32.1662327774363; Sun, 04 Sep 2022 14:42:54 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:23 -0600 Message-Id: <20220904214134.408619-47-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 46/57] dyndbg: drop site-> in add-module, more needed X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" --- lib/dynamic_debug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 41c23ec979f4..059212df68f9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1347,7 +1347,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, struct ddebug_table *dt; int i; - v3pr_info("add-module: %s.%d sites, start: %d\n", modname, di->num_descs, base); + v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_descs, di->num_sites, base); if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1375,19 +1375,20 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, if (di->classes && di->num_classes) ddebug_attach_module_classes(dt, di->classes, di->num_classes); + //BUG_ON(di->num_descs != di->num_sites); + for (i = 0; i < di->num_descs; i++) { - if (di->descs[i].site->_function != packed_sites[(*packed_base)]._function) + if (di->sites[i]._function != packed_sites[(*packed_base)]._function) + memcpy((void *) &packed_sites[++(*packed_base)], - (void *) di->descs[i].site, sizeof(struct _ddebug_site)); - else - di->descs[i].site = &packed_sites[(*packed_base)]; + (void *) &di->sites[i], sizeof(struct _ddebug_site)); di->descs[i]._index = i + base; di->descs[i]._map = *packed_base; - v3pr_info(" %d %d %s.%s.%d - %d\n", i, *packed_base, modname, - di->descs[i].site->_function, di->descs[i].lineno, *packed_base); + v3pr_info(" %d %d %s.%s.%d\n", i, *packed_base, modname, + packed_sites[*packed_base]._function, di->descs[i].lineno); } mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); From patchwork Sun Sep 4 21:41: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: 12965356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DFA2ECAAD5 for ; Sun, 4 Sep 2022 21:50:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C5CE10E26F; Sun, 4 Sep 2022 21:44:15 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87C0D10E274; Sun, 4 Sep 2022 21:42:55 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id m16so861619ilg.3; Sun, 04 Sep 2022 14:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jSafBWcpIkewykTpB/1313WvVuyh8yQZEmhBKVyM37c=; b=kbrF6hjoM+H17g9j3Wc1/6pJQXLvRnZ3Vs2WK1V3kWoZOwTfI3zERDRkFgtpBOrFAe aGn093m3smVeCRZc5LHalL7AoxbuS4AQdvZJaVIGnimvkEeM+rU3RRvd61Y/+6IWXHfl kzGQAdJFvZEfilUjxUNjkQBoZrnnNuWzDxd3Yt6Ikt65YhKsu8QQofbdJP1Nb7Jw0VW5 kMVkkJh4rdB9IpjDMcRVjEMDMbxOf5ddpY8akTKF8dSThHmxapKpkB5IEwhZVzCE7tj7 3JBKIi1e8jUIyR7UaiNXs4jjXjUOieSwp2MgZNZauf5xpbvtBGKzVaok6AF7eoTkzZnt HL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jSafBWcpIkewykTpB/1313WvVuyh8yQZEmhBKVyM37c=; b=Ux/oBWXjiQp/BI2yIpYb8ZY4JoeRA+6gA3oNygkVgE7z3cr/8RtS6CYmllyluveauK ry05MfXQHLvU6z7TpbUq/3MvnrMdkVfyxWgmP1tBvkOH4a10feMjLYd/eYEiuCTpK2Z+ UzTTL42qR3l8GEVFRAfefnsA0LEWgHjg6UGKuTUl6v/XshMpPngqp1Fu3x1wtJfPDyJ6 Un+tVq7MGZqD0F3R+CI8hKrqth75PoqKEXyNXQzM+YwY3kDAgL+5AiwDDHtRw57SPLJJ nmIRyghRRQic0AnemNnOxQrvfEKjhixmbw65NflGxU/Yeo7AI8Fkqe5eMSmd9beBSEkP hnhg== X-Gm-Message-State: ACgBeo1zDez6qKe9BIX7IXDnbNstS4LUnO4kDRy5CQpQjdw4eQOR8AQZ Fjr/ZkOzwaAayIfn9wgAcGU= X-Google-Smtp-Source: AA6agR5AVD3WIg2eP3iWjFE39m5/nR6rpJNEPwSMnDilTle2doeCtgXvqbPXlS48tak7nK63rsd6XQ== X-Received: by 2002:a05:6e02:1b86:b0:2f1:76ec:4b91 with SMTP id h6-20020a056e021b8600b002f176ec4b91mr848152ili.191.1662327775227; Sun, 04 Sep 2022 14:42:55 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:54 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:24 -0600 Message-Id: <20220904214134.408619-48-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 47/57] dyndbg: demote iter->site in _init X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 059212df68f9..65b0a1025ddf 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1547,7 +1547,7 @@ static int __init dynamic_debug_init(void) } iter = iter_mod_start = __start___dyndbg; site = site_mod_start = __start___dyndbg_sites; - modname = iter->site->_modname; + modname = site->_modname; i = mod_sites = mod_ct = site_base = 0; for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { From patchwork Sun Sep 4 21:41: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: 12965349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C5CEC6FA86 for ; Sun, 4 Sep 2022 21:49:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF03510E2F5; Sun, 4 Sep 2022 21:44:00 +0000 (UTC) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by gabe.freedesktop.org (Postfix) with ESMTPS id C651E10E279; Sun, 4 Sep 2022 21:42:56 +0000 (UTC) Received: by mail-il1-x132.google.com with SMTP id a9so3885645ilh.1; Sun, 04 Sep 2022 14:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=58gChvxjBedxDU/dSXgKq8f75Aq/PMP0VWOkECUeGr8=; b=J2tQsdq2kkHf85Z9ASRTiHs9OI3ZDVILIcK9yZOObu9+KlrqqjVNIjRz1rl5rphOwC 2Qfnz0oI/RsX3V70MD8E8G/yZztrNm2ZfOZnCp9690q1IH4JJ+adDmarycETlY/12rhr Db+6+SqEctFD/7m0SrX4AuGqEeuaJOmohsGrTlCLPTPTc/eFNhQn9dKNl96NeOx5rxdC vum//49JpYe1Z4oGVnwyv1uBitMZ8t5aokHuE388ICOZLGyjaZC6ZUwl7qnvJ1ZVUgUl OCs0CimfeNixxoHVLc+cIByGyUxmeix8tj9SCyBEQkzsOFFYl2FMPL60Yd7P36fczO+9 Pthw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=58gChvxjBedxDU/dSXgKq8f75Aq/PMP0VWOkECUeGr8=; b=40EF5BeWK2riML1AnsptLdQO1pAJ4GmMCO6f4hyXKhH5A1sfUXMGkN9Zk2v/tlrnED WhACTNdfVmmYswZ5PBpZOineVllPf57uN3yOPIApcP5VSvTh74SqtpLde4vc7c9QdeTv 3I88cCiLbVJkwsXYAqUVzEvfR8JqQUJg9zyShyFUMAAPJ98sdfaShY+OFUAELebydSA9 3sxe2b+7lGKjG80YZvWYDHEQW/kttlCDz9mHC7Wgz4gCEPU5z3gE7oBUcFqCXVHIecc5 nU4ZIB+LQPkVVe4K+KtMPFfEybbtFg9y0pbIJcW+g2FF0wLwD0iT91tEc10F57EzRsEp ZEdA== X-Gm-Message-State: ACgBeo2DxxsLqoT1UUh4A1gNYDI7M3njNEjEXApkVpkaKH4cMr02TnK/ g8wMpsKEYlqXYkzceJuhXEA= X-Google-Smtp-Source: AA6agR61bCYoBFhO606MrMj2e5JJ9ontZpH/7gcxtdHyPlYtKYvvYkTqL53A1Ak5xf1hQmk380rWDQ== X-Received: by 2002:a05:6e02:16cd:b0:2ea:e75b:f357 with SMTP id 13-20020a056e0216cd00b002eae75bf357mr19038138ilx.110.1662327776105; Sun, 04 Sep 2022 14:42:56 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:55 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:25 -0600 Message-Id: <20220904214134.408619-49-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 48/57] dyndbg: add .gnu.linkonce slot in vmlinux.lds.h KEEPs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add linker symbols and KEEPs for .gnu.linkonce.dyndbg and .gnu.linkonce.dyndbg_sites sections, placing them in front of their respective dyndbg and dyndbg_sites sections. This placement gives us a known relative offset (ie -1) from the start of the vector to the header, letting us use container_of to get it. The _index added previously allows determining &descs[0] from any desc[N]. The .gnu.linkonce. collapses possible multiple declarations into a single allocation, with a single address. todo: will need similar for modules.lds.h Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 1e7ee65e8591..20fdea9efd78 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -348,9 +348,13 @@ __start___dyndbg_classes = .; \ KEEP(*(__dyndbg_classes)) \ __stop___dyndbg_classes = .; \ + __dyndbg_header = .; \ + KEEP(*(.gnu.linkonce.dyndbg)) \ __start___dyndbg = .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg = .; \ + __dyndbg_site_header = .; \ + KEEP(*(.gnu.linkonce.dyndbg_sites)) \ __start___dyndbg_sites = .; \ KEEP(*(__dyndbg_sites)) \ __stop___dyndbg_sites = .; \ From patchwork Sun Sep 4 21:41: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: 12965343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D29F9C6FA82 for ; Sun, 4 Sep 2022 21:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EB8710E3B3; Sun, 4 Sep 2022 21:43:53 +0000 (UTC) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62E6110E1C5; Sun, 4 Sep 2022 21:42:57 +0000 (UTC) Received: by mail-il1-x129.google.com with SMTP id l16so3889251ilj.2; Sun, 04 Sep 2022 14:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ghge3Dg1q/uGEuUESUrEdkwsT+z6CpJtuRfuq34U0Ug=; b=FLT5bN9bU1jESQsj9wEWPf6TBBHS0oph0LypFJwzq/K+zCkxyteteH2bTqZQBcNzRk mSR3h7PMvUN4YMVkvnO87hK2EpNkCDlGSKyeeqjogwoe6lhs1W0j8NVv5K50LsJtZg06 R92M/cvFSPip9b/dMAktsgXw9ub1l1yxpBS3OvRLmDew3VfDVMnqQ0y++Z8JirN4wlxB lJnxEt70v9wGz0k/jpVu8dHy7KvJOhLu72eHep8RD2rQzQKX8nJI5JvRr6ZFWV/vp1QA rb8QvbLzf2xps15VlW8JMp2QgHnpXqCAJLTT4tXeVn3zK7n/t3dqhX+s0crDVymyRVVS JLpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Ghge3Dg1q/uGEuUESUrEdkwsT+z6CpJtuRfuq34U0Ug=; b=2vq/Sf2AYTWsYnnXigthBYr5v68eNsVG6irNp3hzww6JuTAzAcHicpYhyqSFYIc/PK 3SYvGLsA4aIsRG2E09dUZ17h7cX8zEJwsnjp4H7E7PgXjKtO55O7CENuEKj1ei9HCW01 uSWGYpKpOKqaf1b86edVRk6JemkGoHyDA1N0QnoK22P9HS4Dc3LMsMHAjxhT2uLuO56M 6DVZkmKb8H/DvCBSJVoQxH0iVmJ2boRG8oN88hiE+0Ch/FPcpefkpbHFiatLrDZ/3gun WjorBdWQ70H23Sq1tXp9Onpu/LmONP5JJ0q4LGvYyBtj5FZeR8sTP9V62i4krRAJfrVH lnKg== X-Gm-Message-State: ACgBeo0odY3/dXdk6DrlhTt6VMgeg5kZxafaDbnqMvURcUwu+Ys7nyQY 8JIfm4JKC8k+LJRCRR/RzcWjq5zZ9lM= X-Google-Smtp-Source: AA6agR7yrIYfyzVDzlMev9fxaOVFcrN/YRY+eo0Bb7o+kB7gpv9wc7uwho5jDTzaHbxaUMbJjOU49g== X-Received: by 2002:a92:ad0d:0:b0:2e6:4294:bc45 with SMTP id w13-20020a92ad0d000000b002e64294bc45mr24581884ilh.278.1662327777020; Sun, 04 Sep 2022 14:42:57 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:56 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:26 -0600 Message-Id: <20220904214134.408619-50-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 49/57] dyndbg: add structs _ddebug_hdr, _ddebug_site_hdr X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add new structs _ddebug_hdr and _ddebug_site_hdr, latter for symmetry. The job of the struct _ddebug_hdr is to: Contain an _uplink member, which points up to the _ddebug_info record that keeps builtin and module's dyndbg state. That record is init'd (by dynamic_debug_init for builtins, or find_module_sections for loadables). Be declared in .gnu.linkonce.dyndbg section, which places it just before the __dyndbg section; a fixed relative offset. This allows _ddebug_map_site(desc) to cheaply compute &descs[desc._index], &descs[0], then container_of() to get the header and its ._uplink, to the _ddebug_info, which gives access to ->sites[desc->_map]. Structurally, the header has a single unnamed union (which exposes its field names upward) containing an embedded struct _ddebug{,_site} (this forces the size to be compatible with the array/section its destined for), shared with our new struct _ddebug_info * _uplink member, which is also inside an unnamed struct, to allow adding other fields later to use the remaining space. In dynamic_debug.c: ref the linker symbols for the headers, print them to confirm expected linkages; things look proper. Add a header ref to struct _ddebug_info, to facilitate the validity checks. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 23 ++++++++++++++++++++++- lib/dynamic_debug.c | 9 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 268e903b7c4e..f23608c38a79 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -126,8 +126,29 @@ struct ddebug_class_map { #define NUM_TYPE_ARGS(eltype, ...) \ (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) -/* encapsulate linker provided built-in (or module) dyndbg data */ +/* define header record, linker inserts it at descs[0] */ +struct _ddebug_hdr { + union { + struct _ddebug __; /* force sizeof this */ + struct { + struct _ddebug_info * _uplink; + /* space available */ + }; + }; +}; +/* here for symmetry, extra storage */ +struct _ddebug_site_hdr { + union { + struct _ddebug_site __; /* force sizeof this */ + struct { + struct _ddebug_info * _uplink; + }; + }; +}; + +/* encapsulate linker provided built-in (or module) dyndbg vectors */ struct _ddebug_info { + struct _ddebug_hdr *hdr; struct _ddebug *descs; struct _ddebug_site *sites; struct ddebug_class_map *classes; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 65b0a1025ddf..91fe7fb5dda9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -49,6 +49,9 @@ extern struct _ddebug_site __stop___dyndbg_sites[]; extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; +extern struct _ddebug_hdr __dyndbg_header[]; +extern struct _ddebug_site_hdr __dyndbg_site_header[]; + struct ddebug_table { struct list_head link, maps; const char *mod_name; @@ -1522,6 +1525,7 @@ static int __init dynamic_debug_init(void) char *cmdline; struct _ddebug_info di = { + .hdr = __dyndbg_header, .descs = __start___dyndbg, .sites = __start___dyndbg_sites, .classes = __start___dyndbg_classes, @@ -1545,6 +1549,11 @@ static int __init dynamic_debug_init(void) pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_sites); return 1; } + + /* these 2 print the same, until _TABLE is added */ + v2pr_info("%px %px \n", __dyndbg_header, __dyndbg_site_header); + v2pr_info("%px %px \n", di.descs, di.sites); + iter = iter_mod_start = __start___dyndbg; site = site_mod_start = __start___dyndbg_sites; modname = site->_modname; From patchwork Sun Sep 4 21:41: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: 12965355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8510C6FA86 for ; Sun, 4 Sep 2022 21:49:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E886710E8A2; Sun, 4 Sep 2022 21:44:13 +0000 (UTC) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3858D10E283; Sun, 4 Sep 2022 21:42:58 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id y187so5724154iof.0; Sun, 04 Sep 2022 14:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0iGLn9xqCpcC4gcXCQSb7q1CfO8AItXp+UrSrC23ofg=; b=c4Kq7xloZvvHFQ9epBPNdcfT88slUONFGhsZx5MMGEMETHKqfUD9s2gzih6ALSi3wD RrSDXPBRasBgiwo4/u96iVTFZBqUgPsrGJ215FEXB49z7jnLyWi457WMuaGNd/EON1XH GyjBZNFnOS45dRu6gLJPWVkFsKVueCkOjPTRK+IINcSb2jbyp3YwEPuMkYNSzl/rirQM d5EwuNynlS8h4OY8pAJTaF7QeWBKZcUVuMJzzAnk0maYPeDvxCRYSxmx7XIOTzxGp1yV PLaexfCoB2wQoSDMH+kN17KC+TwYCpQd6YSNc7LXPW74NfB8khKnhZvXekFB8EQPRMeQ pFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=0iGLn9xqCpcC4gcXCQSb7q1CfO8AItXp+UrSrC23ofg=; b=aGirrv5idrxju4T1Ra6aLfWXuLyB3C8gGa+ZR2liwgGB4Mohi10C60oL7fACKPaWOf l47dI8QQKqcVw0p5kQrjlBJ5uvYAeuJnMZrSUE4JZAvoxCZxT1L3Ui4V5v+r+SAhIO9T 9KgvqIpyyiJboLMTiOYRY7z6w5BeCAjZlgt0MyJdA31TmpAp7YLUeBDGLm5jRK/UfV5h 9Rp24FMHPUpOv+g0RNNOlI5a+2fWAxx4ujYy8sd9kd5RCYgCcrY0sQ6QoC81UjH2M7xj 3D5JhWOfaFafvI/1pQrP/0vCezMhGTcjgfMTrRI+yiyL1CVI+EqcOuEhRkkXwmdOGvft VabA== X-Gm-Message-State: ACgBeo2cOEWBgOcszjsVd2RwOwj6mdd36pX5t2AC7CYgLb2+Cs6pViNQ rA5Dk/+ZjtB3aPbGXwqQGH4= X-Google-Smtp-Source: AA6agR5hVc9DnYKL0ZIAQuzKxXKG0S5DufyPzrHmQJwD8MfDjPFuhObXx/a4iT1L7ykoRUbvzDY2Pw== X-Received: by 2002:a05:6638:1350:b0:349:f94d:5ea7 with SMTP id u16-20020a056638135000b00349f94d5ea7mr24681226jad.129.1662327777931; Sun, 04 Sep 2022 14:42:57 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:57 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:27 -0600 Message-Id: <20220904214134.408619-51-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 50/57] dyndbg: count unique callsites X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Count de-duplicated callsites. Since the _ddebug_site excludes lineno, all callsites in a function are identical, and this effectively counts functions in the module with callsites. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 91fe7fb5dda9..891d70d7fed4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1348,7 +1348,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, unsigned int *packed_base) { struct ddebug_table *dt; - int i; + int i, num_funcs = 0; v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_descs, di->num_sites, base); if (!di->num_descs) { @@ -1381,12 +1381,11 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, //BUG_ON(di->num_descs != di->num_sites); for (i = 0; i < di->num_descs; i++) { - - if (di->sites[i]._function != packed_sites[(*packed_base)]._function) - + if (di->sites[i]._function != packed_sites[(*packed_base)]._function) { + num_funcs++; memcpy((void *) &packed_sites[++(*packed_base)], (void *) &di->sites[i], sizeof(struct _ddebug_site)); - + } di->descs[i]._index = i + base; di->descs[i]._map = *packed_base; @@ -1397,7 +1396,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); - vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); + vpr_info("%3u debug prints in %d functions, in module %s\n", di->num_descs, num_funcs, modname); return 0; } From patchwork Sun Sep 4 21:41: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: 12965341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04079C6FA82 for ; Sun, 4 Sep 2022 21:48:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFEF510E1EB; Sun, 4 Sep 2022 21:43:49 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8953410E290; Sun, 4 Sep 2022 21:42:59 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id s3so1911308ilv.4; Sun, 04 Sep 2022 14:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KACUwbv9zFDFS+/NnZ2+bHc0BJ5XxAtoDioY/cngaq0=; b=VWLo9KQRx3wUEpHavD9gtPYNFllTyy4JKxvs/7m7tkQZM4ST377wbMAzvfbzKUgbOp J6WuHZ3P93mqwHnELmx4xWY2iE88bkmZTSJqZgzV49g9rgdp//m9df+iAKw5mapuizNM 8N7/7jcJanbJgpES8DxAtzXNIpOD8ZbW5WOPK05nV0i1YT9y6m46gm5tX0ZuDvQutVME hVXVPzZsqJYaB2x7eaQgiQ5QGXMW5MZGs2s9lLUmDUh275cuM3Hr9LM8UftEseh/RA6Z Yc6+zDt9i1m5X50alTa/P6gMXlOYHL2RiMbZY6SXX3tIiEk2zkHyzL+A2td9lp2Hi3c2 vR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KACUwbv9zFDFS+/NnZ2+bHc0BJ5XxAtoDioY/cngaq0=; b=TODwl0ZnAWhfJzsks+oSTjz5sDpxRzjLgfwV4bexRYxZ4/8iOgE1Ij3mO+WSS/ndRb js/QLo9CFLp26lmNqmhi6NRENEDfITAM50RiimcPidqwvqwi4NakFJrDCbIDAH/h958g +QOkaNZbpegYJAtCHyyL7cbCfYIdxTLzOlYqjxm01+Apdp80KtBfgkp38wnowEbfaH3o rXstka2EfSYKSvBcClDIEXu5pIXlu/feFncQST9T0F4nRAEIbXZWrUZbotWhHmn4iymW wIcVvYRb88cmQIYpTaTBCiWC0g0xPjWp/7jvd0MgItVOjyuItF71IYxieNICKvIv7rK1 PZMw== X-Gm-Message-State: ACgBeo1W0K9Ihou1RK8JJksW+gJpSZRBEYfJQvExDdYU1XNQ6QC/l0HM WSZt8IWuVDRNMUBYD2cSx4o= X-Google-Smtp-Source: AA6agR4Fn4lGPNDj+VkdpCwid3ve66XVQ8L4VIZBVbVLfcwMhJmhHwO+CmYwocy3EXC3pDUoc7POZw== X-Received: by 2002:a05:6e02:1c2b:b0:2e9:f263:2942 with SMTP id m11-20020a056e021c2b00b002e9f2632942mr24514448ilh.74.1662327779197; Sun, 04 Sep 2022 14:42:59 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:58 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:28 -0600 Message-Id: <20220904214134.408619-52-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 51/57] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several subtrees, including efi, vdso, and some of arch/*/boot/compressed, with various relocation errors, iirc. Avoid those problems by adding a define to suppress the "transparent" DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems myself, lkp@intel.com found arm & sparc problems, and may yet find others. Reported-by: # on [jimc:lkp-test/dyndbg-diet] recently Signed-off-by: Jim Cromie --- arch/arm/boot/compressed/Makefile | 2 ++ arch/sparc/vdso/Makefile | 2 ++ arch/x86/boot/compressed/Makefile | 1 + arch/x86/entry/vdso/Makefile | 3 +++ arch/x86/purgatory/Makefile | 1 + drivers/firmware/efi/libstub/Makefile | 3 ++- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 41bcbb460fac..f2d7a3b62727 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -81,6 +81,8 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size compress-$(CONFIG_KERNEL_XZ) = xzkern_with_size compress-$(CONFIG_KERNEL_LZ4) = lz4_with_size +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index 77d7b9032158..58ed4d64c978 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -30,6 +30,8 @@ obj-y += $(vdso_img_objs) targets += $(vdso_img_cfiles) targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so) +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + CPPFLAGS_vdso.lds += -P -C VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \ diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 35ce1a64068b..b76bbf9fc504 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -36,6 +36,7 @@ KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) KBUILD_CFLAGS += -fno-strict-aliasing -fPIE KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone KBUILD_CFLAGS += $(cflags-y) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 12f6c4d714cd..3182728f9f4d 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -29,6 +29,9 @@ vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o vobjs32-y += vdso32/vclock_gettime.o vobjs-$(CONFIG_X86_SGX) += vsgx.o +# avoid a x86_64_RELATIVE error +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + # files to link into kernel obj-y += vma.o extable.o KASAN_SANITIZE_vma.o := y diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 31c634a22818..8d264836ae64 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -35,6 +35,7 @@ PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += -fno-stack-protector +PURGATORY_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 3ef67431f05e..2b7e34555c5a 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -14,7 +14,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ $(call cc-disable-warning, address-of-packed-member) \ $(call cc-disable-warning, gnu) \ -fno-asynchronous-unwind-tables \ - $(CLANG_FLAGS) + $(CLANG_FLAGS) \ + -DNO_DYNAMIC_DEBUG_TABLE # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin From patchwork Sun Sep 4 21:41: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: 12965335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD755ECAAD5 for ; Sun, 4 Sep 2022 21:47:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F46F10E352; Sun, 4 Sep 2022 21:43:37 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94A4610E299; Sun, 4 Sep 2022 21:43:00 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id e195so5690947iof.1; Sun, 04 Sep 2022 14:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HlXlcsu2RqT6fAUiV6NVhuDn1t0xR93nZ+jChKYhqUw=; b=aHV/k9J2PuitBnlhA4br73E9JnLl2gCBHHBTGdkL9KmqcRS5bomgzwR0OaqXBlVyql Mf+7Y+KsEOXcIs+D0+rNcc1xfUx+tf11ZEtL7jgmdcXn3KKcYRtVgMKv2QivMhgwGB6p qhysutFwua8FbpIFvlVp/S3j8MzU+FtQko8iiKsgLlooadXPLQQ21I6Q1NTrYJTip/4D 0VC0OYdPKhw0V3Mzu3DZ0R5yhcn852KcFxvjVL4Bi2PKi8TFHfnlMTt0MfuMqEB1W0cT r3SV72vbw59OuMsz2HCPNecCDPTzT4EzG4nBHs7LsaOq7fTjOvTkLYW8hBG4OuYPJt9E DnRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HlXlcsu2RqT6fAUiV6NVhuDn1t0xR93nZ+jChKYhqUw=; b=EDxselT83jQL0qvrXntF5Ga9xS5B4MhrHTX41w+0Z0egLvLhpKVKQjtJI6j4RUmEN6 zm7m1Q/nRAu1qS2NVs6igBWslUjt2cf19vXQlSWNeeivxbeMeaLesWtJytOMreqR+OB0 gmKrkcVhYhoNW3nmBUI+hZ7hiPa1k7TtG8hKUG0RIi5l0hCH0RCnADHKfxZI0l5pPGaz CPaVjzhl97RocA1Q/ET3pdDFlWQF2L/qa+SI5nzt4450P7KU+zrFvT4u84KGuEgTDilL aBiA0ue17F/dumpHTW1fqPSAPesSpmDfAFGGxGQ7XxML20O6xIC4/V20jMEosvxSolIW XSrQ== X-Gm-Message-State: ACgBeo2p0MHYh1TZAD6TsF1ZLTeM5M00TYpZy16CL0WhD5jZD9L8uCN5 YXEQY4RbCxvQeMs8HP3tnkk= X-Google-Smtp-Source: AA6agR7vlI7R7BZjvt5nOZUe1nHbAjNSYfJLtX8tg1fOrQTMkIvWzLEFddRnIK11jzK+Lp9kCqNOZQ== X-Received: by 2002:a05:6638:22d1:b0:34f:5d31:5fe with SMTP id j17-20020a05663822d100b0034f5d3105femr6114929jat.185.1662327780173; Sun, 04 Sep 2022 14:43:00 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:59 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:29 -0600 Message-Id: <20220904214134.408619-53-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 52/57] dyndbg: add DEFINE_DYNAMIC_DEBUG_TABLE, use it tacitly RFC X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This defines a new macro (tbd: tweak name) which is a special version of DEFINE_DYNAMIC_DEBUG_METADATA_CLS(). Unlike that macro, which declares callsites in pairs of desc/site recs. This macro declares a pair of header records, which the linker script then places once (.gnu.linkonce.) into the front of the respective sections. For builtins, the .linkonce gives us a single header preceding all ~3-5k callsites. It uses __unused, __weak, .gnu.linkonce to avoid trouble with multiple inclusions, and should not consume space when not linked to by a callsite in a loadable module. Atypically, this macro is also tacitly invoked in the header, which is indirectly included by printk.h. This means 2 things: it mostly insures that source files will declare it at least once, and that multiple decls resolve to the identical storage address. I did this with the expectation that I could let the linker compute the offset and initialize ._index accordingly, but that resulted in some "linker cant compute" error. Ive initialized it in __ddebug_add_module() instead. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f23608c38a79..23d3d2882882 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -220,6 +220,32 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) +/* + * DEFINE_DYNAMIC_DEBUG_TABLE(): This is a special version of + * DEFINE_DYNAMIC_DEBUG_METADATA(). It creates a single pair of + * header records, which the linker scripts place in front of their + * respective sections. + * + * To allow for a robust runtime test in dynamic_debug_init(), the + * pair of records is hardwired into a self-reference loop which can + * be validated before the field is altered to support _ddebug_map_site() + */ +#define DEFINE_DYNAMIC_DEBUG_TABLE() \ + /* forward decl, allowing loopback pointer */ \ + struct _ddebug_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header; \ + struct _ddebug_site_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg_site") \ + _LINKONCE_dyndbg_site_header = { \ + ._uplink = (void *) &_LINKONCE_dyndbg_header \ + }; \ + struct _ddebug_hdr __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header = { \ + ._uplink = (void *) &_LINKONCE_dyndbg_site_header \ + } + #ifdef CONFIG_JUMP_LABEL #ifdef DEBUG @@ -390,4 +416,12 @@ static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_par extern const struct kernel_param_ops param_ops_dyndbg_classes; +#if ((defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))) \ + && defined(KBUILD_MODNAME) && !defined(NO_DYNAMIC_DEBUG_TABLE)) + +/* transparently invoked, except when -DNO_DYNAMIC_DEBUG_TABLE */ +DEFINE_DYNAMIC_DEBUG_TABLE(); +#endif + #endif From patchwork Sun Sep 4 21:41: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: 12965357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06827ECAAD5 for ; Sun, 4 Sep 2022 21:50:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D0BA10EA49; Sun, 4 Sep 2022 21:44:27 +0000 (UTC) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7762810E183; Sun, 4 Sep 2022 21:43:01 +0000 (UTC) Received: by mail-il1-x136.google.com with SMTP id h14so3864060ilh.10; Sun, 04 Sep 2022 14:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=BbbFDk5Ds3TKsvXVbegzI7CpK80eT1rLEmQAVhGGmkbjefDTu1gcIWX3uZ+Gm3W16k 3S2yBAZFyR4M8ryCfllvuDfTEF5RipMBjPts8hfi0pV7bgB3wzkcHuY4zKj4khhmKXMX pSl1t58XXxStJLZnSVd/tYgQeSDea1W2Q0b2Yjqp1FxlZFqw6LWpNqFhC6szuGaRu8dl 5KSWJpEvt20IxDYiChjLMX8wBoKwHlILNtfzF8+iMXyfBHmY6aJSuvXzt1gP3PkSoi/Q ObHbdHfGYhfOUrMIzj4dzek2gnNfsuuTirJYodRLuPa4LRKsvPAHjppmK36ztUBZgFy/ TBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=4H7/K/9dwxSeIR+S0Ua6L8yAegt1yf4fTq5J+ZJwIEx8hJ797nmNsfkxA/89Fclx4+ DR/eUB8puQcM+F4FD+aQl8pvXSyyRnbTR+r3mM+bMjKieJWGHtoNpPOuQDLA/O1od8lx L7vFvSCFJVKMuE4bf59XFU/9TiCy4E/1jRdomZ9jEbWsQ5IjTgniw5woHOHr5FVg24pl WZI1kIzBiuuc7xw4FJgdwys0LndOubm9ZFM7P+8RIg054C0S6nrNCS1JLEIbPPKqAHJ7 m4XShX1zPnbxzMRmCYoMIVV4brMrbt1Ext6pKGq1EQ1ghzyVMtLPPkrvbgXMDfCHMLkJ XNTg== X-Gm-Message-State: ACgBeo2+r+F+6NGrJvMwMBZx0DKMkMVk8tocVFTEePz6ymA+LXc8ANcM Cxqh/KESSHPaGZtjnPPEYYo= X-Google-Smtp-Source: AA6agR5Ky+BjL0NnfIX4cYKS1KnsINOXh0NpNlMijj01ekGHcYdvtJWlYQecsvf47LfzeAoLHEZ2MA== X-Received: by 2002:a05:6e02:1524:b0:2ec:71c6:7b85 with SMTP id i4-20020a056e02152400b002ec71c67b85mr9725292ilu.237.1662327781031; Sun, 04 Sep 2022 14:43:01 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:00 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:30 -0600 Message-Id: <20220904214134.408619-54-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 53/57] dyndbg: add/use is_dyndbg_header then set _uplink X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add static int is_dyndbg_header(d), which verifies that the arg is initialized as expected; that it points to the _ddebug_hdr & _ddebug_site_hdr records initialized by DYNAMIC_DEBUG_TABLE(). That init macro sets the _uplink fields in the 2 records to point at each other. This is an impossible situation for the regular callsite record pairs built by *_METADATA_CLS(), so it provides a robust verification that linkage happened as we require/depend upon. In dynamic_debug_init(), is_dyndbg_header() validates the header, and sets _uplink to builtin_state. Thereafter, ddebug_map_site() can use it, and we can drop the _ddebug.site member, and shrink the DATA footprint. --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 38 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 23d3d2882882..ed3e1e1c08eb 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -149,6 +149,7 @@ struct _ddebug_site_hdr { /* encapsulate linker provided built-in (or module) dyndbg vectors */ struct _ddebug_info { struct _ddebug_hdr *hdr; + struct _ddebug_site_hdr *site_hdr; struct _ddebug *descs; struct _ddebug_site *sites; struct ddebug_class_map *classes; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 891d70d7fed4..0a68fbfd8432 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1339,6 +1339,25 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); } +/* + * detect the hardwired loopback initialized into the header pairs' + * _uplink member. In dynamic_debug_init(), it verifies the presence + * of the header, before setting its _uplink to either &builtin_state + * or the module's embedded _ddebug_info. __ddebug_add_module() will + * also use it.. + */ +static int is_dyndbg_header(struct _ddebug_hdr *hdr) +{ + struct _ddebug_site_hdr *sp; + + if (!hdr || !hdr->_uplink) + return 0; + + sp = (struct _ddebug_site_hdr *) ((struct _ddebug_hdr *)hdr)->_uplink; + return hdr == (struct _ddebug_hdr *) + ((struct _ddebug_site_hdr *)sp)->_uplink; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1351,6 +1370,15 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, int i, num_funcs = 0; v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_descs, di->num_sites, base); + + if (is_dyndbg_header((struct _ddebug_hdr *)&di->descs[0])) { + pr_info("module header\n"); + di->hdr = (struct _ddebug_hdr *) di->descs; + di->descs++; + di->sites++; + di->num_descs--; + di->num_sites--; + } if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1525,6 +1553,7 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di = { .hdr = __dyndbg_header, + .site_hdr = __dyndbg_site_header, .descs = __start___dyndbg, .sites = __start___dyndbg_sites, .classes = __start___dyndbg_classes, @@ -1548,11 +1577,16 @@ static int __init dynamic_debug_init(void) pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_sites); return 1; } - /* these 2 print the same, until _TABLE is added */ - v2pr_info("%px %px \n", __dyndbg_header, __dyndbg_site_header); + v2pr_info("%px %px \n", di.hdr, __dyndbg_site_header); v2pr_info("%px %px \n", di.descs, di.sites); + if (is_dyndbg_header(di.hdr)) { + di.hdr->_uplink = &builtin_state; + } else { + pr_err("missing header records: cannot continue!\n"); + return 1; + } iter = iter_mod_start = __start___dyndbg; site = site_mod_start = __start___dyndbg_sites; modname = site->_modname; From patchwork Sun Sep 4 21:41: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: 12965353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD53CECAAD5 for ; Sun, 4 Sep 2022 21:49:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63D3F10EA52; Sun, 4 Sep 2022 21:44:12 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id CFA0E10E2A9; Sun, 4 Sep 2022 21:43:02 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id p187so5653229iod.8; Sun, 04 Sep 2022 14:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bXSeYH0zduNfWYtAn2/GFLXR9T03/2CnSS0WiVim3VQ=; b=Kz5c1apWMX0yddvgXTrt/BjoeN52CrK81vVC2ejDG94BrieUIvPuQxqUc9mOpTS/PP HWECHkoY/OGUf08e39Nmu5OrgrRhJWG04JFoAaPLsxT6JyFH/YDSudtSKAU+VFekFYsq Vod9PDrJCKlyWzWt7qenFWfsvqXS3nuOE+JpI9yW2OwLoVmYddOY5g5wBsTWGPdp/8D4 T8EWSg90FSXg58mfxM0h4Ijo4DgetN371n10Vzcly6r5kLaSzcQu1NTLn9EFrrE/z+XJ JBzGq1uSt6X2fse4mVKP1vmF2LWn1W1sfDqy+6kqDBUE4JOdFjuhQGLvtnC0Saz04FMW fgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bXSeYH0zduNfWYtAn2/GFLXR9T03/2CnSS0WiVim3VQ=; b=FlIOT/nAibk5KswXBEb+JEIbIyqGQMw8vTZb90YgI+QhtB1FJap2M8NQ4xCT+H8fc7 vOkP+90KgtTtUuvJJSPsFkZ+31nxmPR4JoVnbYiw6E4gLqyNeLk/KM7VMnA45vm0OTIi y7HaVKdmUe2SKy9Ie4RK8oKsxB6bFkcqk34gHmM9HuCTlzRiyeQD/JGMOu1GS68R0Iax kR6+YfDt/HVgxolRqVsvOHv7TwX7BABnREg10VfRAfnoq+/FkNjj3NQrgSHvEJc+QbM+ TYsrzsFT0foDnemUqrQm372zpS1U5qt2WxDyd4Ax4FEBG6p7i6yYfB6+TGvrMLpYtiUr hfyw== X-Gm-Message-State: ACgBeo0m8EQXUyPxZZDTB+aw2hmpz/bWsWMDuj3jsy4Hu4n6N6XQwdlH UwtKkCnfW61Lfpyy6Ch7f/w= X-Google-Smtp-Source: AA6agR4F0Y5uoS0j9obmZc9hPIHDQS7tGY0siR2ILOqRr5ep1L+AxeY27R3APLGSgxbHOp+TIgipXA== X-Received: by 2002:a05:6638:40a8:b0:346:8e3c:8141 with SMTP id m40-20020a05663840a800b003468e3c8141mr24647914jam.107.1662327782109; Sun, 04 Sep 2022 14:43:02 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:01 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:31 -0600 Message-Id: <20220904214134.408619-55-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 54/57] dyndbg: add .gnu.linkonce. & __dyndbg* sections in module.lds.h X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" For a long time now, loadable modules have tacitly linked the __dyndbg section into the .ko, as is observable in dmesg by enabling module.c's pr_debugs and loading a module. Recently, __dyndbg_sites was added, following the original model. But now, we need to explicitly name those (__dyndbg, __dyndbg_sites) sections in order to place new .gnu.linkonce.dyndbg* sections in front of them. This gives us the properties we need for _ddebug_map_site() to drop the _ddebug.site pointer: fixed offset from &__dyndbg[N] to &__dyndbg[0] container_of gets &header header has ptr to __dyndbg_sites[] __dyndbg_sites[_map] gives de-duplicated site recs NOTE HEAD~1 took headers off front of descs,sites and saved them into _ddebug_info, this puts the gnu.linkonce.* records into those vectors. Signed-off-by: Jim Cromie --- include/asm-generic/module.lds.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/module.lds.h b/include/asm-generic/module.lds.h index f210d5c1b78b..328c48dfc88c 100644 --- a/include/asm-generic/module.lds.h +++ b/include/asm-generic/module.lds.h @@ -4,7 +4,17 @@ /* * can specify arch-specific sections for linking modules. - * Empty for the asm-generic header. + * + * For loadable modules with CONFIG_DYNAMIC_DEBUG, we need to keep the + * 2 __dyndbg* ELF sections, which are loaded by module.c + * + * Pack the 2 __dyndbg* input sections with their respective + * .gnu.linkonce. header records into 2 output sections, with those + * header records in the 0th element. */ +SECTIONS { +__dyndbg_sites : ALIGN(8) { *(.gnu.linkonce.dyndbg_site) *(__dyndbg_sites) } +__dyndbg : ALIGN(8) { *(.gnu.linkonce.dyndbg) *(__dyndbg) } +} #endif /* __ASM_GENERIC_MODULE_LDS_H */ From patchwork Sun Sep 4 21:41: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: 12965351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40BFFECAAD5 for ; Sun, 4 Sep 2022 21:49:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46D3C10E853; Sun, 4 Sep 2022 21:44:11 +0000 (UTC) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB56710E2BE; Sun, 4 Sep 2022 21:43:03 +0000 (UTC) Received: by mail-il1-x136.google.com with SMTP id k9so701422ils.12; Sun, 04 Sep 2022 14:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=CI4O5/XsaFLXciSt5Rdge4MemsUClxFVBZfystEbNfehM5+pbWGL+3/LfbSrWpLkDe QLouWGHfFHkP9Q9uTLPz7X3ERsbJXjw8LNi6aoavpvlpTPh0dTvh+IgfdUCbYJdj0GgH lUfG76Rd0gmLjbbl/3rZMOmYqTD+WkTN/9K2f2dm2qZHEDNaVZgbBO5+nFxuSbB/CFz4 0MWqrUks5jKXTp61hPvRrQtbY7qo2RxRkVavCrphAIUunhh48rh0GzTzPFGrJ6BKZ0CD yShrbz0hun/rGp39oZ6PrAdWgNTyqGMKHUoak/rTVekwOK81+67c+ffYoQ1p3mVC8bzd oPTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=Mf7ji4EsMb4k4GrfFZlHJ2QwJMp+hE4zDyWemJNG+aAqlRVsuoDXZSSA89BvYTIRXR 3sK3tfcmCBYV7PmtYFEaz5zIYTzQZE/4QJH3S5tKgXF+bG65x63Mzk9/wU44Rq9A4TE6 w5Jnm1dv+ntpvipYP2+oxSVwYoYk9B33vfkT8D2cnqtBlhFWXdIJmg8Tj8klkruCIDbc T2U1xbmMUS/XuLF1jcthYCFU3nJ8de2DujcaXCkPsdZpeSFdrv5aI3bMhQqiPl+NTDe3 FKPeqg5rtOeat4BlTiTqPsfEK5WtXJbZYAqyXxoePKODSMdfK0Hvp8jfiKoq7GnDCcvl cy0A== X-Gm-Message-State: ACgBeo1/kOOPhfPsad6iYfzoYi72PwlSAJnWolx/nY2E/+sG9I3zHg7E AF+uTDo+gUTS44c78wWBjk8= X-Google-Smtp-Source: AA6agR7eGPKnIe81RJVDfoPI3jJBBD+OXvseERYIHoYQlkUb2mdyRY/RHX6luTHiUDhiH85tZBOfIg== X-Received: by 2002:a05:6e02:180c:b0:2f1:5405:4bba with SMTP id a12-20020a056e02180c00b002f154054bbamr1923294ilv.152.1662327782986; Sun, 04 Sep 2022 14:43:02 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:02 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:32 -0600 Message-Id: <20220904214134.408619-56-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 55/57] dyndbg: dynamic_debug_sites_reclaim() using free_reserved_page() WAG X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@redhat.com, Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" STATUS: broken with some over-free, punt and comment out late_initcall Implement dymamic_debug_sites_reclaim(as a late_initcall) to free the tail~47% of the builtin __dyndbg_sites[] vector back to the buddy allocator. Code is copied from mm/init.c:free_initmem(), wo the poisoning. Comments cargo culted wo grokking. v3pr_info: dyndbg: freeing range: ffffea00000c5500-ffffea00000c5700, ffffffff83154668-ffffffff8315c480 dyndbg: ie range: ffffea00000c5500-ffffea00000c5700, ffffffff83154000-ffffffff8315c000 dyndbg: freeing page: ffffea00000c5540, ffffffff83155000 dyndbg: freeing page: ffffea00000c5580, ffffffff83156000 dyndbg: freeing page: ffffea00000c55c0, ffffffff83157000 dyndbg: freeing page: ffffea00000c5600, ffffffff83158000 dyndbg: freeing page: ffffea00000c5640, ffffffff83159000 dyndbg: freeing page: ffffea00000c5680, ffffffff8315a000 dyndbg: freeing page: ffffea00000c56c0, ffffffff8315b000 Presuming those are 4k pages, 28kb is reclaimed, which is reasonably consistent with the numbers below; 1532/2761 compresson of 64KiB. I have fixed one edge-case over-free, which gave me a coredump on ```cat control```, there may be (one) other. dyndbg: 2762 prdebugs in 235 modules, 11 KiB in ddebug tables, 86 KiB \ in __dyndbg section, 64 KiB in __dyndbg_sites section CC: david@redhat.com # free_reserved_page() tip Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0a68fbfd8432..194367bc13fb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1542,6 +1542,7 @@ static int __init dynamic_debug_init_control(void) fs_initcall(dynamic_debug_init_control); static struct _ddebug_info builtin_state; +static __initdata struct _ddebug_site *last_site; static int __init dynamic_debug_init(void) { @@ -1622,11 +1623,12 @@ static int __init dynamic_debug_init(void) if (ret) goto out_err; + last_site = &__start___dyndbg_sites[site_base]; ddebug_init_success = 1; - vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", - i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), - (int)((i * sizeof(struct _ddebug)) >> 10)); + vpr_info("%d prdebugs in %d functions, %d modules, %d KiB in ddebug tables, %d,%d kiB in __dyndbg,_sites sections\n", + i, site_base, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), + (int)((i * sizeof(struct _ddebug)) >> 10), (int)((site_base * sizeof(struct _ddebug_site)) >> 10)); if (di.num_classes) v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); @@ -1652,3 +1654,40 @@ static int __init dynamic_debug_init(void) /* Allow early initialization for boot messages via boot param */ early_initcall(dynamic_debug_init); +static int __init dynamic_debug_sites_reclaim(void) +{ + unsigned long addr, end, start; + /* + * from mm/init.c:free_initmem (void) wo poisoning + * The init section is aligned to 8k in vmlinux.lds. + * Page align for >8k pagesizes. + */ + start = (unsigned long)__start___dyndbg_sites; + end = (unsigned long)__stop___dyndbg_sites; + addr = (unsigned long)last_site; + + vpr_info("full range: %px-%px, %lx-%lx\n", + virt_to_page(start), virt_to_page(end), start, end); + + vpr_info("freeing range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + addr &= PAGE_MASK; + addr += PAGE_SIZE; + end &= PAGE_MASK; + end += PAGE_SIZE; + + vpr_info("ie range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + if (verbose < 2) { + vpr_info(" skipping reclaim cuz its broken by `cat control`\n"); + return 0; + } + for (; addr < end; addr += PAGE_SIZE) { + vpr_info("freeing page: %px, %lx\n", virt_to_page(addr), addr); + free_reserved_page(virt_to_page(addr)); + } + return 0; +} +//late_initcall(dynamic_debug_sites_reclaim); From patchwork Sun Sep 4 21:41: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: 12965354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 589FCC6FA82 for ; Sun, 4 Sep 2022 21:49:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 985A310EA30; Sun, 4 Sep 2022 21:44:14 +0000 (UTC) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3709110E2C3; Sun, 4 Sep 2022 21:43:04 +0000 (UTC) Received: by mail-il1-x12d.google.com with SMTP id s11so3868449ilt.7; Sun, 04 Sep 2022 14:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=enn6xVuYphe+hXVPoV5iWIYr1g8ASji6MTEr9zuj34c=; b=MHZ+j5vq+DgcrRYUNssA/mQhOIh3IuE7Zq+aUJb41YdzWZC9PSDSIhOvEQ3TdCICX5 WTCvmLp7RobRHWpiQpug9Ise55wiJ4uYADB3QCMYatUnEHE8Jziwms0gNLdJzSy1SzKa weVrPvvMaJPWqT6SfVFtUwOQv+sOyCuhrhi/oJW7xApjkbYa3ldckzG68imOVm76KV+m Xwjrlq1ZQVkjBcKsJbOYdKGeSdp/d/LglobU+D8HgN3Kz9AvMJF9xfzvrS0x23RcYOMb o7tMHOwXqEMULGc4tCi168zLZkAoPrmdiBkQzY7FRbs0xD1GH/Ij8ZhWMXzT0upfwrl7 rC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=enn6xVuYphe+hXVPoV5iWIYr1g8ASji6MTEr9zuj34c=; b=YHy/g+p4i+dySmaQIpudLQT8jHEWUwQdRGMJ9Rxtj8TUOKM68ir+5lr1OnpZh3Gmlu kAg6Bjgw4diVEJ6qZZNd9Rxu/A//N0+npAke+aBU6+KWSseUv146e+WfTEVhl6QQc01p /fj9QLyqy9R9IkQTGMOnTjtAJ+y4nl2DggTri6C6+L9TFkOzapnJki5ZEu6iZ2AasQru E6Sw4QJ9zZbJ8Rwe7pkHvi9m5XY591t5Zu/vUtgahtUm3r1YTySattbOcRDxHGixEkbT 737UVIR2542eI5B8RynC7wmk0Z0jUuQVD7y10apkqqGweNKG4ZbLxf36MrglBJaGqdHs uJrA== X-Gm-Message-State: ACgBeo0FwgrrrTn3ThrQH3cTq68/RwlSKiqLwpImHmCXZRGGWW0dlsNz miNXYcdNqxAJ0b79cR4TTD4= X-Google-Smtp-Source: AA6agR5YpuT8Q9JQCumSZI1qIIDzfmGUPYBDoLNXJiZ6x9bW2LfTNC3WN5DzbhXOp2lE4bQ4o8fKCA== X-Received: by 2002:a05:6e02:1605:b0:2ed:be80:59ae with SMTP id t5-20020a056e02160500b002edbe8059aemr7558764ilu.319.1662327783877; Sun, 04 Sep 2022 14:43:03 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:03 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:33 -0600 Message-Id: <20220904214134.408619-57-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 56/57] dyndbg: work ddebug_map_site X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" attempt container-of, broken, missing use of uplink... took that out. ptr computations are naive, and wrong. Deeper prob is lack of _ddebug_vec, with header and descs in same struct. maybe. builtin_state looks right in debugger --- lib/dynamic_debug.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 194367bc13fb..11fea1f818a7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -173,8 +173,25 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons return NULL; } -static inline struct _ddebug_site * _ddebug_map_site(const struct _ddebug *desc) +/* + * mapping from desc to site is multi-step: + * - _index back to &descs[0] + * - container-of to get header struct above + * - ._uplink field, pointing to _ddebug_info (for builtins, loadables) + * - di->sites[desc->_map] + */ +static struct _ddebug_site * _ddebug_map_site(const struct _ddebug *desc) { + struct _ddebug_info *di; + struct _ddebug const *d0 = desc - desc->_index * sizeof(struct _ddebug); + + di = (struct _ddebug_info *) d0; + + v3pr_info("map_site idx:%d map:%d %s.%s di:%px site:%px ds:%px\n", + desc->_index, desc->_map, + desc->site->_modname, desc->site->_function, + di, desc->site, &di->sites[desc->_map]); + return desc->site; } #define _desc_field(desc, _fld) (desc ? (_ddebug_map_site(desc)->_fld) : "_na_") @@ -866,7 +883,7 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) return buf; } -static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) +char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) { if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) return __dynamic_emit_prefix(desc, buf); From patchwork Sun Sep 4 21:41: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: 12965346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 279CDECAAD5 for ; Sun, 4 Sep 2022 21:48:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D59F10E778; Sun, 4 Sep 2022 21:43:58 +0000 (UTC) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81D4610E2CB; Sun, 4 Sep 2022 21:43:05 +0000 (UTC) Received: by mail-io1-xd2b.google.com with SMTP id 62so5674429iov.5; Sun, 04 Sep 2022 14:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gc3CEPtxYjk29+Wh9qd9Uhba+Qcycq/xTeA557V/yJA=; b=pjBlhL+ATdSasCB8eiAlDBtg6VQZe3cAxxbzs1dn4fhsTGll1ZJKZVPkMR2mAe6vQD +1ZUleBqb9yFLUkLQLuRp4esV7jUMm+9nkPY8LhEgMfb+aZzAVC2mkPJrqbpGbEQhkRo beZ5FNifB5rdJxWg7R8D5bcVcnK7tDty4bpm3uL/kbFe0gGnoJy6MFouLJWvzkGtbSFw KbDqjScDXUcFQ9R/5Be0XLDU0graPMWJvrt9XQvpuQIZmHQO8jVZA6GPpMTQquJWxpzE uymD2AvAzBcc+9sFlbROngihXuT8MzFti5OGgYB/TVQyB52NFye/DNbIZ9Wq82jlh8uk kuiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=gc3CEPtxYjk29+Wh9qd9Uhba+Qcycq/xTeA557V/yJA=; b=aDGqCwjdA+bWLEIBtyn+2NjY/j2CF/7TdOJRCEZHdERfGB1Z4A4segeRQ2oj/yeOSU k85aROVZZdqzYQ4k0oxHX5QDmTb+vvDOg5gjhTwDhDOkrqZ0ilce6rtU7IFgaRBc3+g6 T0SgAZ1YdqOny+VsQwbmVrVir/RESYaLWFRfGCE9xYeeTzZ0UEPQSJZabuXwDGeWYQ/s BuRPDjXAx3tnFtn0lztTnYlpsmFwpbL6HrUsgFACFRo3HrMcC9FzjliMVF1QbsFYaRA3 c0PD5G8dUyAb8xyq34R0CXkY8UhvL3ag6Mo5xYSrh3rWF5VhiodwEr7dA4ewyFGwPrN7 dENg== X-Gm-Message-State: ACgBeo3efeaURAKS0u/8VUQMvjU/QZ3jJvddx9dF7mbbZhrjGq6izDQk t8w0H6xnZzUhN0I5tIyR9ow= X-Google-Smtp-Source: AA6agR62BzXzT17KlWx9uqQOlpAhM116jyafKxT3anpuAMgqBhik1FZ5pmVPGg2GE9QdKZVv5ooKrQ== X-Received: by 2002:a05:6638:24c2:b0:346:ce9e:3eff with SMTP id y2-20020a05663824c200b00346ce9e3effmr25894336jat.262.1662327784843; Sun, 04 Sep 2022 14:43:04 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:04 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 4 Sep 2022 15:41:34 -0600 Message-Id: <20220904214134.408619-58-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 57/57] dyndbg: fiddle with readback value on LEVEL_NAMES types X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Cromie , daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, seanpaul@chromium.org, joe@perches.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" my test scripts were writing one val, reading back val+1 echo L3 > p_level_names cat p_level_names L4 fix this w a -1 offset. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 11fea1f818a7..7d458601a61b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -830,6 +830,8 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); case DD_CLASS_TYPE_LEVEL_NAMES: + return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl - 1); + case DD_CLASS_TYPE_LEVEL_NUM: return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); default: