From patchwork Mon May 16 22:56: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: 12851572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD52DC433EF for ; Mon, 16 May 2022 22:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hMXtLOZ5daOC4Q6bRWJ3H14veDufWrlFV5AyBkYm220=; b=wk0ErQmWJV+jix ucL9wFg5iOXb3Hco/jstP2lrIHJSkaB5o3hKI/7a9cHICl2lSLfleUdNddZ8eOd1Kp0Ea5gOxzWEK 6wWIV01R4uO1Hf0SXo9aPoMkeOb4ACoC/JbhHIwtwdnMCvdqsdKm0pzUC7cY9DBJUWdl7K39ha7FR 4iG+CPywQJ//yRgV78nrm62sxGsfshrvxpJg0YiC0BSG3IEhqEsv/3H/iD7FtgFZwfSRTdMtAjF0B zQrt6n6NgGsmUpasq8b1WjMBiM8dvPaTz+rslA+T02hyxWTS1d6jPfbLTIGECiuNZYoDOtnDlgOdC VsMQjgkVfIAUMbol9JWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjex-00AZqo-Dk; Mon, 16 May 2022 22:57:52 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqje6-00AZIW-GC for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:03 +0000 Received: by mail-il1-x136.google.com with SMTP id f9so1820857ils.7 for ; Mon, 16 May 2022 15:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cpRV3Wk55836kFETyr3P+oiMpdiGkRAymJ30pnxlc/A=; b=QWDky+6aYSWTOwbaXHfQ0qh88ZnwyW0nlRYt7AFIGi+pr/O7HtcDIZJoUwY2uQliu9 5DAnS8pAk7ltR19hsFx8xD11J2e9C34b2EjKu7G6GZifsv++3x/PCoYhmSfc/jI82CXO JUEUoEtDBZ7pN9W2qjVFdRQisajSDDRF9gBcGxncCVHpLUX9MVMMQrf7oBR96vEAgw3v G1Vvu/OQQjiiWdQZCJFaUgvE5rJQOlDtXzKaHx5ANWL3e16JKqk/EXa4Id3glwwNsY4o WuevVJX9Rtx87k0vFCNdiF7BW2MjYUmONfgUNWzT6G14Gl158geu3MfQqxnhhv8rS5mn OMsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cpRV3Wk55836kFETyr3P+oiMpdiGkRAymJ30pnxlc/A=; b=PUkD+qZ2HzFYJnxOpO8L5d1fjMxAFpLkKePjnztd89lJUqRBpuq1rNdqB3kUKbqZMr bc69PO3rwuuXZiet3MAcRoUWl8Hrj/3l7e7PPry5wDtE3K8v2XWtuezm+jtMZHv6gwXN mvgLzCOISb/Gd2ux7s9H3dfrW48osE6tWdqFmJRDZzRtm325ol1WZdilm+Hloe6BgQ+t yqtIAFWhhF0PKA2ipJc9I5zqbcRHDS96QQPRlWgXkAfRuDX4Rhr2nOyYlJrnzEppdrlz wxgv5P3b0/ejX3Pg0LsPl0Ff007zFoy0vJ6FVmDjDW9r85oN22NkbcsrhuJjRFso/HKd XjPA== X-Gm-Message-State: AOAM533LE/WqZ+8T9YJex8b3DZUbE5aLwweBEyglIVPjel1vEwL03yTl jJcrDPYg5Wn68LeZVyK0GZ4= X-Google-Smtp-Source: ABdhPJxZQnf4PMb/pE6aahB0jrFIkVLr5qLnxheVKq6wugGMIzNly4UwftUMV/XycUHdiBmfQ/0yIQ== X-Received: by 2002:a05:6e02:190c:b0:2cf:31b2:b0f7 with SMTP id w12-20020a056e02190c00b002cf31b2b0f7mr10351042ilu.46.1652741816349; Mon, 16 May 2022 15:56:56 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:56:55 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com, Jason Baron Subject: [PATCH v2 01/27] dyndbg: fix static_branch manipulation Date: Mon, 16 May 2022 16:56:14 -0600 Message-Id: <20220516225640.3102269-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155658_624732_DEA44854 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In 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 Signed-off-by: Jim Cromie Acked-by: Jason Baron --- .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 Mon May 16 22:56: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: 12851573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 843B2C433EF for ; Mon, 16 May 2022 23:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1DtCfIbQA3BgX0qeigNR4hbXppeKu6cnTmPZ73OsG1k=; b=SB7UaJ8UIbmptC n3lD1JFxid2iPWZmUmYRVCTZ3xeuJwMo2cJTbwtu1OjypDlNe3jgDeE56+w/1JVsNl+mFAAUxRO2y jz4f6Ijm/x++A0CATQyJC+X4jxQfQMYtlHEDtqtJVsWXzznFM3+k9tRy9//CeLpsd2o1UVUw/0/ia rXF9PvrVSPo2Z9dLGpQHpzrtzGXMNBj6xaMCIfQ/i9tOIAMRN1/tEKTZR/8xwaIZrHP4aswKdP2ka 0ykxNbJfCE/JjJBgceZgQwGg4bzbVKpA9+OIDbqHp/u97eHgefCVi05FO79gUAHvbypb66vGIQRNq EzY5Epeg7q8xJhBY3tDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjgD-00Aagn-6E; Mon, 16 May 2022 22:59:09 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeB-00AZKW-Ha for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:06 +0000 Received: by mail-il1-x135.google.com with SMTP id l15so11555352ilh.3 for ; Mon, 16 May 2022 15:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0q2zph1ZCXFs7WKRxPFWrSWi15W02opZe3T7QJQ5ap4=; b=D+2Nl0pQxEGTDTo5NEF/KAytSKaLe4sJXJOvqpnRcVc/IZnyy0W1wMyiITHglFfU+S pmgMHonBN1r0D+h6EVslkidi/tGcgNxCrfkplfoHiLHtENqxSaHXpEOV0hmlGsFAL1gy WMxhbfMRHDPmJQ/ima0D6KrMxyMEU/NPxcGgdV7u6BIi/1NfRuMaCWvgJ8b98Hsi8aaP 1/xNeEJKp2IotfVLQl30vHtClfiO0oBvomhf8Ch3ixkoss6Uu0JBJpVSpnl0gqlMhNEp cIX+I7Q981LaG/iyCIs3c9iLX+tz40fiurace8CRPhis2aLMQuPPHB3Us22EtfY/w7TJ OiwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0q2zph1ZCXFs7WKRxPFWrSWi15W02opZe3T7QJQ5ap4=; b=mz/++LTZOxfYvFgro0jTDi90+A3WvPGzhx+u7zKLp+UTiBJ5b7ql4+N0nJUkjo7oFj ffeJPqm2csZv7s7NVx8CYup32mctIM50wV17Go90arH67EPtAnQyhcBpE84H8EETmX51 Nc8LbN54QOWJiZuLm8E/1VA73VFhZ0KmOhl+cJLotmMGmS25BTbyDPC1fGvL9NVQtV4t BGhcHcEV3GSxziI+Ila/ByPX4QeHced/8TZtaHGzXq2K0IvNK7HDKhyYA6+GGiBni3Bg 9CljS8JegnU0RACNr8ATQ9zCLwVyiLltp3NxxVXdsCdGr492acDEBD3Wivqqsd3gG3KG J4xw== X-Gm-Message-State: AOAM531BoDH/qKlvY3ZnTH7YM+UrOzSbbPiSp5feQbDwsKDSMx2KI5DE eWceyW5v4qvIeo84yvg1b5k= X-Google-Smtp-Source: ABdhPJxzuDtDs3r2+Nl0gh2+cAwejD1t+Ts8LpHwPq/tWghODbyudseUdSlIKZM7WeMOEenc8xf2qA== X-Received: by 2002:a05:6e02:1a2f:b0:2d1:2399:dc36 with SMTP id g15-20020a056e021a2f00b002d12399dc36mr3231577ile.12.1652741820481; Mon, 16 May 2022 15:57:00 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:00 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 02/27] dyndbg: show both old and new in change-info Date: Mon, 16 May 2022 16:56:15 -0600 Message-Id: <20220516225640.3102269-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155703_668952_51B4EA31 X-CRM114-Status: GOOD ( 11.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org print "old -> new" flag values in the info("change") message. no functional change. 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..ca2a28f1d51c 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 Mon May 16 22:56: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: 12851574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E185C433F5 for ; Mon, 16 May 2022 23:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FQvPzdDjr1f1xXI6DZptAKEWgX/LVSRMawm5NNhnUkQ=; b=mfZIE404phTu1l kk9fHm95Z6lm+v/vvmlBCHIRFS6pEYqj6W2xqy7dEPt3FKe7tE1vQ5/SlT1HUHPPgR2Lhzhh8ckKg ic8inMUIUx2w/ijd3cx7kGRjPpx3FSJnnCyK2Xe0uSKZT335tyB/uO1Gk4P/RiSraGm4V6RHd/zP7 IcXa9kZbHUMzT4mvHHIIVQxR1lmUp9B4A/ogKZuNMWuYPiVP2rbnVe2RHT4PZ42A+wujL7FIoUr5l Hei5teGCSDIYHNeaBb5hjXkqCt/a8JJ1aKVqZfn3dH5Z2GJ3thVU1OyQEw7w+ulQuWiJ2cPrDt/qO eXPuGoH0iXoTqatP3l/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjgc-00Aasj-QR; Mon, 16 May 2022 22:59:35 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeC-00AZML-Sk for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:08 +0000 Received: by mail-il1-x136.google.com with SMTP id j7so2187998ila.1 for ; Mon, 16 May 2022 15:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PoO/FHr0Tzfzf5P1B6XW1SDDzBeQTtD4lR71J35fVB4=; b=hc4BLkqpCT9R4W4i7l0zefNNlEKY2zz43aOLOytEmIYryaqtFTXD70GWmf0k7ytBSm PJqH1duNIjfaYz/dZu9lsTxRmq5rdkLB7Z5H4aiGjvlDvnq1O/sJxzCKbR9TGOBycAyj YdFdyAGyiRyLaUCLyQnuZUzm7eymIHnN13wrUv+Ew5wXPQxZhXnhhBOfw7exNw7pSQSz XNO3vMkVaXZUdfkfQSkLejRUdXE3fHM5Z8+efXpPJh3fM+yEvN81wzneSgdN2aB6Y8Iy 3gppEV7yEv86QkoDdeYF3eQZNX5wy+pbp41VoYuA9IxX4Md64KSW12G9/JddFlYNgSEn 8HFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PoO/FHr0Tzfzf5P1B6XW1SDDzBeQTtD4lR71J35fVB4=; b=mvI/eYgmcQH70JoA+J6PxP8JaKi5jtlm84qHDk1awnEodZKO6yd8tczKQgkjlfEImU 4+v1IZCkKsNo/Ef7q4MMU1uTdG9EgSNG8K62E6K6s1fnqBKPSkFTdRmmG/z6LplOPgGT qtiYMfvouQ7VTm8BqGxm+d5n0AZX9DIM1PHilLqm8HTGb/8V/+V9EahvUL/O7tWJpOCw +LeQjaCk8z+jQrjUhF05EAU7Y7VVK326PZE/rmhpd+qbHpq3WTu2Ucn2yvofaZJXaWyT 6fj2wcWzXmm5l4t9fK/drWzC4mPqcrQ5TPdpypP2EtXzrWb2eORj7VfkyGBn6+1jiHAE gLbw== X-Gm-Message-State: AOAM533FYStVMj+01q2LtGXYA5FfcVxpiqSUX+kexp/9KAe/gX8edICp 8gFY1on0ip37UJKtipJ1DAQ= X-Google-Smtp-Source: ABdhPJwuNA8eYlVKbPRsQ7MSW422HjHltNMa6MYgzwzBN3oyRsIKn3be980+iuLjBzfHqKn+YxCiwQ== X-Received: by 2002:a05:6e02:216c:b0:2cf:3b9f:72c5 with SMTP id s12-20020a056e02216c00b002cf3b9f72c5mr10013301ilv.225.1652741824045; Mon, 16 May 2022 15:57:04 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:03 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, Rasmus Villemoes Subject: [PATCH v2 03/27] dyndbg: fix module.dyndbg handling Date: Mon, 16 May 2022 16:56:16 -0600 Message-Id: <20220516225640.3102269-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155705_014838_08139E42 X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, see below), or ignored because dyndbg allows its no-effect use on non-dyndbg builds. That said, the code has an explicit feedback message, which should be issued accurately. Fix with strcmp, for exact param-name match. Here is fixed behavior: bash-5.1# modprobe drm dyndbgJUNK [ 20.127473] drm: unknown parameter 'dyndbgJUNK' ignored [ 20.128835] ACPI: bus type drm_connector registered bash-5.1# rmmod drm [ 37.961656] ACPI: bus type drm_connector unregistered bash-5.1# modprobe drm dyndbg [ 42.933220] dyndbg param is supported only in CONFIG_DYNAMIC_DEBUG builds [ 42.937484] ACPI: bus type drm_connector registered Reported-by: Rasmus Villemoes 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 Mon May 16 22:56: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: 12851576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 900C3C433F5 for ; Mon, 16 May 2022 23:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RSceFFknZS2GPaRlG3BaI5KOXPs3jKiPXWlOE8wbuf8=; b=1/7Y2rfdy5A37j BSus7xGw+OVXyVBO1YZjtoRlOBfmI0fhPjwREAxgp0oU+D7KE7mGdTRJSWBjg8ydqay1C6rVa6Xr8 nB2GjzYwd++AkQw52UGJqFnzdwlgwVXFhng2Es6TTaVVlzQoCdiWT+MfDyJDItPKLfg4ALFcMHfCL Kz6Mxxx+GdnF0bJdfU8UBqOTwwvWJsfRv8lAbaG8zdLsD85upzX//VK6kKB1CEy+GiLtLeYtjl6jR ujBIapmNUlkpWiHQXlKS4QDzp9gRRMakIogQSWk0Z3nvY0wXBGmHerl774y2kG5Ttg+kyyZGfhM0P ptYISERq5SbDQNIem8Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjhW-00AbJ5-9g; Mon, 16 May 2022 23:00:30 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeF-00AZNW-7m for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:10 +0000 Received: by mail-il1-x132.google.com with SMTP id s6so6758279ilp.9 for ; Mon, 16 May 2022 15:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JnVwspe5uVckeO1htOV0stxvFuwasrGdrVlM7tfSrfg=; b=OuCUf4sb69edJrEZ0gKdZzUlEGkHa8dxOXluIHFfd6mv5ISx7ldIjhYAFFNn02Uw07 MObKaGN8fpxZnvPpJGBIwCuIiuR9IyeS7iH1uxXj/jhLQGhcfat661+qgzEFktP5seY8 GiaibvoJ532MURzfeqBgThog2fe9DLO4A2hVL/DOhn/6IFDp+oBelBemRUpy55N0zLqI zER5IPos8OFUfpDFENsaqh+ouoKsLIvtcyA+eImWseUCcwepToR1grw0WW/uysyVvaIv 1eJO5nP+NFljczTz12OqQvUpG1AJSUX1UZQUh7+ic0iZgws4hnpW+TgwNJvS24y6rqno m2mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JnVwspe5uVckeO1htOV0stxvFuwasrGdrVlM7tfSrfg=; b=T6Gc5OHpOWGpSr7V9tYb4bqwin2xV/ZoRKvdrXFVQNcG+9tDPXwj1qsXjutSGvtJZK reWltZD8fBtUPAtxr/kEYkP1mCupQ5HTCKy2QTQFOkv1I12HoFrFXM3NgMBhIq2ExKbA OjrMmgkFL39M8+UDF078XS/bRoykLaGMGuRi9aaqy7U/YFoOybSQy2F54cO4i3LzkjR+ gGVFwO9pc2VfDettIa4iV7eI4dqEb+px/7bvP5upF8l3HhFCjwapRzUOTMhc3qK+XlV9 KwA29gfZ1dVnJ1fpuljpiuIercxDEeFRrPvWIa8P9DafL5/KjORidzvNS18NWzNnoLiS W92Q== X-Gm-Message-State: AOAM531vo0SdBAFPCUHsrBwv9XNoLjRAAlaH4Myg3REz2WzH7ZeBN5Oo YjKYk1srhQsz66xMF0e9pcY= X-Google-Smtp-Source: ABdhPJxwTzocvNIWCrH3mXf/01/smRYYOyx0fBIce2z2QYjkxLZMX7EQwEEWdjIctASlFEwNKAFkXw== X-Received: by 2002:a05:6e02:16cf:b0:2cf:8ecb:c8d4 with SMTP id 15-20020a056e0216cf00b002cf8ecbc8d4mr10064349ilx.174.1652741825259; Mon, 16 May 2022 15:57:05 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:04 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 04/27] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Mon, 16 May 2022 16:56:17 -0600 Message-Id: <20220516225640.3102269-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155707_378874_4ADAAF21 X-CRM114-Status: GOOD ( 12.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This exported fn is unused, and is effectively obsoleted by a forthcoming commit, so remove it. The export was added to let drm control pr_debugs, as part of using them to avoid drm_debug_enabled overheads. But following patches implement the drm.debug interface, and adapt drm to just use it, so nobody will never need the export. This also drops the CONFIG_DYNAMIC_DEBUG=N stub-func, and its pr_warn(), which I avoided in 2012, then added in 2020 :-/ Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()") Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 8 -------- lib/dynamic_debug.c | 29 ----------------------------- 2 files changed, 37 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f30b01aa9fa4..dd20e825c36f 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,11 +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 */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ca2a28f1d51c..cdc0b03b1148 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -555,35 +555,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 Mon May 16 22:56: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: 12851575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A854C433EF for ; Mon, 16 May 2022 23:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sdeAOpeBTWBOt4cVx7LLK/GeZW83+shMI6t/IOT+uE0=; b=qvzonRMb5tQb/N A2v47MPST0a+tkaRv9uv8ZspEXrz3c5Y7+yYIG8LJj9BW3KUH0hnAOm3xzdlY3exPwXUYq/K6nmIq WO/cn8pIeG+JgK3sfir5kovHdvmUw6UJobwsl/DShXidKNGuFg4zOBexy/zEXnxY59sv0T3GPGhMr IJ9EPUff0+9iMhyzkLlNS89FRhcK1vg8/hjNScfz/JGB+WrZ+qYfHwYBr392us/yHuYCqBIpsLKzp fGA1mB0DsOyYZZIi7U3rDP5demiJBtaXIY13UzMn9yfMUk/orRc9AVW/AA9rWpHZ/4h2E1u1CcJMh +dxiRNY1ORFVpvNHq7mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjhE-00AbBC-7h; Mon, 16 May 2022 23:00:12 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeE-00AZIW-Se for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:10 +0000 Received: by mail-il1-x136.google.com with SMTP id f9so1820857ils.7 for ; Mon, 16 May 2022 15:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sVz4wSplNYJeolwmkIVwQxuaib3U9PeK8r0DMH1HXak=; b=qlRr9o9J1iRZDGev3s2XHIkpyzd5BVBjqJHfyArjLKIkA6l/fdX3cZMJaMltlMTQ6r Fa61jz1uE9GoYUzI9zlpVvrRi1c4utEKzH4piW8YUY86QvxmKYMKlC5V6uY4KieYffKH 9hfuNb9TnBon+k3vVD1XkckDvPEwq2Hu0AQ0NwcVFhYdwBTVApu+O3SEyUwcPbQ5d3da gqmI6X3zkGqfgKADBJIJVIGiQYEucBuhXqvEWuOr//JtOP7xKfm+K0h56awHXx9iCd+5 qv+OR8qwvCmuTADk7Wx2tJpMX50dxMM8nDYUNlINe2k88Ou25kniQC/eRHTBHjMvcyKJ Yvyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVz4wSplNYJeolwmkIVwQxuaib3U9PeK8r0DMH1HXak=; b=mEklqqVg9PG/HhyafJusTg62vt4y77Htkm16l6UCqWfXsw7ttjgHOCOdE699rUZCyV ahM/O7b8mehS89I2qJcQNP8m+vRML6HYa5aG1my4gS0FmVpgfVatzh6gUecO/hBkQYoS hhaWtzEEFKY0Vkh/FEDsqlVBB0FsbLOA9rGuOl6syqu1ELb+J52Awn/21iZYYf2cFHn+ 30yiKKiWNQx1ZKNVlUHtn9e33I2xEoxGDqCtx02vDlmDqTPiYV1SZGBwlFLmLQcwxTTp 1eOqhci+84xbrsm3Lncz31mPu8vFU3slQtkcjO+jB4LqI2eyTMkek96UzIditW+h4OHO w8AA== X-Gm-Message-State: AOAM532qCZA9leLB6ZHaVqI8LNvN+4nl5Ji3E2mGmj3fv7n672IOKXr3 /qsMo/4eNLqMIY8NCWGzWLA= X-Google-Smtp-Source: ABdhPJwySl7MUlvXnA+IuDsilswY5WzP4U30CtwupLL4X9+oOZEmW9Rz64np3jYs/BwYTq/QGzQdyg== X-Received: by 2002:a05:6e02:1c81:b0:2d1:3971:9343 with SMTP id w1-20020a056e021c8100b002d139719343mr297731ill.237.1652741826539; Mon, 16 May 2022 15:57:06 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:06 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 05/27] dyndbg: add exclusive class_id to pr_debug callsites Date: Mon, 16 May 2022 16:56:18 -0600 Message-Id: <20220516225640.3102269-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155707_019141_FFA9F1B7 X-CRM114-Status: GOOD ( 17.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DRM issues ~10 exclusive categories of debug messages; to represent this directly in dyndbg, add a new field: struct _ddebug.class_id:5. We only need 4 bits for drm, and with that reserved, we have 2 to spare on 32 bit builds; lets take one extra (5 bits total), and keep a spare bit. 32 classes-per-bitmap is a practical usability limit anyway with a bitmap interface: #> echo 0x012345678 > /sys/module/drm/parameters/debug All existing callsites are initialized with _DPRINTK_CLASS_DFLT, which is 2^5-1. This reserves 0-30 for use in new categorized/class'd pr_debugs, which fits perfectly with natural enums (ints: 0..N). To achieve this, DEFINE_DYNAMIC_DEBUG_METADATA_CLS(cls,...) is added, and DEFINE_DYNAMIC_DEBUG_METADATA is altered to call it with the default. The factory macro chain between there and pr_debug is adjusted similarly. No behavior change. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 54 ++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dd20e825c36f..39550fefcf0f 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 5 + 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 @@ -84,7 +89,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, \ @@ -93,8 +98,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 @@ -125,18 +136,26 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #endif /* CONFIG_JUMP_LABEL */ -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) + +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(id, _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) + /* * "Factory macro" for generating a call to func, guarded by a * DYNAMIC_DEBUG_BRANCH. The dynamic debug descriptor will be @@ -145,15 +164,24 @@ 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_no_desc_cls(fmt, cat, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), cat, \ + fmt, func, ##__VA_ARGS__) + +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + __dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), \ + _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) #define dynamic_pr_debug(fmt, ...) \ _dynamic_func_call(fmt, __dynamic_pr_debug, \ From patchwork Mon May 16 22:56: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: 12851653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 359BCC433F5 for ; Mon, 16 May 2022 23:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mtBMvKl/XXHk6Uckx62ixvCUwu69g70COiOmGdcXd7U=; b=UCtQlwPROhas4q pvo16AVY1YuibYlA9Stbzsk+YSEeF+X7WS4IIZoaHC4hSKhuQYX8hCNnz2OKGveK8KR5tL9VrR9iP 2nPRRvc0qBu0CRQDsFxwY35ky7La68a7gGXcR246RN4yeNpApqMRQdv21HkrlMedMj/8kxLoJbdQ0 8DaRAnzzl3klYJWw2MBsQ+5vCJ35uFyBOmwoh1WzvmLhPLUDAwE6/PWufG22tyJpWBO8ZJDusITmI TWWoIx+nFKg+2GLsn97kXneQ82cW7m3LEePBmlYxVUzUapNiDU+WcLPnZTHAmBAi8Ig8HGEzy/X6M NpzBAyRPU6nIZrxwttdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjjO-00AcFR-92; Mon, 16 May 2022 23:02:27 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeK-00AZPD-Gb for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:15 +0000 Received: by mail-il1-x12a.google.com with SMTP id j7so2188063ila.1 for ; Mon, 16 May 2022 15:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FCcwbojewkLsQYvkUKvi9ZnuSdibkB/9h3rl9AlklQ0=; b=BeGrZc1yYBGXRQAvCajroJY45Q74LlURa0Ayje5jv28R3leJsPJbbYx/29IHtflt0j snhm4cXg8IF3NJ9cpM7XtI9fLxm4NYgdEPjk4txQ8yQVjk2+O7jljjqETHuZUwtJDsm5 xWAXYRuk38aNOHxOcKllwLmeH+zvd7FACklgZhNSsZ79osTKBjvhiXgVclwoZqc2bpjE yelTlxzX/Ql/41MYJXeVU+/+QDchf/5JfDBfBDt4HwmxBYj1dPE0ut/Ixz0jldDIZRKo 1zhjm7O4XnQNVRj1apdu3bYwT5J19T4lgLOKFIY25c2+q1MCCblGLIfqkzd5MTcbODwR soNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FCcwbojewkLsQYvkUKvi9ZnuSdibkB/9h3rl9AlklQ0=; b=F9uXD7v2qteHbub1w4ogFZ3ltEKy8tvhDeRoOaR03kPKsNieUjCQ2ZpnOR1bZlaMub WoG6tqNe6GZyhpujGuk41+/+K60j1YcNeNSapLSgFgWezp/+CNMP7seo3fJAQXGe8dwZ WvlMo7cf73PS8zmcoezs/otIe/ySUDuoZV00JnPXgD7W55qv4GW8rXQj7lrrSd8nLt1u QWTJUjNNIEyU/qKLvln1TzfM3ZvPS+CInlRgKihCE5BBtXvGTXT9ilm7o66DYUzteW4U /HbkEFw4rfZXONmmnj4Myho6XMtpXyrrYVfVjU7eLGVHilYR07Z9Rfx0iOxdN/D2p4Lt 2YgA== X-Gm-Message-State: AOAM531tknfwn6vb18h8vBbg5MH+2JTE32+Z/Lo0h/k+JZXp2GEJuVoh ncd0ZboDuxu6gmsSl3w7ZGU= X-Google-Smtp-Source: ABdhPJxVb768sz14W3aG69KflgqJ0KKyFVj6N0LZ3gnkCyX1Snc1VgNcUxaQiUqGSGOvtt6QMgsJEA== X-Received: by 2002:a05:6e02:1187:b0:2cd:9df5:bfd2 with SMTP id y7-20020a056e02118700b002cd9df5bfd2mr11169744ili.121.1652741827704; Mon, 16 May 2022 15:57:07 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:07 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 06/27] dyndbg: add dynamic_debug_(un)register_classes Date: Mon, 16 May 2022 16:56:19 -0600 Message-Id: <20220516225640.3102269-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155712_645214_EFA6AF73 X-CRM114-Status: GOOD ( 21.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add dynamic_debug_register_classes() to API, allowing user modules (builtin and loadable) to register class_names for the .class_id's they are using. Knowing classes is 1st step to validating with them. Add dynamic_debug_unregister_classes() also. Add struct ddebug_known_classes_map: maps known class_name strings to .class_id[0..N], where N<31. .base allows sharing of that range. A wrapper macro: DYNAMIC_DEBUG_CLASSES(_var, _modmatch, _base, classes) defines and initializes that struct var, _maybe_unused is added so the decl doesn't draw warnings when dyndbg is not enabled; a small list of classnames is tolerable wasted space. _var: user passes this into dynamic_debug_register_classes(var). _base: usually 0, it allows splitting 31 classes into subranges, so that multiple sysfs-nodes can share the module's class-id space. classes: list of strings with classnames, mapped to class-id=idx(+_base) mod_name: KBUILD_MODNAME, available for builtins, loadables mod: ref to loadable module. allows ==, distinguishing loadables. When modules register known classnames, they opt-in to permit dyndbg to allow "class " queries to manipulate their class'd pr_debugs (if any), default class_id pr_debugs are still controllable as before. dynamic_debug_register_classes(&map) finds the module's ddebug_table record, and attaches the map to it. This makes it available to ddebug_change(), which will use it to validate class'd commands. Sharing class-names across multiple modules is how those modules coordinate; all drm* and drivers would respond to: #> echo class DRM_UT_CORE +p > /proc/dynamic_debug/control Therefore no class-name uniqueness check is useful. TODO: Eventually we need a list of registered classes, not just the zero-or-one implemented here. This will support multiple sysfs-nodes, one each for print-to-syslog, print-to-tracefs, or subranges using _base. Signed-off-by: Jim Cromie --- . fix register_classes() for !CONFIG_MODULES . add maybe-unused to var decl in DYNAMIC_DEBUG_CLASSES . kdoc for DYNAMIC_DEBUG_CLASSES . add dynamic_debug_unregister_classes --- include/linux/dynamic_debug.h | 36 ++++++++++++++++++++++++ lib/dynamic_debug.c | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 39550fefcf0f..328722ba2d8e 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -56,6 +56,34 @@ struct _ddebug { #endif } __attribute__((aligned(8))); +struct ddebug_known_classes_map { + struct list_head link; + struct module *mod; + const char *mod_name; /* needed for builtins */ + const int base; /* index of 1st .class_id, allows split/shared space */ + const int length; + const char *classes[]; /* index maps .class_id */ +}; + +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype)) +/** + * DYNAMIC_DEBUG_CLASSES - declare classnames known by a module + * @_var: passed to dynamic_debug_register_classes(_var) + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names known/used by of .class_ids[_base.._base+length] + * + * @classes specifies names for the classids used by a module; dyndbg + * accepts "class " commands if is known and registered. + */ +#define DYNAMIC_DEBUG_CLASSES(_var, _base, ...) \ + static __maybe_unused struct ddebug_known_classes_map _var = { \ + .mod = THIS_MODULE, \ + .mod_name = KBUILD_MODNAME, \ + .base = _base, \ + .length = NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .classes = { __VA_ARGS__ } \ + } #if defined(CONFIG_DYNAMIC_DEBUG_CORE) @@ -206,6 +234,9 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +int dynamic_debug_register_classes(struct ddebug_known_classes_map *map); +void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include @@ -247,6 +278,11 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, } while (0) +static inline int dynamic_debug_register_classes(const struct ddebug_known_classes_map *map) +{ return 0; } +static inline void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map) +{} + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index cdc0b03b1148..8f600c13048a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,6 +45,8 @@ extern struct _ddebug __stop___dyndbg[]; struct ddebug_table { struct list_head link; const char *mod_name; + /* a module can have multiple class-sets eventually, but not yet */ + struct ddebug_known_classes_map const *map; unsigned int num_ddebugs; struct _ddebug *ddebugs; }; @@ -916,6 +918,57 @@ static const struct proc_ops proc_fops = { .proc_write = ddebug_proc_write }; +/** + * dynamic_debug_register_classes - register a module's known classes + * @map: &struct ddebug_known_classes_map + * + * modules using non-default pr_debug.class_id's should call this to + * inform dyndbg which classes they use (0..N), and what their + * classnames are. They are then usable in ```echo $cmd >control``` + */ +int dynamic_debug_register_classes(struct ddebug_known_classes_map *map) +{ + struct ddebug_table *dt; + int rc = -ENOENT; + + mutex_lock(&ddebug_lock); +#ifdef CONFIG_MODULES + if (map->mod) { + /* loadable module */ + list_for_each_entry(dt, &ddebug_tables, link) { + if (dt->mod_name == map->mod->name) { + rc = 0; + dt->map = map; + break; + } + } + } +#endif + if (!map->mod) { + /* builtin module */ + list_for_each_entry(dt, &ddebug_tables, link) { + if (!strcmp(dt->mod_name, map->mod_name)) { + rc = 0; + dt->map = map; + break; + } + } + } + mutex_unlock(&ddebug_lock); + if (rc) + pr_warn("register_classes: module %s not found\n", map->mod_name); + else + vpr_info("register_classes: %s\n", map->mod_name); + + return rc; +} +EXPORT_SYMBOL(dynamic_debug_register_classes); + +void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map) +{ + vpr_info("unregister_classes: %s\n", map->mod_name); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. From patchwork Mon May 16 22:56: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: 12851652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B46BC433EF for ; Mon, 16 May 2022 23:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ow/dE+fEIexUXUcXcFSgCMJSzjExS2dwUoQqPtbnVzw=; b=d1JHsISWtS8AyZ 3UURkbt7d3tY7hko8R6C2auG0dOn2z8Jb++SqhweSBcUJ9YyLDDh8ojNUgyTU7e2Cj33MvzHY6b8R rA10ZOgYOxHQDFMreXu2nkzO0nGDOqy8yNQqiFCNRpRTT04FHRZ3t/aGnRmqJyUIZbIVNElPzo44q JZUQIaWC1ykdtE9hOC0KvAiwly1ZauY4djlnzN/HKluWlH1hVhPf5W84yb7ZV41zAcJxs0p1vpLQE mnPTpWsSc8bJdul1F3H/Xf9ZZ2XqZNJsSOfRkcuDdImdpjDWjoC0410hRhE/g3XALT4j+liCnByz1 TdNjeHM0+6Kuoue3gXYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjiw-00Ac1u-F8; Mon, 16 May 2022 23:01:58 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeK-00AZPv-8f for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:15 +0000 Received: by mail-io1-xd2f.google.com with SMTP id z26so17596348iot.8 for ; Mon, 16 May 2022 15:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oowxXNKCjHWnLn3p6Ic/6Uo3PByaWnVU9pS3Z8uXSpQ=; b=laqZYh+7BRG4JmqbTRUuBXSeJoX3qpeXSKyN4W6lB9YEap+oHbdDxololCguGAMh5j nHo+iMbV1KgWacmGr6OLitd9c+OJnO/2tWVL5454+sTXI5fwoIeNvVDZP+BTxyk5yGlH ZjrvfoQIdRrFxg9V0mySCwKU+ZLqJSv6aNnoGqrEzRufoLC8tKnYJtycpQMjFWGmDDr3 XyoPA0hWE6dcKb4E22Yos6Ma/DhT6NxLI9xKOdKQ8d4wyL2WZgmmBqcUF5zLa+EHROcJ OQLF0z+uPf11CatazTyEpY+D3XSh3bsCN33how5DTmDELfXhYvgRWRLTGHM4+RVfuC7n KmeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oowxXNKCjHWnLn3p6Ic/6Uo3PByaWnVU9pS3Z8uXSpQ=; b=IYJ8hQVL/uPn1AMhAe+Meu9X251DL4wFjXO0fn3R8ji457h24pWD2kVovukJhspWeL +lnLysXn359dteU06+itcebWtTOFz2JS4CvNcmDaUJkSmPh0I59sW6xoGnWQai5sBRo8 GvDYFH5rNm8xCm9/orsyU7ZiErydkvsRsgk3+vpzQA/DsocIaly/t0SjACe/Qf+gGwMu 0Ig+XqnYsuFiYzmumhOVvfbJ9X2hAdRnJ/5Rs62+Boy+OIZg4qfDl7ADWUOhtK4Lsrqq hbV2SE+K4Em9WA9bNxamhkOK7QtbonM6VKhgcrWFmyVNkdcdM/0OtSH7P8kQvT2v0T0J bNGg== X-Gm-Message-State: AOAM532KMYxzo2S55vylKct7HAfEpyG+us1VbB7sC47UiT8JePF7rCR8 3eXRHdRZq2JBVzbV3z4ZxE4= X-Google-Smtp-Source: ABdhPJwp2CUlJ62GPweaP9pCG2DJx2i+qE3mjO0+Bwn7/YiIM+8Fh1IYWcLxvILiLSzZdTx4mDun4g== X-Received: by 2002:a05:6638:504:b0:32e:55a0:dee9 with SMTP id i4-20020a056638050400b0032e55a0dee9mr162907jar.82.1652741828844; Mon, 16 May 2022 15:57:08 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:08 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 07/27] dyndbg: validate class FOO on module Date: Mon, 16 May 2022 16:56:20 -0600 Message-Id: <20220516225640.3102269-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155712_388524_27B3786E X-CRM114-Status: GOOD ( 22.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add module-to-class validation, in #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control If a query has "class FOO", ddebug_validate_classname (called from ddebug_change) requires that FOO is known to module X, otherwize X is skipped entirely. The 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). Ignoring a bad query, with dynamic_debug.verbose=3: (lots of modules will not know other module's classes) bash-5.1# echo module drm class FOO +p > /proc/dynamic_debug/control [ 54.507983] dyndbg: read 24 bytes from userspace [ 54.509549] dyndbg: query 0: "module drm class FOO +p" mod:* [ 54.511502] dyndbg: split into words: "module" "drm" "class" "FOO" "+p" [ 54.513672] dyndbg: op='+' [ 54.514575] dyndbg: flags=0x1 [ 54.515547] dyndbg: *flagsp=0x1 *maskp=0xffffffff [ 54.517112] dyndbg: parsed: func="" file="" module="drm" format="" lineno=0-0 class=FOO [ 54.519707] dyndbg: class: drm.FOO unknown [ 54.521302] dyndbg: no matches for query [ 54.522581] dyndbg: no-match: func="" file="" module="drm" format="" lineno=0-0 class=FOO [ 54.525236] dyndbg: processed 1 queries, with 0 matches, 0 errs Also add a new column to control-file output, displaying the class-name when its not default. If a module has pr_debugs with non-default .class_id's, and has not registered them, "" is issued. Signed-off-by: Jim Cromie --- . split out validate_classnames() --- lib/dynamic_debug.c | 70 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8f600c13048a..b1aaf8893cdf 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,13 +137,40 @@ 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); +} + +/* return <0 if class-name is unknown/invalid, 0..CLASS_DFLT otherwise */ +static int ddebug_validate_classname(struct ddebug_table *dt, const char *class_string) +{ + int query_class = -ENOENT; + int idx; + + if (!class_string) + /* all queries w/o class given work only on default class */ + return _DPRINTK_CLASS_DFLT; + + /* + * XXX single list will need to be a for-list + * so that modules can have 2 sets of class-decls + */ + if (!dt->map) + return -ENOENT; + + idx = match_string(dt->map->classes, dt->map->length, class_string); + if (idx < 0) { + v3pr_info("class: %s.%s unknown\n", dt->mod_name, class_string); + return -ENOENT; + } + query_class = idx + dt->map->base; + + return query_class; } /* @@ -159,6 +187,7 @@ static int ddebug_change(const struct ddebug_query *query, unsigned int newflags; unsigned int nfound = 0; struct flagsbuf fbuf, nbuf; + int query_class; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -169,9 +198,18 @@ static int ddebug_change(const struct ddebug_query *query, !match_wildcard(query->module, dt->mod_name)) continue; + /* validate class-string against module's known classes */ + query_class = ddebug_validate_classname(dt, query->class_string); + if (query_class < 0) + continue; + for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; + /* match against query-class, either valid input or default */ + if (query_class != dp->class_id) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -424,6 +462,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; @@ -851,6 +891,13 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) return dp; } +static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) +{ + if (iter->table->map) + return iter->table->map->classes[dp->class_id]; + return NULL; +} + /* * Seq_ops show method. Called several times within a read() * call from userspace, with ddebug_lock held. Formats the @@ -862,6 +909,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, @@ -874,7 +922,13 @@ static int ddebug_proc_show(struct seq_file *m, void *p) iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape(m, dp->format, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id != _DPRINTK_CLASS_DFLT) { + class = ddebug_class_name(iter, dp); + seq_printf(m, " class:%s", class ?: ""); + } + seq_puts(m, "\n"); return 0; } From patchwork Mon May 16 22:56: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: 12851651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 795EDC433F5 for ; Mon, 16 May 2022 23:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gwF8fJCZJ5OmBHLnf3TM1jhYT889adWz+OiVGpt1+To=; b=eUCSXgzEDWAzKe kRKUwQxiUn4ZcRHTv6qRhgguWYG4mYk5XU/i6SxRuxIdpppELXjDOPa2gRE482gOJ8uXkh6xRdcUs S0ez5T1IbGbWdfwdhcPK974xODxGWm+WpAB6+Mm10SQ87DwmH4Nducxpx3jT2pKr513V9ZqSzuu0G LH90T3iKbHgzxsFys76lvIWldgS61YLmTxC+81cg034WJXT+4suYPKvR5EbhOINmHYI2IN3IJl5fA gQlHzyhDkCi5gk6J24bB19R9Ki+74FF/K7NS2fy4aGl2547+xvoHB32X5iT+r1HbAo2M7JIJl0K26 QB+NN0Pz/mW03uQ66qgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjiN-00Abln-QI; Mon, 16 May 2022 23:01:23 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeK-00AZRf-Ca for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:15 +0000 Received: by mail-io1-xd2f.google.com with SMTP id o190so17590403iof.10 for ; Mon, 16 May 2022 15:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EljbVfMm3ciorUPWk1+p+ks3bn6Qsh0+zX8r/PPo110=; b=Zdi6HWiwDP4t/No+bs8ZyQ+N6pXEumJ8NOvdkpl8c7j45sWwNOx/N8YlJOrgh9/AnP jbDGDpSx7JCHW8cYg5WF30gpG6shFX1ivEnpEf2UuujAylh3b6gDRdkEzf6OXyNH1nGz oc6eGN/CFum1i5KegUfrxV3DabV+GkFEGzawTo2UMfGtMG/52Ky1CVrf5I85mF0/+LVq Ug0fEIUyeHdzXmn4xrZOZ12NeGkpxV1FRlRu4pPc1qBuvVl0d6pSsn4YB0WCjF1Rheda u3Sz+WAgW4cfIx6RAiv0exAi23+vfYevTZ0T1wKxm5KJ+IMmwtVS7CLTCZgyulzIILa2 Mr4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EljbVfMm3ciorUPWk1+p+ks3bn6Qsh0+zX8r/PPo110=; b=pLFi1MT8KcPUwNghhzQTaA4Aoxax2YxEXEsA0E6jgxAaL+SM0dV9Tcm1b8GeHdtSY4 rD6UrCu59ZbftVyEDla8SJ0mf6eClhwPOP/2Jvz31U3X4UVtEdmGF6FY8hDtLx0r/BC8 ZKrjHJXIhc6J7LJl9hDUYZLEIx2NSiWkKzMoqb2V88ZwEiiMGmZ4sKM5B+YuAEa5s1Ba 5xlYci+VLuzq1L/DxjjUrSAf1m+U0+DQFnzqH4Tj85Gx7Qx61XyvKvLLbc49Zj0e3DnB w3aHo3zD4ygOnu7WvfCJ8yEX2jStK4gJNmiEhkR1/shQ9SIyAnbnMUlkWwqCOcb+9kbC FJ8g== X-Gm-Message-State: AOAM533NTNpE9mPgsVKzhBcVToMhSJzxM15/crbX5k/QM75mKpgJTfcW 7eX9iBUQEvbvI5IKi1oajHg= X-Google-Smtp-Source: ABdhPJy0hsQfe0cbLe0hTQSf/uMXvISVb4yJrfO0/vky8EKFsXcYrjczUoYfNneLC90q6wNVKqC07Q== X-Received: by 2002:a05:6638:405:b0:32e:586:8803 with SMTP id q5-20020a056638040500b0032e05868803mr8944685jap.157.1652741830163; Mon, 16 May 2022 15:57:10 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:09 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 08/27] dyndbg: add drm.debug style bitmap support Date: Mon, 16 May 2022 16:56:21 -0600 Message-Id: <20220516225640.3102269-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155712_521348_D571550A X-CRM114-Status: GOOD ( 18.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add kernel_param_ops and callbacks to implement a bitmap in a sysfs-node. 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. get/set use an augmented kernel_param; the arg refs a new struct dyndbg_classes_param, initialized by the macro, containing: BITS: a pointer to the user module's ulong holding the bits/state. By ref'g the client's bit-state, we coordinate with existing code that uses it, so it works unchanged; for example drm_debug_enabled(). The change to ulong allows use of BIT() etc. FLAGS: dyndbg.flags toggled by bit-changes. Usually just "p". MAP: a pointer to struct ddebug_known_classes, which maps those class-names to pr_debug.class_ids 0..N. Using the sys-node, with dynamic_debug.verbose=1: bash-5.1# echo 1 > /sys/module/drm/parameters/debug [ 29.821298] dyndbg: set_dyndbg_classes: new 0x1 current 0x0 [ 29.822841] dyndbg: query 0: "class DRM_UT_CORE +p" mod:* [ 29.824348] dyndbg: no matches for query [ 29.825428] dyndbg: total matches: 0 Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 17 ++++++++ lib/dynamic_debug.c | 81 +++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 328722ba2d8e..e9e6d0f503f3 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -85,6 +85,11 @@ struct ddebug_known_classes_map { .classes = { __VA_ARGS__ } \ } +struct ddebug_classes_bitmap_param { + unsigned long *bits; + char flags[8]; + const struct ddebug_known_classes_map *map; +}; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) @@ -237,6 +242,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, int dynamic_debug_register_classes(struct ddebug_known_classes_map *map); void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map); +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); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include @@ -283,6 +292,14 @@ static inline int dynamic_debug_register_classes(const struct ddebug_known_class static inline void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map) {} +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 b1aaf8893cdf..b67bf9efec07 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -597,6 +597,87 @@ static int ddebug_exec_queries(char *query, const char *modname) return nfound; } +static int do_callback_changes(const struct ddebug_classes_bitmap_param *dcp, + int bitpos, unsigned long *inbits) +{ +#define QUERY_SIZE 128 + char query[QUERY_SIZE]; + int matches; + + snprintf(query, QUERY_SIZE, "class %s %c%s", dcp->map->classes[bitpos], + test_bit(bitpos, inbits) ? '+' : '-', dcp->flags); + + matches = ddebug_exec_queries(query, NULL); + + v2pr_info("bit-%d: %d matches on class:%s\n", bitpos, + matches, dcp->map->classes[bitpos]); + + return matches; +} + +/** + * param_set_dyndbg_classes - bits => categories >control setter + * @instr: string echo>d to sysfs + * @kp: kp->arg has state: bits, map + * + * Enable/disable prdbgs by their "category", as specified in the + * arguments to DEFINE_DYNAMIC_DEBUG_CLASSES. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_classes_bitmap_param *dcp = kp->arg; + unsigned long inbits; + int rc, i, totct = 0; + + if (!dcp || !dcp->map) { + pr_err("set_dyndbg_classes: no bits=>queries map\n"); + return -EINVAL; + } + rc = kstrtoul(instr, 0, &inbits); + if (rc) { + pr_err("set_dyndbg_classes: expecting bits/integer\n"); + return -EINVAL; + } + vpr_info("set_dyndbg_classes: new 0x%lx current 0x%lx\n", inbits, *dcp->bits); + + for (i = 0; i < dcp->map->length; i++) { + + if (test_bit(i, &inbits) == test_bit(i, dcp->bits)) + continue; + + totct += do_callback_changes(dcp, i, &inbits); + } + *dcp->bits = inbits; + vpr_info("total matches: %d\n", 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 bits, underlying prdbg state may have changed since. + * Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ + const struct ddebug_classes_bitmap_param *p = kp->arg; + unsigned long val = *p->bits; + + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", val); +} +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 Mon May 16 22:56: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: 12851577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74754C433FE for ; Mon, 16 May 2022 23:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aKFrNr3Fl2IwJV9WPO6tcZhy9mTo6Fp0IwnSOd4Qpn4=; b=ge+bGX4+rWQD3e cn6/f9CYTOy6/ER/zSml9GitQW3ftGPtNh8WoTDaDuf/+zUy4HEcv6Ipkc6sOFv8dibmJrooEN6vU lYeddUGYllFSH9qLwyG2gDZODVl1Tr90H/9KoijPBlQB6nkzLm3qu2FMpMBhyrJ3id9y0UszvBMzJ WjsZrx1UIa2i70i4cuwPTA5yiRw9jnBQKXq+cZ3vyQHowqnmTRmYGFniQrLOC2oL9r9VWTFU6FQY1 YTtOSik8mNDlMiDWWDM+cPOki1RW+g9yEZ3KXKiiCpMY0ouukuw16dltrN1TWt2/oRlYtJJxNdFsJ Vrc2yWEk7CLGSA6aojEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjhv-00AbWZ-Nf; Mon, 16 May 2022 23:00:56 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeJ-00AZRZ-Vi for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:14 +0000 Received: by mail-io1-xd34.google.com with SMTP id y12so9272761ior.7 for ; Mon, 16 May 2022 15:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MiJjjZdxaha67CSMTI1r0BLom3ol2jA6WSWjlEZ1BTo=; b=j1OPvP3C9jzXimCIyP8PoqRmxw+BRCMFtN3Kc98fXUqazTR8W99pYA0kCZDMXLOLJp +oKyHJsCC6GTmZKC8UHw5tKkI2nbsmIVzY7pic2mn4wdDsjnCh6KCE5yKjVzDgizKEXb V3v9TU4a1CZ0xaEdkmhZV9JCIy/2uJtBGE4KztwXV0xXvP00wJo6EJgx3XrgcmCEjvDB mHakjZoZWxRSjEBcGXCCfFXU5ecCp+sOoXTR/H9XJxden/M+lBntak5Xol5WL17PMKh5 fn6faaYJtp/pPNfh6627Fd/dGtn8PSYKoRU5O5s3eXW0TPxxlmwJGHlpmuBKvnl2hB8Q tu7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MiJjjZdxaha67CSMTI1r0BLom3ol2jA6WSWjlEZ1BTo=; b=hL9As2hKgYwXrsNkIxNLSRqg4tR1sZdKtbB5z/9H4yrfk3almgtqwtivkHb5iGBfhM dCljBxepQgVioFqpEHMXeuPlLjwz78gIa6cnNbhjTFR7xFdFs7m6NroQ6/O4LmkYabl7 IqqD3KeOdlnoUN4NtHbWKTL3ZsWNFebg7q+dm07krnsI589ufQQfCI9Z9jVkReIHMRRl yWR0BsZE1T4T13d352eNsBWrzjDYcyxYqODM/0evLscfsSvtt0OfOnzZ68VK5QP/jPqb 0j5S9SEH5swX5+lHTK08S36uF1PEeSdhLo1+3fDaV8Zr4Xvz2xOlOk00QxMfUqpGcY3q o2tw== X-Gm-Message-State: AOAM5311XtuTvmZITWdQn/h80tilHR9bhAZWi0LWn3r5g1qUPNkTTMNn 5+zPyC2L6QnX64h0gB9a3uA= X-Google-Smtp-Source: ABdhPJzg3E6Dvu2xvvEgwlGLUhvaUBtxTTam4Jtwh7ic+r/MBjnynyLt4vZbjaxcZ8EUCArbYeUCRw== X-Received: by 2002:a05:6638:616:b0:32e:614:9c4b with SMTP id g22-20020a056638061600b0032e06149c4bmr8948820jar.203.1652741831372; Mon, 16 May 2022 15:57:11 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:11 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 09/27] Doc/dyndbg: document new class class_name query support Date: Mon, 16 May 2022 16:56:22 -0600 Message-Id: <20220516225640.3102269-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155712_073030_6A7D3FEF X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The added paragraph is slightly process oriented, rather than in language of guarantees; I thought the implications were clear enough. It does perhaps undersell the selectivity gained with string class_names; only drm/* would sanely register DRM_UT_CORE etc, so doing multiple "module {drm*,amdgpu,i915}" queries is unnecessary. 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..01ca6f635dcc 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 string (as known 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 registered a list of known class_names. If the class_name is + found for a module, callsite matching and adjustment proceeds. + Examples:: + + class DRM_UT_KMS # unless DRM wants different + 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 Mon May 16 22:56: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: 12851654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A34CC433F5 for ; Mon, 16 May 2022 23:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6ApGRpvxFwzyKoWmA8BPqvYoj7y3BVtOBai7qURMcmM=; b=aEUiYXWadv+XwC 2dxTWQdmbXPB+Ob9FRmsbguFE35C+/r7rDE202U4/FrAzaDip8Loqad1UeMrMAXCCBae+p/WGfiUr hBTsPnF3eLH3LS+a74VBMj5EREfQsN/GJyTNQ5zl7qd7NrstGHle6YL+Yk/YO8S0YrFMIrx3NphsN Cnjv/Qx9U5tqnOVa2kIyEXTqa2+4XjqXD3zw+qrFsdLS7waj7gzV2vqpFkgIew3rSxCyBM3SaCJAP wgdT2RdQTAf5zOJ+knQw1A44LvGEY8YhnZafdNlkVZ4VAkLnNbrX8RJTh8tx9RKXQXFVBSArvU1cW fBFrIgZPYF/VXeTiY65g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjjw-00AcUz-H3; Mon, 16 May 2022 23:03:00 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeM-00AZSw-Ay for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:16 +0000 Received: by mail-io1-xd2b.google.com with SMTP id e15so17624661iob.3 for ; Mon, 16 May 2022 15:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bt4oL+4NDueQ7IK1/UaXo6CBgL/asEIgenKpiK57T5o=; b=p80yQOTShj3uaqG5IpCE93ONCxQVqEljr+raFPdtHx7yza8I7Auwkg5j2bxHF4QmZX 7hDsop8LQgJklHsh5NkBvkY/Vv8QLfXg5SzbSHGjtdLtbZS6bge7Mfp37N/nQDAHXOHM DPSmpfdT+xo8fvilpnKL0BCPW7hwI/SSmleqzr8ho7kXo3B0ASzSYnKK0mMYayL9WCYn cBZ3uQMTJeKfIA+aCsijIrndP9wv2WrojahrrzikMZAaomnxQM3ix8Zh+kdX6NUgSMFq Oo3etlEqkzn/ITkV3Vhx1R+9yMgYpJtQWoPPh3lpxfowVmBH/+IwqUvtVbCpN1Ioe4Gs YaHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bt4oL+4NDueQ7IK1/UaXo6CBgL/asEIgenKpiK57T5o=; b=jNeXcYaz/w15KJMgZ1ZtjWePVqibaJtMqeuvhDczSYvk9RWwI8BTti9D4k73v9gUZA RHukPu4OqYcuSi4pNfjTFaJbytabb7eYmnlIGw2x58kcqaNuHfKp7hA7WFuJ9zbvQT9W w8n1eeRhJGKFIJCZWFxUPttHeMkVRMgZe+2zJNVWmduIhrQiz9/3rMIJfYVjDDdZnJSD SgBML7Qaqj+E6lnPpabwoyl0jwO4wLMvwR9XAr7AN9xFV7Ykuzu2Dpm2MpcedLTPNoa1 hi6i1C+rISdfkawT5NuvSUBSFVfEOBBwaevRtHgjrojnIjO+pbcyKqZ/jNRLIF+Uxo9Y Da1w== X-Gm-Message-State: AOAM530SfJ7cHj47mELd/nOvYm/lEGoAaQKGzGFi5uStuHktCMEamura 8fOZY2llyHnPnZiPAKZwk/w= X-Google-Smtp-Source: ABdhPJy66MckGQDyLsJIvF4VToS5sqJd0myJwjL9fDBA20NLuZbxaWNutVsSqrmALyzEJvTgqsIHSA== X-Received: by 2002:a05:6638:2185:b0:32b:73ff:ef16 with SMTP id s5-20020a056638218500b0032b73ffef16mr11024498jaj.192.1652741832638; Mon, 16 May 2022 15:57:12 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:12 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 10/27] dyndbg: let query-modname override defaulting modname Date: Mon, 16 May 2022 16:56:23 -0600 Message-Id: <20220516225640.3102269-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155714_465712_9C58077B X-CRM114-Status: GOOD ( 13.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org dyndbg's control-parser: ddebug_parse_query(), requires that search terms: module, func, file, lineno, are not used 2x in a query; a thing cannot be named both foo and bar (not even wildcards, no OR is contemplated). Amend the treatment of module; while still enforcing the 2x rule on it, set the default module at end, if none was given in the query itself, so the preset doesn't spoil the check. Background: ddebug_parse_query() got a modname arg to support boot-args with compound queries, all with "module aMod" added by default. aMod.dyndbg="func foo +p; func bar +p" With default module at end, this becomes possible; "module *" in the query overrides the default "module aMod". aMod.dyndbg="module * class FOO +p" This means aMod can modify (by explicit means) any FOO class'd pr_debugs in other modules. It is intended for use by DRM, which generally would want sub-system wide coordination. 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 b67bf9efec07..42dce2e76014 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -425,10 +425,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]; @@ -471,6 +467,13 @@ static int ddebug_parse_query(char *words[], int nwords, if (rc) return rc; } + if (!query->module && modname) + /* + * support $modname.dyndbg=, + * allowing query.module to override $modname + */ + query->module = modname; + vpr_info_dq(query, "parsed"); return 0; } From patchwork Mon May 16 22:56: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: 12851655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FD2CC433F5 for ; Mon, 16 May 2022 23:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ij5wb7lUueKV9/YlaXkn4fMmppMYajmVO9IOSE3YqFc=; b=eoiGVRT8heSpxx 1hcr8Bba7j3cSD5VJOcR5+x+qMTsIWV32NipEeRVZc37GdkV82DhHG7XW90T6Aotfp3MdhPwXijcb TzV8PM2OEtNZ2Af70XrquZ9u/5RgphW9RmIw+tnsdY67WcTXryOoLUFz97u8v0A5ve1mSKxw5hH8/ YT2RycV3e6+rVlR/YztUloFbrJTb4exa5mqN65WW06/U3UvaEuz360vylVzjrZOBIwiFbhOJpm4f5 kCCguHps/O5lzw10V9H7OWY4Ng5Yslg6DGf13p39bK++2i9yboGOhyh8DQlaHfNWAVncBA+hQMyZf icyBbQnyltmvSUNxL2bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjkb-00AcmS-Az; Mon, 16 May 2022 23:03:42 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeM-00AZML-J7 for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:16 +0000 Received: by mail-il1-x136.google.com with SMTP id j7so2187998ila.1 for ; Mon, 16 May 2022 15:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pcTCD0gjQirPulppRUPJolVEvdGl8HWNF457l2/VCpM=; b=Q9CmR/OAi4f1fJoHiSq/A4+KKe+6D/bRcwzXAN4CXFUDU9W2e/2rDFlaPtn9DFL3UZ 0OP+IoKCCh6jybN/4qKugRJr9T7OMuUWB4WPcOmePoEDyIWmnOH/Ox90OJPiIk7Uj2Ay X08/tZRG4GW7glyZeaVHPS0481a3PaSmacbBlv0ZZESoKc5evx9H5So0ulM0I63j44yN SP5T0u614Gkgwz78lPA4m5oH9zHG8D7tq0xAtxEPiBhUov/810saX6SSHCROypTyuHX/ Hi1iw+N+BFIEL+BpwjFUjSZL5bIvVsgrCFPtwfR3vAntRQZrHwooDLmOROaOb3jpAut/ oK6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pcTCD0gjQirPulppRUPJolVEvdGl8HWNF457l2/VCpM=; b=nhke4109rcYYJvW8AZ8w1aBwb+tSKAjxCO+olz/VRZpvoCeDqTAyVU167GqUfeNpNn I9Go3YLYIVv9BmpF6sHz9EsnahUCzsGHyQm5hdWEhhDZXfAGTFRSYmA/VkqTy3W+WlmY mHj6IJXX7ulDRA2KIcVGMvMPf5zxeNZgBd7g9mx0Ozq3VGhYqic8B6rp4l1VEne4iYsg WflFF86dYTkiD0kSUZKD14QLReKbRZSa+xfMdW/2RBKETMm43OCZhqtOT/c40q8FWZd/ 5+XdV3udFmEh9KaTrshqTzkkC+vo06mnRk8dJHrEG1ltVA2RYcrYLwJFzeVut7i7DELc GAqg== X-Gm-Message-State: AOAM530EQy9zq/0W/O8P94rAy9PKv9q5h05lQAYYmJyWCtIo3XYlLHuL txTZF0385KnpjvWJGCDpkkc= X-Google-Smtp-Source: ABdhPJx/jSyAjp7ehDTr/MAgCBe4VOWPaEYbecT5v2lmg6AJpeafbX8FKEwrz5Q30LOOcV3+TCIIVg== X-Received: by 2002:a05:6e02:158c:b0:2cf:db51:f69b with SMTP id m12-20020a056e02158c00b002cfdb51f69bmr9710970ilu.263.1652741834203; Mon, 16 May 2022 15:57:14 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:13 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 11/27] dyndbg: support symbolic class-names in bitmap Date: Mon, 16 May 2022 16:56:24 -0600 Message-Id: <20220516225640.3102269-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155714_691733_C26B2914 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Extend the sysfs-node bitmap support to accept class-names registered by the module, allowing: #> echo DRM_UT_CORE,-DRM_UT_ATOMIC,+DRM_UT_KMS \ > /sys/module/drm/parameters/debug Do this in param_set_dyndbg_class_strings(), which is called from param_set_dyndbg_classes() when the input string isn't a integer. Signed-off-by: Jim Cromie --- . continue/skip on unknown class, so following symbols are processed. . better loadable module handling, no more KP_MOD_NAME . add do_callback_changes --- lib/dynamic_debug.c | 63 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 42dce2e76014..8e1b9159e881 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -618,6 +618,61 @@ static int do_callback_changes(const struct ddebug_classes_bitmap_param *dcp, return matches; } +/* support for [+-] symbolic-name boolean list */ +static int param_set_dyndbg_class_strings(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_classes_bitmap_param *dcp = kp->arg; + unsigned long inbits; + int idx_rc, totct = 0; + bool wanted; + char *cls, *p; + + if (!dcp || !dcp->map) { + pr_err("set_dyndbg_classes: no bits=>queries map\n"); + return -EINVAL; + } + + cls = kstrdup(instr, GFP_KERNEL); + p = strchr(cls, '\n'); + if (p) + *p = '\0'; + + inbits = *dcp->bits; + vpr_info("set_dyndbg_class_strings: %s on 0x%lx\n", cls, inbits); + + for (; cls; cls = p) { + p = strchr(cls, ','); + if (p) + *p++ = '\0'; + + if (*cls == '-') { + wanted = false; + cls++; + } else { + wanted = true; + if (*cls == '+') + cls++; + } + idx_rc = match_string(dcp->map->classes, dcp->map->length, cls); + if (idx_rc < 0) { + pr_err("%s not found for module: %s\n", cls, dcp->map->mod_name); + continue; + } + if (test_bit(idx_rc, &inbits) == wanted) { + v3pr_info("no change on %s\n", cls); + continue; + } + + vpr_info("set_dyndbg_classes: bit %d: %s\n", idx_rc, dcp->map->classes[idx_rc]); + inbits ^= BIT(idx_rc); + totct += do_callback_changes(dcp, idx_rc, &inbits); + } + kfree(cls); + *dcp->bits = inbits; + vpr_info("total matches: %d\n", totct); + return 0; +} + /** * param_set_dyndbg_classes - bits => categories >control setter * @instr: string echo>d to sysfs @@ -639,10 +694,9 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) return -EINVAL; } rc = kstrtoul(instr, 0, &inbits); - if (rc) { - pr_err("set_dyndbg_classes: expecting bits/integer\n"); - return -EINVAL; - } + if (rc) + return param_set_dyndbg_class_strings(instr, kp); + vpr_info("set_dyndbg_classes: new 0x%lx current 0x%lx\n", inbits, *dcp->bits); for (i = 0; i < dcp->map->length; i++) { @@ -650,6 +704,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) if (test_bit(i, &inbits) == test_bit(i, dcp->bits)) continue; + vpr_info("set_dyndbg_classes: bit %d: %s\n", i, dcp->map->classes[i]); totct += do_callback_changes(dcp, i, &inbits); } *dcp->bits = inbits; From patchwork Mon May 16 22:56: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: 12851657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA40EC433F5 for ; Mon, 16 May 2022 23:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=x5H87wwH24VZcMa1DSafvRXRANDY7Y9EO/pbJE6rWZc=; b=yO2BvfrzHf3+iI Q9zf51A1HiWW74qOHxg4e93LU8I3jA7K/FFgZ6KD3eGIR+KqoSwRnPTkunYrRWcmxNa1TzICMrefT jfZHcqSHYBDfdJgkiR6SPz7mMIB4/XnlV34+fm8LXk1ZY/QsUvxPRgoBCSm/byI8xH8cMAmLXThUh 4pvNocawRbU3WUUZD2xzd7+5QjqaspjAssSCIehyU2XZzBopRweyL0ek+FmU47JWp7eDkLq9d4kZs gt3nvOZQMPArSLN6HwAYyQDPetYYCt5Ksgc+rX/NMOMTV7IfK5Zxpo/lolI7SFDX8ZXeTtYXxbLDA 4J1+gHv9jr0cgTWwLMKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjm6-00AdWl-72; Mon, 16 May 2022 23:05:14 +0000 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeP-00AZV1-PL for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:20 +0000 Received: by mail-il1-x12d.google.com with SMTP id d3so11532921ilr.10 for ; Mon, 16 May 2022 15:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Wk014TwyjnrOaQ2i3WNMMRKpv2e+mMH/KYOzUNpIOE=; b=NbC3sbmxQ0gNlrzlR6q30F5DeIDupJtg/rWawsgTFkINjdCXcKwcQjJ+80AMWIsf38 8LFB7eLOgSryfGffVVoVbm6DUrrP/Ea2cEe2zYmQCl5zQw04DDTNTUdyoN/Z1QUuFMPC tC7D4LPtwPgOaRl6JXoEqld602TZ50DbL8yu61BZUzG6TQ4Dv+vC+K35WGFouu1Elsbu eeVoIPCbMW7zL3ymZ6nhdNZ+j+U2ej6XMf6WKb0i63W9YVL7MgNCv4nTLgDywQnl8irm ow6CNlSYNmujeLBprx1idrRFeRo6Nj9U1IyTMWAvarnXzuWDJDI1xLEIfdhu0yDJjf9C q41Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Wk014TwyjnrOaQ2i3WNMMRKpv2e+mMH/KYOzUNpIOE=; b=ODPFPD3GI5ORBn8v9kmya3OaSmRz/rUDNp+g4PjfvsPix4eItSDWB1GalBxWRhIgZB mNkvRrDIM/RHcaCoZ53p5ZjQ6GlxaCixuq7cSWM6illkXHwUvudJ81RxBvMi2ME2iAH2 UzmJfS9/GkVwxhJTL9qM9XugON4lZvMoEyZP0VJVcrFE1GAo3FftLFLs8z6DkCrz6YPv xTpigRWRz4TNO6/HAKMcpwmHqmtSbUUkP7d5GVWPY681CKsvRq/6HWE8n53RH/i1v9Ko ag8NLeGNcBQTwJb9EyQarv91L4EkjMIZLikrUzqJBTRLx80OQVKgcUWEblE8/H8OEJlv 8fKw== X-Gm-Message-State: AOAM533HXBbTX7xkQCJZibVUV1wtBJbP7YOynnM/XLiywjQ4pMyrsRG+ 48PyCLOq+XdCrunMkLKD1oM= X-Google-Smtp-Source: ABdhPJzsYhdemnsNa7jolhgES0cXpVtGwAcCj/g475kUSD5yZiac8pvgAJmKVJyqTCsdFP4vD4XH9A== X-Received: by 2002:a05:6e02:1788:b0:2cf:3150:f26c with SMTP id y8-20020a056e02178800b002cf3150f26cmr10109037ilu.214.1652741835464; Mon, 16 May 2022 15:57:15 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:15 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 12/27] dyndbg: change zero-or-one classes-map to maps list Date: Mon, 16 May 2022 16:56:25 -0600 Message-Id: <20220516225640.3102269-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155717_894266_AC6EB2E3 X-CRM114-Status: GOOD ( 20.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Upgrade single classes-map to list of them: This allows multiple DYNAMIC_DEBUG_CLASSES(class-map)s per module, using _base to segment the 0..30 classid space. alter struct ddebug table: replace .classes (a &map) with maps (list-head) dynamic_debug_register_classes(map) - adds new map to maps list. dynamic_debug_unregister_classes(map) - deletes map after ID-check. ddebug_validate_classname() - check all maps in list before failing. ddebug_class_name() - which supports ```cat control``` now walks maps list, finds the map whose sub-range of .class_id's spans the one in the callsite, and returns that class-name. Signed-off-by: Jim Cromie --- . split out validate_classnames() . fold in fixes for multi class-maps --- lib/dynamic_debug.c | 76 +++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8e1b9159e881..f9c5bbf9d43b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -43,10 +43,8 @@ extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; struct ddebug_table { - struct list_head link; + struct list_head link, maps; const char *mod_name; - /* a module can have multiple class-sets eventually, but not yet */ - struct ddebug_known_classes_map const *map; unsigned int num_ddebugs; struct _ddebug *ddebugs; }; @@ -149,28 +147,18 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) /* return <0 if class-name is unknown/invalid, 0..CLASS_DFLT otherwise */ static int ddebug_validate_classname(struct ddebug_table *dt, const char *class_string) { - int query_class = -ENOENT; + struct ddebug_known_classes_map *map; int idx; if (!class_string) - /* all queries w/o class given work only on default class */ return _DPRINTK_CLASS_DFLT; - /* - * XXX single list will need to be a for-list - * so that modules can have 2 sets of class-decls - */ - if (!dt->map) - return -ENOENT; - - idx = match_string(dt->map->classes, dt->map->length, class_string); - if (idx < 0) { - v3pr_info("class: %s.%s unknown\n", dt->mod_name, class_string); - return -ENOENT; + list_for_each_entry(map, &dt->maps, link) { + idx = match_string(map->classes, map->length, class_string); + if (idx >= 0) + return idx + map->base; } - query_class = idx + dt->map->base; - - return query_class; + return -ENOENT; } /* @@ -1032,8 +1020,14 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) { - if (iter->table->map) - return iter->table->map->classes[dp->class_id]; + struct ddebug_known_classes_map *map; + + list_for_each_entry(map, &iter->table->maps, link) { + if (dp->class_id < map->base || + dp->class_id >= map->base + map->length) + continue; + return map->classes[dp->class_id - map->base]; + } return NULL; } @@ -1124,6 +1118,7 @@ int dynamic_debug_register_classes(struct ddebug_known_classes_map *map) struct ddebug_table *dt; int rc = -ENOENT; + INIT_LIST_HEAD(&map->link); mutex_lock(&ddebug_lock); #ifdef CONFIG_MODULES if (map->mod) { @@ -1131,7 +1126,7 @@ int dynamic_debug_register_classes(struct ddebug_known_classes_map *map) list_for_each_entry(dt, &ddebug_tables, link) { if (dt->mod_name == map->mod->name) { rc = 0; - dt->map = map; + list_add(&map->link, &dt->maps); break; } } @@ -1142,7 +1137,7 @@ int dynamic_debug_register_classes(struct ddebug_known_classes_map *map) list_for_each_entry(dt, &ddebug_tables, link) { if (!strcmp(dt->mod_name, map->mod_name)) { rc = 0; - dt->map = map; + list_add(&map->link, &dt->maps); break; } } @@ -1159,8 +1154,38 @@ EXPORT_SYMBOL(dynamic_debug_register_classes); void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map) { - vpr_info("unregister_classes: %s\n", map->mod_name); + int rc = -ENOENT; + + mutex_lock(&ddebug_lock); +#ifdef CONFIG_MODULES + if (map->mod) { + struct ddebug_known_classes_map *dmap; + struct ddebug_table *dt; + + list_for_each_entry(dt, &ddebug_tables, link) { + if (dt->mod_name != map->mod->name) + continue; + list_for_each_entry(dmap, &dt->maps, link) { + if (dmap != map) + continue; + rc = 0; + list_del(&map->link); + break; + } + } + } +#endif + if (!map->mod) { + pr_err("shouldn't be unloading a builtin module: %s\n", + map->mod_name); + } + mutex_unlock(&ddebug_lock); + if (rc) + pr_warn("unregister_classes: module %s not found\n", map->mod_name); + else + vpr_info("unregister_classes: %s\n", map->mod_name); } +EXPORT_SYMBOL(dynamic_debug_unregister_classes); /* * Allocate a new ddebug_table for the given module @@ -1186,6 +1211,9 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, dt->num_ddebugs = n; dt->ddebugs = tab; + INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->maps); + mutex_lock(&ddebug_lock); list_add(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); From patchwork Mon May 16 22:56: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: 12851656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B379C433F5 for ; Mon, 16 May 2022 23:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dOwswmfaNWTGCBIYQvXWyjolJ1tTgMrGTBLm5q2hbVg=; b=AnMZuRMrLbz14+ /QIqEjTF9+nntrGFFxeLke+aQttXkT8I3/bR+QxrYnHKIY6PtUwqbP//Cr8CPK/UB4ofLv3E1l9wT VxgCo+xZUdO/nBXngD5LHpv/ReZutLZbJ6Ar5omx9C6jqXa7LGNSiE9QgKudDMok2FR5WCO/xfuHF CI1Dnp+QhEAPELFiqK44waagqGMdQ0kQtraXQGDGYIPnlrFZlz56TD5c395Mg19gr8Pfdbe0jaKeM DqF8cMfNTP83MsKBEYI1kwRMVCB7DDLXd1HluQvX58SinVyYV2i7t2GCw0X6wLJX4G2vmulqewMQB f/vPfPPQfy3TM5ywMOZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjlI-00Ad5n-9W; Mon, 16 May 2022 23:04:25 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeP-00AZNW-51 for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:19 +0000 Received: by mail-il1-x132.google.com with SMTP id s6so6758279ilp.9 for ; Mon, 16 May 2022 15:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kFgHG2tewJsN9CYAlq+NJbyhVM4qxnXd9vUi/EQochg=; b=APwWUbR7WCm/vV2bYkZXreJGyjTXBdujWBM/SmErqdwxgUV0hDj0LLMU6s9poeH5iT FXKjac2KPaRmv5i79zC0mhsAUsVXiwZqRh6viD88comH/LsImmGjEPd5EKvJJjjGwetm dtdMPDlrGdED1Igfq+1ncnqB3mLuF8AnEA9mwLdvjf74BU6/WlsaIU1uqRVA/gkYJFFJ xzX5VE9gHbP7E5WIC99KeZ8T7SwN6qhNeEUFjOZvi3imC2ZnFxskOMGw/wC7PKgEVeW4 mB7B32fpSnKhf5ymmcNfiMKYx2Mfx1TPQo9gLZcNV3R/rJU9tIZ4TCYpnFCG1zTWOu3n UjMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kFgHG2tewJsN9CYAlq+NJbyhVM4qxnXd9vUi/EQochg=; b=ERt8rzKcy77Jq7BDZwjJg5ODloyOFsHUuPo95N38HkDnli+51rNykqxfO9AEcc5TtA L5zAVNbwGxEyH95amcSw5kck3ackhYlICJfivLGGbl6zX4u1A/8bYGwbz6uh9Yv54aGe c/4K2julrhMFtZ+CEnF7wIdXoj2SabxA3P7aY9bKbddSFmGa/cZ5CGFMqFSJST2WqC6n XOjp6Bq31YAxxiUFkn3QX4mb8k8BUQGH50OVjPETbH8i7zul0rXrUYDaYEmuHGy7avOp nGGiRRJAedHjehriB+ZaYUqMtyPfas9ByoBffI3ylQM90ffW4iEkO98RDADAQspjVn8Q 8r6Q== X-Gm-Message-State: AOAM531/+kEQN35ZeE8YoWCmArcL0J+RWEqI1wDuPUtpBHDEDedbT4Rr Wykis7PoLqe/okgtsa3fNQo= X-Google-Smtp-Source: ABdhPJwTljlWB+rSMPzyqgN07gjHdFBLaJfrHnMONzCrRckPACxxE9mLZ+oS1CTCjNd2OY7YFa1OSw== X-Received: by 2002:a05:6e02:1587:b0:2c2:5c48:a695 with SMTP id m7-20020a056e02158700b002c25c48a695mr10131603ilu.169.1652741836722; Mon, 16 May 2022 15:57:16 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:16 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 13/27] dyndbg: add __pr_debug_cls(class, fmt, ...) Date: Mon, 16 May 2022 16:56:26 -0600 Message-Id: <20220516225640.3102269-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155717_243223_DB526C02 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. But test_dynamic_debug needs it in order to demonstrate all the moving parts. Note the __ prefix; its not intended for general use, and doesn't include any builtin-constant checks that could pertain. I'd prefer to see a use-case where copying the drm.debug model isn't better. 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 e9e6d0f503f3..abf43e28d8d3 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -216,6 +216,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, _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, \ pr_fmt(fmt), ##__VA_ARGS__) @@ -246,6 +250,9 @@ 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); +#define __pr_debug_cls(cls, fmt, ...) \ + dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__) + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include From patchwork Mon May 16 22:56: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: 12851658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64533C433EF for ; Mon, 16 May 2022 23:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zogAOOSJD0tdOY02Q0okH1qRgGou8worY4GSuGYDl18=; b=WhRMibFuRTs/bJ wBp6bYayYEl7kQ7+dadijAjTpT0E+tOxMkZSu3CSbaIwDxMqRGNR93vIvHO3ZcuZbPEz42KOhtJLb +bljCo0tRTdviLaiV7ie0EYanPzvoFTkFsYA9L/5VPLyBRcUyEFzBIx3g0mtZcyXWdh5BhKuHhecr sOk9gi7PgUYLwSBVXMsb2UctouwO7k/45huH+nBC9a8qEdiNhPWZsc51WtiGVnRslCC07uv9zXMcg 7Zc8+icr7eWYEi+lVGx2U+mmy2bXcOdE7GEy/xzIGTUqJF471Pa/69mQ91zubkriGJuR3QAIldvBS isfyjTh1q2j9xHyQwA2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjmz-00Adyi-OC; Mon, 16 May 2022 23:06:10 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeR-00AZXA-MM for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:21 +0000 Received: by mail-il1-x129.google.com with SMTP id s12so8934917iln.11 for ; Mon, 16 May 2022 15:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4+OOX1OvjkZsN3TSD9RgwwVgcTBaI2m+uT5AbHUS6m0=; b=Fo7YXOf/0vFpkLY8Uk/yY0nT5SmPi5y3dHrHluxiH+jPSSKgG/p1Gz5zK7Vu5n6UxZ adpJHsxKhBbt1AKuP/901DivHo+vHYALOYRgk1qIRa516KCkldDX94eJ7bs7maLShCvL yXLtI4UQzjqwM/jdu7hPJ/Fa8PKfjUkEUkZVEHTUCxZs7L2OQhpyIvljd/WT3ti+Vcb5 jIyuq0xWDkawREPHWBdqqDjrcGo4i4IDSorHGgRDzfopEesYDc1Y563hH+6Si+9YntGB GOGkbE2mJ32gkdmtkIWrgfkvMltVXBVQh4IvArvSY61UnBULbKT1PiPUYwzrahZpFEuZ 6aXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4+OOX1OvjkZsN3TSD9RgwwVgcTBaI2m+uT5AbHUS6m0=; b=Ndqk6T93stoU91AbDkpAEzaBDpMqs9H4+DRRyNDGQFl3C00eIbR+l6i4u6CEmUM3Lp lBIKnxxRCU29n21/3A+koewdCE9UDAOY3FmSfuXvTuTsxFo745pQI3iu5c61ST2DDTUy 3vyEEUh52LsMt0YHcIm/5Dvbi3d6jVQfasbTmzGwjcDgVZ1snrEYpcIow51TqW8bcBPC UAfxU5IAjx6kDzF5aKAbi3bYuvC1nU3CNz4PCAw7qeuqCzxpQ+wDYm5Uqb8rPa6Osg7j eflwPJfbcSED4gnTcdZ7iZeW4PIJcD0szyjEcZJ48Pe1jAGo8qqd2L4csUmDIQDl0KQR gxLw== X-Gm-Message-State: AOAM530jyLis3CFODzSCnrh6t1NEfM8m62CYK5YnLC7u1y/IYnopq/Bv UuWk2dumRmwuiq31+mrQqS8= X-Google-Smtp-Source: ABdhPJxiH2HWdFdauTnvGpj4Rme8nnchoUQHFiTC7tx6lbGdrSpdRV5tZOHEmwpDAUNac856y9edUg== X-Received: by 2002:a05:6e02:1c4a:b0:2d1:183e:4ce0 with SMTP id d10-20020a056e021c4a00b002d1183e4ce0mr4908778ilg.150.1652741837929; Mon, 16 May 2022 15:57:17 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:17 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 14/27] dyndbg: add test_dynamic_debug module Date: Mon, 16 May 2022 16:56:27 -0600 Message-Id: <20220516225640.3102269-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155719_800307_1FFCD780 X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Demonstrate dyndbg's "class FOO" and bitmap-to-classes support. This support is meant to plug into drm.debug system, and largely replace the use of drm_debug_enabled(category) with JUMP_LABELs. Recap: #> echo class DRM_UT_CORE +p > /proc/dynamic_debug/control This is made "safe" because dyndbg skips it for any modules which don't know that class (havent called dynamic_debug_register_classes). Other modules may use the same .class_id for a separate classified debug scheme. Use the API: - DYNAMIC_DEBUG_CLASSES(_var, classes), to declare static _var by name - dynamic_debug_register_classes(_var) - dynamic_debug_unregister_classes(_var) Use these 3 times; with base = 0,8,16 respectively, to demonstrate the segmenting of the module's .class_id range [0..30] For each of those 3 class-name-sets, add 2 sysfs-node-bitmaps, one each for p-syslog, and T-tracefs, the latter will work once dyndbg gets that patchset. #> modprobe test_dynamic_debug dyndbg=+pfm #> cat /sys/module/test_dynamic_debug/parameters/do_prints #> echo class FOO +pf > /proc/dynamic_debug/control #> echo class Foo +pfm > /proc/dynamic_debug/control #> cat /sys/module/test_dynamic_debug/parameters/do_prints RFC: This use case exposes a weak point in the api; the 2nd query command given in the dyndbg option will not work like the 1st: #> modprobe test_dynamic_debug dyndbg='+pfm; class FOO +pfm' This is because the option is processed early in module-load, well before the registration can attach the class-map to the module's ddebug_table entry. Signed-off-by: Jim Cromie --- MAINTAINERS | 1 + lib/Kconfig.debug | 11 +++ lib/Makefile | 1 + lib/test_dynamic_debug.c | 172 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 lib/test_dynamic_debug.c diff --git a/MAINTAINERS b/MAINTAINERS index e8c52d0192a6..bf615853be47 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6918,6 +6918,7 @@ M: Jason Baron S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +F: lib/test_dynamic_debug.c DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 075cd25363ac..c88d691d3df1 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2601,6 +2601,17 @@ config TEST_STATIC_KEYS If unsure, say N. +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on m + 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 6b9ffc1bd1ee..e5727fbbfc7d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -82,6 +82,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..65c37ba6c0da --- /dev/null +++ b/lib/test_dynamic_debug.c @@ -0,0 +1,172 @@ +// 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 */ + +int param_set_do_prints(const char *instr, const struct kernel_param *kp) +{ + do_prints(); + return 0; +} +EXPORT_SYMBOL(param_set_do_prints); + +int param_get_do_prints(char *buffer, const struct kernel_param *kp) +{ + do_prints(); + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); +} +EXPORT_SYMBOL(param_get_do_prints); + +const struct kernel_param_ops param_ops_do_prints = { + .set = param_set_do_prints, + .get = param_get_do_prints, +}; +EXPORT_SYMBOL(param_ops_do_prints); + +module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); + +/* + * Declare 3 groups of classes, with different .class_id[] ranges, + * each with 2 sysfs-node bitmaps controlling p,T flags respectively + * for those named classes. This example is rather more involved than + * anyone will likely use. + + * The T-bitmap sysfs-node functionality will need a few patches which + * add trace-events to dyndbg. + + * Rules: + * - enum symbols must match/correlate with class-name strings + * - base must equal enum's 1st value + */ + +enum cat1 { FOO, BAR, BUZZ }; +DYNAMIC_DEBUG_CLASSES(ddt_classes1, 0, + "FOO", "BAR", "BUZZ"); + +unsigned long bits_1p, bits_1t; +EXPORT_SYMBOL(bits_1p); +EXPORT_SYMBOL(bits_1t); + +static struct ddebug_classes_bitmap_param p1_bitmap = { + .bits = &bits_1p, + .flags = "p", + .map = &ddt_classes1 +}; +module_param_cb(c1_syslog_bits, ¶m_ops_dyndbg_classes, &p1_bitmap, 0600); + +static struct ddebug_classes_bitmap_param t1_bitmap = { + .bits = &bits_1t, + .flags = "T", + .map = &ddt_classes1 +}; +module_param_cb(c1_trace_bits, ¶m_ops_dyndbg_classes, &t1_bitmap, 0600); + + +enum cat2 { Foo = 8, Bar, Buzz }; +DYNAMIC_DEBUG_CLASSES(ddt_classes2, 8, + "Foo", "Bar", "Buzz"); + +unsigned long bits_2p, bits_2t; +EXPORT_SYMBOL(bits_2p); +EXPORT_SYMBOL(bits_2t); + +static struct ddebug_classes_bitmap_param p2_bitmap = { + .bits = &bits_2p, + .flags = "p", + .map = &ddt_classes2 +}; +module_param_cb(c2_syslog_bits, ¶m_ops_dyndbg_classes, &p2_bitmap, 0600); + +static struct ddebug_classes_bitmap_param t2_bitmap = { + .bits = &bits_2t, + .flags = "T", + .map = &ddt_classes2 +}; +module_param_cb(c2_trace_bits, ¶m_ops_dyndbg_classes, &t2_bitmap, 0600); + + +enum cat3 { bing = 16, bong, boom }; +DYNAMIC_DEBUG_CLASSES(ddt_classes3, 16, + "bing", "bong", "boom"); + +unsigned long bits_3p, bits_3t; +EXPORT_SYMBOL(bits_3p); +EXPORT_SYMBOL(bits_3t); + +static struct ddebug_classes_bitmap_param p3_bitmap = { + .bits = &bits_3p, + .flags = "p", + .map = &ddt_classes3 +}; +module_param_cb(c3_syslog_bits, ¶m_ops_dyndbg_classes, &p3_bitmap, 0600); + +static struct ddebug_classes_bitmap_param t3_bitmap = { + .bits = &bits_3t, + .flags = "T", + .map = &ddt_classes3 +}; +module_param_cb(c3_trace_bits, ¶m_ops_dyndbg_classes, &t3_bitmap, 0600); + +static void do_prints(void) +{ + /* raw integer classes */ + __pr_debug_cls(0, "class 0"); + __pr_debug_cls(1, "class 1"); + __pr_debug_cls(2, "class 2"); + + /* enum ints */ + __pr_debug_cls(FOO, "class FOO"); + __pr_debug_cls(BAR, "class BAR"); + __pr_debug_cls(BUZZ, "class BUZZ"); + + __pr_debug_cls(Foo, "class Foo"); + __pr_debug_cls(Bar, "class Bar"); + __pr_debug_cls(Buzz, "class Buzz"); + + __pr_debug_cls(bing, "class bing"); + __pr_debug_cls(bong, "class bong"); + __pr_debug_cls(boom, "class boom"); +} + +static int __init test_dynamic_debug_init(void) +{ + pr_debug("module-init\n"); + /* + * these are too late to enable class FOO at module load time: + * #> modprobe test_dynamic_debug dyndbg='class FOO +p' + */ + dynamic_debug_register_classes(&ddt_classes1); + dynamic_debug_register_classes(&ddt_classes2); + dynamic_debug_register_classes(&ddt_classes3); + + do_prints(); + + pr_debug("module-init done\n"); + return 0; +} + +static void __exit test_dynamic_debug_exit(void) +{ + dynamic_debug_unregister_classes(&ddt_classes1); + dynamic_debug_unregister_classes(&ddt_classes2); + dynamic_debug_unregister_classes(&ddt_classes3); + + pr_debug("module-exit\n"); +} + +module_init(test_dynamic_debug_init); +module_exit(test_dynamic_debug_exit); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); From patchwork Mon May 16 22:56: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: 12851659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A818C433EF for ; Mon, 16 May 2022 23:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yak9RQsfzxYg9utFa69r5+eGOQq2zIsXAln1rG0DeaE=; b=xOhLhrwSUWCD2t pplBH3vakw7LShNiulcG99UuBVSA6UUMZNaUip19vj88i+kgY+xP6qQuQ5EIPkaCNitgh96pZU89l E0rQ88UXrpxMMneCmGA5jLCB7916eVeQMfi9RruHlz54Uf3W6kjb51iS3J0r37FG5B6V7nRAs79XD HwY2auHSwiS3nMLy7MxnxtqXKxQFKjCMsgWyZIMCFiXy0R+kwNeNa8IvO+a5yc3jzHNOeZPW8ERh2 lIZ30yBm12wSfjzkxRUHHyUokf6YlzHxYufEDOLGgNT/kNJAvh0Eerr7WTFJD4RA1J+hKQLGLkUwI XHzk+Pta0viBISjfnCNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjo5-00AeWC-P7; Mon, 16 May 2022 23:07:17 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeT-00AZXq-EM for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:23 +0000 Received: by mail-io1-xd2c.google.com with SMTP id e194so17580531iof.11 for ; Mon, 16 May 2022 15:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sfS8WUqxRbYLHzWszspkTXnIl4N1CgLbVdRhg+W+v5Q=; b=JSGyNtm+oykZkHkIegb7uQ2SxKJPwMiwzdUaWO7Y68laVB1orKGZ22JvbSz51Iww/h gPNYoIjd9ufV70PTbI2TafWd8gA/m0eqDbLqH34XEEl0cl2U/pYsxQ542O+e9l8Ara4a GX/AhbnmxBIvZveJmefUpwmlks8127t2Y1LSPOYd+/bMRI9FqwfNyklwDWGRNGFzpjSZ tJKQYBLwQuOhZpYBr3J2GdSAiIbq9zJBea0YLp2Cz7tAo/s9ySOH34KryQQjD/FlcD+1 3y2laHAjc9g8moUIhK5R9MdVXcT7VMZOwplQccCjN80c0qW8VyM3SvZK5mFo8uHsY//K eBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sfS8WUqxRbYLHzWszspkTXnIl4N1CgLbVdRhg+W+v5Q=; b=VqCdFFkI9u3WrfsdxMlwTbRzkyCS3pGoJvutD8Un3kPnHwVqMFOW/HyIITxPJIBgSV kaD+Z7c4z1MdUSrlG/h01Jps2SKoO1R1rODwhzxB1vpKtaLXSrhAvliYXRGRRUPI0asP bqjwintOs/oETSg2WZRGODTcJldBNNQWoZNZehHyz5zumSQBxews0p8wcMsgIjGqAkVN c3S3h0F19pYaGw8yKY2nwM5GzyhESrt0BB55RgmxsKNUNOnytYs82U7m5YeBkDkd3bYB fApGSBIBSIXnjaX+jjontmBW5y6gFJhhXw3sW/l4QgxHpGDVWYFO/d1pSUWsJezDnC1U pvVg== X-Gm-Message-State: AOAM531fEvk7Cj+Aev6JV0KMhNIRj1J3+iKh+lmogjuyzUMAQStupzkg D+CCr2mu9FHUhlGd5aKm6Nw= X-Google-Smtp-Source: ABdhPJwAlu9u50ELwUlPAYiYw2vARy3pg1Ca3hYkCtMjkUDC6LJazLHQKGeJOm7jyHLQVeZGT4le8g== X-Received: by 2002:a05:6638:516:b0:32e:26e7:30b3 with SMTP id i22-20020a056638051600b0032e26e730b3mr4987356jar.287.1652741839166; Mon, 16 May 2022 15:57:19 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:18 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 15/27] drm: POC drm on dyndbg - map class-names to drm_debug_category's Date: Mon, 16 May 2022 16:56:28 -0600 Message-Id: <20220516225640.3102269-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155721_533468_63B1AFF2 X-CRM114-Status: GOOD ( 16.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Invoke DYNAMIC_DEBUG_CLASSES from drm_drv.h. This declares a maybe-unused struct ddebug_known_classes_map var, initialized with: . var: passed to dynamic_debug_register_classes() . class-names: "DRM_UT_CORE", "DRM_UT_DRIVER", "DRM_UT_KMS", etc. These names map to .class_id's by their index, ie: 0-30. Then in 4 test-case drm-drivers (drm, i915, amdgpu, nouveau); call dynamic_debug_register_classes(var). i915 also gets an adaptor func, and calls it 1st in the array of initialization helpers, since early logging might be valuable for diagnosing setup problems. Since these modules all use the same class-names, they all will respond together to class FOO changes: #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: DRM uses enum drm_debug_category across modules and common core, so our class-names => index map must apply across them too, hence drm_drv.h invokes the macro once for everyone. 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 work. Once enum drm_debug_category is naturalized (value inits dropped, yielding 0..N), then this condition holds true: assert(!strcmp(classes[DRM_UT_KMS],"DRM_UT_KMS")); Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie different corresponding .class_id) and things would work. No callsites are actually selected here, since none are class'd yet. bash-5.1# dmesg | grep register_class [ 7.095579] dyndbg: register_classes: drm [ 7.557109] dyndbg: register_classes: i915 [ 8.096818] dyndbg: register_classes: amdgpu Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +++ drivers/gpu/drm/drm_drv.c | 2 ++ drivers/gpu/drm/i915/i915_module.c | 11 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 4 ++++ include/drm/drm_drv.h | 14 ++++++++++++++ include/drm/drm_print.h | 4 ++++ 6 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 7fd0277b2805..addb991b4663 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2765,6 +2765,8 @@ static int __init amdgpu_init(void) if (r) goto error_fence; + dynamic_debug_register_classes(&drm_debug_classes); + DRM_INFO("amdgpu kernel modesetting enabled.\n"); amdgpu_register_atpx_handler(); amdgpu_acpi_detect(); @@ -2787,6 +2789,7 @@ static void __exit amdgpu_exit(void) amdgpu_amdkfd_fini(); pci_unregister_driver(&amdgpu_kms_pci_driver); amdgpu_unregister_atpx_handler(); + dynamic_debug_unregister_classes(&drm_debug_classes); amdgpu_sync_fini(); amdgpu_fence_slab_fini(); mmu_notifier_synchronize(); diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8214a0b1ab7f..16683fb169aa 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -1045,6 +1045,8 @@ static int __init drm_core_init(void) { int ret; + dynamic_debug_register_classes(&drm_debug_classes); + drm_connector_ida_init(); idr_init(&drm_minors_idr); drm_memcpy_init_early(); diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c index 65acd7bf75d0..31f00f973866 100644 --- a/drivers/gpu/drm/i915/i915_module.c +++ b/drivers/gpu/drm/i915/i915_module.c @@ -44,10 +44,21 @@ static int i915_check_nomodeset(void) return 0; } +static int i915_ddebug_classes_register(void) +{ + return dynamic_debug_register_classes(&drm_debug_classes); +} +static void i915_ddebug_classes_unregister(void) +{ + dynamic_debug_unregister_classes(&drm_debug_classes); +} + static const struct { int (*init)(void); void (*exit)(void); } init_funcs[] = { + { .init = i915_ddebug_classes_register, + .exit = i915_ddebug_classes_unregister }, { .init = i915_check_nomodeset }, { .init = i915_active_module_init, .exit = i915_active_module_exit }, diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 561309d447e0..9a780b6d4796 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1355,6 +1355,8 @@ nouveau_drm_init(void) driver_pci = driver_stub; driver_platform = driver_stub; + dynamic_debug_register_classes(&drm_debug_classes); + nouveau_display_options(); if (nouveau_modeset == -1) { @@ -1391,6 +1393,8 @@ nouveau_drm_exit(void) nouveau_backlight_dtor(); nouveau_unregister_dsm_handler(); + dynamic_debug_unregister_classes(&drm_debug_classes); + #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER platform_driver_unregister(&nouveau_platform_driver); #endif diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index f6159acb8856..c2ffe12161b8 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -29,6 +29,7 @@ #include #include +#include #include @@ -43,6 +44,19 @@ struct drm_mode_create_dumb; struct drm_printer; struct sg_table; +/* these must comport with enum drm_debug_category values */ +DYNAMIC_DEBUG_CLASSES(drm_debug_classes, "*", 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"); + /** * enum drm_driver_feature - feature flags * diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..5b7eedb0f477 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -274,6 +274,10 @@ static inline struct drm_printer drm_err_printer(const char *prefix) * # echo 0xf > /sys/module/drm/parameters/debug * */ +/* + * These must be kept in sync with the class-names given in drm_drv.h + * DYNAMIC_DEBUG_CLASSES + */ enum drm_debug_category { /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, From patchwork Mon May 16 22:56: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: 12851660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 764CCC433EF for ; Mon, 16 May 2022 23:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C9Zm35bjAXoYTRiNPiuyahhi5LerO6kidgMzky9oIZU=; b=E7eBBQWIRzOZgL nY/L/HyLUMG29KDpJQBSxZ4ZKBj8rsE3wtDg6/ArA9EfyIvuVg6heeVbGZ+rY/nIFSrgXqhN1wm/7 5XV91YLjQm3NAjlhx9u9sYdl9M/x+jJXEhuSs4LUKRHfAcsQuSfXe8aVe8Ys+CuMaH6j699OhKKd7 WoHQxxt3AGH5Q4nBvJv9wEygmaTBRMbMh0Ou/T5WhtuBh1MtKYnOdijvDhq1KEdbIcQ3i4eCCTB6L j/jjoanYIKvzxklWa9lutX+gUNXUGh+s1poPQpwJ7giO0WmI0moiz9Oh8+Pmh6Bo5XILXbRGvjgUq DMfAD1WAnBCHBMyzsZrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjpM-00Af6s-Uz; Mon, 16 May 2022 23:08:37 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeU-00AZYh-OL for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:24 +0000 Received: by mail-io1-xd36.google.com with SMTP id s23so17572455iog.13 for ; Mon, 16 May 2022 15:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5Ml9ZEIbtQPoX0Jy/kpSXgxpIe2fb966gSifTzlGH6A=; b=gwjsPi3nUk5PPFCQG1WeJNe3HCM0x8Xeos1NDV0VnD3pOqAer1DhgXG5pTHIn4C5HG uu0ghOYaS79ct94ac8I4ILxLnqlkvQ2TJlrat/b0xb1u4rczFC1xwRs5Sg+6xKdna/+w 1abDELtFgKpuYt/QCDa4bZyPizCDIdsmt9N3RRVs69/d3N40C45K1J+5H2ZmRtJ4bRW1 0/DMNOn/BkxVECRNvTgcjKvskhtTr36T5aDcCh5pdzdV41+SKEorHFNagIBm+zQ4IIk+ m2hmL82F2/hv3sx70r3SidT+bgq/YCaK8VUM3WGonMSuPeT1z6tCN+JPdvmAf+rUTVyT VThw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5Ml9ZEIbtQPoX0Jy/kpSXgxpIe2fb966gSifTzlGH6A=; b=UMNc3bLkRVEMN+pA3NVoj0oKPc2S74bnRUrlctTPfcNp0AeBySB1bt2L99UobLUIZJ JuoVeHcO4TkuUifL5/tWjNz1LS39h8TyCCtK+WsuyAUEI7Vnc3l+bvjR/VhLYZNBpsut /V+TXpVxutQPscJl+kLvOaBR/DPVUMPB6bxYY5zDHEXxnhOSlsolx48SZIQFx+Fhz7ek /Ptn10LNPWLNHpcgBRc7Z1Bu5RgMS6aTz/+vqxDcf3EDoIcMpH/HOndzL4uyIC7H2cp2 3s8eUlBjZX5wKOpQ/pJmLQeP4VAHZyXhOVSaMx5Mq5GBflWKJCVjLbyMbkqyJ78ItO7q FuZQ== X-Gm-Message-State: AOAM531z/5uv0Jy5bgAJSg+/qhNyJ5K26lgdGl3WeVj3Lb7ZIPof4UYR PvpyaQilYrexgLurYKp8sBI= X-Google-Smtp-Source: ABdhPJwz3KCUfWqZef8egGVgZt6hg7h2HOTzoEtyl/qB0kRRtq3StfmQYRNHBpeqczzMlwu5Z9r89Q== X-Received: by 2002:a5d:9342:0:b0:654:9336:81d7 with SMTP id i2-20020a5d9342000000b00654933681d7mr8874996ioo.136.1652741840593; Mon, 16 May 2022 15:57:20 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:20 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 16/27] drm/print: POC drm on dyndbg - use bitmap Date: Mon, 16 May 2022 16:56:29 -0600 Message-Id: <20220516225640.3102269-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155722_851418_207BA998 X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org POC: adapt drm_print to use/test the bitmap callback support. with dynamic_debug.verbose=1: bash-5.1# echo 1 > /sys/module/drm/parameters/debug [ 33.697039] dyndbg: set_dyndbg_classes: new 0x1 current 0x0 [ 33.697571] dyndbg: query 0: "class DRM_UT_CORE +p" mod:* [ 33.698072] dyndbg: no matches for query [ 33.698498] dyndbg: total matches: 0 bash-5.1# echo 2 > /sys/module/drm/parameters/debug [ 46.687012] dyndbg: set_dyndbg_classes: new 0x2 current 0x1 [ 46.687655] dyndbg: query 0: "class DRM_UT_CORE -p" mod:* [ 46.688280] dyndbg: no matches for query [ 46.688632] dyndbg: query 0: "class DRM_UT_DRIVER +p" mod:* [ 46.689122] dyndbg: no matches for query [ 46.689441] dyndbg: total matches: 0 This changes typeof __drm_debug to unsigned long from unsigned int, which dyndbg requires so it can use BIT(). It is currently dependent on CONFIG_DYNAMIC_DEBUG_CORE, which is only aproximately correct, it will need proper DRM dependence too. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 14 ++++++++++++-- include/drm/drm_print.h | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..e49ffda0a47e 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,17 @@ 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_DYNAMIC_DEBUG_CORE) +module_param_named(debug, __drm_debug, ulong, 0600); +#else +static struct ddebug_classes_bitmap_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/include/drm/drm_print.h b/include/drm/drm_print.h index 5b7eedb0f477..0597137bac75 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,11 +31,12 @@ #include #include #include +#include #include /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; /** * DOC: print From patchwork Mon May 16 22:56: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: 12851680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81EEEC433F5 for ; Mon, 16 May 2022 23:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xr72/oPHAMshqBOB9Yy5P5z4twbFMIA3UGHTJuqtIr0=; b=fh1U7VXRBdILT8 Nj2Ngz2Oz3ErovpqClFl2ZyE6/Ss3BLiy40HYwFT6Dbtey08nyUEhz05hr+ZGWzfEY159jXtwTID+ /sIFQ2dzO0C7R5t8fiYkFg4afDlNN8IwzcG9xOL9SE95OZO4CGIMvKoDLeaTadiih/LMg3XEfctVS /Bjf3B+rJts5YhS5U6pm4B9w0WkSYkLR2AWtaGh/LUSUl2zO+tF7p+vTY3J3rylYouJu2JzlPRuH+ atwDjYkU+fMcWmh1YgwYhqddllsX57e/sdt46xG6F7hfVVLFyKIFvTp5Lz7uMQD8Z5uwOoHehtDuT +Dj2DB7VRvJ5aT9RXeRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjuv-00AhMp-JK; Mon, 16 May 2022 23:14:23 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjec-00AZfP-V5 for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 22:57:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=NVvP6ii8T54t9tBCAwTvz1dz4MZixkOISs4Qo1GSsZ8=; b=kFbgm6OMdFmxu4zk078RIw9AJS V/s/Fq8QmgL1CLo33x8G+n9jbTJmSH6KIcBUzw1E6mMS0kNygqxQ638/5lPHAD6uwisEsxiwC0NLi h/QInuRttaQYtk3n0n5Qa+8Fh0oRmQt9kuRFIjtK8qgCaw23t80ArE1CVnz6qJCyisoOeEAJsv5GC 65Y5EDGbW+LVmRn4Ac47bLlyuedkUGzjtaEO7wAi3SEozYQObDdq5GcOBsaBC7CUvTvDdMJ1omBhY W1xhBJWzPkXq3tW+Mq3oQUZ735/ibe/Hn/eAHLYlo9g0YNuWjT6thM2FRGJH4s42UhzMLN/6ZjKYB zNjHfP0A==; Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeX-0012uL-K7 for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:28 +0000 Received: by mail-io1-xd2c.google.com with SMTP id h85so17602260iof.12 for ; Mon, 16 May 2022 15:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NVvP6ii8T54t9tBCAwTvz1dz4MZixkOISs4Qo1GSsZ8=; b=KaaEEVL/0Fno1HcfyHEf4z/GuhJ9D5azg/OjAEcSM6DLHTTuis6Xccyy1ycBgsKvpc yABcTngNZ6IB03n9FcCx+x5tr0OGamuH26VwGNrMjTbOMMi3HONtobw/Fogsnt465ByI FqVV8k8b/C02uYoFKxmplXXpTfBsJRhKRWbwMypPmFFywgnvDLRfylUFScGzQrVHxrQQ quJrCJ+HWHexPzKsRTX4u7w9PgYJi+eoJzechmdTsbGzUZEhZ3M67srd2/FZnTHT4wAL 5GKOiLS5DBwinLdgp5CUnslbZp4lzqFBT2wT+LC84PQkn2+HOK4+oLgm9CfIPrV9vv7K DzZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NVvP6ii8T54t9tBCAwTvz1dz4MZixkOISs4Qo1GSsZ8=; b=56NgtS5UvePOvpqOBcOZr+LUNvsfYgcQp6NNiT305mTKTYZiM/NOzNpFV076gAasXV NnZe5IDM/AGkoH/oYZAGQSEfAdCaz8JhQb+auxcdAm/eQQB5rFJPa9GuI3WQggrdBwfa HTh9M6uRLEQHxbq/2V3YhBTz4CUxCetGMyD+VJFzfPlMjGo6KmCmgxlRr6TMEdTvHatz zYFcsCEYbxCPknBKkl+GPZ2SONBnG+c9inVuhcPsq/gSvqpu6MJQ0VdwjJ7wzdp+/zia NlBrOtb57uA8BFnCi57JaRz69MVPzMGcu4edRcyI0moAfcLuoJjOHmg2cz3UTOL9A8kd wo5A== X-Gm-Message-State: AOAM530g/AMHLTDHVMOvH+9NISqVBn42udeivv2NoNsfJpEBYeK+Bpi4 Nj8LhUdGTwLUz2m/I9Us5Go= X-Google-Smtp-Source: ABdhPJz8lyov+C1KJqzppIklQpEs/1gCdUKmcwNab/OloZ1fJ1162ay06ESiwgFyboGG2TdJ0eSyzw== X-Received: by 2002:a5d:9f42:0:b0:654:9a2b:cab1 with SMTP id u2-20020a5d9f42000000b006549a2bcab1mr9039211iot.89.1652741841822; Mon, 16 May 2022 15:57:21 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:21 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 17/27] drm_print: condense enum drm_debug_category Date: Mon, 16 May 2022 16:56:30 -0600 Message-Id: <20220516225640.3102269-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_235725_919362_2A248D8F X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 0597137bac75..a157485bf573 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -284,49 +284,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 Mon May 16 22:56: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: 12851661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4AA6C433EF for ; Mon, 16 May 2022 23:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=InsUZsKRP7ZiI/L/JRA2TGf79vdDJi32VqMxv4fF81o=; b=HXX1fa4vs6o38o 2NkS3v+Cyt2f5ngeP0Qnh5rNgq9992Ln/1LQYmu6FRoDvITB23k+I/JAzktuvpuOs5tXRaRgALT6I ajb40AM7vWLT6BU6RX06VHMgKyv/2EYe0mkji4Xb81x+3sN7DIEKdpJBme23FPzW2rjLAdmmHHvNj eNLm0GCA2J2r3ecX15pfIjymQgW6GWLRjMTyu5p4S7jKTwpk7Eh//h7+vldEm1+c5q9Uz6gNDXMOt Nkn/Eb1aUwAPOxpr7v0HhebyQ7sfZzIxfhgPt3XojsNDYgKGy5J49YHt+tCNV7b4KsEQtJVTjn3BV n9lEyqFJHW9rhqCIPCDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjq2-00AfOW-Gf; Mon, 16 May 2022 23:09:20 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeV-00AZPv-NC for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:25 +0000 Received: by mail-io1-xd2f.google.com with SMTP id z26so17596348iot.8 for ; Mon, 16 May 2022 15:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0whoQsHeXptrD3TNBMDfcpTVQVx7yqX9gABSaE73ckE=; b=AjOW5QKHWAhuW8wlCA8uuv2ZQT1FNjJDoVWdRAg9V4oMd1YtwLUqQZVDxiv/rbW71G tDRTWR9Job2tMXwm4Qd8Ii/ebOOvCikKkxjmZrBLO7ISvABeNVw6gvCLoASZz5A5pXkO 2bN2fkk04CX99rIuougRR1DDpjTLdlW3z+ihfirjoo2HTNidV3pvGzBWVYgh96HuwnW0 UCf9qP6aDTPW1iDEu1RvSp4uR1BITAHIy69wuCgUtAna9woMD6giGXzerTkJfuxaz0uw XDXaoC2eMmQa4b1Be17Zhmfqngw3hKXPfmYkxXSju1ug26b57seHZvjLaJAjhjRR7K+E cBMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0whoQsHeXptrD3TNBMDfcpTVQVx7yqX9gABSaE73ckE=; b=MLrIe26Y+NOXuYx4sb5Wj+46p6uPU1Oj2d8CL3EZEM4ZXMEsK40oN7uib+HPRW+n2U 2OUvf0OhgAy1wLvPUduJZil6pU+6ozejEUE0LJpSZu1MZjrMGuc5w0W7X2musf0wR4TJ tUqTlsqmjuecwvF+cxAOksz5w7iFioqk0RYRDxU2M4xew7Ccah7MJjyEG6BYPRk+zeNx hND+NZEFeaPZz6NcO5Fg8rMUawg9y5Q8Z2Ar6gMyWVWjVoAqu3AXd273QvTWSSfhT5gQ evuu2GLHRwwoEjef7cf8ZXdTZOYQSJyC5hMcrUYm09N8jxuWTbSqfWwZKXYGmSIBnp29 PU7w== X-Gm-Message-State: AOAM533hPDP6gQty3QhSXhDnQYr8/dTuzNdfxNnrtjRwvPGPRGt09w8J 2fAcKN1galAFnWe1iepQOZ8= X-Google-Smtp-Source: ABdhPJxJyh+nGZnbHrXoqOEA6GXq4pUukckz/GPygz5+sl0Mlr8SK0ojc44qkJAMzCz0Rf5asl73WQ== X-Received: by 2002:a05:6638:2416:b0:32d:be90:ecae with SMTP id z22-20020a056638241600b0032dbe90ecaemr10896364jat.156.1652741843354; Mon, 16 May 2022 15:57:23 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:22 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 18/27] drm_print: interpose drm_*dbg with forwarding macros Date: Mon, 16 May 2022 16:56:31 -0600 Message-Id: <20220516225640.3102269-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155723_790189_9C5CE03A X-CRM114-Status: GOOD ( 13.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org change drm_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 e49ffda0a47e..e77b49c7725b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -266,8 +266,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; @@ -288,9 +288,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; @@ -307,7 +307,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 a157485bf573..383feb0d34fe 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -339,7 +339,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, ...); /** @@ -388,6 +388,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 * @@ -489,10 +492,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 Mon May 16 22:56: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: 12851679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A88A4C433F5 for ; Mon, 16 May 2022 23:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dRFOzhzWbeZPwghDO5Ay1MUsUWgugSkOeEDnVHNharY=; b=TQkeF4Lx9Yij3g ezt5guxs/qVyK8GpIXJMMg1I/TRXUjt7ZobPbgNGhKLR9LIpacIiA7ct0wjytErsTyuux9WLqbVaY ysnAGbqnGyZhb8aFbzaPEEI+AOKYYLRKioe/K1Y+ONOc9QmPdyaWQDRMDNA6f9PAX2Vxt2LsSijP5 ogy7r9k8oawT/lhs/LVUWSF3DFTLrWK1ElUvijWu4L0Uf/jZH5gItJ0Oty/3Uy0swIa27MjZl5SXU O/QmlE40Dajic9R/Vva4QCuPJipnb7tQY77maEY84/B07Splz4FG+khcZ2Q7r7klWrOWCCn9kQk+o zwZEGNotb7moTyxDqhAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjuD-00Ah5G-In; Mon, 16 May 2022 23:13:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjec-00AZfl-V5 for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 22:57:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1Yg0hfvp+BmxcSgu8fytrAqr0N0fDhKY5AcGJ541Vt4=; b=b7vqoAoNpz69ataKihoLilT1IX UJ9z4ab2uCV7TlkC9Ts2TvIvGpQ491aWsBeCCoJqJpDW2QiNceSgzVwMYGtVIPgrsRkw5PvvZVh5r 7BCzTCrNCfDfyVLg8zP8bSFVyoDpuvDogJVmAO7oMmMXPZKxd0TIgoprV8F2A3alrcFZvTTlcjOgc WAfSQi89asGn4r53YHaFtNN7WfmonoAhFWAJVvtjmQ5V1utabeQg3HEuzutBc/LQmK8i3Tp41HWwV jT3toFx8RR5ZzMBGjatK89NuNBCJel58phRpmWlayAnWT1p2DyTTcKvIJgnBSv0QvtvILdCNpklTN L6JyiYbg==; Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeY-0012uN-Ds for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:28 +0000 Received: by mail-io1-xd2f.google.com with SMTP id z26so17596839iot.8 for ; Mon, 16 May 2022 15:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Yg0hfvp+BmxcSgu8fytrAqr0N0fDhKY5AcGJ541Vt4=; b=dWGN52/uMGZPLCm9DAsNSwPc8WDoRa3MYIYpBLVuktftVDHdPBMXzNT7bw2NK0d4QS tlhq8uqKcYP0mA6rGrTCTtTBiRhSsZjmBR2XPxSitUdzeTvpDCY20jEdPMFkf4Mgzq6I kAbXN0hkZ4gyh2r/JibCVdwOUb0/AVVYsgy6sM6Ft1mYm+TlpAzL4/gWLcDorVFGbpsy lQhpLGDETkmyJEwojdA6Oh8QbWss1EXi6Q56FFGC5NtiuISvtwH9211qeYOYIlGot7PW WnOCxK8TL5nmKm2N6HncMik7pqaTmbF+vILYMXfnFs/cP/LzybB7fg0TW2u+XHA6Ib70 USSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Yg0hfvp+BmxcSgu8fytrAqr0N0fDhKY5AcGJ541Vt4=; b=L7e/jozKHgIL+QaC5wWL+gM7ynsP4yZbpq6Ld6L51M9ohuPU+nYP3Kj+t2DpuL5Tlz uUFbnioEdgnBv4FdeYCb9+yntIEq8ecZ/mriHEkQM3zO3QAEVyz1TauPqns/bd3Vnxog Damd7hTH9giYRIgTYMYKp4sP/pWzFsXSUz1MXYBNwAPrnXrvSediGezKPCoY/pIY0eT+ E3o1JDYu1QAABFGfaLZ+GhiawdEJRUxT20pUENkWjXDEiJ0F/46ZK1+yphLDiItwq3hA wB6bZOwcx0Q1Mr5QMNP3MwqoTCNJvyVgkZAsx2Gtx0PGUTAm9ATMYWkfGu622nqWAD0d f5VA== X-Gm-Message-State: AOAM530sFFODdRetGU4oxsmXKJP8Ff1Oh6N25ZcmjWqTVqSMB2QCKSRz XqYs3MBZRqHi/5ghYhqda90= X-Google-Smtp-Source: ABdhPJyCiUxiMjcIl4lKkntDnVrLc+KJKSwf9tOnaQ9S/++Hg+2TbTnp5ybSIf+mrEvURBO/J3FHSQ== X-Received: by 2002:a05:6638:24d6:b0:32b:e72d:1a33 with SMTP id y22-20020a05663824d600b0032be72d1a33mr10309855jat.226.1652741844567; Mon, 16 May 2022 15:57:24 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:24 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 19/27] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Date: Mon, 16 May 2022 16:56:32 -0600 Message-Id: <20220516225640.3102269-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_235727_029029_C1778DB4 X-CRM114-Status: GOOD ( 15.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(). Next, those functions are adapted to accept a descriptor arg, and we drop the _no_desc suffix, then the (~4000) drm.debug callsites will be controllable by their class-names: #> 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 ++ drivers/gpu/drm/drm_print.c | 2 +- include/drm/drm_print.h | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index f1422bee3dcc..5ab31753c25d 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -63,6 +63,18 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default y + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + Use dynamic-debug to avoid drm_debug_enabled() runtime overheads. + Due to callsite counts in DRM drivers (~4k in amdgpu) and 56 + bytes per callsite, the .data costs can be substantial, and + are therefore configurable. + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index c2ef5f9fce54..e93b7902994a 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/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index e77b49c7725b..5192533794a2 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -53,7 +53,7 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -#if !defined(CONFIG_DYNAMIC_DEBUG_CORE) +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) module_param_named(debug, __drm_debug, ulong, 0600); #else static struct ddebug_classes_bitmap_param drm_debug_bitmap = { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 383feb0d34fe..5c39bacac2b3 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -388,8 +388,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 @@ -496,7 +502,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 Mon May 16 22:56: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: 12851662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26389C433F5 for ; Mon, 16 May 2022 23:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N8FmK3xhzv6tLosfEMm/3zBEGVa+av6/U1FLPS8EfGc=; b=jR3ZQKFnRG9k1r E5hjFYdEDenEUH4vXFI2dlgD87ETz/33tlWpQvCutVIFqpxAw6cFtkTrVhdKMpcWlJlqPsVRGr0xq lnTyeuVeXRbWL9hl1Tp+jpv2vEW+cNFGO51nx58C66xRYS7LYCFmz3KAbEZsqEpDvRdo20/rZDdiJ mYc0gjZnlJnSMkrO9MXDyxKPIxraQrWi5SJTKGiNcFoIghJaA72wSThqxWxEvl7sd8PLNkkCY2w20 cuoIW4NeIi2XIjfX14k9E+rSdRoy/Y0H6p4lZH43qyWPhspxcWBFQnNqRLu5QbOrVdnBcB+M49zxX Y+iPRGzZK1Uk3hEoP9OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjr4-00Afnk-IW; Mon, 16 May 2022 23:10:23 +0000 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeY-00AZd1-Cd for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:28 +0000 Received: by mail-il1-x12d.google.com with SMTP id t2so8465470ilm.13 for ; Mon, 16 May 2022 15:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=it6bLhFwPCS9KNMNbVAc9u0r1hyTQEpcTOU7DVjaIzc=; b=cLcNGP066hHaVqlFNtXCmZ1CGCDAlRmjr8Ddi2wGeCAS0G188epVjNoMgFTsYz1FhS KwC/fi5w0MCKcVhAzgWTaAyw+jbVNB24fPtZqpyM2QJFQ425pkWWyCI9IkbK/sjrV1Nr VH0wWrWNzvvR6xEjBnwkVSgs88cMc3hP8dkgdaIQ1LrtD/VWN/UO2s3FRnPa5oMd5so8 fSnTqRZENTyoMjCDNvkBUwdEdImN8cxny/1EuyBgylEspCk+qlkkMhhF7mjiK7FL010n kgcvXTfvTotxDueX1P4iF6MOjOgVE7J7E3ZeBWAm2Cih8qFLTTugQGWmxTynuy+uGziA gtrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=it6bLhFwPCS9KNMNbVAc9u0r1hyTQEpcTOU7DVjaIzc=; b=qfwEEWbjDzU1m0KxiJpsOPo6NZH9ZlZwuiAx8BHGyc6EZJTNdWJgFUFqW6JcH3vSyM mMVGQpau3r0M3OuR8XDXOwOlb+GcHjgDe9uSTo2fuN9VINAoqC6odkIaGCSx1O4qJsrL OdyIbR0dEiu+GJuWBRY8kKVa8BvijWkX+uHczIL7oLmRh8P70B73R6BjQ7wQ3xukR5ra RIMzRbCosI7gsoqpDZGM8JKEY9SSZxPel2jmoph9MYj2O78DJtzlsYZN3pG0qU+gOfA6 CsjbOhS0TpX4C2R/r0ZXyaTn6J4yi3cks5+yxFaNk9GY9ojIm9OfrbqctR/C9NIBAQVa Ow5g== X-Gm-Message-State: AOAM530HzYh2TEpAY3zgx/AAkUvZOHB2OV4z/5z1KnAr3hKmXZOoz+Gs 8dOP5ugVpZmHNI1NONlJDwM= X-Google-Smtp-Source: ABdhPJxL66r9um/Qj19jzq2i+w5GjaE1kV2BNicea7CTlLXB+S6WjzXBR8GSASV1PB+CpOnfV72D2w== X-Received: by 2002:a05:6e02:1d8a:b0:2cd:fa75:6395 with SMTP id h10-20020a056e021d8a00b002cdfa756395mr10067705ila.294.1652741845777; Mon, 16 May 2022 15:57:25 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:25 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 20/27] drm_print: refine drm_debug_enabled for jump-label Date: Mon, 16 May 2022 16:56:33 -0600 Message-Id: <20220516225640.3102269-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155726_484672_1E8BA55F X-CRM114-Status: GOOD ( 17.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to use dynamic-debug's jump-label optimization in drm-debug, its clarifying to refine drm_debug_enabled into 3 uses: 1. drm_debug_enabled - legacy, public 2. __drm_debug_enabled - optimized for dyndbg jump-label enablement. 3. _drm_debug_enabled - pr_debug instrumented, observable 1. The legacy version always checks the bits. 2. is privileged, for use by __drm_dbg(), __drm_dev_dbg(), which do an early return unless the category is enabled (free of call/NOOP side effects). For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, it identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- 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 5192533794a2..22b7ab1c5c40 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -272,7 +272,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); @@ -295,7 +295,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 5c39bacac2b3..ccd177236ab3 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -324,11 +324,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 Mon May 16 22:56: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: 12851677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBD37C433F5 for ; Mon, 16 May 2022 23:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/O2fXMzmGuh9ozDZO6o+aQGLkVLooYeWBUrnJDKDkHQ=; b=Z+Q6UWdMjhaWVx eWUB7skO/nbMECaMUMxFCrxea4j1tMndDon0PfqT8mgrXLeZNA7D5fNwlPAHdRtp598oM7TSbwIpB jkRTgITyM3q2AArLxLhUcQmaHYqgrjHUX1k44LOPqSp+HCN2hW+Vv+6ghDrsibCGFH8cbQurzvN3r N+ACcxAnOBOfBSFPXdSR7Uwsi0q61pVpvv/SRBWl0hgPcDJP6p0utZO3QiVWy1+UaLMYsCP87pBwP tA3bIN5q4MR66wQ3m89cZputfuXHNeULFwbtyxXp85TiEWjFrEDrWROp4oJRJSdkLyCxzMJVI9EFW BlOm7aof7meaTx82/ydw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjsJ-00AgJ5-CJ; Mon, 16 May 2022 23:11:40 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeZ-00AZSw-OC for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:29 +0000 Received: by mail-io1-xd2b.google.com with SMTP id e15so17624661iob.3 for ; Mon, 16 May 2022 15:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=275OPBiQ2XPDTBRqKvoZzw/+Pf2YOYW8BZL5aogRIAM=; b=erXw/YodA3OXO6nPINUovqh61wUerUIUtr0unKej/ygKy09BntPa7b2Ga/snFnWqRN mtoKDgBhHIuI18S7owrD22QKbctFTy/M6o9shAJ6+0ouzudUyjANzXNDMc0Q3hIV+f5q XnYixuoQFoJZCiCQDsXoPHqPdfWbeEA0c/7106IbTnzOiTQOCS35fre1X9yfUACWftd8 LgQfxHSO1ccHM7ZFABS+oM9u+ZYIQfZXUVXowulqyibhSPLwsJiSFjdYhvpsOOygWG+u n6kLxDSr0CYelPk7OPO3/RynfWIFOXZ/aAUWpWWu1hoV6RWlrK08yikqaaHJMadlmP8H L6Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=275OPBiQ2XPDTBRqKvoZzw/+Pf2YOYW8BZL5aogRIAM=; b=EAXS9yNpWHoe+ew0kvszeDZQdO4h5VRDMF1a3qm9XwNp4ISeZ3EF6LFvOLN12MANev WZjctIMTp9BEBKZbjcniuB1v7L70itgvMhyr3nd/nmw9MTt4Ues7Ddg2Rk9GSUnsFh6g vtCi5vwsjmmFIQUVpiGNDF8dCERMhzZ/iaTGkoiCkFQVU6qaVo+1Ygc8M6xXF/glrYdI mUAU+QKWnnNdAHye0lpocaS2uZnV6PDXXVWG0nc+p9CFBxtaWAqoRmCMm4ajVWFQtqp9 E4Ux2dAT3zlZ46kuv0Ma4Co9dGQjwVsrm2vkrmDc5T2mSHfIU3VY3clRn1YqTQFHqHZC o0lg== X-Gm-Message-State: AOAM531n0NmkYxBxHIPNrkaolOBMX9RYc/IakMALC1xXDxsm/wuyqunj 3/Zchg3VbWCcU+PurojcR2Y= X-Google-Smtp-Source: ABdhPJz8ja5KMGhfVRvrrgjeLgWG6Cp8mO/6M9ENzbru9N3/0pmPE3IQ+As/ImX5TSoW3EuTo0LvtA== X-Received: by 2002:a05:6638:b:b0:32e:3b8d:3e5d with SMTP id z11-20020a056638000b00b0032e3b8d3e5dmr2979106jao.91.1652741847355; Mon, 16 May 2022 15:57:27 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:26 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 21/27] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Mon, 16 May 2022 16:56:34 -0600 Message-Id: <20220516225640.3102269-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155727_839942_4080FBC7 X-CRM114-Status: GOOD ( 11.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org drm_print.c calls pr_debug() just once, from __drm_printfn_debug(), which is a generic/service fn. The callsite is compile-time enabled by DEBUG in both DYNAMIC_DEBUG=y/n builds. For dyndbg builds, reverting this callsite back to bare printk is correcting a few anti-features: 1- callsite is generic, serves multiple drm users. its hardwired on currently could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading they describe only the generic site, not end users IOW, 1,2 are unhelpful at best, and possibly confusing. reverting yields a nominal data and text shrink: text data bss dec hex filename 462583 36604 54592 553779 87333 /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 22b7ab1c5c40..1b11a15366b7 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 @@ -172,7 +170,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 Mon May 16 22:56:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12851678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDCD7C433F5 for ; Mon, 16 May 2022 23:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DNKcxsrfMCEREbnXYHBchIu3lEjQhh4TM2HyV2kaGII=; b=u/WbHvNEnl40I1 ZLarjmamp4PSyB1oRDGxsyIDXmk46lez2lm2a65F2ki3kkAqC9Gqbz0kZP8PP1ym44ZOB8/6NivGY dtma/o6tmAqiYQZa4fw655ZPgCBjrYESuU7Tp3PKQCvYxWe4W0T0yFS6aGC0+8nX+Hp6cP1RstMDY sPK+9YnnN7bc+6Zbmzm4fjRn0KAGGYQh/kxBlYa8nxXC9kOK7sYG3inL+eK+7VUZJf6e4M5MOYZkP g63q6S3KdxypCrfkh8L1i1OqFxj7XM6Aoc60V30mE2slP75+I4UMHSmTDe8x+1hhLDS3k/Msyx9XZ +Dvu9UuT4sOFFhqhvmqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjtO-00Agih-M1; Mon, 16 May 2022 23:12:48 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeb-00AZPD-1P for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:30 +0000 Received: by mail-il1-x12a.google.com with SMTP id j7so2188063ila.1 for ; Mon, 16 May 2022 15:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Lorhsk0X7YamG5elji+uQ1/gsBB2n7Jli+kbKqhzIg=; b=jy+CCznjgA7L1dhgzXrr4jlT4O/diTgk+LIO0EH+xOiCnetz7+vDqqCckOORUlXdfi CwbbYXdjAEzXOKUPSTX6/VmeIFWkhbhW6DOgUbIdzS//muVJvPgXhoGRwiN5I+gPpauF z2Ce0S6NP/Ix2wJE5JYz8eqy3KBfT8W14Gnqg5d7ID/6i8fWFVXvE146qO2236dZ94US TsgPLIFIr1+C3maWaa7e8Lgk9n32ax4uyoSoHLIH73f91qMj32AUOSJeq3jMCkaQeAbA 1+tXve0thRfbAjtaHC4IQZhVeIlvuH4WQjH5GjXvsB+s5fReOsuRRcsln7eajDNk57/E Tysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Lorhsk0X7YamG5elji+uQ1/gsBB2n7Jli+kbKqhzIg=; b=EyDUJ5FJ8aGZAA9bI4ww4Qilhr8cepq5r4riTOjMuKLGmDTQoeoj3Sc/BXYp37bFgb 4my4sKNevX58NDPlZopk8mWs9cviDIngP+U0gMUe3xVqryEJq1uL3b9AeKu3FHyaD3x1 DUIAp9X7Ul/8P0BNwslJ82s5+0Q4Qylssa7Qo3AbRzVKE4Wh8AeRUI0P/jLShdEfsMXe 7iqynqc/S6Vl9PU82V4wDvHpdtkeOR6uNl7EjTF0s59CvNw38wHKqr/gw6+TfI69s30s TtQmyuRsmDoesTZSMhxyibCkpO+6UOjjKfx0MQHbpfrunrr5VwTPDXXHcDERaygHrNO9 BCWQ== X-Gm-Message-State: AOAM530mgPNqANFkQdpiSH/0VnT1ktPUZYc4KH1CpXszDhImNGbTbiY3 /ZIsZSAQZt4nLiZ9uCzUIRU= X-Google-Smtp-Source: ABdhPJxjJINasg3hAWp7d73zeGu9P4K3x20riV+fru35nOD3ueGvMgNUWGevc44ji4O03Dl/YneXMw== X-Received: by 2002:a05:6e02:218c:b0:2d1:2a75:7751 with SMTP id j12-20020a056e02218c00b002d12a757751mr2652901ila.22.1652741848590; Mon, 16 May 2022 15:57:28 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:28 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 22/27] drm_print: add _ddebug desc to drm_*dbg prototypes Date: Mon, 16 May 2022 16:56:35 -0600 Message-Id: <20220516225640.3102269-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155729_159732_43A89E94 X-CRM114-Status: GOOD ( 14.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a struct _ddebug ptr to drm_dbg() and drm_dev_dbg() protos, and upgrade their callers - the interposed macros added recently, to use _dynamic_func_call_no_desc(); ie drop the '_no_desc', since the factory macro's callees (these 2 functions) are now expecting the arg. This makes those functions controllable like pr_debug(). It also means that they don't get to use the decorations implemented by pr_debug(). DRM already has standards for logging/messaging; tossing optional decorations on top may not help. 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 | 23 +++++++++++++---------- include/drm/drm_print.h | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 1b11a15366b7..1752b40b0189 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -265,8 +265,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; @@ -274,22 +274,25 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, if (!__drm_debug_enabled(category)) return; + /* we know we are printing for either syslog, tracefs, or both */ va_start(args, format); vaf.fmt = format; vaf.va = &args; - if (dev) - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - else - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - + if (dev) { + if (desc->flags && _DPRINTK_FLAGS_PRINT) + dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + } else { + if (desc->flags && _DPRINTK_FLAGS_PRINT) + printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); + } va_end(args); } EXPORT_SYMBOL(__drm_dev_dbg); -void ___drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index ccd177236ab3..fc0f2f6c2b91 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -366,9 +366,9 @@ static inline bool drm_debug_enabled(enum drm_debug_category category) __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); -__printf(3, 4) -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...); +__printf(4, 5) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...); /** * DRM_DEV_ERROR() - Error output. @@ -418,11 +418,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 /** @@ -525,17 +525,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 Mon May 16 22:56:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12851723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2FDAC433EF for ; Mon, 16 May 2022 23:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LwU5dXXhF/Lr81V64q2E9O1bcEcSSUYpv2+g/MJkCdM=; b=py0iewqUut17xh jab5A+BV537uOHoCn/EU8etDJiZEO2fIVzSmJ4Pi0dW5w/hDxMBFNOTA/cAhzRiGl36YeKKHp3TMx tlQy9jLSYTRvMl9HixI2BW1PXrIJieGFT4H/h6sgRHpQS+qSz/ncoSjuE1PUZ1jaYIbR1oiU1V5kP CTsv5StvOKLmTyo6U8y8pOCWe4taeRd8fVtXCyvxlg98CtWuH+S4RZ8HRLUMZRpMqx7aG56h1hpOI 9vB5sU6T4rVDvcr7LLu6/xCeWLqWWtszFONqnfGpn2Gk+90dqsa2LpqpnN8c72MZYboESlHdwur4F eLY1sq/cfrAgB/zNpgVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjxK-00Aifl-J2; Mon, 16 May 2022 23:16:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeh-00AZjP-V3 for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 22:57:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=98dXLwCwtvAkevCuwtWfQGU6ISlKpMHx9nUQlY+D/5A=; b=l7OrgOuZzfRQfM2mUMgb9bIF4/ xY525ptdjUQcr9j3dKP0QAbMiIsTj5jT6JY+CsoHOwt+gL3hxFPFUqUilThzzeum814hBkRsKC+Wz Ms4hAdYFFu8sfaV+o0aeYVzk7rGcR72F0RnI2bawFndrbK2OQrNR2ql3tv8WKsmQM6sn6bmZvcu+t wl4VIqD/hTXJ7CyzBLBDIR1FZHmaXJOFQ3UPZzpkZaA4HZve9J9Qf7BeFvhIBkwEq6VQ0/oY7klhF qr1D163GvGMydzvZ3rZL2nfVhlyBikLTez38YpZxOitgIb52PiCVNOK63jk0P3ptQZuvt4KPbW5Zs BbwCO8XA==; Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjed-0012v0-PZ for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:34 +0000 Received: by mail-io1-xd31.google.com with SMTP id z18so17631570iob.5 for ; Mon, 16 May 2022 15:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=98dXLwCwtvAkevCuwtWfQGU6ISlKpMHx9nUQlY+D/5A=; b=ZEGRk6DFco5m5XlUAGmr2Mhthn/XqWidnCJTjWGQKyyfdqThI3GnZ7mVTSuWXXAobp sJpzUpLz8ut25WaVuAd4MfvdnkHt0aF3Aj0Z6vEZAbq7kRcqNn98htucIF/8w2kgf1Qu hFrIwCK1/tXTEtowkxY4IxQTONdMBIM6zn6Z7AfoE7WtvFJd7nyYm7X8VESIZ+TCgVcV kY7azYIpAyfqHG8OqPTTZ4QFaZVX2ex8AX+FhjazlsIeC24lBdfopKxAJyul5Sn4fU0Z WgIHuSDNciECmT4wSOao7Hw2ihEdolkhYZD/yEC80GY6jJVvCGdB8Mu5c0+0ZMZ8jvgG yKSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=98dXLwCwtvAkevCuwtWfQGU6ISlKpMHx9nUQlY+D/5A=; b=lu+U5b/BZ7O2BYj0v0d/a2jLCzfpBzEKYlBeM6HWC7sla/gAxPEFE9ubvE8tb/oSMZ umJsp1p3uXVDATgy+uYg/us3KFQrWLcQv1cyZoNb9NGMfB4boYvkudxSJI+K88t/wODz wXQd1MKzAWKoNUWAeS0zcykJ0sT7nv9hzTmw3B8s/FUSHi/F/gn4S5Jp/O2/NVRjr4D7 n39i9ytrMHVeUQz0JflBLEnIkFNG1H/KpZ5teFx6CG/JLgh2ZrBHf+bln5b2aurcLEH0 s1Ar1TjdLhH+TrexYVmvSpHQ1FZ+1G4phNA/fRqGZUt5jlgIR/Z+5bpf8aHp9PBQL9GD sKmw== X-Gm-Message-State: AOAM533fJ4679TN+H8ir5BzlQKni/79hgBZUCS5Los/ppCIEXait8TYR /tZ3wn67ThB+nOJ7T6MIfyg= X-Google-Smtp-Source: ABdhPJwwVfb8OtFmz8SO/9FTSA/s2EXiW9+itOUCNnaukYlrF6hYBbLKqUf40k0Y82iDGh+c1YIjFA== X-Received: by 2002:a05:6638:204e:b0:32b:b461:3407 with SMTP id t14-20020a056638204e00b0032bb4613407mr10113394jaj.132.1652741849772; Mon, 16 May 2022 15:57:29 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:29 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v2 23/27] dyndbg: add _DPRINTK_FLAGS_ENABLED Date: Mon, 16 May 2022 16:56:36 -0600 Message-Id: <20220516225640.3102269-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_235732_273832_97646601 X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Distinguish the condition: _DPRINTK_FLAGS_ENABLED from the bit: _DPRINTK_FLAGS_PRINT (and define former as latter), in preparation to add another bit next: _DPRINTK_FLAGS_TRACE And change JUMP_LABEL code block to use the more general _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 --- drivers/gpu/drm/drm_print.c | 4 ++-- include/linux/dynamic_debug.h | 10 ++++++---- lib/dynamic_debug.c | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 1752b40b0189..77b56399147a 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -280,11 +280,11 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, vaf.va = &args; if (dev) { - if (desc->flags && _DPRINTK_FLAGS_PRINT) + if (desc->flags && _DPRINTK_FLAGS_PRINTK) dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); } else { - if (desc->flags && _DPRINTK_FLAGS_PRINT) + if (desc->flags && _DPRINTK_FLAGS_PRINTK) printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); } diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index abf43e28d8d3..0a81a3582281 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 @@ -161,10 +163,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 f9c5bbf9d43b..5682ee477677 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -87,7 +87,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' }, @@ -238,10 +238,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 Mon May 16 22:56:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12851724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5248BC433F5 for ; Mon, 16 May 2022 23:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uDh2KdNf5vLarrWlXKTxaUd1ii0XNZVgKpTtPk+ZZu0=; b=w60C6CSYF3BkGl XF/GnvBL4y34yyesvcYYw3U94aem0MXX/cTH/sC6TS52cPCQ7mXOOZF+eJvx9taPjprNKz+H8Lg3b QQTNjB901zevIXsw9TEWMl2djhQnZ/fO4YsYl5/UTLj1lsHDvTpsrrwkVrCHwex7Ll0SEf2hNEceU 6hzSvukiDotBYzqnpPUdjgfgRRwmZn3gzBnLX69nF9rOUEwTsk/RqsCAIkQ9aPrsyYRlm/nFQbJOs 4IorqIG4g7OOEJX9PR/O4HxWGecV1PkX/n7Gjyz69w2TTzrcL6bKCMGDcrpQN7bjzEtFCtscWDbvw 2xQcl9zbi2uTx4zw7VVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjyB-00AizA-KU; Mon, 16 May 2022 23:17:44 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjej-00AZkR-Gc for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 22:57:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=I+2n+Qi5LKo8xdlXx8cZCrXhjdY5i9BhXeRgFpMPxBs=; b=ijbthrm/ZSM/u7Sz8qbmIpU+HI nGiTvoZdDytl84Pf2FTlefUqelmVQ4gcL+71RT6hdAB2KFM2Kvs2NuLgbg3msa2nirr4wPa5JPKNs JmtWL6mVAdwA9LVe+wh7gMzeeg9cJ/lVm0sZi47hl2/2Lzf65oJkJ/qeqM12uxVbfMXDQ+sss+BWh 6bboTQtgRpMqPtGnFeLqEAq/oXp787Q5y1u+iAWkllHHEp76bHB+RSVUKS/6OPl2GGEH4urIUYcbi tgvPbAJu9A9NWx5Na9LxXvfRac18kNjaSEndyxvhI4oiNe4LUzZUfaRLJmECaZjuqEWlXtgj2emzA hTsG2p9g==; Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjee-0012v1-Oy for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:35 +0000 Received: by mail-il1-x135.google.com with SMTP id o16so3061659ilq.8 for ; Mon, 16 May 2022 15:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I+2n+Qi5LKo8xdlXx8cZCrXhjdY5i9BhXeRgFpMPxBs=; b=NQvoUylIO5JvRYRKkb/PCHnnwolYl6EbdFp0mMCOv7MitmhVqHAb5guVHOretvbXjK ZljP5Zq8ojGECCuyNcDWedKGEwHiFr3bCx9zWLEYf9W0C+nds9whhURlD9XhKiSCO7DQ OGyXFxaVtVysjInj2DdhVyi2W/F6rtyFXOxT1NDAy0Fyt81yzfNimcH58u9kA9Qk38k+ sAUPfKneovsA95xw04+fA0iGvfWCZmSteGV7Z7d92x+iUTw7lesFH+Yg1NwMefbEH99a RIrxuNyTYvZK9T+FMAQcUTHSJMrLbpYDwtOrpy/1WdhW9+HOExR1Q6lM+Eh1+wASXI2c ojNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I+2n+Qi5LKo8xdlXx8cZCrXhjdY5i9BhXeRgFpMPxBs=; b=4SF58xlczz4zcthgo2Utvpwaq2BXTdZFESJQLKTU3dLrk+O/a1hkHkwOrb20gObrHU 2nDs40geYEF+vJoFMgvtzE3hj5vKpSRfHnHyp2NpUin+eZv2qxXRJmkZgPE60gSUfyGF gOqYkIgtvFfb/UgglsvNzSY1LgTSxfNrgmGVf5c+y3uaydYZw32fX2Zegx7AIyGgB6x3 0FrI7Crx12gQJcFOWY3vl1BDcySicjeVMRn9uxAMyiAx4UMMTkc4sJBMoa3nXx5phn5F w9mDF5zI/jS2u5W7wkKZYTvIJ25v3+/xd8wZ0yWhNXAmtBV8bDsuSRxxYrXrvv+NEPjI pYYA== X-Gm-Message-State: AOAM530LAbXvhupHVxKBgP6CWhVhspl5f8cY6m6opG3VI9buVKcUpOcG jKRmptf8z7EuwbIB6ErhxlA= X-Google-Smtp-Source: ABdhPJzgjBowqiniO3Eh7ofaYMSxlAshWUZJs/9dRQj0V0v9y1HG3rau/LeKW1REX4tDssVHSSqPxQ== X-Received: by 2002:a05:6e02:1bc6:b0:2d1:1344:6727 with SMTP id x6-20020a056e021bc600b002d113446727mr5815014ilv.58.1652741851004; Mon, 16 May 2022 15:57:31 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:30 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v2 24/27] dyndbg: add _DPRINTK_FLAGS_TRACE Date: Mon, 16 May 2022 16:56:37 -0600 Message-Id: <20220516225640.3102269-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_235733_232610_9EF32413 X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org add new flag, and OR it into _DPRINTK_FLAGS_ENABLED definition CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 0a81a3582281..7581fe79980a 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 Mon May 16 22:56: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: 12851726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 580E1C433EF for ; Mon, 16 May 2022 23:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mh5pghp69FuF5Dcp+NdZyxqw38+M8HGFJkiVsG7q9mg=; b=F1m0M2Z6/bfoPH RUI91ZwxExs8npC+59VovhTq/TkdeaHK8B1jOogN6Zhs4Vic0W9QkArZG2JqVnG1pdV4LIOKYXIai 0/M4sgie4eSN+/aTpw9VGF0+dIdCqvQ+uocGQIs4Tmz0aOqZgnf7tCIXOHk1wD0Uy9b1QRWd8nrd+ S6S6WFeQ8qYYQnYu8zKPqdd2676UAD0+irKid8gvBT1/cNl8PbNB5kfwRO1fvla1cFqoGQWP8DnVc AL7mdaRJfzMIePV2NBb36ZtMn+4HC4vLdkmV2R32uYtMwzxYQUa4vs3fMUS43N1LaUmFav5oWFKBL lDHxARW3diGudLndDhvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjzh-00Ajd6-Lm; Mon, 16 May 2022 23:19:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjel-00AZle-HC for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 22:57:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=caFoAHAZrN6Nrr5FNeRmlwujqgilZpBF2BSLNzuccOo=; b=TouMBtjuOgwycHeUl88bd/Q1e9 2y/0K+CDT4C9Jdp5Xht7p6QP2xJ79HcrXTzqkTL+/9vGxpoWHHn414gt+0Cbl+reoNwNsA2dxpFN+ lYCtWDEA4WG8l2OPyN0wrTGU/H3lMPqs7+8X0Um1mmI7jUcm2NUz1mJn3QSfcr8ih82Dfur5yodGp IDpBkTPyBTRpw7AAoakOLxo8oE1LI3pCLF0/uImstw3e4tkkLLNDfCES3GR7AC9/TJ25ARL56xbuT 8mr2mVuOu2E1oBAbFNQ+6t63hs0VhBeeCXdKvIuyqJjZd5DXzRU/m/mH8Sk8cYHacET5zOlpdaoUZ 6VNce7fg==; Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjee-0012uL-JN for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:36 +0000 Received: by mail-io1-xd2c.google.com with SMTP id h85so17602260iof.12 for ; Mon, 16 May 2022 15:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=caFoAHAZrN6Nrr5FNeRmlwujqgilZpBF2BSLNzuccOo=; b=NinNvSUN/V7+ZBcOy7kFMOYb2ewqtyqY6O7HWY3BR6FV7Yhj9jnrpeooDnoAcckWIr ELrZbo+4SuvVcAbWbb+xUAL306VSI3QFk6P2p3HXVez72y347OrXoSSKXNosPuUIP+67 r6swfAiLyWz75WRG32WMwXcJ6C33jUFVgQtXkikEfYfA3YG8jpZxKu4XpBImCxI5UNmO UQVXa/N1t8AxBA65WVkCUgRmxqoq8aWSlc1tiWE3HbLH4t8OVTa1Xk8keeXy0JU23E8P FdF6AAajZkc7+S635APfipItn1/LufrGU4CxiBzyrYWiTCMpNCwVvx7yDdGtGyywjj5l smZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=caFoAHAZrN6Nrr5FNeRmlwujqgilZpBF2BSLNzuccOo=; b=kyc2j/l3qCKtbcRX2Arky1uBRW9/ysOfmDhD6zJ8sHCIDK+BtPbwt/KgqAhJ+PZgZi acUP7cNUob+6DQS2fnemsk1zRjrnS4XJjoopGx+MeFg5xasJUJviJMaJ4n93R3wXM2u6 DBaFCLdRRQuoMBFc1SvjNG+YBgVSsmtZE1iD53cc1HcJUqOD6jt5wSGtDnE3hKSjZRNQ Bv6sRGJxA14kCzJ2dwF3Ybf1aw5u0OxNTr56mWwveVs2uSoZqYbc8OQlDU2PE7QuIVpd PwM6e4gImOdnDFfFx/QeYNb1mvY6Zuv/3i/VNFHDy+8O4xdUY+RnJ7U1OKfjboEvnHF9 BDZQ== X-Gm-Message-State: AOAM533LMvuqcyP+/BjI60eqrzneab7uWhhF63AOfSI5FDwMejvj/rNe 2AUh2Vi9ydIcGaLJM3poNgI= X-Google-Smtp-Source: ABdhPJxexOwsRq4mvWcqWxBeARmtX2+64hrtcuD4DHJKBDexKi2pI1LKCe+a949qXkiCGFOgxAz29Q== X-Received: by 2002:a05:6638:19c:b0:32e:fba:fdfe with SMTP id a28-20020a056638019c00b0032e0fbafdfemr7493119jaq.88.1652741852141; Mon, 16 May 2022 15:57:32 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:31 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com, vincent.whitchurch@axis.com Subject: [PATCH v2 25/27] dyndbg: add write-events-to-tracefs code Date: Mon, 16 May 2022 16:56:38 -0600 Message-Id: <20220516225640.3102269-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_235733_060009_E46DFC7B X-CRM114-Status: GOOD ( 22.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org adds: 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 | 1 + drivers/gpu/drm/drm_print.c | 4 +- lib/dynamic_debug.c | 156 +++++++++++++++--- 3 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 01ca6f635dcc..b8c6772b88ac 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -239,6 +239,7 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. + T enables callsite to issue a dyndbg:* trace-event f Include the function name in the printed message l Include line number in the printed message m Include module name in the printed message diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 77b56399147a..63125a507577 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -280,11 +280,11 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, vaf.va = &args; if (dev) { - if (desc->flags && _DPRINTK_FLAGS_PRINTK) + if (desc->flags & _DPRINTK_FLAGS_PRINTK) dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); } else { - if (desc->flags && _DPRINTK_FLAGS_PRINTK) + if (desc->flags & _DPRINTK_FLAGS_PRINTK) printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", __builtin_return_address(0), &vaf); } diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5682ee477677..81cfe6e21d15 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -88,6 +89,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' }, @@ -770,6 +772,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; @@ -784,16 +878,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); @@ -803,16 +899,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); @@ -825,6 +923,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); @@ -834,22 +933,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); @@ -865,26 +966,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 Mon May 16 22:56: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: 12851681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C19C6C433F5 for ; Mon, 16 May 2022 23:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a7InePjSmezXJc//HlFXu/16yrfDx5wbeK+UmErXefM=; b=aU19TbiQlgXiVH 9XvQLWtQX7eb9tM1eN/GWrGJf2AQbQK/CJWlvU+trc8Pc7Mo/qoALzTTGXwcvC+istsWwbU2ojhgf fLXBl1Bp5ciGcAb1AttoiMcavUY+je3hP75S5GvwmcM5rUcYQ6ap05qwn8rVOQxGHN/TXZw3sRR4w ShdMGBLmeFLY9Hv0gT59GQzw9r/wssx9MH/3XWk9CewaHXROYBP4bp8sE5kQ+mZfNconIKGSh6NuA mDdIfLUHj0X9X/XTAEfuaTKY8RXKan/lQoR2Hgik++I3C9Klvw+FuOUU2ZeURv5G2J3pzFliSWDlN fqr52JrBnD6BjobFFktA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjwa-00AiLk-Lw; Mon, 16 May 2022 23:16:06 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjef-00AZRf-P4 for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:36 +0000 Received: by mail-io1-xd2f.google.com with SMTP id o190so17590403iof.10 for ; Mon, 16 May 2022 15:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5YN3gFWspJywlBdR94M3GwnkLtOFuABN4Pf+hFKzHmQ=; b=CcmMQh0kPmG/mGl9sIX5ljtGzreaFyY+zLEeWbI0F+9I2jxNH8XiXCal5UvxHS9dvx E/Bx71gMQt+1mMTOXjmO05++zU4ejmLsjTjha0qWcyWmFX+BT2ecEeAfS0LbHIAyXF2P ZlEG44BrjYRqg538ymK3gHjOMzsidIF5LwjORO7y9R3fp7ATS5rAfjagYj2szfO+rNQe tmwZGGU1tBbJ8xfaJEfuvUUEmUi8C8ENeObZJg9XUjsZD70YTGy1WENzR5sEeWB0NO7i 3aHymezosUBnziGU+fUJohnC1il7TlIRTaSOGjWpixSrbKy8bQwwze93boECK4s8sYR8 l5cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5YN3gFWspJywlBdR94M3GwnkLtOFuABN4Pf+hFKzHmQ=; b=Em+MW0mQZ+4Smt3E50OZykrmyXFDYRmU4Rl9W+iODj7U/3lnW3dRHYKuHgNFi5NUKO V/bb1MtWIi/hdu0EIahDCAsGIc4OilrrgMAUg52SgCaqtrUfULMMiVP8ZA2nm5WvEFAL 8DpzQO5UonsCxQkuUvbBTHzoMRUBEH9T13AeXPHVaeAhxSFPWJX2HV0oyyyJzvOR2fez SyWX+ElQkT1+2kWN/XimvL+/hOWAm89Vbh1KCtvSMikF/zRvOAox7bYZH6FneFOpuecX OB1UswYkPRpU+rBbs/K8BPBNwm8mp03DddjL90X2DwLwu5qa+MQq0E2i10rWZJtsUEPH QoJQ== X-Gm-Message-State: AOAM5339JF3gadjbfHkQKvqS8UBEIWq6lYGl1rYIl1AELkxO/L8NfjPt DR7RGF5D+JpPOnN+hao5+z0= X-Google-Smtp-Source: ABdhPJxQ/HvGhAv8CR9eQzEEl354u66m2ukgeT1V6hfr/VeviMOBm82PeDApak4yOKEqhJQo/fQSaQ== X-Received: by 2002:a05:6638:2603:b0:32b:a724:2b8c with SMTP id m3-20020a056638260300b0032ba7242b8cmr10036821jat.278.1652741853347; Mon, 16 May 2022 15:57:33 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:33 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 26/27] dyndbg: 4 new trace-events: pr_debug, dev_dbg, drm_{, dev}debug Date: Mon, 16 May 2022 16:56:39 -0600 Message-Id: <20220516225640.3102269-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155733_922152_22273B7A X-CRM114-Status: GOOD ( 26.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- drivers/gpu/drm/drm_print.c | 9 +++++ include/trace/events/drm.h | 68 ++++++++++++++++++++++++++++++++ include/trace/events/dyndbg.h | 74 +++++++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 73 +++++++++++++++++----------------- 4 files changed, 188 insertions(+), 36 deletions(-) create mode 100644 include/trace/events/drm.h create mode 100644 include/trace/events/dyndbg.h diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 63125a507577..9afb676bda4d 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -34,6 +34,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. @@ -283,10 +286,14 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *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); } @@ -307,6 +314,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..6de80dd68620 --- /dev/null +++ b/include/trace/events/drm.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM drm + +#if !defined(_TRACE_DRM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DRM_H + +#include + +/* drm_debug() was called, pass its args */ +TRACE_EVENT(drm_debug, + TP_PROTO(int drm_debug_category, struct va_format *vaf), + + TP_ARGS(drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(int, drm_debug_category) + __dynamic_array(char, msg, 256) + ), + + TP_fast_assign( + int len; + + __entry->drm_debug_category = drm_debug_category; + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + + len = strlen(__get_str(msg)); + if (len > 0 && (__get_str(msg)[len - 1] == '\n')) + len -= 1; + __get_str(msg)[len] = 0; + ), + + TP_printk("%s", __get_str(msg)) +); + +/* drm_devdbg() was called, pass its args, preserving order */ +TRACE_EVENT(drm_devdbg, + TP_PROTO(const struct device *dev, int drm_debug_category, struct va_format *vaf), + + TP_ARGS(dev, drm_debug_category, vaf), + + TP_STRUCT__entry( + __field(const struct device*, dev) + __field(int, drm_debug_category) + __dynamic_array(char, msg, 256) + ), + + TP_fast_assign( + int len; + + __entry->drm_debug_category = drm_debug_category; + __entry->dev = dev; + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); + + len = strlen(__get_str(msg)); + if (len > 0 && (__get_str(msg)[len - 1] == '\n')) + len -= 1; + __get_str(msg)[len] = 0; + ), + + TP_printk("cat:%d, %s %s", __entry->drm_debug_category, + dev_name(__entry->dev), __get_str(msg)) +); + +#endif /* _TRACE_DRM_H */ + +/* This part must be outside protection */ +#include 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 81cfe6e21d15..a97ca94a266a 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 @@ -790,7 +792,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; @@ -809,7 +813,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. */ @@ -819,9 +827,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); @@ -829,11 +837,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); @@ -843,19 +851,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); @@ -878,7 +886,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); @@ -889,7 +897,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); @@ -899,15 +906,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); @@ -923,7 +929,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); @@ -933,24 +938,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); @@ -966,18 +969,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), @@ -985,10 +986,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 Mon May 16 22:56: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: 12851725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EB1DC433F5 for ; Mon, 16 May 2022 23:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OC0qorPiL4MrvuyvYyX5ZAxejOV5Hd6sgURiiq1Tmco=; b=eA3Yu4V589s+pe BNvQ0f/nGTECXdSYWnGfAwrU9RPDDhrtOQX4IaXsori/Rm7LkgWFDpiVxZnsUhmHpmEQzcP0dF/2G H1tnOwloY8gekmHByIFSpk7RnQTZxscKyHpxbrcWg4oDpTt+nROFeI8XHl+P2Y+Xfj3jVovSp00OO 435XdcKWCejTwnTFqK9pC7tJHHtwuLn2hssE+InwLWiGYY59n7EjkctOhIqMWPhfoAPI0l3morByt czQGg8pbP5p6qSKwJdsvd9tXJWUKBT62bylbw9vMJ+bhufGojI6lAzqymWuXkUNXkVKVkZL/M6QNI loFWgG9AYSj8pwlZporA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjyx-00AjFo-HR; Mon, 16 May 2022 23:18:31 +0000 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjej-00AZjO-EL for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:39 +0000 Received: by mail-il1-x12c.google.com with SMTP id e4so2303116ils.12 for ; Mon, 16 May 2022 15:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FF9XER8KsVOkO1Gdata3KepQ+J2Lr+NLtjqQThof0Pg=; b=QMR7Uv7IGU4dFlQ7XbaLDl8oMTWWGZP8W/kIowrn4M8i2Lw1cKjWfBvIQCyDVsk3K5 6AUg94ocYqw6aOmdD+JMQJ8X8DPX2rZPU8YSfJbHND7oPm24AfMTT84oH1as3SXEIGb3 523GC2519SINNOFvGjkI78C+OqFZ8wGoaY9rRVexPvZ8T2hd4jVASyMWJYI9P2/sy21C gn6Vwf/lc7O+I2XuHib/dpWz5vH/EfXuoTmNQ+ehHsY1xKFoU1Wo6jL0eSWRiPN4w53C 15ayP/Cr96VmOumROCuOJoWl2HJ0wDKVYoimLCzzofh4L7znSGAuuSODf1ChhXsHSlpz 6JdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FF9XER8KsVOkO1Gdata3KepQ+J2Lr+NLtjqQThof0Pg=; b=FYnFYWmjwhrFgcN567ZeUsYqsplf07h1MXi3zWk8NewcFDaLU82FLUDuuxDx0yTMRb sXKAx+6RXOMjn2yDSzQ+zVZiJ5JU2hyx8is1v0mpkQU5lvUF6U95PaM3gIxKfdkt3TfZ yvV2nImEZd6zBLzXR3z+kzmLnVW3geHYKjzKCLki2aWvRO4Dt2MIjb3v9a/dBQ217F9V jQSBy/94cwXUdwRuOVJbJyd9AWA/sUwIVP15VJ6Y8vnNpL5NSIh3qSWReWXN87GViPhy ABsMpUBlGNeUpyQkYiaba7mbmH+f/pXC7BgvPo+gqbXbMbv798BOlmAvek6FEtZJpmDN Q9mQ== X-Gm-Message-State: AOAM530V9+z9P5HOcHhXqd1Ofb26R5iBx9EgtoGhcGj76E//9eKqm4JJ cKeqZJYm1IB+RXtacK8XdGs= X-Google-Smtp-Source: ABdhPJxS9t9CHQ1y5o2+/sKdUJFOmRXlBo10ke52iiCLaoO7cYr11kQ2d2iMU5f/GP5Uh8uwZxF29g== X-Received: by 2002:a05:6e02:1d1d:b0:2d1:1250:437a with SMTP id i29-20020a056e021d1d00b002d11250437amr5815025ila.35.1652741854834; Mon, 16 May 2022 15:57:34 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:34 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 27/27] dyndbg/drm: POC add tracebits sysfs-knob Date: Mon, 16 May 2022 16:56:40 -0600 Message-Id: <20220516225640.3102269-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155737_522093_F4A49450 X-CRM114-Status: GOOD ( 16.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org clone DRM.debug interface to DRM.tracebits: ie map bits to drm-debug-categories, except this interface enables messages to tracefs, not to syslog. This reuses dyndbg's register-classes API to add the new sysfs-knob: drm_drv.h: [A] 2nd use of DYNAMIC_DEBUG_CLASSES(drm_trace_classes), which declares and initializes a known-classes map with the same literal classnames as in the 1st use. This "shares" the classnames for both sysfs-knobs, which is necessary because they're manipulating a shared dyndbg callsite, toggling "p" and "T" flags respectively. This incurs a tiny waste of constant strings, but its worth it for the simpler declarative macro. drm_print.c: 1- declare and export a 2nd bit-vector: __drm_trace, like __drm_debug 2- declare and init a struct ddebug_classes_bitmap_param with: __drm_trace [1], drm_trace_classes [A]. 3- module_param_cb([2]) - does the sysfs part drm_drv.c: register and unregister [A], and missed unregister on drm_debug_classes. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_drv.c | 3 +++ drivers/gpu/drm/drm_print.c | 10 ++++++++++ include/drm/drm_drv.h | 14 +++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 16683fb169aa..ad141c5e29ca 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -1039,6 +1039,8 @@ static void drm_core_exit(void) drm_sysfs_destroy(); idr_destroy(&drm_minors_idr); drm_connector_ida_destroy(); + dynamic_debug_unregister_classes(&drm_debug_classes); + dynamic_debug_unregister_classes(&drm_trace_classes); } static int __init drm_core_init(void) @@ -1046,6 +1048,7 @@ static int __init drm_core_init(void) int ret; dynamic_debug_register_classes(&drm_debug_classes); + dynamic_debug_register_classes(&drm_trace_classes); drm_connector_ida_init(); idr_init(&drm_minors_idr); diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 9afb676bda4d..970b6dd46c42 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -44,6 +44,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" @@ -63,6 +66,13 @@ static struct ddebug_classes_bitmap_param drm_debug_bitmap = { .map = &drm_debug_classes, }; module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); + +static struct ddebug_classes_bitmap_param drm_trace_bitmap = { + .bits = &__drm_trace, + .flags = "T", + .map = &drm_trace_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) diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index c2ffe12161b8..596de0addfd5 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -45,7 +45,19 @@ struct drm_printer; struct sg_table; /* these must comport with enum drm_debug_category values */ -DYNAMIC_DEBUG_CLASSES(drm_debug_classes, "*", 0, +DYNAMIC_DEBUG_CLASSES(drm_debug_classes, 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"); + +DYNAMIC_DEBUG_CLASSES(drm_trace_classes, 0, "DRM_UT_CORE", "DRM_UT_DRIVER", "DRM_UT_KMS",