From patchwork Fri Aug 5 21:53: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: 12937727 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D04C25B08 for ; Fri, 5 Aug 2022 21:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241544AbiHEVyV (ORCPT ); Fri, 5 Aug 2022 17:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241497AbiHEVyN (ORCPT ); Fri, 5 Aug 2022 17:54:13 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA4DEC43; Fri, 5 Aug 2022 14:54:11 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id p82so2864379iod.2; Fri, 05 Aug 2022 14:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8o46kS926x+QNuy5c4uBrvlsDlM/ABLoibmgwB6shD8=; b=lCM46axrhDjSPX2DcnzhMibG89Bub0Ejuetk3i4ZBIR4SKCTxg15/vbM+20ToloihC 5jJiPEBFpAYYsXVKLemc1F/6Fml/cnNqToitEQ7LP7jGmZGwrFUe80YvURLB4CE8UFmL 0T6/KfGyyq2L+pxXcJk/NFZVoOy4bAeINZaSVm+k6eQyztxe6FxW6QSllYUcNAHv8hoU O9yQgZtxinxHzbgXYMwmvu/KTIro5W39ChI58qjUIfAeJtBrt69zS23Cb+HdPV1ZWhnc JaZbhuEPr4rm39f9bibgDkng3eX1JX7n13q9Zu9wfECZ4hf7vy6yT71yq+UNFpTwV50w JpCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=8o46kS926x+QNuy5c4uBrvlsDlM/ABLoibmgwB6shD8=; b=RrM/Y9vzZj2q/VewZK2pkV3klo3Yfzmw8L/Nc592QKjXxmoYxXzo9sGe+TINi9YLd/ D4nj/JhWPytOYzOxepDtibhTI0BFyu0HfASrX2lfo6c3dFu9k8DZ95O9yO/g4R3suLmK NSDsaKlHGUYfcxRi2mpNgWIf/yL+gAljLuzzPUmgJMGqADoIYuUE90xK8koDuD9yAidz GUqOKNDFLnUsugD7/F7qViPIM1otJ0JGGtsPm3259blLFilZchX1F0H3BoG1263g013a pOVxoR+Jy8Brv8meGbYkTyb5oXsoT1Ys+zrCkk3ANAeNJWXLZ4FdcyTtnexX6bovmZwm IF0A== X-Gm-Message-State: ACgBeo0+k9VJlBocc0GQxRbvdFHtl5fqHx3agzfeg69LBhqEm/mgh22C fBG6W5Oot0jnPj4e4RruL0dbYQQoewx8HA== X-Google-Smtp-Source: AA6agR6i3ziM+LCX9b0EWHuhKQUsORqHbRROxpskVgxuS7LNqXf+MhlHawIxN9ifY+85v7VA3rL23g== X-Received: by 2002:a05:6638:3387:b0:33c:9f9e:5a17 with SMTP id h7-20020a056638338700b0033c9f9e5a17mr3896561jav.12.1659736450608; Fri, 05 Aug 2022 14:54:10 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:10 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH v5 01/33] dyndbg: fix static_branch manipulation Date: Fri, 5 Aug 2022 15:53:23 -0600 Message-Id: <20220805215355.3509287-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 Fri Aug 5 21:53: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: 12937728 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32A5FC25B08 for ; Fri, 5 Aug 2022 21:54:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241474AbiHEVyY (ORCPT ); Fri, 5 Aug 2022 17:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241542AbiHEVyV (ORCPT ); Fri, 5 Aug 2022 17:54:21 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE9FE0D4; Fri, 5 Aug 2022 14:54:15 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id e69so2855970iof.5; Fri, 05 Aug 2022 14:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=dW/qowRKwpSX+eB9zQgpcFjLzbW7/9zpGPg2Go1FHeI=; b=pQqact85NoRb+xtdb4neqHJ2MSf9lwR+gCDz0zUVVjYSEELKbLwImAE6CSqgl+Q4XM /dOHKlBwUpeC9a8Kj6oBimwhLi3DHsK4O7zQm0pwLrcX3ZopEjW6HZIbh6YyUFVaafZr 5szL5MQBQwSMH6R3xf437A6KKteGEzAGGiy7gbo8AlKfmlJRbUz1IBy9CwCiAbuPknfT e4D/JLSz4pesGI29pQZJh6dO5qlsWwfDg/FTM/7hrS1PjqPn4Ghoe084pBnGzOmJ/PYX 0xmtTY4hBf2zQIPotw1GI23q+epE7LZx9a7RP/txZjlmC6Ra0OXTYFDlot7BqDZmDYEk VVxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=dW/qowRKwpSX+eB9zQgpcFjLzbW7/9zpGPg2Go1FHeI=; b=6wpuIIU7p1h9wI3qdptFuf+g7dfZmKDiPt2UrPzD47mcsdyCTIWRBTub6IjLzfXJPO v6EEDSikl4A8jcMMJ77Ra65GndIoqQynKjQaLwB5xEv5LRwepPrTOZYvbTkZu2g7sJ7j frX4J9vjcA9xjWVumhQIyZVZw6NsQcaW81EiL9HRHec69AlXa3wApU+zC7oFutTXbBb3 k4RXqcS2sBdWwkIlct97c5zwZrsyQKCFZj8Gu+P3unG4mRw/vwQWGIaaHLXQ3FZ2i7VA WV5QtKcrAYnTBHqvoK5WydojHsDWSeQfHjCR7hZaNJMB9O8Z2UDiwR4kZv0IyTAo42/o iJLQ== X-Gm-Message-State: ACgBeo1qj6pOyKr0KJ0ebqQX4Cj7k4A27oKPD3u2jXHVVrWjAwNVP/F7 Ne4wm/EuhI2gV/ZYYX1g8t64VXEULR01hw== X-Google-Smtp-Source: AA6agR6g0h/uRqkZBCEfyjVwXC4v1QUrTS31if9Ucl65W+giIN8r0CzRcZcoL+STwGJBx/6L7Fqtaw== X-Received: by 2002:a05:6638:3792:b0:342:b241:13c2 with SMTP id w18-20020a056638379200b00342b24113c2mr3231037jal.257.1659736454304; Fri, 05 Aug 2022 14:54:14 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:13 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie , Rasmus Villemoes Subject: [PATCH v5 02/33] dyndbg: fix module.dyndbg handling Date: Fri, 5 Aug 2022 15:53:24 -0600 Message-Id: <20220805215355.3509287-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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, or ignored because dyndbg allows its no-effect use on non-dyndbg builds. But since the code has an explicit feedback message, it should be issued accurately. Fix with strcmp for exact param-name match. Reported-by: Rasmus Villemoes Fixes: b48420c1d301 dynamic_debug: make dynamic-debug work for module initialization Signed-off-by: Jim Cromie Acked-by: Jason Baron --- 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 Fri Aug 5 21:53: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: 12937729 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C7CC25B08 for ; Fri, 5 Aug 2022 21:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241585AbiHEVy3 (ORCPT ); Fri, 5 Aug 2022 17:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241528AbiHEVyW (ORCPT ); Fri, 5 Aug 2022 17:54:22 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB7B4101C1; Fri, 5 Aug 2022 14:54:19 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id j20so1975163ila.6; Fri, 05 Aug 2022 14:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=66tB9GURiJGDaXzm2IfI1R+C6P9N6jM87DtEYp8w9s8=; b=dgd+LLVPNiPJaSKBVWtT4Zbrhte0+5f0xGVwua9lB+amp0r06ne081BVPeuysGQfVy B29SsUeBngUq34NP88kyqho6gSyjz34xlIC/USckZDng+OQZv8goMxRKQA03ABRzcBd0 aAZ+CBBWePvCN3kUwH4EYfOSISYXjUPP8ZXfH0oPGfcMexyLS6Vxz16Fch/fYRc43CcD h6G6O8nkZbmHpzetqnntDg5Zib/pD4u+1z3iJ8z6TOATqewv5E6xnluDu/IaExNjLqWm 0D3Jd0LJlJOcVmbDYGtHyerwGVhcxoMT874pS287WwzN3ne6cWGax4fucNDz+Iei8SEj /sMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=66tB9GURiJGDaXzm2IfI1R+C6P9N6jM87DtEYp8w9s8=; b=nBuS3x1CMVUUpNgu2jJitG4zRfzAEBhWVesiPqusd5sRh9ibDB0nX2GI8YJb25DCdJ /tDAjcQ5TCKPSYy5Qb17wKjhLjNy8DMrVOB1DjjyWxpDS1sIj/rNfAogvhbDTBj8Gxbf 6Sbfz4VDTQ5iPlgiRoDarlHzs/hSTn5HKkPySk779a+ALRSEG7TaVcor81lbNjHj/r+G PNAjHtRR3VAusijTAxcxluJUEmTDmh310/rxht4t37wYY/q3l5UJdWnBEXeKoImZrQBH +pa8ntMVU72liSYWD1eAQbqvDTE83nsMvTBsIbzhHAT/O4C73X+2ktqgcnZwJ90dsh2M Ct4A== X-Gm-Message-State: ACgBeo1nh1KRKmtIUkvBw19TOBmFgl4vOTCVyWxS2nNpb5cUzXzZKolf b/zOatOIKHeT2l21C8rr+qGeIpne/d6bQg== X-Google-Smtp-Source: AA6agR5KFUx/S28wJBHf8esIf0A1i4foONGppbKZtYzDKa5yseZsXVQGDnoxzq0dnljYp9wy7F7U6A== X-Received: by 2002:a92:d606:0:b0:2dc:e2d1:b75b with SMTP id w6-20020a92d606000000b002dce2d1b75bmr4023671ilm.91.1659736458782; Fri, 05 Aug 2022 14:54:18 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:18 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 03/33] dyndbg: show both old and new in change-info Date: Fri, 5 Aug 2022 15:53:25 -0600 Message-Id: <20220805215355.3509287-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org print "old => new" flag values to the info("change") message. no functional change. Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a56c1286ffa4..8faf584f2f4b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -156,7 +156,7 @@ static int ddebug_change(const struct ddebug_query *query, struct ddebug_table *dt; unsigned int newflags; unsigned int nfound = 0; - struct flagsbuf fbuf; + struct flagsbuf fbuf, nbuf; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -217,11 +217,12 @@ static int ddebug_change(const struct ddebug_query *query, static_branch_enable(&dp->key.dd_key_true); } #endif + v4pr_info("changed %s:%d [%s]%s %s => %s\n", + trim_prefix(dp->filename), dp->lineno, + dt->mod_name, dp->function, + ddebug_describe_flags(dp->flags, &fbuf), + ddebug_describe_flags(newflags, &nbuf)); dp->flags = newflags; - v4pr_info("changed %s:%d [%s]%s =%s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &fbuf)); } } mutex_unlock(&ddebug_lock); From patchwork Fri Aug 5 21:53: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: 12937730 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C9ACC00140 for ; Fri, 5 Aug 2022 21:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241603AbiHEVya (ORCPT ); Fri, 5 Aug 2022 17:54:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241489AbiHEVyY (ORCPT ); Fri, 5 Aug 2022 17:54:24 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC49DF9; Fri, 5 Aug 2022 14:54:23 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id o14so1990037ilt.2; Fri, 05 Aug 2022 14:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=uAM2bHt8Z4xuRTvJFeLRexags7bboegRrLg3WgQNpl4=; b=GttURaGyNyjlXmWKacrpk22jV/0PvPsnt5RSXlSpOmWKIOS1FVVSqslXr8i7diNjqQ B8bkPGOWHdOKP350Spcfvc2YAsmiq/DcD5C1wo0gN9gkyB/bIob/YY66WXpxdtoM3lUZ adw/rX4gz+YhYkxP4A+dvAgGqGer5xJc0fzlLSxAvmp99IRcl8QU2Tw2cTyWIMWa3mbk +WLxYSAXcQKdm2uaaGJq1a4Ooltfmbb2XptYWsKw4nHWkF5LzoQn2PdHKR0NRyGelXun xlOcEXK3Sj29apYYZlO8KM9a8Mtb/H4JV9NYpZbd8JqlUhRtKjxvE8x7Bg+2g4wCPp3q fBfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=uAM2bHt8Z4xuRTvJFeLRexags7bboegRrLg3WgQNpl4=; b=CfTKgs9VHbZjqNZl7GMEUvvUhLJ6irDS3uFSv20yg6M1zNA/EsmvJVOBPL1487pfO4 w5eeMvL6px5j3StqgkVEd5PUcv2pMklk+WywU+AEhQKP5/OMDljvH1gEvqO/I/L0JJvj b3tNmjWYk+pMFd+csdnQ1ZS8YYWm0C1IzXWxeAfyLLSxH4+UVV4MenMe2k/8G7Damrlu Lht4H/x4DNLtwr0fmbyyU5wa2IQkGAogtYyXH3hXBy0/EPI4B9mxcYBIb4zquqmhR6Gi eeVvOrHMQ9MFjtBbENxBw+HVq2zI5QDHgw5O1O7i21//KQrMVHQMbUlMuj0uetOTetiv H9tw== X-Gm-Message-State: ACgBeo3hNQCi63aVVXmxQD9Y8bQWH4SE7ML1iLcBS0M9FQNDhjCM0a5D 7m+wG5pyJdvUIcdTBtmmBmRha5Gwwn8DkQ== X-Google-Smtp-Source: AA6agR7/BqFC2YyWdpPet7vO1o3I+g5zfP53AO5Z/UYQa5Q4GCzcWqQvhq1jsWqDvHh+aYBwIiWqsw== X-Received: by 2002:a05:6e02:194d:b0:2de:a54b:2e51 with SMTP id x13-20020a056e02194d00b002dea54b2e51mr3914987ilu.257.1659736463061; Fri, 05 Aug 2022 14:54:23 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:22 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 04/33] dyndbg: reverse module walk in cat control Date: Fri, 5 Aug 2022 15:53:26 -0600 Message-Id: <20220805215355.3509287-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org /proc/dynamic_debug/control walks the prdbg catalog in "reverse", fix this by adding new ddebug_tables to tail of list. This puts init/main.c entries 1st, which looks more than coincidental. no functional changes. Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8faf584f2f4b..7fb99492c16f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -970,7 +970,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, dt->ddebugs = tab; mutex_lock(&ddebug_lock); - list_add(&dt->link, &ddebug_tables); + list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); From patchwork Fri Aug 5 21:53: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: 12937731 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85AA4C25B0C for ; Fri, 5 Aug 2022 21:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241645AbiHEVyf (ORCPT ); Fri, 5 Aug 2022 17:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241498AbiHEVy2 (ORCPT ); Fri, 5 Aug 2022 17:54:28 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1F4E03; Fri, 5 Aug 2022 14:54:27 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id s7so2899310ioa.0; Fri, 05 Aug 2022 14:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8oKEUq0EPzmllL1JKxsnzcEjeLeYCN2EOuzsBk4Lakg=; b=Z7Y4gNIuk1bd9NXInzS3xECyNbs5yvKfMdNd5uDzQIsLhCynYm5Ml3+Sjl1BQce/pZ whGmKTeAEsMdzkvbdlOjpR5DZryQKK4T8BqruPO+aM6DxWQmY9nH3xMnR5StQzeyTz/M PUKTD3o/51KTbaw1xEXio290b6Zi3mtfpvQtfvwPntT7s9hixz1XTbbvf1jkmjD2fSLS Na3MZDoiawvqnfr1m8sQVoTnzdn7abqs/LnQ1K5BVaF94OQgZi/IJcF6A/YJ6xp7oEVm qhfOV8ABrOupE32VP9UD0HuGKXuDbgOdmQIcA9ZBwORPZ6VQP3FbpDBGPUnYdXZHJFc7 nMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=8oKEUq0EPzmllL1JKxsnzcEjeLeYCN2EOuzsBk4Lakg=; b=gdfquemFJ5UGB4ItjN7Ny9aXiEPAdG5x7GoInGNk8QgQlzmpNkIxt7HK/1DccYm3Z+ EbNJvOcxfhI2UKBjFPmNYKK27IRjoZopA6c6opuYrsRKUqzVNA3qZYTBLfo+oG6tESsK H5JVpkOOuZo6kR7WJf/+GhTHPyxLSP4K/1HBCEZYaqKhDd/+mPpWNhQRiAthSE93RuM6 eqlx3fOsNVFTATavx7RgPI0G5WsOLIfvLBGz6Gc4Ei6yToPQngmydcCqdIhdTDOg3AYr Mbx6u0W2e8J65dKuai3rFvaSKPtSW19eMrtOy41dBPQ3cf6hfOw7ZsfiGS4qdd6Zm7ik DywQ== X-Gm-Message-State: ACgBeo2hiGiIYjqHHXJ4yMyUvBHNSKmKWDM1TF+RMgC2qDx7UX/R0Lbx socV/PaV58OKlksMxPwPOj43nZ61QbZ+7A== X-Google-Smtp-Source: AA6agR7UeYnK8xvl0wwhLHfYV68Yb0uAXZRnCcFJ+O9Xr14Frnao6jEA5Wnu7EbuD1TO+KC8WXNI1w== X-Received: by 2002:a05:6638:22cd:b0:341:6180:c86f with SMTP id j13-20020a05663822cd00b003416180c86fmr3991488jat.57.1659736466315; Fri, 05 Aug 2022 14:54:26 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:26 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 05/33] dyndbg: reverse module.callsite walk in cat control Date: Fri, 5 Aug 2022 15:53:27 -0600 Message-Id: <20220805215355.3509287-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Walk the module's vector of callsites backwards; ie N..0. This "corrects" the backwards appearance of a module's prdbg vector when walked 0..N. I think this is due to linker mechanics, which I'm inclined to treat as immutable, and the order is fixable in display. No functional changes. Combined with previous commit, which reversed tables-list, we get: :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012" init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" init/main.c:1424 [main]run_init_process =_ " with arguments:\012" init/main.c:1426 [main]run_init_process =_ " %s\012" init/main.c:1427 [main]run_init_process =_ " with environment:\012" init/main.c:1429 [main]run_init_process =_ " %s\012" Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 7fb99492c16f..8ff11977b8bd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -59,7 +59,7 @@ struct ddebug_query { struct ddebug_iter { struct ddebug_table *table; - unsigned int idx; + int idx; }; struct flag_settings { @@ -805,13 +805,12 @@ static struct _ddebug *ddebug_iter_first(struct ddebug_iter *iter) { if (list_empty(&ddebug_tables)) { iter->table = NULL; - iter->idx = 0; return NULL; } iter->table = list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx = 0; - return &iter->table->ddebugs[iter->idx]; + iter->idx = iter->table->num_ddebugs; + return &iter->table->ddebugs[--iter->idx]; } /* @@ -824,15 +823,16 @@ static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter) { if (iter->table == NULL) return NULL; - if (++iter->idx == iter->table->num_ddebugs) { + if (--iter->idx < 0) { /* iterate to next table */ - iter->idx = 0; if (list_is_last(&iter->table->link, &ddebug_tables)) { iter->table = NULL; return NULL; } iter->table = list_entry(iter->table->link.next, struct ddebug_table, link); + iter->idx = iter->table->num_ddebugs; + --iter->idx; } return &iter->table->ddebugs[iter->idx]; } From patchwork Fri Aug 5 21:53: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: 12937732 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FA66C00140 for ; Fri, 5 Aug 2022 21:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241595AbiHEVyn (ORCPT ); Fri, 5 Aug 2022 17:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241596AbiHEVy3 (ORCPT ); Fri, 5 Aug 2022 17:54:29 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 336ECF5A2; Fri, 5 Aug 2022 14:54:28 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id h16so1968649ilc.10; Fri, 05 Aug 2022 14:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=J+XMFiNX/q3LQYLLDUo59QkX1sLIyVqPUPsR4ifBrfo=; b=a3pE4rSuZD6ro/cAPZ0Z73WjsYUoQsEAbwyUOAqkxPwqOML8IMtCRzyMMjE6ZCJJCH 4scGqqJcV3JdotbBSmD47jk7lpKPscKlF7ejCkueKNDZc62M5x6RByzui6UXS/yrhEB/ Ma9VANyVI7k0Kt+62fIgtMkwlry0TtsgYx+JzzmG7zLU3gOw8u6v8GVHIOxS78S6ySuJ yQedjpXdXviU2c0CtSvX8JSMMrEMC2fuCmCJ3zZs+/tekpoFMtppdOD1KBHt6WoE6wSl TqyEco90VmD806y4HavPugyYKbr4gmKWihAk17UiplBB9FsIctcOWsPeNGNljMqQiUYj Ds8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=J+XMFiNX/q3LQYLLDUo59QkX1sLIyVqPUPsR4ifBrfo=; b=Fc0IFMLov8QIDw1xX5oomr5tmj7N+oeldsF0DiTgeJCUxbe7is+j2hL78nQgLzu2MT fxR7bLUVP6aFA6Itr+lQx8D0eQj9ahmwwfCI+/+RNEQ+B16+uHjd7Kl14jhpJRqDoMy8 vLmJdSA1+p4zoAr/IYwga8hBPA/IIrBaebBdU+3KqkXjZ529axgIQYYeDfw2r+cB8AlE EkjWEf7MlAJ3wUfXY8T1UwIeQ5r9iIXgIaRwixI1GCIkvfSjVQQoFwjgZWCkEPUKhotZ Au/XoZZPi2mw0bMhscwF1lOvzG1X9uV6ooXj4ScXN5Zvb/N1wB4nCpjTjKCWHe881cTJ QhSg== X-Gm-Message-State: ACgBeo05NS5b1bRMl4a0eB3UZSZKEBLl3bMIZheldWS+TzpVbBxrOk4S 97cdM9XOa2zEXgGN4ypTQ0T6l0eu84kgjw== X-Google-Smtp-Source: AA6agR61kurKmG2CZ4QJXTnktlt/717WlcXUXKttKGA+qVbP2Lsxbsku+CON2rmb9ab1kZ1VnYNO8w== X-Received: by 2002:a05:6e02:180a:b0:2de:20c8:572 with SMTP id a10-20020a056e02180a00b002de20c80572mr3819308ilv.213.1659736467233; Fri, 05 Aug 2022 14:54:27 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:26 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 06/33] dyndbg: use ESCAPE_SPACE for cat control Date: Fri, 5 Aug 2022 15:53:28 -0600 Message-Id: <20220805215355.3509287-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org `cat control` currently does octal escape, so '\n' becomes "\012". Change this to display as "\n" instead, which reads much cleaner. :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\n" init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\n" init/main.c:1424 [main]run_init_process =_ " with arguments:\n" init/main.c:1426 [main]run_init_process =_ " %s\n" init/main.c:1427 [main]run_init_process =_ " with environment:\n" init/main.c:1429 [main]run_init_process =_ " %s\n" Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8ff11977b8bd..e5cbe603000c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -900,7 +900,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) trim_prefix(dp->filename), dp->lineno, iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); - seq_escape(m, dp->format, "\t\r\n\""); + seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\"\n"); return 0; From patchwork Fri Aug 5 21:53: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: 12937733 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28248C19F2D for ; Fri, 5 Aug 2022 21:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241672AbiHEVyq (ORCPT ); Fri, 5 Aug 2022 17:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241605AbiHEVya (ORCPT ); Fri, 5 Aug 2022 17:54:30 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2129C43; Fri, 5 Aug 2022 14:54:29 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id o2so2848610iof.8; Fri, 05 Aug 2022 14:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Ip7G03GeGcrZkSaeVkjkXUMKYERuJTa3x3HVuceUBd4=; b=ewQ92O2vGpMAbSdWrB4+u6UhrXNZYJKTGukr+8UZtGaGb4+w6CiksOOQTQn87WyyNX wo5Df7zH9JxqD9apdFkTFusfidPasfZsOIm6pyx9X5xz5MkMkiQceQcD8+OrEsEe9RhS A/pMGk4fpmKBVUtxm/I+JRb9MVVLji8813bHcb+yg0LTm70CM2NjO4WqYWyNMS0o5FVo fB7O4+WYEYPDWxjM7LUXepooHEFyr8/yW8cCxEcb7t4T8DscS66q6XO7tWCER3eaMdwf DqJwCvy/6DcnFsXqXNmeL59eC/DLc4Qh/dr4dPn+9I8WggKs2QIEWX10y8x0RJXsd1Bm L2wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Ip7G03GeGcrZkSaeVkjkXUMKYERuJTa3x3HVuceUBd4=; b=DLeoDBoN232WmvVOFqXKfAhYOJv1oufeEK1g1hsvDEfoGagVSftqYCMZdep9ge0Dmq VpUG1wo7JdhZZKXD7gg++LycCeEqXmEXrVL6+QKlhuh4lZi/rbSOdHrRDDt7HNWR3VFz LAvhx6DP/Gy2A/6i/ShiG8cqwayYyksXFJskT+K1j3IsER+G5q1TR5nshWp1W46qIEjY 14j0L821o7jo6EfY19Eud12JQbZWKjviiwAsp3KsHTIRYFlshejtabgoRfcgFjCbN3qX gJZu/suPOCUe6XCgeWZbolB7aH/l6IkBaoD+t5wGrimJTUYKLSLV/TMUy3k0kertd8oD QVmQ== X-Gm-Message-State: ACgBeo3Q80Kd1xfpjhIZdWFZcUGqW+jJCMEA/+U7F42r7E5DYEdom710 qVPrkNSJNz1t40RpGprVcEPHhyYZB2jh5w== X-Google-Smtp-Source: AA6agR5F2b8YYYl6aGI+QseCk+8Ms4jeiO8wtWEfnF2wD77In7NaA/BOIIRV1TpkHi0h0b1ACEo2YQ== X-Received: by 2002:a05:6638:4982:b0:342:39e0:1d44 with SMTP id cv2-20020a056638498200b0034239e01d44mr3814986jab.213.1659736468516; Fri, 05 Aug 2022 14:54:28 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:28 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 07/33] dyndbg: let query-modname override actual module name Date: Fri, 5 Aug 2022 15:53:29 -0600 Message-Id: <20220805215355.3509287-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org dyndbg's control-parser: ddebug_parse_query(), requires that search terms: module, func, file, lineno, are used only once in a query; a thing cannot be named both foo and bar. The cited commit added an overriding module modname, taken from the module loader, which is authoritative. So it set query.module 1st, which disallowed its use in the query-string. But now, its useful to allow a module-load to enable classes across a whole (or part of) a subsystem at once. # enable (dynamic-debug in) drm only modprobe drm dyndbg="class DRM_UT_CORE +p" # get drm_helper too modprobe drm dyndbg="class DRM_UT_CORE module drm* +p" # get everything that knows DRM_UT_CORE modprobe drm dyndbg="class DRM_UT_CORE module * +p" # also for boot-args: drm.dyndbg="class DRM_UT_CORE module * +p" So convert the override into a default, by filling it only when/after the query-string omitted the module. NB: the query class FOO handling is forthcoming. Fixes: 8e59b5cfb9a6 dynamic_debug: add modname arg to exec_query callchain Signed-off-by: Jim Cromie Acked-by: Jason Baron --- lib/dynamic_debug.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e5cbe603000c..5a849716220a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -385,10 +385,6 @@ static int ddebug_parse_query(char *words[], int nwords, return -EINVAL; } - if (modname) - /* support $modname.dyndbg= */ - query->module = modname; - for (i = 0; i < nwords; i += 2) { char *keyword = words[i]; char *arg = words[i+1]; @@ -429,6 +425,13 @@ static int ddebug_parse_query(char *words[], int nwords, if (rc) return rc; } + if (!query->module && modname) + /* + * support $modname.dyndbg=, when + * not given in the query itself + */ + query->module = modname; + vpr_info_dq(query, "parsed"); return 0; } From patchwork Fri Aug 5 21:53: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: 12937734 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3010C00140 for ; Fri, 5 Aug 2022 21:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241617AbiHEVyv (ORCPT ); Fri, 5 Aug 2022 17:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241622AbiHEVye (ORCPT ); Fri, 5 Aug 2022 17:54:34 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92B8211811; Fri, 5 Aug 2022 14:54:30 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id l9so1989571ilq.1; Fri, 05 Aug 2022 14:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=J3hK7bUI023BnYR4sokXeCwLdQ8v4VG+y38uaGcbPRI=; b=o0oj1BOG1mKLXImOxNOgfmj9cP/l6Qyu/jfY/wwshKoUYop1cQrBtyQN0j4z2InP2d qwYHy1eRLM2dXWxLxj0bvAOGCy7vsApXbPpiKcoNZb5vwbgKQMZGblwSDJrpUuOxBSql 6jdJfflHBPBB3yDfsU2MiNl+5M8QlCkCXp/jNapCkAe5h9X3A9taawcLI5+KBDU4Pgbw drO8zahX0S+OjowxQ/G3vX9mWjlqx4gRmRvdHwA5lw7p2/LaXX54fybIHXLrSs5Tv81F 9R/DMjmA/gvF9mPSyQwZMrvOMpbu4503UBQUPPD+hnyFF+6VX0T7kUtw/tMFrXaUp1qh i0Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=J3hK7bUI023BnYR4sokXeCwLdQ8v4VG+y38uaGcbPRI=; b=RlPNzzGDfftCojZ187vk8kdUcRDty4d2RlUeorl9s+WWn2TFjXyOlzn+q5me3SC2hR z5QsrkIQX2+EwvurdpDCkE6hVIV2cinqii0qMESoUxLkz7ZxZrqPzyhrI1cHeDw15CB3 KzVKg3YyrE5oAzP6o/spy14K0en105OsUZg9siYrUSO403a8icV5vqYgGLrh8FfNwnvF RRwH7zH9Dh5GRoKJaUUowv/9klcGDz5SP+qmKRT9RuxVsYzL/pqbYSua3mXOnyfhyyIX qpBe88zjrfZhIdhK5WxDyla0O/ogFedxOYRtB4vDPTBsi7R7h3dPsc6Ee7ZuSyouQSZi Yxsg== X-Gm-Message-State: ACgBeo3/dPynI37hyJQCPSUEZTmMct5zZ3c5IGTrsGXc9dcLDBNnHnzP CPQdbILXX97aglyoGa8JYSFNAsGJj2OENw== X-Google-Smtp-Source: AA6agR6acEQ86Et7SlsRUNj2iJh1u88ZjLV2wi4n1jq1iPs7PuY06rR1utA1tbyb101yYRiXj1WsXQ== X-Received: by 2002:a05:6e02:1b84:b0:2de:c27c:600 with SMTP id h4-20020a056e021b8400b002dec27c0600mr3990559ili.292.1659736469508; Fri, 05 Aug 2022 14:54:29 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:29 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 08/33] dyndbg: add test_dynamic_debug module Date: Fri, 5 Aug 2022 15:53:30 -0600 Message-Id: <20220805215355.3509287-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Provide a simple module to allow testing DYNAMIC_DEBUG behavior. It calls do_prints() from module-init, and with a sysfs-node. dmesg -C dmesg -w & modprobe test_dynamic_debug dyndbg=+p echo 1 > /sys/module/dynamic_debug/parameters/verbose cat /sys/module/test_dynamic_debug/parameters/do_prints echo module test_dynamic_debug +mftl > /proc/dynamic_debug/control echo junk > /sys/module/test_dynamic_debug/parameters/do_prints Signed-off-by: Jim Cromie Acked-by: Jason Baron --- MAINTAINERS | 2 ++ lib/Kconfig.debug | 10 ++++++ lib/Makefile | 1 + lib/test_dynamic_debug.c | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lib/test_dynamic_debug.c diff --git a/MAINTAINERS b/MAINTAINERS index 64379c699903..a14fc4b6a10b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7093,6 +7093,8 @@ M: Jason Baron S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +M: Jim Cromie +F: lib/test_dynamic_debug.c DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 2e24db4bff19..ca5978e1d18a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2529,6 +2529,16 @@ config TEST_STATIC_KEYS If unsure, say N. +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on DYNAMIC_DEBUG + help + This module registers a tracer callback to count enabled + pr_debugs in a 'do_debugging' function, then alters their + enablements, calls the function, and compares counts. + + If unsure, say N. + config TEST_KMOD tristate "kmod stress tester" depends on m diff --git a/lib/Makefile b/lib/Makefile index f99bf61f8bbc..9c316df868de 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..ba3882ca3e48 --- /dev/null +++ b/lib/test_dynamic_debug.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +#define pr_fmt(fmt) "test_dd: " fmt + +#include + +static void do_prints(void); /* device under test */ + +/* run tests by reading or writing sysfs node */ + +static int param_set_do_prints(const char *instr, const struct kernel_param *kp) +{ + do_prints(); + return 0; +} + +static int param_get_do_prints(char *buffer, const struct kernel_param *kp) +{ + do_prints(); + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); +} + +static const struct kernel_param_ops param_ops_do_prints = { + .set = param_set_do_prints, + .get = param_get_do_prints, +}; + +module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); + +static void do_alpha(void) +{ + pr_debug("do alpha\n"); +} +static void do_beta(void) +{ + pr_debug("do beta\n"); +} + +static void do_prints(void) +{ + do_alpha(); + do_beta(); +} + +static int __init test_dynamic_debug_init(void) +{ + pr_debug("init start\n"); + + do_prints(); + + pr_debug("init done\n"); + return 0; +} + +static void __exit test_dynamic_debug_exit(void) +{ + pr_debug("exiting\n"); +} + +module_init(test_dynamic_debug_init); +module_exit(test_dynamic_debug_exit); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); From patchwork Fri Aug 5 21:53: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: 12937735 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20737C00140 for ; Fri, 5 Aug 2022 21:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241703AbiHEVzE (ORCPT ); Fri, 5 Aug 2022 17:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241631AbiHEVyf (ORCPT ); Fri, 5 Aug 2022 17:54:35 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9022B13D21; Fri, 5 Aug 2022 14:54:31 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id g18so1982703ilk.4; Fri, 05 Aug 2022 14:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=5COrt8+UBE4dlO0UmlrrMAl6VEmhHXEe2GHU1HbZD24=; b=L043JNA8z+12v91PFQd8hIfM8uLiFmV8nj9LHoJBfI1kLPvGkDEWdC8Wd4p2KZld9S 0zgoUdIOwejHnh294RaTF25kbIywgsTuWesIWEnfzflxvdXVQIAddSszCjlNNai4Gx1q aELRYlSetyNwLJ5JVno+H1ojMessgxxdhaeujBNZAqFX86C5Jlnp2Yar7EKLEJZAJXQe LmE5+fFjVKQ88KmWSEcy8Z5jBLBebC2GIYPGeOBqprLtN2V97uCEmS6KH7wQli+TWOG4 ReT8K1fFGIxKxlacyunZgm/oj5Aa5dKOX7xqDbqNIYwO60YKAUqFdODkz5xKVK64LxEo FUoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=5COrt8+UBE4dlO0UmlrrMAl6VEmhHXEe2GHU1HbZD24=; b=Gjc7OZ9YByuUEH9FFTCQIemXzTATAjIWg0vPTFqULSA2qo7rzpOLNxvWURDxOMPHFr 7SaAdwWknrA7jB4fmKWDtDO1xDdoL5gL+bf78OeiWGCwSzg+fm7ZeCD5kaYUv++QgL/c /3KkToeDWzMyODDeS9fUnUSxQyZy4vbqf+SFaqeWpJeYJbbdH4XM+8Es7c8o2a4j0QcP cWS1hb2riZxMpJhWM/OOQlSQ1zyCpnr2frlzqTL1GosE187Lo8cbozWKaMiHjjQFa2vC l/jpO8I4wEQ8xq6YAxnKGbtsatUE1VKUsHvZ+hrg039Z3IjhByH0ibymX8HGwjbgAg1R 6Svg== X-Gm-Message-State: ACgBeo1z5GmPDMD8GNyljhv17jfznn2niz6pSy4rt/IZ4DyJh4HQb3hY uWEb30B3ZmFo57US9uQYnjxIaM7PS+Z96g== X-Google-Smtp-Source: AA6agR7Up2wCnebNs4iDSz5YId5lNZX4AQVQrMH/DVsNi85YXM9aZ5Sbsa3AlT3EPXU6THVv5XJyNA== X-Received: by 2002:a92:cc04:0:b0:2de:1abf:7414 with SMTP id s4-20020a92cc04000000b002de1abf7414mr3982054ilp.119.1659736470528; Fri, 05 Aug 2022 14:54:30 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:30 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 09/33] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Fri, 5 Aug 2022 15:53:31 -0600 Message-Id: <20220805215355.3509287-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This exported fn is unused, and will not be needed. Lets dump it. The export was added to let drm control pr_debugs, as part of using them to avoid drm_debug_enabled overheads. But its better to just implement the drm.debug bitmap interface, then its available for everyone. Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()") Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") Signed-off-by: Jim Cromie Acked-by: Jason Baron --- include/linux/dynamic_debug.h | 9 --------- lib/dynamic_debug.c | 29 ----------------------------- 2 files changed, 38 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index f30b01aa9fa4..8d9eec5f6d8b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -55,9 +55,6 @@ struct _ddebug { #if defined(CONFIG_DYNAMIC_DEBUG_CORE) -/* exported for module authors to exercise >control */ -int dynamic_debug_exec_queries(const char *query, const char *modname); - int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); extern int ddebug_remove_module(const char *mod_name); @@ -221,12 +218,6 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) -static inline int dynamic_debug_exec_queries(const char *query, const char *modname) -{ - pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); - return 0; -} - #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a849716220a..e96dc216463b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -558,35 +558,6 @@ static int ddebug_exec_queries(char *query, const char *modname) return nfound; } -/** - * dynamic_debug_exec_queries - select and change dynamic-debug prints - * @query: query-string described in admin-guide/dynamic-debug-howto - * @modname: string containing module name, usually &module.mod_name - * - * This uses the >/proc/dynamic_debug/control reader, allowing module - * authors to modify their dynamic-debug callsites. The modname is - * canonically struct module.mod_name, but can also be null or a - * module-wildcard, for example: "drm*". - */ -int dynamic_debug_exec_queries(const char *query, const char *modname) -{ - int rc; - char *qry; /* writable copy of query */ - - if (!query) { - pr_err("non-null query/command string expected\n"); - return -EINVAL; - } - qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); - if (!qry) - return -ENOMEM; - - rc = ddebug_exec_queries(qry, modname); - kfree(qry); - return rc; -} -EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); - #define PREFIX_SIZE 64 static int remaining(int wrote) From patchwork Fri Aug 5 21:53: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: 12937736 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E5C1C00140 for ; Fri, 5 Aug 2022 21:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241657AbiHEVzG (ORCPT ); Fri, 5 Aug 2022 17:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241589AbiHEVym (ORCPT ); Fri, 5 Aug 2022 17:54:42 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC41E13F25; Fri, 5 Aug 2022 14:54:32 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id g14so1967673ile.11; Fri, 05 Aug 2022 14:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=EnuR+keQjXA7ZwTiZJLhSmBlKaThlIrTj1y/b6sKDaY=; b=WV0zPfyg/e+rsqNwIWECvFc+AIdD4kBWBYrI3REAb15JmdHrO7Z4sZ+8Y98wIfVcNp 6H4OUpTUflLeUpZqHc0qKyj0AuCamG+jV3B+T0/IcTG3KqfFKlTp7WK+FQaO1fOBKa+p fB+CyTyxfUEXySNwKwJ5RqkFU6dIOyNkirVrBk4EqcO2wEZBH8yvNpU0DCVkDsEZeH11 BilrfS+JrpJV2XJlPcXEcafAT4MH4qkjF6J/6NuQxClOqon/i4Y6Sr4CHnI59ALSTq2u Zip4eCTxKfWCTC9KjWBePNFD9XrebuEVPMvsv6WMddjhuXe+NxkM0z/jJMAuoVnkY4Bg OBzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=EnuR+keQjXA7ZwTiZJLhSmBlKaThlIrTj1y/b6sKDaY=; b=rNLsia3cC7uVQ3apmU7bsymJoBS57aAAg3IA1VuL11UWDFBDPcof3opzDSbLW296gC IZEVao2jwotZQxGP9tnI8H3pyHlMjOv0afuXfdzlWT97ARxHM/FZ0N30yuqSzqmiK1E/ ADmwYPUChCfRksEXBsaVuh3pPPqPALM26Hnq1ZAZ6s6SNEkQoeriyVTF6I1uImPO3ebv giUDzGMl/JUf6yuDcfUEKKM+tYG+P8lDekLxkS1PHT3ePe0QRiVs3QDjGDayLryT2JO+ O6e6wNtFxxo28s+DlM6b2CzQjSkxtRH+ImNAvNo+gJ6PLeGd6v6hBG9SMRvFVpx427Qq 0mhw== X-Gm-Message-State: ACgBeo3v2GI/XBUD012VxE8H8wYxX2H9hv55h77Oq78UZLVOZFNNYNXU nZMOOvyluWZLC9AIXGBDfCtNFzzWSYKBQg== X-Google-Smtp-Source: AA6agR7RQl6/i8GZ2VkpSGkaEeOT5qr6Gt8uEvpPBs6KmrImmuonAI1Jpb/Qf/zJbkDoHLbSiMTXzA== X-Received: by 2002:a05:6e02:1a07:b0:2de:9742:a426 with SMTP id s7-20020a056e021a0700b002de9742a426mr4136925ild.274.1659736471616; Fri, 05 Aug 2022 14:54:31 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:31 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 10/33] dyndbg: cleanup local vars in ddebug_init Date: Fri, 5 Aug 2022 15:53:32 -0600 Message-Id: <20220805215355.3509287-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org rework var-names for clarity, regularity rename variables - n to mod_sites - it counts sites-per-module - entries to i - display only - iter_start to iter_mod_start - marks start of each module's subrange - modct to mod_ct - stylistic new iterator var: - site - cursor parallel to iter this allows 'demotion' of iter->site (for removal later) treat vars as iters: - drop init at top init just above for-loop, in a textual block Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e96dc216463b..2e8ebef3bd0d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1059,11 +1059,10 @@ static int __init dynamic_debug_init_control(void) static int __init dynamic_debug_init(void) { - struct _ddebug *iter, *iter_start; - const char *modname = NULL; + struct _ddebug *iter, *iter_mod_start; + int ret, i, mod_sites, mod_ct; + const char *modname; char *cmdline; - int ret = 0; - int n = 0, entries = 0, modct = 0; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1074,30 +1073,32 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; return 0; } - iter = __start___dyndbg; + + iter = iter_mod_start = __start___dyndbg; modname = iter->modname; - iter_start = iter; - for (; iter < __stop___dyndbg; iter++) { - entries++; + i = mod_sites = mod_ct = 0; + + for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + if (strcmp(modname, iter->modname)) { - modct++; - ret = ddebug_add_module(iter_start, n, modname); + mod_ct++; + ret = ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; - n = 0; + + mod_sites = 0; modname = iter->modname; - iter_start = iter; + iter_mod_start = iter; } - n++; } - ret = ddebug_add_module(iter_start, n, modname); + ret = ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; ddebug_init_success = 1; vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", - entries, modct, (int)((modct * sizeof(struct ddebug_table)) >> 10), - (int)((entries * sizeof(struct _ddebug)) >> 10)); + i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), + (int)((i * sizeof(struct _ddebug)) >> 10)); /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. From patchwork Fri Aug 5 21:53: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: 12937739 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F325C19F2D for ; Fri, 5 Aug 2022 21:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241684AbiHEVzY (ORCPT ); Fri, 5 Aug 2022 17:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241678AbiHEVys (ORCPT ); Fri, 5 Aug 2022 17:54:48 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C0F47A52D; Fri, 5 Aug 2022 14:54:34 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id q124so2869876iod.3; Fri, 05 Aug 2022 14:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=oXa3J77+ymNXcT3dgrk8PZ8EaI201l90EOblevPX3B0=; b=M0+6Xxiw7YlhVZrRwe4IiGM4so0I/tE1Q37jQ4JczgsEvjxhtjf2ipsay2SWWY50lJ vQk3/JXXYxCHlM4mxfJgIpVbc2NqrH+NhvB93aDALFrpT2N34BTbhdrpdYjYR7iShd8b jhoCahOZQklgiDkeUDyVnQOZRXiL4pdAdjQRYP0/UpG2tBmGYeb0Rb3RjNH9W29O2roG eZdcY0yYQo7jbN2R/TEC99TcUxsEU6fC2cF1v77+he/NEt/s2ZPKIe6AK8eRLBklnKer Fw6wQ3BS+rkzbPHz8M+uXwZVUa3n+/ROfYTMWLUtnean8JiDsq4YBriKZP4vW+5wOWf5 4ldw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=oXa3J77+ymNXcT3dgrk8PZ8EaI201l90EOblevPX3B0=; b=DpKj4J1gqsG9GlJDEuxzwBdTstetF8A7h8k6KnsOO0o9uvgtXOp9ogvWNs7EfhmAqb QYE2hrq7/uCUwPYes5YJdr8pZzmUq1/eOenZpPWKHhVBcsID+w++H40UhQU7uLGc4O9v EHnbqReBx7oclY/bMfOHgAIxR8fwNLeXhHjCMlKrlYS+Uh+in1c2VZt7DmdqNjfBK1D7 Q6TOGQy0mRd1cT2RREViXhvC98NLnhQV3dkmqBxLSPABHG4pNBye/YmS7845A8RwTlVn KMOASNttedl0e8Bh0QTxp+aiF6o6lwUwRuCADv2QEP5eP60tuTUFrBLRUu5Q+6yySxhL XcAQ== X-Gm-Message-State: ACgBeo1lwUeWhAEaE1QXyrqkoDQ8q78roCUAOHpQU/0JS/19J+0qEsmi 8t21Fi+Rl0rsXrexLMSKnzLMKO3sMBna/Q== X-Google-Smtp-Source: AA6agR5/OntY7dZsFs1UDQjm6MgnVJaaF5yH1gzu01jkp4/PSkjEGkzEDN6LKbjmbFyNfe76rzGKQQ== X-Received: by 2002:a02:95c3:0:b0:342:7c31:5443 with SMTP id b61-20020a0295c3000000b003427c315443mr4227882jai.31.1659736472735; Fri, 05 Aug 2022 14:54:32 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:32 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie , Luis Chamberlain Subject: [PATCH v5 11/33] dyndbg: create and use struct _ddebug_info Date: Fri, 5 Aug 2022 15:53:33 -0600 Message-Id: <20220805215355.3509287-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org this new struct gathers the linker provided vectors/sections: descs - the vector of descriptors in __dyndbg section. num_descs - length of the data/section Use it as follows: In lib/dynamic_debug.c: Alter ddebug_add_module() params-list, replacing descriptor-table and its length with a single _ddebug_info object containing them. This future-proofs the function against the looming addition of class-map info, for either the builtin module set, or the loaded module. In dynamic_debug_init(): add & initialize an auto struct _ddebug_info var, and use it like a cursor / multi-part iterator. Re-initialize the var's component values before each call to ddebug_add_module(). This gives us the inch-worm walk thru the modules in the built-in __dyndbgs data section. In kernel/module/{main.c,internal.h}: Embed a struct _ddebug_info into struct load_info, replacing the 2 fields it contains. Populate its members in find_module_sections. Also adjust dynamic_debug_setup/remove() to match the change to ddebug_add_module(). Note: this adds an include dynamic_debug, and might be prone to include loops, since its also smuggled in by printk.h. Nothing has puked in robot-land. cc: Luis Chamberlain Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 13 +++++++----- kernel/module/internal.h | 4 ++-- kernel/module/main.c | 18 ++++++++-------- lib/dynamic_debug.c | 40 +++++++++++++++++++++++++++-------- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 8d9eec5f6d8b..6a2001250da1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -51,12 +51,16 @@ struct _ddebug { #endif } __attribute__((aligned(8))); - +/* encapsulate linker provided built-in (or module) dyndbg data */ +struct _ddebug_info { + struct _ddebug *descs; + unsigned int num_descs; +}; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname); +int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); + extern int ddebug_remove_module(const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -184,8 +188,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include -static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname) +static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char *modname) { return 0; } diff --git a/kernel/module/internal.h b/kernel/module/internal.h index ec104c2950c3..ce42b5b8b4da 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -53,6 +53,7 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const s32 __start___kcrctab[]; extern const s32 __start___kcrctab_gpl[]; +#include struct load_info { const char *name; /* pointer to module in temporary copy, freed at end of load_module() */ @@ -62,8 +63,7 @@ struct load_info { Elf_Shdr *sechdrs; char *secstrings, *strtab; unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; - struct _ddebug *debug; - unsigned int num_debug; + struct _ddebug_info dyndbg; bool sig_ok; #ifdef CONFIG_KALLSYMS unsigned long mod_kallsyms_init_off; diff --git a/kernel/module/main.c b/kernel/module/main.c index 0548151dd933..cfe10356793d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1593,16 +1593,16 @@ static void free_modinfo(struct module *mod) } } -static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num) +static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *dyndbg) { - if (!debug) + if (!dyndbg->num_descs) return; - ddebug_add_module(debug, num, mod->name); + ddebug_add_module(dyndbg, mod->name); } -static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) +static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *dyndbg) { - if (debug) + if (dyndbg->num_descs) ddebug_remove_module(mod->name); } @@ -2093,8 +2093,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) if (section_addr(info, "__obsparm")) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); - info->debug = section_objs(info, "__dyndbg", - sizeof(*info->debug), &info->num_debug); + info->dyndbg.descs = section_objs(info, "__dyndbg", + sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); return 0; } @@ -2783,7 +2783,7 @@ static int load_module(struct load_info *info, const char __user *uargs, } init_build_id(mod, info); - dynamic_debug_setup(mod, info->debug, info->num_debug); + dynamic_debug_setup(mod, &info->dyndbg); /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init(mod); @@ -2845,7 +2845,7 @@ static int load_module(struct load_info *info, const char __user *uargs, ddebug_cleanup: ftrace_release_mod(mod); - dynamic_debug_remove(mod, info->debug); + dynamic_debug_remove(mod, &info->dyndbg); synchronize_rcu(); kfree(mod->args); free_arch_cleanup: diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 2e8ebef3bd0d..457ce936191a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -923,14 +923,20 @@ static const struct proc_ops proc_fops = { * Allocate a new ddebug_table for the given module * and add it to the global list. */ -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *name) +static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, + const char *modname) { struct ddebug_table *dt; + v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); + if (!di->num_descs) { + v3pr_info(" skip %s\n", modname); + return 0; + } + dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) { - pr_err("error adding module: %s\n", name); + pr_err("error adding module: %s\n", modname); return -ENOMEM; } /* @@ -939,18 +945,25 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, * member of struct module, which lives at least as long as * this struct ddebug_table. */ - dt->mod_name = name; - dt->num_ddebugs = n; - dt->ddebugs = tab; + dt->mod_name = modname; + dt->ddebugs = di->descs; + dt->num_ddebugs = di->num_descs; + + INIT_LIST_HEAD(&dt->link); mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); - vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); + vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); return 0; } +int ddebug_add_module(struct _ddebug_info *di, const char *modname) +{ + return __ddebug_add_module(di, 0, modname); +} + /* helper for ddebug_dyndbg_(boot|module)_param_cb */ static int ddebug_dyndbg_param_cb(char *param, char *val, const char *modname, int on_err) @@ -1064,6 +1077,11 @@ static int __init dynamic_debug_init(void) const char *modname; char *cmdline; + struct _ddebug_info di = { + .descs = __start___dyndbg, + .num_descs = __stop___dyndbg - __start___dyndbg, + }; + if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); @@ -1082,7 +1100,9 @@ static int __init dynamic_debug_init(void) if (strcmp(modname, iter->modname)) { mod_ct++; - ret = ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs = mod_sites; + di.descs = iter_mod_start; + ret = __ddebug_add_module(&di, i, modname); if (ret) goto out_err; @@ -1091,7 +1111,9 @@ static int __init dynamic_debug_init(void) iter_mod_start = iter; } } - ret = ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs = mod_sites; + di.descs = iter_mod_start; + ret = __ddebug_add_module(&di, i, modname); if (ret) goto out_err; From patchwork Fri Aug 5 21:53: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: 12937737 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46673C00140 for ; Fri, 5 Aug 2022 21:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241742AbiHEVzU (ORCPT ); Fri, 5 Aug 2022 17:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241675AbiHEVyr (ORCPT ); Fri, 5 Aug 2022 17:54:47 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C8357AC1F; Fri, 5 Aug 2022 14:54:35 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id z8so680433ile.0; Fri, 05 Aug 2022 14:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=uYp30Ojt1jK/5mfyka/eQyG2KeHOKeHThqMCysNtsn8=; b=YAINrW2ZO9Mx6b5PeAs9/E/VXG2BY6wp7UolfqM3mjkD01Dk2Y3ZGuBT8BCueN1AYE Zg4fLo/oxcep9rFyyrTeC0gpfCMVUdZ/5yaktOCwatJ5402yjM1Q8vg+g5QMOkl+wggz Cp3YsIYpCPMZJ+etfA+jdiHFcQ0m1iVg4m0s56U0ptJ4avD1efTF2GMK5CvUnyTc65TD h75nIkqamrE84rRXbUipEpXPHX/OnQ4F+GL1Ge0sZKOXBenuE45rpYtskO5GsmhlPPYr ch4e2R2uyeVJM84EZqx1zmMTsotF47lDWxS7IiK0ZKFXR1cy57H6CZz2qmEaKlCElUj0 g8mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=uYp30Ojt1jK/5mfyka/eQyG2KeHOKeHThqMCysNtsn8=; b=UuypIHRejeArSNTEnL5CKxwY733hErljzWm6wAj6zAhPMDQjX3GSy3jhBLr3ZfLPmH hWaTg1Yvp4zPR7pj1UFz4eFw5ZoUP5SuQ1mKrKxL2yLyj9qgUrqWHetoKFBzcs3rG+/n 5I98w9y09N3SQi1ExfdJLaXvKqMalCNfkIeiUxknbf7WXjx6fqePmpVhL4UHL/ns1ehd Tpf1L2ChRpXkPM8XZhWDqutAmEQmMoQzpS5sK2jtoc9Fb9EacGPblAf6SgEAHXCcvOLJ L7ILUJ6Co1FeB54UWltWqkdXBCkconnYqvIO//cZxMes+6irwBERLIkHQQZ73UQz+6qr dkVQ== X-Gm-Message-State: ACgBeo1MpMq8w8FL0LCch+s7p4Ijn3n1OVE/pys7+JRndySgbinIrnhn GNUO7ZoeANnVqIlyjg9DMbMW7StPGz04KQ== X-Google-Smtp-Source: AA6agR6ialmwjln3K7Ocs8Msxoba/6IEWAhZ45NiYmLAX5sV3hu7QsT+pvJbiwH3fkhKbf/LTYXWcQ== X-Received: by 2002:a92:2a0a:0:b0:2d9:2571:f57e with SMTP id r10-20020a922a0a000000b002d92571f57emr3862647ile.154.1659736473781; Fri, 05 Aug 2022 14:54:33 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:33 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie , Rasmus Villemoes Subject: [PATCH v5 12/33] dyndbg: add class_id to pr_debug callsites Date: Fri, 5 Aug 2022 15:53:34 -0600 Message-Id: <20220805215355.3509287-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org DRM issues ~10 exclusive categories of debug messages; to represent this directly in dyndbg, add a new field: struct _ddebug.class_id:5. This gives us 32 classes, which is a practical usability limit 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). Then extend the init macro: DEFINE_DYNAMIC_DEBUG_METADATA() with _CLS(cls, ...), and redef old name using extended name. And extend the factory macro callchain with _cls() versions to provide the callsite.class_id, with old-names passing _DPRINTK_CLASS_DFLT. This sets us up to create class'd prdebug callsites (class'd callsites are those with .class_id != _DPRINTK_CLASS_DFLT). No behavior change. cc: Rasmus Villemoes Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 71 +++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 6a2001250da1..b6803f7e818f 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 @@ -88,7 +93,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name = { \ .modname = KBUILD_MODNAME, \ @@ -97,8 +102,14 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ + .class_id = cls, \ _DPRINTK_KEY_INIT \ - } + }; \ + BUILD_BUG_ON_MSG(cls > _DPRINTK_CLASS_DFLT, \ + "classid value overflow") + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) #ifdef CONFIG_JUMP_LABEL @@ -129,17 +140,34 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #endif /* CONFIG_JUMP_LABEL */ -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ -} while (0) - -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ +/* + * Factory macros: ($prefix)dynamic_func_call($suffix) + * + * Lower layer (with __ prefix) gets the callsite metadata, and wraps + * the func inside a debug-branch/static-key construct. Upper layer + * (with _ prefix) does the UNIQUE_ID once, so that lower can ref the + * name/label multiple times, and tie the elements together. + * Multiple flavors: + * (|_cls): adds in _DPRINT_CLASS_DFLT as needed + * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) + */ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ + func(&id, ##__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ +} while (0) +#define __dynamic_func_call_no_desc(id, fmt, func, ...) \ + __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ + fmt, func, ##__VA_ARGS__) /* * "Factory macro" for generating a call to func, guarded by a @@ -149,22 +177,33 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__) #define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) + _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) + /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ + func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ + func, ##__VA_ARGS__) + +#define dynamic_pr_debug_cls(cls, fmt, ...) \ + _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \ + pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_pr_debug(fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_pr_debug, \ + _dynamic_func_call(fmt, __dynamic_pr_debug, \ pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_dev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ + _dynamic_func_call(fmt, __dynamic_dev_dbg, \ dev, fmt, ##__VA_ARGS__) #define dynamic_netdev_dbg(dev, fmt, ...) \ From patchwork Fri Aug 5 21:53: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: 12937738 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FBBCC25B08 for ; Fri, 5 Aug 2022 21:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241611AbiHEVzW (ORCPT ); Fri, 5 Aug 2022 17:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241677AbiHEVys (ORCPT ); Fri, 5 Aug 2022 17:54:48 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E4E7B1D5; Fri, 5 Aug 2022 14:54:36 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id i84so2858888ioa.6; Fri, 05 Aug 2022 14:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Wy5iLP6AZumShjO+0eNESryd3jL0wHYWEmUuoQeB6Wk=; b=FJi9ZS8yNGWRuVXEb1kvd352nLf1hSziwSVWIreKLSVMpu8X1lYShDpLSG9DVDiQja 82lnfmTC2tmKCrZLriqdeqfnM8e6qf48GgYX45/llrO+De/9603wtfNrO5/eA1JI0dDj 9GaziLwHSRjV4Y5rbQp9HqPwwG/4cBnULRwRUkXoacFn1iUOiHt2LnRFGZCuTnpz+8Xe f6JsXNI1JUK5pPe9PVM2ltwYzcidAYcZlXtUUbQp0AlcSs1VB9kXIdc2/mR+4iNQObCx 4ZDMAd560TWKJ3kItAwAObe++DeFtMS/nWUW9rAtgdHZM6tyOjviEK5TqVVn7A76ghSP J+1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Wy5iLP6AZumShjO+0eNESryd3jL0wHYWEmUuoQeB6Wk=; b=3vtBBzzL9lO32nXE/ZpH85RumtTxleRQpZnsMVONNMXIf+J+B8HFH+GVN7ZIsegUiC NhJPmfA1FqdNlyndfpHcesw3k7TIDf0iOPedX4t4A0nVBuPuOhN5cOmLt0LCnsREq0Un 7z7PckvCGga1IBZbdRmklwiXj+WQ3H3ycsYHYOwvDWPGr7bDPeN9NR5IePArzKL3rCGF qbU8lFk0A8sqO12uVpasf+IlGT/erDgsjPLTsl9SBlHCTuQ9pSRmpqfVWDCLCEZIJeiY rOz9vRHvGfintOVUzFGoZaS0v2TfIbQNmBq+bIgy2z31byoF+t5p+g/3NoNwDaL0zQGf TKcg== X-Gm-Message-State: ACgBeo2+TZIjZn6cKIWKMzXnJ7MFztiH/dYZAW+YX65CGuHPq/BisHFY znKX9VbMVCW1OuiiCfe/zDGT86oLCE8JTw== X-Google-Smtp-Source: AA6agR5rftNopfD1MVDtLO+pW5nBNveJnieow1ouxMckvYPN9UxAo5uwg6bO3/M4RzbjvwaptL/vLA== X-Received: by 2002:a05:6638:1408:b0:342:86c4:52bd with SMTP id k8-20020a056638140800b0034286c452bdmr3980760jad.119.1659736474811; Fri, 05 Aug 2022 14:54:34 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:34 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 13/33] dyndbg: add __pr_debug_cls for testing Date: Fri, 5 Aug 2022 15:53:35 -0600 Message-Id: <20220805215355.3509287-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 in drm_dbg, drm_devdbg. But test_dynamic_debug needs it in order to demonstrate all the moving parts. Note the __ prefix; its not intended for general use, at least until a need emerges. ISTM the drm.debug model (macro wrappers inserting enum const 1st arg) is the baseline approach. That said, nouveau might want it for easy use in its debug macros. TBD. NB: it does require a builtin-constant class, __pr_debug_cls(i++, ...) is disallowed by compiler. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b6803f7e818f..cb4696c91901 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -221,6 +221,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +/* for test only, generally expect drm.debug style macro wrappers */ +#define __pr_debug_cls(cls, fmt, ...) do { \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ + "expecting constant class int/enum"); \ + dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ + } while (0) + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include From patchwork Fri Aug 5 21:53: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: 12937740 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 190D5C00140 for ; Fri, 5 Aug 2022 21:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241561AbiHEVz0 (ORCPT ); Fri, 5 Aug 2022 17:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241693AbiHEVy6 (ORCPT ); Fri, 5 Aug 2022 17:54:58 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BE347B1F7; Fri, 5 Aug 2022 14:54:37 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id h138so2830941iof.12; Fri, 05 Aug 2022 14:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=j+hykMqdbmYFr1NqjZ89GQdbT5beT8R+gHdILha2zJU=; b=nxW91IqfGR0pfzM6UOrXM2Bhw3WEhj9ajlDXgcXsYmlnTjlxn0T7yhlldkgnIhKM+j RJLXxFSrD18FQ8ZF30z+F0RgUeUsa36uV31o+nAybfTtVpGw2BI96WeVGDMbVuqYFqAb sp1qL3/ZTTk0jDpmhrGA3cOrnrugx5C8rditN412Nf9EfVpVX1w/aqQukXyOpMiErs35 2pZ45u9SIx8h3Dl3v2Xawk0btutGgC7zZjBY0ufPCCtEEOhbE/YZwzgvkxX+9Y4KQu1L KvTn8HRgBx3ajWNnRxEt7BgDEZTxWXuJ6IO1CWIJUCVYTAEEF3w3sNhJEbSizD5RxSWw gTjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=j+hykMqdbmYFr1NqjZ89GQdbT5beT8R+gHdILha2zJU=; b=JsunRNGpSeLmoEvKGezaFNmQaBNbZeJNa5nfwH3I4OX+/DpDO3MRJqBEhh4s1QmA6n h9w8SgF0iJdRMJGGkkbmbIPk8zhR4XHgYiJ/mEeHAkX4tAgj/YglPvBgdntEWfCJuc1g ZHuMXLUD1Bn1M6PFrB6KJzXHHPRGgVYEE18CERHJVfJj6FTDqo78xMVrbRiOuyYtuqY0 T7YwBQSkqHeQjXS+vt9ermrvdpvba2gz4v+kGh7Wr3dcwKCauSfVxpY145xLx6CselAn huzwSGmZw6jw4ErnJy5pLQNcLO5bW9bDKMdS31SfjOOYm0jzF/v0KDKn9T7eWtPE73pT AkJg== X-Gm-Message-State: ACgBeo1ipyIdrqpY5SqnpYFDjAGh/C+iU+KaEW87/jjSjNr9mHGjwaSk gzNeXOOYKNzjpOIztiVEqwzsTXW0i9BFYw== X-Google-Smtp-Source: AA6agR6QBWed0lyVvHYNugDvJfD10jdKNkK5mER4rDMRc0ISAOo3qbMRaABZaYmS8HwhAblDRLO9hQ== X-Received: by 2002:a05:6638:3d0d:b0:342:8b79:9484 with SMTP id cl13-20020a0566383d0d00b003428b799484mr4118742jab.274.1659736475770; Fri, 05 Aug 2022 14:54:35 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:35 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 14/33] dyndbg: add DECLARE_DYNDBG_CLASSMAP macro Date: Fri, 5 Aug 2022 15:53:36 -0600 Message-Id: <20220805215355.3509287-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org With DECLARE_DYNDBG_CLASSMAP modules can declare up to 31 classnames. By doing so, they authorize dyndbg to manipulate class'd prdbgs (ie: __pr_debug_cls, and soon drm_*dbg) :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control The macro declares and initializes a static struct ddebug_class_map: - maps approved class-names to class_ids used in module, by array order. forex: DRM_UT_* - class-name vals allow validation of "class FOO" queries using macro is opt-in - enum class_map_type - determines interface, behavior Each module has its own .class_id space, and only known class-names will be authorized for a manipulation. Only DRM stuff should know this: :#> echo class DRM_UT_CORE +p > control # across all modules pr_debugs (with default class_id) are still controllable as before. DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, classes...) is:: _var: name of the static struct var. user passes to module_param_cb() if they want a sysfs node. _maptype: this is hard-coded to DD_CLASS_TYPE_DISJOINT_BITS for now. _base: usually 0, it allows splitting 31 classes into subranges, so that multiple classes / sysfs-nodes can share the module's class-id space. classes: list of class_name strings, these are mapped to class-ids starting at _base. This class-names list must have a corresponding ENUM, with SYMBOLS that match the literals, and 1st enum val = _base. enum class_map_type has 4 values, on 2 factors:: - classes are disjoint/independent vs relative/xcontrol interface doesn't enforce the LEVELS relationship, so you could confusingly have V3 enabled, but V1 disabled. OTOH, the control iface already allows infinite tweaking of the underlying callsites; sysfs node readback can only tell the user what they previously wrote. 2. All dyndbg >control reduces to a query/command, includes +/-, which is at-root a kernel patching operation with +/- semantics. And the _NAMES handling exposes it to the user, making it API-adjacent. And its not just >control where +/- gets used (which is settled), the new place is with sysfs-nodes exposing _*_NAMES classes, and here its subtly different. _DISJOINT_NAMES: is simple, independent _LEVEL_NAMES: masks-on bits 0 .. N-1, N..max off # turn on L3,L2,L1 others off echo +L3 > /sys/module/test_dynamic_debug/parameters/p_level_names # turn on L2,L1 others off echo -L3 > /sys/module/test_dynamic_debug/parameters/p_level_names IOW, the - changes the threshold-on bitpos by 1. Alternatively, we could treat the +/- as half-duplex, where -L3 turns off L>2 (and ignores L1), and +L2 would turn on L<=2 (and ignore others). Signed-off-by: Jim Cromie --- . revised DD_CLASS_TYPE_{DISJOINT,LEVEL}_* names . reorder-enum by necessity - _NAMES feature is extra. --- include/linux/dynamic_debug.h | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index cb4696c91901..71cdc8612257 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -56,6 +56,62 @@ struct _ddebug { #endif } __attribute__((aligned(8))); +enum class_map_type { + DD_CLASS_TYPE_DISJOINT_BITS, + /** + * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit. + * expecting hex input. Built for drm.debug, basis for other types. + */ + DD_CLASS_TYPE_LEVEL_NUM, + /** + * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N. + * N turns on just bits N-1 .. 0, so N=0 turns all bits off. + */ + DD_CLASS_TYPE_DISJOINT_NAMES, + /** + * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES, + * classes are independent, like _DISJOINT_BITS. Model user + * would be /sys/module/drm/parameters/debug_categories. + */ + DD_CLASS_TYPE_LEVEL_NAMES, + /** + * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES, + * intended for names like: INFO,DEBUG,TRACE, with a module prefix + * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug + */ +}; + +struct ddebug_class_map { + struct list_head link; + struct module *mod; + const char *mod_name; /* needed for builtins */ + const char **class_names; + const int length; + const int base; /* index of 1st .class_id, allows split/shared space */ + enum class_map_type map_type; +}; + +/** + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module + * @_var: a struct ddebug_class_map, passed to module_param_cb + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names used to control class'd prdbgs + */ +#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ + static const char *_var##_classnames[] = { __VA_ARGS__ }; \ + static struct ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_classes") _var = { \ + .mod = THIS_MODULE, \ + .mod_name = KBUILD_MODNAME, \ + .base = _base, \ + .map_type = _maptype, \ + .length = NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .class_names = _var##_classnames, \ + } +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) + /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; From patchwork Fri Aug 5 21:53: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: 12937742 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12AC2C25B08 for ; Fri, 5 Aug 2022 21:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241698AbiHEVz2 (ORCPT ); Fri, 5 Aug 2022 17:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241699AbiHEVzD (ORCPT ); Fri, 5 Aug 2022 17:55:03 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E178E7B79F; Fri, 5 Aug 2022 14:54:37 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id o2so2848774iof.8; Fri, 05 Aug 2022 14:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=T7Gv4hwZzTdpj2N7T4svMFG77jA8WU8rV9TsGh2u6B0=; b=DjCGd7nja7GLoKs/YEi+AypGd/X5RUZGGqxDmaVd6Ctsnq6XlGUVNUtvQyQJ/w8ejL pZ7HppMOc0bnl8TstfhIQgOAyWPXRR+4KnI/LumnfLg5LQ2p7ucvrwj3RD3UE6Nqy/l8 65NtEWs5YCTXHe58FpUirbUlfw69LWASsPbeV2MQZXNhwNO7rDaZEDU2eS3I1W6qvAJn kaBxgCvuGWYxhtv44ILt5Ei88UZauIudeV3qaEOW7BcnWe0lp5cwMuja93PlcWYM9p4u PGvF3xS9gVgb4jDLgtRqZyQpMz+4eB9SSWkfPHFL6dfZ8OD5XWLDteNzMQg8vIKXGYfj hH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=T7Gv4hwZzTdpj2N7T4svMFG77jA8WU8rV9TsGh2u6B0=; b=kHIavjf0GCXxRgB8L8WypmiD+gYHzqOeiq8gYQm/DplByvyi9I8pp/ptje5O9ivznj 1xJCs/HMS3r4Leb0kt/rYf8LAIZGNG1NgiF/b0VU71T4QwXkvYfACpkCiZb22jVLDaOV 3r+hxbm6FtzMQXF9jxI2qL00u5WFn66BkVVf2EY8FcvIxRHeqhVuQcpegR+uoDJPhOqM 7CMTEX3ovOjX2D/osq0HryW/PRPi0yjUz7Ib84O5zdfC0E4ENL4ChDXhse20kzRN5PjH A7qsUlPolxHpTTCFPd9u4p8Jmc4lGPIClWupfgTIPIQQnfqProwqQIrXBPmaNAAnQSRT aPSw== X-Gm-Message-State: ACgBeo2YRcHWA6xOjSruVwjtgozslmZBu6dBVEhChlu08bjs6R4R8H2f l3xqAS2iJE3lrSihuXIuuIWylCWTo4TGYg== X-Google-Smtp-Source: AA6agR6ZuhPO2oFawvVRsW7GJ9C/KsGqggvTjGHRxhiW0IA8Nx9Nnyq3ipyOdpphdUyK/Rp71ztUcA== X-Received: by 2002:a05:6638:300e:b0:335:c73c:3d25 with SMTP id r14-20020a056638300e00b00335c73c3d25mr3886676jak.77.1659736476898; Fri, 05 Aug 2022 14:54:36 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:36 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 15/33] kernel/module: add __dyndbg_classes section Date: Fri, 5 Aug 2022 15:53:37 -0600 Message-Id: <20220805215355.3509287-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add __dyndbg_classes section, using __dyndbg as a model. Use it: vmlinux.lds.h: KEEP the new section, which also silences orphan section warning on loadable modules. Add (__start_/__stop_)__dyndbg_classes linker symbols for the c externs (below). kernel/module/main.c: - fill new fields in find_module_sections(), using section_objs() - extend callchain prototypes to pass classes, length load_module(): pass new info to dynamic_debug_setup() dynamic_debug_setup(): new params, pass through to ddebug_add_module() dynamic_debug.c: - add externs to the linker symbols. ddebug_add_module(): - It currently builds a debug_table, and *will* find and attach classes. dynamic_debug_init(): - add class fields to the _ddebug_info cursor var: di. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 2 ++ kernel/module/main.c | 2 ++ lib/dynamic_debug.c | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 7515a465ec03..9b8bd5504ad9 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -345,6 +345,9 @@ *(__tracepoints) \ /* implement dynamic printk debug */ \ . = ALIGN(8); \ + __start___dyndbg_classes = .; \ + KEEP(*(__dyndbg_classes)) \ + __stop___dyndbg_classes = .; \ __start___dyndbg = .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg = .; \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 71cdc8612257..46ed10682e87 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -115,7 +115,9 @@ struct ddebug_class_map { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct ddebug_class_map *classes; unsigned int num_descs; + unsigned int num_classes; }; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) diff --git a/kernel/module/main.c b/kernel/module/main.c index cfe10356793d..f68f331c867d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2095,6 +2095,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) info->dyndbg.descs = section_objs(info, "__dyndbg", sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); + info->dyndbg.classes = section_objs(info, "__dyndbg_classes", + sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); return 0; } diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 457ce936191a..0d6cb6b258bd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -41,6 +41,8 @@ extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct ddebug_class_map __start___dyndbg_classes[]; +extern struct ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { struct list_head link; @@ -1079,7 +1081,9 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di = { .descs = __start___dyndbg, + .classes = __start___dyndbg_classes, .num_descs = __stop___dyndbg - __start___dyndbg, + .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, }; if (&__start___dyndbg == &__stop___dyndbg) { @@ -1122,6 +1126,9 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); + if (di.num_classes) + v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. * While this has already been done for known boot params, it From patchwork Fri Aug 5 21:53: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: 12937741 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84355C3F6B0 for ; Fri, 5 Aug 2022 21:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241677AbiHEVz3 (ORCPT ); Fri, 5 Aug 2022 17:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241702AbiHEVzE (ORCPT ); Fri, 5 Aug 2022 17:55:04 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60DA17B7B0; Fri, 5 Aug 2022 14:54:39 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id z145so2842708iof.9; Fri, 05 Aug 2022 14:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=03YfOG/DYkz2iArGNb3db5n/xIxeb8G0N8JzLa+YgtM=; b=Ef8WxDG6NyTqC1EZi34gpAEnT+rPZyUcpKaupYnsastTiTGt/Zml/WC2ZzmjZbPHJd phHYyJnYLo6WNB7AlpKLXeN7qbGd1YhUzPvz54QZqQHrtKcLgdsPeyn5+iu9TjI7SjCc Qt/6C50I1yy1ZjGFAU+VCo8OEqIPU+1me4r5nevY5orszEf7tJIjZit7XmergLU/BhIS ORDvsxyCYrTMPQgMLi5PvpsAC4TmoxZwKTf11WtCzm1JE0tcK5kecwMswiOh5HEtMNgs rPlk4sTnLuYzZlm/RO3Nt/CpOY5B3amJFFyJpZOUJOsMWYTIJo5Bn0xeyqAHZ46Benmm PB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=03YfOG/DYkz2iArGNb3db5n/xIxeb8G0N8JzLa+YgtM=; b=SQScmYbSzWTk9y/j6+dGXb9hJTsV5BeOkHv1cDEvRMyYrcIeuIGRaSaqxH+gePk1wi 3WmzGM/tzu/iN6ToVmmEuKNgZnjDwNwVFXlOUI4jptEhvqk1zfi93RfiU+mUJTmxczQu QQWvsTvjU5ar6GcnVJPdkzkrLeJDhqWz6puIF7l0+1vktUfYJ4nLkQyc+6zKQ8q5ulUU Zfg9AS3ljLshPVhhTOpmuE+aPL99w3VS2umHd6KRO5bEctjZa9LzP5uHGZcvpAI2J+FY uqZlMnlBhThGPMK2k90qYxBn1Hs5Axw7rdXbdIS150NUj1jugh1GGzjm+p+zxyKzB2Xd tWxg== X-Gm-Message-State: ACgBeo3me0G+RS5iz/vEFYyMjG/sqgn/oXQX7phEGvJCCEACB6CTwdnp sQt9h61a1m5XilU+N+/6ByDDp3tSKPs/3Q== X-Google-Smtp-Source: AA6agR55/RU9MHoTbUutY3ptQmA/V1qzWroUOdNy6Xs+Ay1Qupqmyek5BzBPcr17ZMFLvPmsNZWM3A== X-Received: by 2002:a05:6638:d86:b0:341:4ece:3c4 with SMTP id l6-20020a0566380d8600b003414ece03c4mr3708242jaj.235.1659736477900; Fri, 05 Aug 2022 14:54:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:37 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 16/33] dyndbg: add ddebug_attach_module_classes Date: Fri, 5 Aug 2022 15:53:38 -0600 Message-Id: <20220805215355.3509287-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add ddebug_attach_module_classes(), call it from ddebug_add_module(). It scans the classes/section its given, finds records where the module-name matches the module being added, and adds them to the module's maps list. No locking here, since the record isn't yet linked into the ddebug_tables list. It is called indirectly from 2 sources: - from load_module(), where it scans the module's __dyndbg_classes section, which contains DYNAMIC_DEBUG_CLASSES definitions from just the module. - from dynamic_debug_init(), where all DYNAMIC_DEBUG_CLASSES definitions of each builtin module have been packed together. This is why ddebug_attach_module_classes() checks module-name. NOTES Its (highly) likely that builtin classes will be ordered by module name (just like prdbg descriptors are in the __dyndbg section). So the list can be replaced by a vector (ptr + length), which will work for loaded modules too. This would imitate whats currently done for the _ddebug descriptors. That said, converting to vector,len is close to pointless; a small minority of modules will ever define a class-map, and almost all of them will have only 1 or 2 class-maps, so theres only a couple dozen pointers to save. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0d6cb6b258bd..a3ace5866f1b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,7 +45,7 @@ extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { - struct list_head link; + struct list_head link, maps; const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; @@ -921,6 +921,32 @@ static const struct proc_ops proc_fops = { .proc_write = ddebug_proc_write }; +static void ddebug_attach_module_classes(struct ddebug_table *dt, + struct ddebug_class_map *classes, + int num_classes) +{ + struct ddebug_class_map *cm; + int i, j, ct = 0; + + for (cm = classes, i = 0; i < num_classes; i++, cm++) { + + if (!strcmp(cm->mod_name, dt->mod_name)) { + + v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, + cm->mod_name, cm->base, cm->length, cm->map_type); + + for (j = 0; j < cm->length; j++) + v3pr_info(" %d: %d %s\n", j + cm->base, j, + cm->class_names[j]); + + list_add(&cm->link, &dt->maps); + ct++; + } + } + if (ct) + vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -953,6 +979,12 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->maps); + + if (classes && num_classes) + ddebug_attach_module_classes(dt, classes, num_classes); + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); From patchwork Fri Aug 5 21:53: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: 12937743 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F21A7C19F2D for ; Fri, 5 Aug 2022 21:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241769AbiHEVza (ORCPT ); Fri, 5 Aug 2022 17:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241706AbiHEVzE (ORCPT ); Fri, 5 Aug 2022 17:55:04 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 308A4E03; Fri, 5 Aug 2022 14:54:40 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id l9so1989720ilq.1; Fri, 05 Aug 2022 14:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1ntMBXwA74iBC/RlqNBXTIaWrG+kFWcB6AY7njBN2E8=; b=jiKbznWqsXjnP+nUkACFEuo9GLpsV4w0LdDV6VR+64VxU20bBIs5H1qHWsVZDNnjN1 HDUPyXqV/Y2/BskBxpheQi66GlAwE/961ySm+A219innWXJt45tTwZm3VuxopmsfcM3v nAie1r+MpIJi0S65HzrNouziXi7fJ38ivEz+K2pqmZTiBVHUL0YkCJmkdqSh3KRgT4qG 8FsLCQXdb8UShevAQtwj2f5jLTZADYZBdDhWRJuJXLLHljHmiPWAqZ/BSBx6IDeQKSHR WU3Vwgi/no7/5L8PslPYr3HxGPN1G9ib8tq+ktEbHnj/qVx5iPoBXgAdClcnwv8OHcih 0KdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=1ntMBXwA74iBC/RlqNBXTIaWrG+kFWcB6AY7njBN2E8=; b=vPx7bSTFXtU4lj/Kp4qhC+5H25V7IuwwhXFflTD53KdEK/hjBfWy/JX761+0uj12Xn 2Iefgp6DsvNvGZ6RsU7LhKnQeI7uiA7rN4SaBfeciS6RPFami1wOtkdr4bop5EE/QSW9 LfSq/hdh5CvCCceR4pdxSnnPMdkD1DKnTJfqIGCM9tw8C9Y6CnSoxRqQKB9nczCK01wz mXj4PGHR87se4xo0vCM1jd3IzC+H53HN+3cG9pN7EQpGds6trSNtw5Qfr6rk4jfkZH7v 5VRGLy7lza7H5MVkGZKUmZtmSqwjLiWm9TK+TIf/rMO2u3NlofcQxUAy3wb7q4eLe86a m6jg== X-Gm-Message-State: ACgBeo3CqnSJcvjDor5ojfTZVhtVtcV3ragSVMMzeGNO+J+R3dzz6GwE 1mY3rITWe7LtI44Z+aqar3WydBaA8ZziXw== X-Google-Smtp-Source: AA6agR48s5NPRt1YhcAWvCagIn/BS0C0y8WsvLDToFTnMGHjigtHrLFLYeGrlXnsnMUiteVk8NR1bQ== X-Received: by 2002:a92:cd84:0:b0:2df:52fa:30c4 with SMTP id r4-20020a92cd84000000b002df52fa30c4mr3727235ilb.314.1659736479367; Fri, 05 Aug 2022 14:54:39 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:38 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 17/33] dyndbg: validate class FOO by checking with module Date: Fri, 5 Aug 2022 15:53:39 -0600 Message-Id: <20220805215355.3509287-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add module-to-class validation: #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control If a query has "class FOO", then ddebug_find_valid_class(), called from ddebug_change(), requires that FOO is known to module X, otherwize the query is skipped entirely for X. This protects each module's class-space, other than the default:31. The authors' choice of FOO is highly selective, giving isolation and/or coordinated sharing of FOOs. For example, only DRM modules should know and respond to DRM_UT_KMS. So this, combined with module's opt-in declaration of known classes, effectively privatizes the .class_id space for each module (or coordinated set of modules). Notes: For all "class FOO" queries, ddebug_find_valid_class() is called, it returns the map matching the query, and sets valid_class via an *outvar). If no "class FOO" is supplied, valid_class = _CLASS_DFLT. This insures that legacy queries do not trample on new class'd callsites, as they get added. Also add a new column to control-file output, displaying non-default class-name (when found) or the "unknown _id:", if it has not been (correctly) declared with one of the declarator macros. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 76 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a3ace5866f1b..eb410b412f0d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -56,6 +56,7 @@ struct ddebug_query { const char *module; const char *function; const char *format; + const char *class_string; unsigned int first_lineno, last_lineno; }; @@ -136,15 +137,33 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) fmtlen--; } - v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n", - msg, - query->function ?: "", - query->filename ?: "", - query->module ?: "", - fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno); + v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s\n", + msg, + query->function ?: "", + query->filename ?: "", + query->module ?: "", + fmtlen, query->format ?: "", + query->first_lineno, query->last_lineno, query->class_string); } +static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, + const char *class_string, int *class_id) +{ + struct ddebug_class_map *map; + int idx; + + list_for_each_entry(map, &dt->maps, link) { + idx = match_string(map->class_names, map->length, class_string); + if (idx >= 0) { + *class_id = idx + map->base; + return map; + } + } + *class_id = -ENOENT; + return NULL; +} + +#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -159,6 +178,8 @@ static int ddebug_change(const struct ddebug_query *query, unsigned int newflags; unsigned int nfound = 0; struct flagsbuf fbuf, nbuf; + struct ddebug_class_map *map = NULL; + int __outvar valid_class; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -169,9 +190,22 @@ static int ddebug_change(const struct ddebug_query *query, !match_wildcard(query->module, dt->mod_name)) continue; + if (query->class_string) { + map = ddebug_find_valid_class(dt, query->class_string, &valid_class); + if (!map) + continue; + } else { + /* constrain query, do not touch class'd callsites */ + valid_class = _DPRINTK_CLASS_DFLT; + } + for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; + /* match site against query-class */ + if (dp->class_id != valid_class) + continue; + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -420,6 +454,8 @@ static int ddebug_parse_query(char *words[], int nwords, } else if (!strcmp(keyword, "line")) { if (parse_linerange(query, arg)) return -EINVAL; + } else if (!strcmp(keyword, "class")) { + rc = check_set(&query->class_string, arg, "class"); } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; @@ -854,6 +890,20 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) return dp; } +#define class_in_range(class_id, map) \ + (class_id >= map->base && class_id < map->base + map->length) + +static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) +{ + struct ddebug_class_map *map; + + list_for_each_entry(map, &iter->table->maps, link) + if (class_in_range(dp->class_id, map)) + return map->class_names[dp->class_id - map->base]; + + return NULL; +} + /* * Seq_ops show method. Called several times within a read() * call from userspace, with ddebug_lock held. Formats the @@ -865,6 +915,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) struct ddebug_iter *iter = m->private; struct _ddebug *dp = p; struct flagsbuf flags; + char const *class; if (p == SEQ_START_TOKEN) { seq_puts(m, @@ -877,7 +928,16 @@ static int ddebug_proc_show(struct seq_file *m, void *p) iter->table->mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); - seq_puts(m, "\"\n"); + seq_puts(m, "\""); + + if (dp->class_id != _DPRINTK_CLASS_DFLT) { + class = ddebug_class_name(iter, dp); + if (class) + seq_printf(m, " class:%s", class); + else + seq_printf(m, " class unknown, _id:%d", dp->class_id); + } + seq_puts(m, "\n"); return 0; } From patchwork Fri Aug 5 21:53: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: 12937755 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4A93C19F2D for ; Fri, 5 Aug 2022 21:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241738AbiHEV43 (ORCPT ); Fri, 5 Aug 2022 17:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241719AbiHEVzF (ORCPT ); Fri, 5 Aug 2022 17:55:05 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC787C1A6; Fri, 5 Aug 2022 14:54:41 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id z8so680546ile.0; Fri, 05 Aug 2022 14:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ZSrYcW0n+hMGbP13qtU8Pp8sbnMOwvc1NQla3G+MVBY=; b=pPw4i+VqbQa25X7qFM0wRNJ8nxyDnFuNDaCsDun2ttngNr71qRrGr4k8NyN7xsD80B 7OEIqPTiLY9pjqLlMqCA6IqcQ4HOo+XNP1ix9evPlP7vO7Y4Inyr2r4bjjSX+Y7R5zKj HBqzGMZzxBa4+4ptNMHk1htpzfhYtw+mflA0z/piZ8WMUwb2U1ZqHiU3Imd97+NRj9ky 9s+6OnPcOXDsdoVQnqcU89Epq/rxnhZWvYbGfrNLUGI18PpSQORnjRdXOq31ZhCtjElZ 5vcklUbLM0pu+LW/VNKLMAEWqRA+MegMEmVcJXzQkN1+nedaHwzujL6llty5ACx/1Dp4 s4aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ZSrYcW0n+hMGbP13qtU8Pp8sbnMOwvc1NQla3G+MVBY=; b=fQaXsN3TPkpsB7tc6G+3pKI8XsTgJKjiJp4oOafB86mDUpbvlSyJWJiIyCK1s3cxlg ph/TeXP5mSbNIvFWNacFPqHr68BSVUA8seL1Ywa++zOC2ncVUs1r5WkXKhm0RNTSuef7 ptMvsuuj+zo4MUHWwfGomxnrsdQ0xo9/9rk8ruV2RcXeZNNn+Qe2diPRRGi3Nffw3uOa d5wQp2lBJtfL2TJ3UEVKPdk73CaaQgq72iiizagmENkaNcYaxWNT09Ml7SNmXZJRjBgF SxsuZLEl4V7IFyTKQisBlgU8Xh6tNuWyc3ueb/dKgogBCeVgIDcCCLOqnBn2LlHJT3QZ Wl/w== X-Gm-Message-State: ACgBeo0PDBwZBxW23vMtAH33+3FOcWs6B+cxJS1PRK3Bm3RwNE9FSB0E dbonT3k4TC05WslStgGunXm01aivZPvMVw== X-Google-Smtp-Source: AA6agR6G2mXKbweLP8JJH09ZIwf4toE4HNTDaPGGZAufMuf4+BUTj0JP+37VK2t41KmICClDFLB/DQ== X-Received: by 2002:a05:6e02:2164:b0:2de:e996:b8f with SMTP id s4-20020a056e02216400b002dee9960b8fmr4037903ilv.0.1659736480406; Fri, 05 Aug 2022 14:54:40 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:40 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 18/33] doc-dyndbg: describe "class CLASS_NAME" query support Date: Fri, 5 Aug 2022 15:53:40 -0600 Message-Id: <20220805215355.3509287-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add an explanation of the new "class CLASS_NAME" syntax and meaning, noting that the module determines if CLASS_NAME applies to it. Signed-off-by: Jim Cromie --- Documentation/admin-guide/dynamic-debug-howto.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index a89cfa083155..d8954ab05c7b 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -35,6 +35,7 @@ Dynamic debug has even more useful features: - line number (including ranges of line numbers) - module name - format string + - class name (as known/declared by each module) * Provides a debugfs control file: ``/dynamic_debug/control`` which can be read to display the complete list of known debug @@ -142,6 +143,7 @@ against. Possible keywords are::: 'file' string | 'module' string | 'format' string | + 'class' string | 'line' line-range line-range ::= lineno | @@ -203,6 +205,15 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitespace +class + The given class_name is validated against each module, which may + have declared a list of known class_names. If the class_name is + found for a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a DRM.debug category + class JUNK # silent non-match + line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single From patchwork Fri Aug 5 21:53:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937748 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB849C25B08 for ; Fri, 5 Aug 2022 21:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241688AbiHEV4S (ORCPT ); Fri, 5 Aug 2022 17:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241737AbiHEVzP (ORCPT ); Fri, 5 Aug 2022 17:55:15 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE4C37C1B6; Fri, 5 Aug 2022 14:54:42 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id z8so680561ile.0; Fri, 05 Aug 2022 14:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=tA/XE49fwwL6j4TkbBp789Ln8YhWTld6qz46/aQexmM=; b=QDX9cyuMtE5sHE6L4s9s0tt6oIZz5Wj6fVPsANJc0wM0JX442uFnl28vdLTm15RnVQ 8jaaUZwSOCmhrUK7DLjTYf+u76IFED9omegKnktDm9u6jh9gdmJI/1j5fJMuGfssJspB knI72RVF0muUrCXMh/25ZS/OZavK9fPz0kdWLNhGKGzpSea6dqY1GMIEIetPzGR+69xt K2fn3LgBQPAL+LpRgZpsw5s3MElfOQtNxg0v2ylYJ2z3TFQtIWJo/lUzSRhhIAjWiqmm 2dqdDEZRQRjTAm04wmot6e2ecPEcRgv6htGcrQ9qTEc5m0aZKqpXMf3oeAzc1okz7Ln5 T33g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=tA/XE49fwwL6j4TkbBp789Ln8YhWTld6qz46/aQexmM=; b=dfp8auoTnize7p4uYvl1BshvJwxSdfwvwdbXYI8MHISwJ7zyMvrs35WJjrhGtCXAdx n1o+RViUnicEt9oKYV6XPrvV/joTGolI8NQLr5ukyvQVMeVIHWLKoZfGtvcWykmRSgdl 6EIt3hmouTIYB24NyeWYVbyPtkuWgD82GxWm8RrYHkyqOQIED8k3iNizyHWcm3PDCphh 8LYfYX6SCNCXvryGlr0j54A/5jDTOECtGqwLPKHIq5mrbYvoFnG5BoFJQo2Vi3vu+CvB n5UjEi7u30aQNvnS9MICnwIomBwFj+wqjQG2jUI0K7MmNEbCGaazalqZkG3U7bPzPZAH kkPA== X-Gm-Message-State: ACgBeo0tLSVJfojKIk0dr3ScQ0Ym6pbslJYQxUOqLGFQV/Ylfpw6xHD+ 5RDlXi+gEprRjCnYfwfuKg3bugU2eIZkbw== X-Google-Smtp-Source: AA6agR7S9lzgsFX1hOYdGMjYLTyPOEPsiHlCtTugoAJ6+F+zyXwTEYDdYhUVOpcEfVeD4dIcyMEx9g== X-Received: by 2002:a92:c264:0:b0:2de:bf95:118a with SMTP id h4-20020a92c264000000b002debf95118amr3915893ild.160.1659736481481; Fri, 05 Aug 2022 14:54:41 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:41 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v5 19/33] doc-dyndbg: edit dynamic-debug-howto for brevity, audience Date: Fri, 5 Aug 2022 15:53:41 -0600 Message-Id: <20220805215355.3509287-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rework/modernize docs: - use /proc/dynamic_debug/control in examples its *always* there (when dyndbg is config'd), even when is not. drop talk, its a distraction here. - alias ddcmd='echo $* > /proc/dynamic_debug/control focus on args: declutter, hide boilerplate, make pwd independent. - swap sections: Viewing before Controlling. control file as Catalog. - focus on use by a system administrator add an alias to make examples more readable drop grep-101 lessons, admins know this. - use init/main.c as 1st example, thread it thru doc where useful. everybodys kernel boots, runs these. - add *prdbg* api section to the bottom of the file, its for developers more than admins. move list of api functions there. - simplify - drop extra words, phrases, sentences. - add "decorator" flags line to unify "prefix", trim fmlt descriptions CC: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie Reviewed-by: Bagas Sanjaya --- fixup-doc: trailing colons for block headers, trim fedora numbers. Bagas --- .../admin-guide/dynamic-debug-howto.rst | 235 +++++++++--------- 1 file changed, 117 insertions(+), 118 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index d8954ab05c7b..faa22f77847a 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -5,30 +5,19 @@ Dynamic debug Introduction ============ -This document describes how to use the dynamic debug (dyndbg) feature. +Dynamic debug allows you to dynamically enable/disable kernel +debug-print code to obtain additional kernel information. -Dynamic debug is designed to allow you to dynamically enable/disable -kernel code to obtain additional kernel information. Currently, if -``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and -``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically -enabled per-callsite. +If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic +debug. You'll need root access (sudo su) to use this. -If you do not want to enable dynamic debug globally (i.e. in some embedded -system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic -debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any -modules which you'd like to dynamically debug later. +Dynamic debug provides: -If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just -shortcut for ``print_hex_dump(KERN_DEBUG)``. + * a Catalog of all *prdbgs* in your kernel. + ``cat /proc/dynamic_debug/control`` to see them. -For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is -its ``prefix_str`` argument, if it is constant string; or ``hexdump`` -in case ``prefix_str`` is built dynamically. - -Dynamic debug has even more useful features: - - * Simple query language allows turning on and off debugging - statements by matching any combination of 0 or 1 of: + * a Simple query/command language to alter *prdbgs* by selecting on + any combination of 0 or 1 of: - source filename - function name @@ -37,107 +26,88 @@ Dynamic debug has even more useful features: - format string - class name (as known/declared by each module) - * Provides a debugfs control file: ``/dynamic_debug/control`` - which can be read to display the complete list of known debug - statements, to help guide you - -Controlling dynamic debug Behaviour -=================================== - -The behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a -control file in the 'debugfs' filesystem. Thus, you must first mount -the debugfs filesystem, in order to make use of this feature. -Subsequently, we refer to the control file as: -``/dynamic_debug/control``. For example, if you want to enable -printing from source file ``svcsock.c``, line 1603 you simply do:: - - nullarbor:~ # echo 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - -If you make a mistake with the syntax, the write will fail thus:: - - nullarbor:~ # echo 'file svcsock.c wtf 1 +p' > - /dynamic_debug/control - -bash: echo: write error: Invalid argument - -Note, for systems without 'debugfs' enabled, the control file can be -found in ``/proc/dynamic_debug/control``. - Viewing Dynamic Debug Behaviour =============================== -You can view the currently configured behaviour of all the debug -statements via:: +You can view the currently configured behaviour in the *prdbg* catalog:: - nullarbor:~ # cat /dynamic_debug/control + :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format - net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012" - net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012" - net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth : %d\012" - net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests : %d\012" - ... + init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012 + init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" + init/main.c:1424 [main]run_init_process =_ " with arguments:\012" + init/main.c:1426 [main]run_init_process =_ " %s\012" + init/main.c:1427 [main]run_init_process =_ " with environment:\012" + init/main.c:1429 [main]run_init_process =_ " %s\012" +The 3rd space-delimited column shows the current flags, preceded by +a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites. -You can also apply standard Unix text manipulation filters to this -data, e.g.:: +Controlling dynamic debug Behaviour +=================================== - nullarbor:~ # grep -i rdma /dynamic_debug/control | wc -l - 62 +The behaviour of *prdbg* sites are controlled by writing +query/commands to the control file. Example:: - nullarbor:~ # grep -i tcp /dynamic_debug/control | wc -l - 42 + # grease the interface + :#> alias ddcmd='echo $* > /proc/dynamic_debug/control' -The third column shows the currently enabled flags for each debug -statement callsite (see below for definitions of the flags). The -default value, with no flags enabled, is ``=_``. So you can view all -the debug statement callsites with any non-default flags:: + :#> ddcmd '-p; module main func run* +p' + :#> grep =p /proc/dynamic_debug/control + init/main.c:1424 [main]run_init_process =p " with arguments:\012" + init/main.c:1426 [main]run_init_process =p " %s\012" + init/main.c:1427 [main]run_init_process =p " with environment:\012" + init/main.c:1429 [main]run_init_process =p " %s\012" - nullarbor:~ # awk '$3 != "=_"' /dynamic_debug/control - # filename:lineno [module]function flags format - net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" +Error messages go to console/syslog:: + + :#> ddcmd mode foo +p + dyndbg: unknown keyword "mode" + dyndbg: query parse failed + bash: echo: write error: Invalid argument + +If debugfs is also enabled and mounted, ``dynamic_debug/control`` is +also under the mount-dir, typically ``/sys/kernel/debug/``. Command Language Reference ========================== -At the lexical level, a command comprises a sequence of words separated +At the basic lexical level, a command is a sequence of words separated by spaces or tabs. So these are all equivalent:: - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control - nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' > - /dynamic_debug/control - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd file svcsock.c line 1603 +p + :#> ddcmd "file svcsock.c line 1603 +p" + :#> ddcmd ' file svcsock.c line 1603 +p ' Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: - ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \ - > /dynamic_debug/control - -If your query set is big, you can batch them too:: - - ~# cat query-batch-file > /dynamic_debug/control + :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd <<"EOC" + func pnpacpi_get_resources +p + func pnp_assign_mem +p + EOC + :#> cat query-batch-file > /proc/dynamic_debug/control -Another way is to use wildcards. The match rule supports ``*`` (matches -zero or more characters) and ``?`` (matches exactly one character). For -example, you can match all usb drivers:: +You can also use wildcards in each query term. The match rule supports +``*`` (matches zero or more characters) and ``?`` (matches exactly one +character). For example, you can match all usb drivers:: - ~# echo "file drivers/usb/* +p" > /dynamic_debug/control + :#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion -At the syntactical level, a command comprises a sequence of match -specifications, followed by a flags change specification:: +Syntactically, a command is pairs of keyword values, followed by a +flags change or setting:: command ::= match-spec* flags-spec -The match-spec's are used to choose a subset of the known pr_debug() -callsites to which to apply the flags-spec. Think of them as a query -with implicit ANDs between each pair. Note that an empty list of -match-specs will select all debug statement callsites. +The match-spec's select *prdbgs* from the catalog, upon which to apply +the flags-spec, all constraints are ANDed together. An absent keyword +is the same as keyword "*". -A match specification comprises a keyword, which controls the -attribute of the callsite to be compared, and a value to compare -against. Possible keywords are::: + +A match specification is a keyword, which selects the attribute of +the callsite to be compared, and a value to compare against. Possible +keywords are::: match-spec ::= 'func' string | 'file' string | @@ -213,6 +183,7 @@ class class DRM_UT_KMS # a DRM.debug category class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names line The given line number or range of line numbers is compared @@ -239,17 +210,16 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. - f Include the function name in the printed message - l Include line number in the printed message - m Include module name in the printed message - t Include thread ID in messages not generated from interrupt context - _ No flags are set. (Or'd with others on input) + _ enables no flags. -For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag -have meaning, other flags ignored. + Decorator flags add to the message-prefix, in order: + t Include thread ID, or + m Include module name + f Include the function name + l Include line number -For display, the flags are preceded by ``=`` -(mnemonic: what the flags are currently equal to). +For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only +the ``p`` flag has meaning, other flags are ignored. Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. To clear all flags at once, use ``=_`` or ``-flmpt``. @@ -324,7 +294,7 @@ For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or enabled by ``-DDEBUG`` flag during compilation) can be disabled later via the debugfs interface if the debug messages are no longer needed:: - echo "module module_name -p" > /dynamic_debug/control + echo "module module_name -p" > /proc/dynamic_debug/control Examples ======== @@ -332,37 +302,31 @@ Examples :: // enable the message at line 1603 of file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c line 1603 +p' // enable all the messages in file svcsock.c - nullarbor:~ # echo -n 'file svcsock.c +p' > - /dynamic_debug/control + :#> ddcmd 'file svcsock.c +p' // enable all the messages in the NFS server module - nullarbor:~ # echo -n 'module nfsd +p' > - /dynamic_debug/control + :#> ddcmd 'module nfsd +p' // enable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process +p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process +p' // disable all 12 messages in the function svc_process() - nullarbor:~ # echo -n 'func svc_process -p' > - /dynamic_debug/control + :#> ddcmd 'func svc_process -p' // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. - nullarbor:~ # echo -n 'format "nfsd: READ" +p' > - /dynamic_debug/control + :#> ddcmd 'format "nfsd: READ" +p' // enable messages in files of which the paths include string "usb" - nullarbor:~ # echo -n 'file *usb* +p' > /dynamic_debug/control + :#> ddcmd 'file *usb* +p' > /proc/dynamic_debug/control // enable all messages - nullarbor:~ # echo -n '+p' > /dynamic_debug/control + :#> ddcmd '+p' > /proc/dynamic_debug/control // add module, function to all enabled messages - nullarbor:~ # echo -n '+mf' > /dynamic_debug/control + :#> ddcmd '+mf' > /proc/dynamic_debug/control // boot-args example, with newlines and comments for readability Kernel command line: ... @@ -375,3 +339,38 @@ Examples dyndbg="file init/* +p #cmt ; func parse_one +p" // enable pr_debugs in 2 functions in a module loaded later pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p" + +Kernel Configuration +==================== + +Dynamic Debug is enabled via kernel config items:: + + CONFIG_DYNAMIC_DEBUG=y # build catalog, enables CORE + CONFIG_DYNAMIC_DEBUG_CORE=y # enable mechanics only, skip catalog + +If you do not want to enable dynamic debug globally (i.e. in some embedded +system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic +debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any +modules which you'd like to dynamically debug later. + + +Kernel *prdbg* API +================== + +The following functions are cataloged and controllable when dynamic +debug is enabled:: + + pr_debug() + dev_dbg() + print_hex_dump_debug() + print_hex_dump_bytes() + +Otherwise, they are off by default; ``ccflags += -DDEBUG`` or +``#define DEBUG`` in a source file will enable them appropriately. + +If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is +just a shortcut for ``print_hex_dump(KERN_DEBUG)``. + +For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is +its ``prefix_str`` argument, if it is constant string; or ``hexdump`` +in case ``prefix_str`` is built dynamically. From patchwork Fri Aug 5 21:53:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937790 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E1B9C00140 for ; Fri, 5 Aug 2022 21:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241655AbiHEV5d (ORCPT ); Fri, 5 Aug 2022 17:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241736AbiHEVzP (ORCPT ); Fri, 5 Aug 2022 17:55:15 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B3E17CB4F; Fri, 5 Aug 2022 14:54:43 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id j20so1975519ila.6; Fri, 05 Aug 2022 14:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=oIpC7ZC5m5oABjbCTUQwv/9GbpNDm2YFIKa/3d4KInk=; b=hE/xrJ9j2dYTiSesOKcrODfJJLU/a4ldIODLFLiXhQf4GJcrUu+iNVOlqQykrGN8Z+ mmM4z+Fkd566mIcG9GqAOLN5h4gXECZWpGLLyucbD9XujymtAydTS1UYGwzrer71eVmI 3Ua4X7vsB6u2xIrGFaxg+wOyA2xH8JkqqVjrtRvMjErZeIvpInLi8s5hiOiAMZTqY0dC 7nHWMnJ5aCYmAUlSt1UmAIJlw+icM81SJ8dVYhCcswJ3dArmI8aksUAv59z1LHh0fBCy voOUuNo1OV4z+kq1+L+Fm7/y3B6eAexunwlt6Ba6T04B+xiVxownKTPq5GSGOUCaMVwM itSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=oIpC7ZC5m5oABjbCTUQwv/9GbpNDm2YFIKa/3d4KInk=; b=mP2pOKnwgFMfEmthQsu2pzdhMRjUonLb6o0wIx488Q8tIYWnTuOZBz0RUNaumgsFcc KAMCl+L125owl/+/EWb7cR2dnXGbKQU47ZjtCMMPVKdAgbPOT4fH5HBgBPChMXQLArKT KzzxJJJVivc7P5puQ8RsTNSygnIjvshzk1WIkodgqiYiKE/dSuNBRqUjLK9QyMJZQwZK qw1pvWzeJjX8vf02RSPTR6tvkLRejl4Bl8j/Be4UwroXKg2vyzil5dNxjZuZgjvLyvJg u2KEsVqL72TJJ1hUBuYPXcdRNmDTfExSHs9URF5+G8fHg0PXb74ZFCPA3DTauLo0kKQI UzKA== X-Gm-Message-State: ACgBeo1UoWjFkk1ZuZ6WyZTTV6Gk/hJ2hE/NziyakuOzipwrX+hWUGck 9OVR6CIn8CCy1BKTX8WhwGHgh66vK4w1GQ== X-Google-Smtp-Source: AA6agR5qLapTrIl3lGp1qJoLRHcH/Evt6be2L7DDRrLM4hWocnV0QMSiHSZIpUvSNC/3a8paQjxKjQ== X-Received: by 2002:a92:d64d:0:b0:2dc:e337:58ab with SMTP id x13-20020a92d64d000000b002dce33758abmr3727652ilp.85.1659736482599; Fri, 05 Aug 2022 14:54:42 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:42 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 20/33] dyndbg: add drm.debug style (drm/parameters/debug) bitmap support Date: Fri, 5 Aug 2022 15:53:42 -0600 Message-Id: <20220805215355.3509287-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add kernel_param_ops and callbacks to use a class-map to validate and apply input to a sysfs-node, which allows users to control classes defined in that class-map. This supports uses like: echo 0x3 > /sys/module/drm/parameters/debug IE add these: - int param_set_dyndbg_classes() - int param_get_dyndbg_classes() - struct kernel_param_ops param_ops_dyndbg_classes Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. This might be unnecessary here. get/set use an augmented kernel_param; the arg refs a new struct ddebug_class_param, which contains: A union of &ulong bits, level; which points to user module's ulong storing the module's debug-state. By ref'g the client's bit-state _var, code coordinates with existing code (like drm_debug_enabled) which uses it, so existing works unchanged. Changing to a ulong allows use of BIT() etc. FLAGS: dyndbg.flags toggled by changes to bitmap. Usually just "p". MAP: a pointer to struct ddebug_classes_map, which maps those class-names to .class_ids 0..N that the module is using. This class-map is declared & initialized by DECLARE_DYNDBG_CLASSMAP. map-type: 4 enums DD_CLASS_TYPE_* select 2 input forms and 2 meanings. numeric input: DD_CLASS_TYPE_DISJOINT_BITS integer input, independent bits. ie: drm.debug DD_CLASS_TYPE_LEVEL_NUM integer input, 0..N levels classnames-list (comma separated) input: DD_CLASS_TYPE_DISJOINT_NAMES each name affects a bit, others preserved DD_CLASS_TYPE_LEVEL_NAMES names have level meanings, like kern_levels.h _NAMES - comma-separated classnames (with optional +-) _NUM - numeric input, 0-N expected _BITS - numeric input, 0x1F bitmap form expected _DISJOINT - bits are independent _LEVEL - (x /sys/module/drm/parameters/debug_catnames A standard _LEVEL_NAMES use, with one class, that sets all in the class-map according to (x /sys/module/test_dynamic_debug/parameters/p_level_names : problem solved echo -L1 > /sys/module/test_dynamic_debug/parameters/p_level_names Note this artifact: : this is same as prev cmd (due to +/-) echo L0 > /sys/module/test_dynamic_debug/parameters/p_level_names : this is "even-more" off, but same wo __pr_debug_class(L0, ".."). echo -L0 > /sys/module/test_dynamic_debug/parameters/p_level_names A stress-test/make-work usage (kid toggling a light switch): echo +L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7,L0,L7 \ > /sys/module/test_dynamic_debug/parameters/p_level_names ddebug_apply_class_bitmap(): inside-fn, works on bitmaps, receives new-bits, finds diffs vs client-bitvector holding "current" state, and issues exec_query to commit the adjustment. param_set_dyndbg_classes(): interface fn, sends _NAMES to param_set_dyndbg_classnames() and returns, falls thru to handle _BITS, _NUM internally, and calls ddebug_apply_class_bitmap(). Finishes by updating state. param_set_dyndbg_classnames(): handles classnames-list in loop, calls ddebug_apply_class_bitmap for each, then updates state. NOTES: _LEVEL_ is overlay on _DISJOINT_; inputs are converted to a bitmask, and is done by callbacks. IOW this is possible, and possibly confusing: echo class V3 +p > control echo class V1 -p > control IMO thats ok, relative verbosity is an interface property. _LEVEL_NUM maps still need class-names, even though the names are not usable at the sysfs interface (unlike with _NAMES style). The names are the only way to >control the classes. - It must have a "V0" name, something below "V1" to turn "V1" off. __pr_debug_cls(V0,..) is printk, don't do that. - "class names" is required at the >control interface. - relative levels are not enforced at >control _LEVEL_NAMES bear +/- signs, which alters the on-bit-pos by 1. IOW, +L2 means L0,L1,L2, and -L2 means just L0,L1. This kinda spoils the readback fidelity, since the L0 bit gets turned on by any use of any L*, except "-L0". All the interface uncertainty here pertains to the _NAMES features. Nobody has actually asked for this, so its practical (if a little tedious) to split it out. Signed-off-by: Jim Cromie --- . drop kp->mod->name as unneeded (build-dependent) . param_set_dyndbg_classnames, not _class_strings . DD_CLASS_TYPE_* name changes, per Jason . callbacks: extend comments on DD_CLASS_TYPE_* handling, flow notes varname changes . kdoc tweaks . add stub macro: #define KP_NAME(kp) kp->name later, add "$module." prefix when config doesn't do it . s/struct ddebug_classes_bitmap_param/struct ddebug_class_param/ . fix levels state handling v4 had trouble where level-type's state was fouled by conversion to bitmap form given to apply-bitmap. fix by: (simplify/clarify) add old-bits, new-bits to sysfs-iface&support use CLASSMAP_BITMASK more in param_set_dyndbg_class{es,names}(): move state-saving inside switches, and tailor it to type. this preserves lvl-state, vs -v4 which didnt. I could "hack" in an offset, but the problem feels deeper. The root-problem may be the ambiguity wrt 0x0 > knob; per a input-is-assert-bitpos interpretation, it turns on bit 0. Thus far, code has avoided this ambiguity, by recommending against coding pr_dbg_cls(V0|L0, ""), which makes "+L0" & "-L0" equivalent, and "0" silent. That might be "too clever by 1/2"; accepting an int, so -1 means all-bits-off as well as verbosity-off, might be the better way. --- include/linux/dynamic_debug.h | 20 ++++ lib/dynamic_debug.c | 218 +++++++++++++++++++++++++++++++++- 2 files changed, 234 insertions(+), 4 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 46ed10682e87..956614a208a4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -120,6 +120,14 @@ struct _ddebug_info { unsigned int num_classes; }; +struct ddebug_class_param { + union { unsigned long *bits; + unsigned long *lvl; + }; + char flags[8]; + const struct ddebug_class_map *map; +}; + #if defined(CONFIG_DYNAMIC_DEBUG_CORE) int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); @@ -279,6 +287,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +struct kernel_param; +int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp); +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp); + /* for test only, generally expect drm.debug style macro wrappers */ #define __pr_debug_cls(cls, fmt, ...) do { \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ @@ -325,6 +337,14 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, rowsize, groupsize, buf, len, ascii); \ } while (0) +struct kernel_param; +static inline int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +extern const struct kernel_param_ops param_ops_dyndbg_classes; + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index eb410b412f0d..c41e22d850e0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -596,6 +596,218 @@ static int ddebug_exec_queries(char *query, const char *modname) return nfound; } +/* apply a new bitmap to the sys-knob's current bit-state */ +static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, + unsigned long *new_bits, unsigned long *old_bits) +{ +#define QUERY_SIZE 128 + char query[QUERY_SIZE]; + const struct ddebug_class_map *map = dcp->map; + int matches = 0; + int bi, ct; + + v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + + for (bi = 0; bi < map->length; bi++) { + if (test_bit(bi, new_bits) == test_bit(bi, old_bits)) + continue; + + snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], + test_bit(bi, new_bits) ? '+' : '-', dcp->flags); + + ct = ddebug_exec_queries(query, NULL); + matches += ct; + + v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, + ct, map->class_names[bi], *new_bits); + } + return matches; +} + +/* stub to later conditionally add "$module." prefix where not already done */ +#define KP_NAME(kp) kp->name + +#define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) + +/* accept comma-separated-list of [+-] classnames */ +static int param_set_dyndbg_classnames(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + unsigned long curr_bits, old_bits; + char *cl_str, *p, *tmp; + int cls_id, totct = 0; + bool wanted; + + cl_str = tmp = kstrdup(instr, GFP_KERNEL); + p = strchr(cl_str, '\n'); + if (p) + *p = '\0'; + + /* start with previously set state-bits, then modify */ + curr_bits = old_bits = *dcp->bits; + vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); + + for (; cl_str; cl_str = p) { + p = strchr(cl_str, ','); + if (p) + *p++ = '\0'; + + if (*cl_str == '-') { + wanted = false; + cl_str++; + } else { + wanted = true; + if (*cl_str == '+') + cl_str++; + } + cls_id = match_string(map->class_names, map->length, cl_str); + if (cls_id < 0) { + pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); + continue; + } + + /* have one or more valid class_ids of one *_NAMES type */ + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_NAMES: + /* the +/- pertains to a single bit */ + if (test_bit(cls_id, &curr_bits) == wanted) { + v3pr_info("no change on %s\n", cl_str); + continue; + } + curr_bits ^= BIT(cls_id); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + *dcp->bits = curr_bits; + v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, + map->class_names[cls_id]); + break; + case DD_CLASS_TYPE_LEVEL_NAMES: + /* cls_id = N in 0..max. wanted +/- determines N or N-1 */ + old_bits = CLASSMAP_BITMASK(*dcp->lvl); + curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); + + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + *dcp->lvl = (cls_id + (wanted ? 1 : 0)); + v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, + map->class_names[cls_id], old_bits, curr_bits); + break; + default: + pr_err("illegal map-type value %d\n", map->map_type); + } + } + kfree(tmp); + vpr_info("total matches: %d\n", totct); + return 0; +} + +/** + * param_set_dyndbg_classes - class FOO >control + * @instr: string echo>d to sysfs, input depends on map_type + * @kp: kp->arg has state: bits/lvl, map, map_type + * + * Enable/disable prdbgs by their class, as given in the arguments to + * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative + * levels by bitpos. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + unsigned long inrep, new_bits, old_bits; + int rc, totct = 0; + + switch (map->map_type) { + + case DD_CLASS_TYPE_DISJOINT_NAMES: + case DD_CLASS_TYPE_LEVEL_NAMES: + /* handle [+-]classnames list separately, we are done here */ + return param_set_dyndbg_classnames(instr, kp); + + case DD_CLASS_TYPE_DISJOINT_BITS: + case DD_CLASS_TYPE_LEVEL_NUM: + /* numeric input, accept and fall-thru */ + rc = kstrtoul(instr, 0, &inrep); + if (rc) { + pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); + return -EINVAL; + } + break; + default: + pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + return -EINVAL; + } + + /* only _BITS,_NUM (numeric) map-types get here */ + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + /* expect bits. mask and warn if too many */ + if (inrep & ~CLASSMAP_BITMASK(map->length)) { + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", + KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); + inrep &= CLASSMAP_BITMASK(map->length); + } + v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); + totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + *dcp->bits = inrep; + break; + case DD_CLASS_TYPE_LEVEL_NUM: + /* input is bitpos, of highest verbosity to be enabled */ + if (inrep > map->length) { + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", + KP_NAME(kp), inrep, map->length); + inrep = map->length; + } + old_bits = CLASSMAP_BITMASK(*dcp->lvl); + new_bits = CLASSMAP_BITMASK(inrep); + v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); + totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + *dcp->lvl = inrep; + break; + default: + pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + } + vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg_classes); + +/** + * param_get_dyndbg_classes - classes reader + * @buffer: string description of controlled bits -> classes + * @kp: kp->arg has state: bits, map + * + * Reads last written state, underlying prdbg state may have been + * altered by direct >control. Displays 0x for DISJOINT, 0-N for + * LEVEL Returns: #chars written or <0 on error + */ +int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) +{ + const struct ddebug_class_param *dcp = kp->arg; + const struct ddebug_class_map *map = dcp->map; + + switch (map->map_type) { + + case DD_CLASS_TYPE_DISJOINT_NAMES: + case DD_CLASS_TYPE_DISJOINT_BITS: + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); + + case DD_CLASS_TYPE_LEVEL_NAMES: + case DD_CLASS_TYPE_LEVEL_NUM: + return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); + default: + return -1; + } +} +EXPORT_SYMBOL(param_get_dyndbg_classes); + +const struct kernel_param_ops param_ops_dyndbg_classes = { + .set = param_set_dyndbg_classes, + .get = param_get_dyndbg_classes, +}; +EXPORT_SYMBOL(param_ops_dyndbg_classes); + #define PREFIX_SIZE 64 static int remaining(int wrote) @@ -1037,13 +1249,11 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, dt->ddebugs = di->descs; dt->num_ddebugs = di->num_descs; - INIT_LIST_HEAD(&dt->link); - INIT_LIST_HEAD(&dt->link); INIT_LIST_HEAD(&dt->maps); - if (classes && num_classes) - ddebug_attach_module_classes(dt, classes, num_classes); + if (di->classes && di->num_classes) + ddebug_attach_module_classes(dt, di->classes, di->num_classes); mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); From patchwork Fri Aug 5 21:53:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937745 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AB05C00140 for ; Fri, 5 Aug 2022 21:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241600AbiHEV4P (ORCPT ); Fri, 5 Aug 2022 17:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241597AbiHEVzQ (ORCPT ); Fri, 5 Aug 2022 17:55:16 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 959ABF5B0; Fri, 5 Aug 2022 14:54:44 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id l9so1989797ilq.1; Fri, 05 Aug 2022 14:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1y159ZhAT7UwYDHx836NbKz/sH4FGDT0eWA3LtOPK28=; b=aZpGJUfkVtvgVQOcA2F7tAMS9ukLmpQUh3ljHkf8mdLln5qcpZB9sw8JktDUOZUfin xLOZQjWOpSuON3eyAeAu0CbF/36kkedJfxlVb8EilpP8NgwuOHRUROHCZ53wKAtwcHW8 Jeh/gyh1fxpZRMsteWVDc3LGjglz0Koq17XZfoMIqYlbNNK6YVVpFJPTcabGrF+zUxOl 3nDrv09wEZVtUo5DXADv4GIftR4TjYij61T53L1CgmlxQ6y0DTdbSvu7fQFGEmt/3xqZ sWUWbDNbwEpc/QRQVCatjqHnf92fBh0/OP4rLiZSj5g5A76MlyvGpiP8ydfP9zWcgESr ZWSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=1y159ZhAT7UwYDHx836NbKz/sH4FGDT0eWA3LtOPK28=; b=7EPcPM4z+2I+VFhmPB9czF6YB7TTZeOYUtBR6FQ0XGZExrmUdhrqO7hNCxQaPpX2Ek aJkBR62iv/lw2pnRpmApFFPrP5frnYL0GYWl7y5HyRSStjYjt4JVuufzSxTsjLOkQzMp /DBxLak6PKco9kSoCLhFNhMGa/gVJL5gFxDQ0J0gbrLukH2mLRIfn58hFAfq/jcCqqWX MbcPpIlKStSNzI17PdI+qAmktnKpVGGZP9lDYnLSC3dQqsDZXXIEvAelJTuu6V3QK6tt III7EM+X3kC+kW0YsxBUr+YyG1hVxKTijvqYgIVlojUmD5frSjcyrACG181qIDiPxUxA PTWw== X-Gm-Message-State: ACgBeo2pe9sEmSwhHX0XbMwpgD6xDaJAxFbkIgbRRRUL2/ry5JwVigSe Rh1G7KncxQHxlXssccLakdMYFBkoIXqbNQ== X-Google-Smtp-Source: AA6agR7d9MaevNi+wYrhfwwaCK505X33v/tWLIHGXSbOGLIz9cTvnFOlWaEafAqO2toexMXLdgER5Q== X-Received: by 2002:a05:6e02:194d:b0:2df:8893:90bb with SMTP id x13-20020a056e02194d00b002df889390bbmr2260522ilu.242.1659736483850; Fri, 05 Aug 2022 14:54:43 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:43 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 21/33] dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes Date: Fri, 5 Aug 2022 15:53:43 -0600 Message-Id: <20220805215355.3509287-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Demonstrate use of DECLARE_DYNDBG_CLASSMAP macro, and expose them as sysfs-nodes for testing. For each of the 4 class-map-types: - declare a class-map of that type, - declare the enum corresponding to those class-names - share _base across 0..30 range - add a __pr_debug_cls() call for each class-name - declare 2 sysnodes for each class-map for 'p' flag, and future 'T' flag These declarations create the following sysfs parameter interface: :#> pwd /sys/module/test_dynamic_debug/parameters :#> ls T_disjoint_bits T_disjoint_names T_level_names T_level_num do_prints p_disjoint_bits p_disjoint_names p_level_names p_level_num NOTES: The local wrapper macro is an api candidate, but there are already too many parameters. OTOH, maybe related enum should be in there too, since it has _base inter-dependencies. The T_* params control the (future) T flag on the same class'd pr_debug callsites as their p* counterparts. Using them will fail, until the dyndbg-trace patches are added in. :#> echo 1 > T_disjoint [ 28.792489] dyndbg: disjoint: 0x1 > test_dynamic_debug.T_D2 [ 28.793848] dyndbg: query 0: "class D2_CORE +T" mod:* [ 28.795086] dyndbg: split into words: "class" "D2_CORE" "+T" [ 28.796467] dyndbg: op='+' [ 28.797148] dyndbg: unknown flag 'T' [ 28.798021] dyndbg: flags parse failed [ 28.798947] dyndbg: processed 1 queries, with 0 matches, 1 errs [ 28.800378] dyndbg: bit_0: -22 matches on class: D2_CORE -> 0x1 [ 28.801959] dyndbg: test_dynamic_debug.T_D2: updated 0x0 -> 0x1 [ 28.803974] dyndbg: total matches: -22 Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 125 ++++++++++++++++++++++++++++++++++----- 1 file changed, 110 insertions(+), 15 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index ba3882ca3e48..8dd250ad022b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -10,57 +10,152 @@ #include -static void do_prints(void); /* device under test */ - -/* run tests by reading or writing sysfs node */ +/* run tests by reading or writing sysfs node: do_prints */ +static void do_prints(void); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_param *kp) { do_prints(); return 0; } - static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { do_prints(); return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); } - static const struct kernel_param_ops param_ops_do_prints = { .set = param_set_do_prints, .get = param_get_do_prints, }; - module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); -static void do_alpha(void) +/* + * Using the CLASSMAP api: + * - classmaps must have corresponding enum + * - enum symbols must match/correlate with class-name strings in the map. + * - base must equal enum's 1st value + * - multiple maps must set their base to share the 0-30 class_id space !! + * (build-bug-on tips welcome) + * Additionally, here: + * - tie together sysname, mapname, bitsname, flagsname + */ +#define DD_SYS_WRAP(_model, _flags) \ + static unsigned long bits_##_model; \ + static struct ddebug_class_param _flags##_model = { \ + .bits = &bits_##_model, \ + .flags = #_flags, \ + .map = &map_##_model, \ + }; \ + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_model, 0600) + +/* numeric input, independent bits */ +enum cat_disjoint_bits { + D2_CORE = 0, + D2_DRIVER, + D2_KMS, + D2_PRIME, + D2_ATOMIC, + D2_VBL, + D2_STATE, + D2_LEASE, + D2_DP, + D2_DRMRES }; +DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); +DD_SYS_WRAP(disjoint_bits, p); +DD_SYS_WRAP(disjoint_bits, T); + +/* symbolic input, independent bits */ +enum cat_disjoint_names { LOW = 11, MID, HI }; +DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10, + "LOW", "MID", "HI"); +DD_SYS_WRAP(disjoint_names, p); +DD_SYS_WRAP(disjoint_names, T); + +/* numeric verbosity, V2 > V1 related */ +enum cat_level_num { V0 = 14, V1, V2, V3, V4, V5, V6, V7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, + "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); +DD_SYS_WRAP(level_num, p); +DD_SYS_WRAP(level_num, T); + +/* symbolic verbosity */ +enum cat_level_names { L0 = 22, L1, L2, L3, L4, L5, L6, L7 }; +DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, + "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); +DD_SYS_WRAP(level_names, p); +DD_SYS_WRAP(level_names, T); + +/* stand-in for all pr_debug etc */ +#define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") + +static void do_cats(void) { - pr_debug("do alpha\n"); + pr_debug("doing categories\n"); + + prdbg(LOW); + prdbg(MID); + prdbg(HI); + + prdbg(D2_CORE); + prdbg(D2_DRIVER); + prdbg(D2_KMS); + prdbg(D2_PRIME); + prdbg(D2_ATOMIC); + prdbg(D2_VBL); + prdbg(D2_STATE); + prdbg(D2_LEASE); + prdbg(D2_DP); + prdbg(D2_DRMRES); } -static void do_beta(void) + +static void do_levels(void) { - pr_debug("do beta\n"); + pr_debug("doing levels\n"); + + prdbg(V1); + prdbg(V2); + prdbg(V3); + prdbg(V4); + prdbg(V5); + prdbg(V6); + prdbg(V7); + + prdbg(L1); + prdbg(L2); + prdbg(L3); + prdbg(L4); + prdbg(L5); + prdbg(L6); + prdbg(L7); } static void do_prints(void) { - do_alpha(); - do_beta(); + do_cats(); + do_levels(); } static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); - pr_debug("init done\n"); return 0; } static void __exit test_dynamic_debug_exit(void) { - pr_debug("exiting\n"); + pr_debug("exited\n"); } module_init(test_dynamic_debug_init); From patchwork Fri Aug 5 21:53:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937757 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00EF1C3F6B0 for ; Fri, 5 Aug 2022 21:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241758AbiHEV4c (ORCPT ); Fri, 5 Aug 2022 17:56:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241668AbiHEVzS (ORCPT ); Fri, 5 Aug 2022 17:55:18 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC95C7CB59; Fri, 5 Aug 2022 14:54:45 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id j20so1975557ila.6; Fri, 05 Aug 2022 14:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1+1UJim8vhT48B81Hjf2bc/Sa3YkiMXKvAKc0hA3YOs=; b=CrJgpQHbDBJ7RwTZKwsK2nXYyHhQp0KotTfA/P+uE/DFkz59bW5r74wG1/yBHFM/fk lcds8RusyQGP77GIRAOgM2dvk6VIWnIniw1zZsRFshKADGXYoCQpm/0hO/TPURqFaPeK +ib27KVmxXzoxn2ixUeAZuxrc6hFjetet7Tq1/5tjEgeaTMsI0liK2hjo37AIx2SbU/9 jwOEM5cmIGQwU+kEydBQxTnP2E27ovG3zbqjY9AtirFFHHnNPEV3ajSSBDPoNWfEuBGy xnO8SRMMDG9CUNKvM6SXEhBXSsqjloGSEULNWC/P+dWD2UwRk2ywIDuekd2gTdrsHipJ K7PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=1+1UJim8vhT48B81Hjf2bc/Sa3YkiMXKvAKc0hA3YOs=; b=IuqXkBQmrmb0IYBNwOJSRQZ/hkXtfklUQw3isoFpilMfQojGx2TveIFG7ZkucJ/9m5 9JCf4p+vGNZGzqZJ+pnikuZLuV+LbQ2y6xd+G8jmqefL8u6KkFSfSDHOguzlOflghcQB TzwGq1hvAOTXbDiH4dB4pL0+JSvZeelxNErMC5v4jesn1DKnbZGODgaat8K+tqovF36a U0ZaNeTrGXrluBFV0ie3itPHSDSmvXfrgadnmJKQSH+XTTwKlpOzlr0nWKwTrcvHDonF 4yhnsk8P5+y4HarTUzGY+ChrXSTX5afp/+K6kdAA72w+/rDjblqgZyqMGNUMRhaQ1xVM vaxQ== X-Gm-Message-State: ACgBeo3jmqZPpPO7JuiiBV4vMYSKbp+0xrj4SdCmt/whJXq5PRTxbMtE VJxsM6b9VSx2IBva3IZMZzbV6tQsPlnWqw== X-Google-Smtp-Source: AA6agR5abo0JydvBW85i/jxSa7Y77IIU9fCsUQEULS/JdZFW7H1qpJFVh6RC7t0e+zg9wp+RncUlNw== X-Received: by 2002:a05:6e02:17c7:b0:2de:ae1d:35a6 with SMTP id z7-20020a056e0217c700b002deae1d35a6mr3837745ilu.123.1659736484992; Fri, 05 Aug 2022 14:54:44 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:44 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 22/33] drm_print: condense enum drm_debug_category Date: Fri, 5 Aug 2022 15:53:44 -0600 Message-Id: <20220805215355.3509287-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 22fabdeed297..b3b470440e46 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -279,49 +279,49 @@ enum drm_debug_category { * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... */ - DRM_UT_CORE = 0x01, + DRM_UT_CORE, /** * @DRM_UT_DRIVER: Used in the vendor specific part of the driver: i915, * radeon, ... macro. */ - DRM_UT_DRIVER = 0x02, + DRM_UT_DRIVER, /** * @DRM_UT_KMS: Used in the modesetting code. */ - DRM_UT_KMS = 0x04, + DRM_UT_KMS, /** * @DRM_UT_PRIME: Used in the prime code. */ - DRM_UT_PRIME = 0x08, + DRM_UT_PRIME, /** * @DRM_UT_ATOMIC: Used in the atomic code. */ - DRM_UT_ATOMIC = 0x10, + DRM_UT_ATOMIC, /** * @DRM_UT_VBL: Used for verbose debug message in the vblank code. */ - DRM_UT_VBL = 0x20, + DRM_UT_VBL, /** * @DRM_UT_STATE: Used for verbose atomic state debugging. */ - DRM_UT_STATE = 0x40, + DRM_UT_STATE, /** * @DRM_UT_LEASE: Used in the lease code. */ - DRM_UT_LEASE = 0x80, + DRM_UT_LEASE, /** * @DRM_UT_DP: Used in the DP code. */ - DRM_UT_DP = 0x100, + DRM_UT_DP, /** * @DRM_UT_DRMRES: Used in the drm managed resources code. */ - DRM_UT_DRMRES = 0x200, + DRM_UT_DRMRES }; static inline bool drm_debug_enabled(enum drm_debug_category category) { - return unlikely(__drm_debug & category); + return unlikely(__drm_debug & BIT(category)); } /* From patchwork Fri Aug 5 21:53:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937746 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30CC6C25B0E for ; Fri, 5 Aug 2022 21:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241631AbiHEV4R (ORCPT ); Fri, 5 Aug 2022 17:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241682AbiHEVzX (ORCPT ); Fri, 5 Aug 2022 17:55:23 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE0F7CB63; Fri, 5 Aug 2022 14:54:46 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id i84so2859189ioa.6; Fri, 05 Aug 2022 14:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FQJy/qqiHCmQdlu6SuRvhMe2mrD0HZVzRMvbpkNsB1E=; b=iuJH0wiwQoEaVb7Q4AsbaXqrAdwbfLpY7Hd9G18N/D5aRcX2PoXlE3UFJD+W+H2ZMB rQymIZ3LQqQeKx5stXS0volPtU33rOT7Kb9zsMriymly9fMyunhvggXaLkMjB6ESgqSA Wg7ifyTvyl9vejD+Mrd1YUPag1ez7FVTlBVRMrOgY0CTEasmAF0GccKZc5JPGTVdsdMr aAweZkQgjMukigdvdxAft4QIm3wEy67eGD1Na9ethHqNRQ8BuGYVl92T4GbqSe30v+m8 CaclzAeIk9zyTFYjbP9l5N8r8leNLUSB2tkP+5R+idmzzo9WN/yVK+PL4XV9nPYD5KIb Y9AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FQJy/qqiHCmQdlu6SuRvhMe2mrD0HZVzRMvbpkNsB1E=; b=zfaC8YeTRrf2KzrHhKUnu846Esz1W5mUyQgo5t48SkP3THm/U69GVe5DD6bKq4XSxY zX1aKQXwsYZDDHr96q3rYkBOGqSPBmsecQZ23omxZtUSPyqHqaU4LtNkhuC6uW/e+jZz IWav6MlU8S/BfAXAfbq8MEjcjhxpeuRaZOsk7zeQ4aNDvtkB8KHNiACNvJ7xF4w5/oKz RRoHxiN8dMfxO9BraDFl6hrJNyQQwkf6YW338Y8CJnu7AZqwwP7iQIcDURpw9+Fd0yXe A3ui84rEF5LxoJPJ0vpJSt1CilsiynzsUwYLxHpjdIskgUhgUDj0LDeDlhdTmo8k7brU 5wUg== X-Gm-Message-State: ACgBeo0Bjkqm7LDaAljQZcJnpbo6Bp3No/8ZkHFTZvL6ZJWeqCz6XtUN 2RubY6C/6Vx7QnLyzBZh/YEBnTBI50ZHMA== X-Google-Smtp-Source: AA6agR5ooln/tZisTOQEwRc7LPeig3F+oRl83SDL8XD6ix5y7hIK0M+b/wzOqjz3pSoFmgBeGC2E1Q== X-Received: by 2002:a05:6602:2d4f:b0:67b:f7c9:a3e with SMTP id d15-20020a0566022d4f00b0067bf7c90a3emr3543396iow.77.1659736486070; Fri, 05 Aug 2022 14:54:46 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:45 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 23/33] drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers. Date: Fri, 5 Aug 2022 15:53:45 -0600 Message-Id: <20220805215355.3509287-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use DECLARE_DYNDBG_CLASSMAP across DRM: - in .c files, since macro defines/initializes a record - in drivers, $mod_{drv,drm,param}.c ie where param setup is done, since a classmap is param related - in drm/drm_print.c since existing __drm_debug param is defined there, and we ifdef it, and provide an elaborated alternative. - in drm_*_helper modules: dp/drm_dp - 1st item in makefile target drivers/gpu/drm/drm_crtc_helper.c - random pick iirc. Since these modules all use identical CLASSMAP declarations (ie: names and .class_id's) they will all respond together to "class DRM_UT_*" query-commands: :#> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: This changes __drm_debug from int to ulong, so BIT() is usable on it. DRM's enum drm_debug_category values need to sync with the index of their respective class-names here. Then .class_id == category, and dyndbg's class FOO mechanisms will enable drm_dbg(DRM_UT_KMS, ...). Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie a different NAME => class_id mapping), changes are made according to each module's private class-map. No callsites are actually selected by this patch, since none are class'd yet. Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++ drivers/gpu/drm/display/drm_dp_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_crtc_helper.c | 13 ++++++++++++ drivers/gpu/drm/drm_print.c | 27 +++++++++++++++++++++++-- drivers/gpu/drm/i915/i915_params.c | 12 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 13 ++++++++++++ include/drm/drm_print.h | 3 ++- 7 files changed, 92 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 8890300766a5..183d604559fe 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "amdgpu.h" #include "amdgpu_irq.h" @@ -183,6 +185,18 @@ int amdgpu_vcnfw_log; static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + struct amdgpu_mgpu_info mgpu_info = { .mutex = __MUTEX_INITIALIZER(mgpu_info.mutex), .delayed_reset_work = __DELAYED_WORK_INITIALIZER( diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index e7c22c2ca90c..c8a4076aa4ab 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,18 @@ #include "drm_dp_helper_internal.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + struct dp_aux_backlight { struct backlight_device *base; struct drm_dp_aux *aux; diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index b632825654a9..73e16fc0659f 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,18 @@ #include "drm_crtc_helper_internal.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + /** * DOC: overview * diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..ec32df35a3e3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -40,7 +40,7 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned int __drm_debug; +unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" @@ -52,7 +52,30 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -module_param_named(debug, __drm_debug, int, 0600); + +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +module_param_named(debug, __drm_debug, ulong, 0600); +#else +/* classnames must match vals of enum drm_debug_category */ +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + +static struct ddebug_class_param drm_debug_bitmap = { + .bits = &__drm_debug, + .flags = "p", + .map = &drm_debug_classes, +}; +module_param_cb(debug, ¶m_ops_dyndbg_classes, &drm_debug_bitmap, 0600); +#endif void __drm_puts_coredump(struct drm_printer *p, const char *str) { diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 701fbc98afa0..aa4e43b59daa 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -29,6 +29,18 @@ #include "i915_params.h" #include "i915_drv.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + #define i915_param_named(name, T, perm, desc) \ module_param_named(name, i915_modparams.name, T, perm); \ MODULE_PARM_DESC(name, desc) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 561309d447e0..fd99ec0f4257 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,18 @@ #include "nouveau_svm.h" #include "nouveau_dmem.h" +DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, + "DRM_UT_CORE", + "DRM_UT_DRIVER", + "DRM_UT_KMS", + "DRM_UT_PRIME", + "DRM_UT_ATOMIC", + "DRM_UT_VBL", + "DRM_UT_STATE", + "DRM_UT_LEASE", + "DRM_UT_DP", + "DRM_UT_DRMRES"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b3b470440e46..668273e36c2c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -35,7 +35,7 @@ #include /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; /** * DOC: print @@ -275,6 +275,7 @@ static inline struct drm_printer drm_err_printer(const char *prefix) * */ enum drm_debug_category { + /* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ... From patchwork Fri Aug 5 21:53:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937758 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA234C25B0C for ; Fri, 5 Aug 2022 21:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241763AbiHEV4d (ORCPT ); Fri, 5 Aug 2022 17:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241747AbiHEVzZ (ORCPT ); Fri, 5 Aug 2022 17:55:25 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0569D7CB6B; Fri, 5 Aug 2022 14:54:48 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id q124so2870199iod.3; Fri, 05 Aug 2022 14:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FP6JoOpcsPiu1BPTclm5wHedSoKs2JtHZ6xsyHOlop8=; b=N1R/s7ivLp2/sPuzJIiO6Ks8HehwdRFJkr6Ix3xbni0a4RyJKladqIy4RI8srW9uLk v4KvtBuxNNylYoh2PtZuFOgg4f4Pekwan09tnlfSzSYfh1XRXqNPFmr10gJ4zsCcSJ6J LkLEoiNQmZ22iMR4yqw+rvCVwPxf2QbNL13GPea2bhYURNf3ALZ4uoDkh9qEKi+Cy/r6 Bqeua0HX7Fci9T3OnCo8Z17BcUlJVtrvRMnEuyfdqh5QeTORmdGWNDQrXknPUIYQ+bMc Cn+Mv0NjSC5763lvRbvr8YyYbNUt045OmK9+vY9oGIlb/+Aqe1JVyZFrjokzVYbFBzPP eH5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FP6JoOpcsPiu1BPTclm5wHedSoKs2JtHZ6xsyHOlop8=; b=h3KsfKgRFsyXooly7fZm0yjJZ/Bb3ZX7C9tod5TorHf2gssQnU14ibPoxrGNibrMQq KU7xzq8fThipG5WKcXXIFrrKjgizXd6P6GYmQ3PPB6pRoiTB2VQpLtTmwPSbc/Ew95lX YBn4qMg2dNlpzTXGZ3ciK2SDNQZiGUNWfjJMzOlh81q+PWZ/Tl38DDIt3YsCJz4pLSSU UCYi+x13A/prpgXlVLRifh93D7rOSfn/TWVP4bEAVdtUFJDEbME6hDTcy/gSbX9KN5ji Bonut33plQy/Yo5u84uubKW2l+sK+4uDJubTsIyWlYpJi/7/LfdbH5bpVuDuXjTMu9Rp 4EqQ== X-Gm-Message-State: ACgBeo226gp5jG945dD3lUZY6rsCaajQKSgmKZiNStYRR2mYRjgyK4UY NJczH8ZudNxnLDprOdrXoRdlnCG/K8rJpw== X-Google-Smtp-Source: AA6agR5c6sa3U4liyEUp27w1FLX//O1mPzIN5ouIQsElkrkNBQ9yLhyTyifLFyGhFGt6wUDWEt6vTA== X-Received: by 2002:a05:6638:2642:b0:33f:5172:e77 with SMTP id n2-20020a056638264200b0033f51720e77mr3882670jat.85.1659736487238; Fri, 05 Aug 2022 14:54:47 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:46 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 24/33] drm_print: interpose drm_*dbg with forwarding macros Date: Fri, 5 Aug 2022 15:53:46 -0600 Message-Id: <20220805215355.3509287-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 ec32df35a3e3..29a29949ad0b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -279,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...) { struct va_format vaf; va_list args; @@ -301,9 +301,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -320,7 +320,7 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...) va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); void __drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 668273e36c2c..c429c258c957 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -335,7 +335,7 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, const char *format, ...); /** @@ -384,6 +384,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +#define drm_dev_dbg(dev, cat, fmt, ...) \ + __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -485,10 +488,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, */ __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); +#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) + /* Macros to make printk easier */ #define _DRM_PRINTK(once, level, fmt, ...) \ From patchwork Fri Aug 5 21:53:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937750 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EA85C3F6B0 for ; Fri, 5 Aug 2022 21:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241699AbiHEV4U (ORCPT ); Fri, 5 Aug 2022 17:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241756AbiHEVz2 (ORCPT ); Fri, 5 Aug 2022 17:55:28 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5AA37D1C0; Fri, 5 Aug 2022 14:54:49 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id p9so733213ilq.13; Fri, 05 Aug 2022 14:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=3tbZW5AZ3qCYXKZY6ptPQPN9S/gJryWQ8OuOuJSIseY=; b=HSidcAC7ZBSc6H0xNsI07BBvYDK3jCEFmzWgVvTmOf319ZAbeM6hupFZ7v47Ud9Qax WUG8yvkCTkgrFsBuNROGNE4uJLCqZnTB73IK95hXcE9GAH27+XbGRDxz2bRULFTstPrz ncl/V8+Yc2yw5yNNns3gA1apDM9uuxonhd6NWi5WbY9VPwBXGvOZ5etoKaZbhLQt2doR 8GHXu6PdcsSrMDjk2zKHN9FtP5daSF2osFFk9mwrh3E4VxJYqzC3bGaaOpncBJS+R4Vj f9zKFUxjayQ5SzwjAfnfXhfrqTQYps9XYp8ChHOpmEJqpbL+XU7fay0WR4NpuS2+8c9y hC/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3tbZW5AZ3qCYXKZY6ptPQPN9S/gJryWQ8OuOuJSIseY=; b=oM74yb8TjFAZWVduol3z6aVcvtnD0iBKtcy7Uy4KOLxuu2uwPCXM/f2vbJn9jtOWVs aJoaOYkj/wyVT2soCAQWyy8xoJtmhdSniaXZLan2zD9JkKP/jHp3Ugw3dCWT8mdl58ko dVrpr72O1UTjFaASAWNove+WX0f6XxoyukpFdxoOetaz4QBLUveRGBh69PAbWGFLGOjQ Zq9pCd/RKDGpc8uRaWiE4S9iN6NyJLXUIbweW6Ylq+LbiYqgeXMBRYxOsgXtYwxjajtz ZEvoPoEIkBMI1NgX7J5bNImvMWFfPYU0ukartWOogh2p9lLhfLzDba49yWVECo+EON3x YQvQ== X-Gm-Message-State: ACgBeo0Jb1errL6ODx43qdv5Izo6Fy9fg196ar3rr5+J2etWsWQkNyma r6Y90W53X1anUbiz2xKE1mt7E4QdKqCWJw== X-Google-Smtp-Source: AA6agR5cHAE8oWSlbUKwhrg8/SIN3a5mrS2a1f0NVOEh2eERBBJ2oKVz1OdX10qBwoc3V7q3mBNzEg== X-Received: by 2002:a05:6e02:160a:b0:2df:6df5:23eb with SMTP id t10-20020a056e02160a00b002df6df523ebmr3433261ilu.280.1659736488544; Fri, 05 Aug 2022 14:54:48 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:48 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 25/33] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Date: Fri, 5 Aug 2022 15:53:47 -0600 Message-Id: <20220805215355.3509287-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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(). This adds the callsite descriptor into the code, and an entry for each into /proc/dynamic_debug/control. #> echo class DRM_UT_ATOMIC +p > /proc/dynamic_debug/control CONFIG_DRM_USE_DYNAMIC_DEBUG=y/n is configurable because of the .data footprint cost of per-callsite control; 56 bytes/site * ~2k for i915, ~4k callsites for amdgpu. This is large enough that a kernel builder might not want it. Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 12 ++++++++++++ drivers/gpu/drm/Makefile | 2 ++ include/drm/drm_print.h | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index f65656df3619..aad2ac5641c1 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -50,6 +50,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 15fe3163f822..272de137d207 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -3,6 +3,8 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. +CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE + drm-y := drm_aperture.o drm_auth.o drm_cache.o \ drm_file.o drm_gem.o drm_ioctl.o \ drm_drv.o \ diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index c429c258c957..2d2cef76b5c1 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -384,8 +384,14 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, cat, fmt, ...) \ __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) +#else +#define drm_dev_dbg(dev, cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) +#endif /** * DRM_DEV_DEBUG() - Debug output for generic drm code @@ -492,7 +498,13 @@ void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#else +#define __drm_dbg(cat, fmt, ...) \ + _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) +#endif /* Macros to make printk easier */ From patchwork Fri Aug 5 21:53:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937753 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACF54C19F2D for ; Fri, 5 Aug 2022 21:56:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241718AbiHEV4Z (ORCPT ); Fri, 5 Aug 2022 17:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241772AbiHEVzb (ORCPT ); Fri, 5 Aug 2022 17:55:31 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9B011811; Fri, 5 Aug 2022 14:54:50 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id v185so2831944ioe.11; Fri, 05 Aug 2022 14:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=38b4ptDDIvz2ddGSj5VKmEi/zh+RmsO1/UedvwI7WxU=; b=DtJrrTM0KeU+8b/viLC94jltyJcFE60mrEuVXYQV1o++JUn4Ob+xUZE0y5y7tVW3cB CbDi305LuxsU/K6tMe6B4AeLFT8aZhIvbuOGpEQYwmHa/VPMdPh+0b1Mmb7tbhnslq2l NxbSbsWCdcYZG9PT7jg9bgZ8gupfdCfvM49RioZ+yd/sGMGxWUK+ug9RkciRZFCt2An8 nOBJMTq5Phw0oEkmUR/XOzwHkyWv89v62jV+rD7vQ7c/UgmiJofYtxToWqYxXFTyquF/ 59XiNq51Cf8UJiRb8IVQTDeiThvAFqbOJIrBr/oIN+HTOE6f39AVY64wFDRW8WffWdoh uEjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=38b4ptDDIvz2ddGSj5VKmEi/zh+RmsO1/UedvwI7WxU=; b=S2ULAqfHGagxqI5inzhMTZLmR6o8rXNodl1k4GVKZLBsAYBSVGisHBmeObqiDupP2f jDwHjHU2kF2rA9axpnnVGKs1gSBwvqQ7bkBpX/7nPC1xhBTa02dc3BDY22IGDaJSdD8G SO7CKsIkmAYFdfmmQuXKT2Jm2t8+I00g+WAPOhgwBUTKVt+p5e7T9GnhExPb3wc48Ylq P+Cjn6S/UnfW6AuN54h0wReC47x4+T5KWbffOQU9mp1T4LdQFjEI0cJKgG749MBSjY0b yinMzHMjDAPJ63JSAsdivAK/10RaLJ/zBN/+jAm2Tv7bmUNMoPW80wIzLgsMmfiKOldG /nIA== X-Gm-Message-State: ACgBeo1vSl6HHZb65gMaGMHn200pKwtU3rFO1FV1hr4XGX6TBqfM/uaM u/NY84gSQRvmg/7npTqLFdbFhIfIfqR45A== X-Google-Smtp-Source: AA6agR621XKXrLQiWUu1/0axmxkoh81epfEoghE2k1YD0aYPKC9SfRWprmpI0qGAoNtVO0ewMEUPPQ== X-Received: by 2002:a6b:c3c3:0:b0:67f:f487:987e with SMTP id t186-20020a6bc3c3000000b0067ff487987emr3625137iof.0.1659736489639; Fri, 05 Aug 2022 14:54:49 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:49 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 26/33] drm-print.h: include dyndbg header Date: Fri, 5 Aug 2022 15:53:48 -0600 Message-Id: <20220805215355.3509287-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org lkp robot told me: >> drivers/gpu/drm/drm_ioc32.c:989:2: error: call to undeclared function '_dynamic_func_call_cls'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] DRM_DEBUG("comm=\"%s\", pid=%d, dev=0x%lx, auth=%d, %s\n", Since that macro is defined in drm_print.h, and under DRM_USE_DYN*=y configs, invokes dyndbg-factory macros, include dynamic_debug.h from there too, so that those configs have the definitions of all the macros in the callchain. This is done as a separate patch mostly to see how lkp sorts it. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 2d2cef76b5c1..f8bb3e7158c6 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -31,6 +31,7 @@ #include #include #include +#include #include From patchwork Fri Aug 5 21:53:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937752 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9AEFC25B08 for ; Fri, 5 Aug 2022 21:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241715AbiHEV4W (ORCPT ); Fri, 5 Aug 2022 17:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241774AbiHEVzb (ORCPT ); Fri, 5 Aug 2022 17:55:31 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A7F7D1D7; Fri, 5 Aug 2022 14:54:52 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id c185so2857531iof.7; Fri, 05 Aug 2022 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=V3EmUW3uCJhVtlfIw0MXAC6Ylt2LCS6+A+4ZDgY1kTo=; b=ShBrGYIwiJ5Z5UFM4aatUf0XZbdzveqaHYzBMbd00rDzxakjjXMab/x0Q0YHiYMC5s PdQvJ3lkSWbzReG+11eWSG0qdPBf3i3lhEtcnYkfW++CfbyH1OiFePCxGAINrxxSSVGn Gp6W0nSfj5GQfhzkSYmhCOClGsvHRgvDIVz5I9VEINcxbayuH6yrjofEm0TmMkORLGUB HhuaGjdFI8t/lZ5V/9x/H7ZGQoC7FGsnXbpRULy73MmTkOf6MjhGLuVNmKpw0DNGeK+L jD74miLkviGk2LZHs3/D4xolo/pZN3NNYt/DoWJixqqM1WVZfLkt6FLfz6SqEVbrALGd T0QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=V3EmUW3uCJhVtlfIw0MXAC6Ylt2LCS6+A+4ZDgY1kTo=; b=SiKZklQFZc+97Ivd6IzNE6amwargn4GGHbWpkb3ca+npffZbTz1OkN5QPnnLo7+rel ZEKW4tqEfvAhtQuux1QXKaKYj6LDoRQDodPV4pP2lNyKWeezKSLHaZ2tF6y11lr9NRLH o7A4nqgxhmzKs/LAafhcPaPQ7o7Wspk3KTjXFnVVbDukWJwpyMHZYpB/uGH98o3gc9/A 8IpZUqLepbzYdJZpEB9sIHMok64NSJBRzYJ/ZbU+3Pm1+qhsoT4afn+KhY7iV7JIFeLe L/26ijD6O99LLlBgfSH7ni4jeXQuJK2f2QFtXsofJsFpZdPBYWjoPe+ea54M8qAd9W8X i//g== X-Gm-Message-State: ACgBeo3LjQH2cI0ccgj1qSAyR/Sohd75ZQjbYIEbNHoWCtATN4kzubLW 9eVLg8IiwPhEN9e9zSf9leNYniSG2rLhJQ== X-Google-Smtp-Source: AA6agR5vaPMifnt//T6bSjIi//2udEDTd2tRxQPbcvsCKYwI5779ubMpxC1YlLcWEXL4yXw/5ukcsA== X-Received: by 2002:a02:cb47:0:b0:342:8e65:7518 with SMTP id k7-20020a02cb47000000b003428e657518mr3942262jap.242.1659736490879; Fri, 05 Aug 2022 14:54:50 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:50 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 27/33] drm-print: add drm_dbg_driver to improve namespace symmetry Date: Fri, 5 Aug 2022 15:53:49 -0600 Message-Id: <20220805215355.3509287-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org drm_print defines all of these: drm_dbg_{core,kms,prime,atomic,vbl,lease,_dp,_drmres} but not drm_dbg_driver itself, since it was the original drm_dbg. To improve namespace symmetry, change the drm_dbg defn to drm_dbg_driver, and redef grandfathered name to symmetric one. This will help with nouveau, which uses its own stack of macros to construct calls to dev_info, dev_dbg, etc, for which adaptation means drm_dbg_##driver constructs. Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index f8bb3e7158c6..dfdd81c3287c 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -468,7 +468,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_core(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) -#define drm_dbg(drm, fmt, ...) \ +#define drm_dbg_driver(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) @@ -487,6 +487,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) +#define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__) /* * printk based logging From patchwork Fri Aug 5 21:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937751 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D709C00140 for ; Fri, 5 Aug 2022 21:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241714AbiHEV4V (ORCPT ); Fri, 5 Aug 2022 17:56:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241782AbiHEVzh (ORCPT ); Fri, 5 Aug 2022 17:55:37 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158817D1DD; Fri, 5 Aug 2022 14:54:53 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id p82so2865313iod.2; Fri, 05 Aug 2022 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=2ptm0C+TAgay7iDeZMdRBvd/IWOnljmKY3NHUsB11LE=; b=XN3wX4KJsZDlX/MycOJGDI6oN6r8wbmHJB5E4szTDTi/t4qGngJEwX2oEZEzR7Z0Pi pvJapAQwgPtqFmakcn3lcGCaDVe1UYJGmTzDMvrYLrNjdZlf8W+kSGJt3DQ/7d9kWRCT yzDXmBMr6n1LNloRiHqaI9tUWBTJZ3j6TZGkg6ps9rZJKUz+ATmejEaGLuQdtNJS5m5I SBcvhfAllufZZSizfZazMLWLt43fZbv2uKcgLJgPWxSrB5oo0hMsKfFZ6Zac20mFprLQ Ke0APEiVp2sNLHmcN0Tk5GXxxpoW3WRqnpP/umQASxQEN+jJByg2OpUmMHpqRrkgQ0Q3 WgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=2ptm0C+TAgay7iDeZMdRBvd/IWOnljmKY3NHUsB11LE=; b=AFvEYco4gYBw96xxnICzsN/cMvfQSEEAaC5gE62ok6NfSdtx/XBHebeWssvFPPGv78 ffx/hoG8n4i3OWSgPllq7t47CBgjYugNOQdeoWzlx1gMTtUNj3ECSrQW3C5+zl3mgVsu WFM3bxiKv+WKzDNgN55OitlC3kc1/qp3RqiKIXOt3YYa6lbeO1zcy+O9fEecHbDT/2Zw r763MqU1tMfF+xBQEqydUXeWOInpVZSjDFKjRXsoHTUaKGx6INlilVkNML2MPATs6XoW A6l18Ysc/DYlu9zEe90Fd9gXaigyp/pW3gow2OpN53a1s3WPDRu7OP8IuLdbWX2ZyH5P 40rw== X-Gm-Message-State: ACgBeo0chTxvoNZdaqpLfSsT9GgEFGk/u1sHIc4jalyOxVTi0/JcnxEh KPbL/TD8xzDuYAnrPiLgjPpN64OeRuK1qQ== X-Google-Smtp-Source: AA6agR5iMxMPyUfhGJL9gITVCdPNGp9SnJZ3GtjVfFx6SKPwl38f+VGrOLtvj/rgLCMPyC4RHMXj6Q== X-Received: by 2002:a05:6602:29d1:b0:669:428e:8c59 with SMTP id z17-20020a05660229d100b00669428e8c59mr3607080ioq.85.1659736492081; Fri, 05 Aug 2022 14:54:52 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:51 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 28/33] drm_print: refine drm_debug_enabled for jump-label Date: Fri, 5 Aug 2022 15:53:50 -0600 Message-Id: <20220805215355.3509287-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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. For dyndbg builds, debug callsites are selectively "pre-enabled", so __drm_debug_enabled() short-circuits to true there. Remaining callers of 1 may be able to use 2, case by case. 3. is 1st wrapped in a macro, with a pr_debug, which reports each usage in /proc/dynamic_debug/control, making it observable in the logs. The macro lets the pr_debug see the real caller, not an inline function. When plugged into 1, 3 identified ~10 remaining callers of the function, leading to the follow-on cleanup patch, and would allow activating the pr_debugs, estimating the callrate, and the potential savings by using the wrapper macro. It is unused ATM, but it fills out the picture. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 4 ++-- include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 29a29949ad0b..cb203d63b286 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -285,7 +285,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); @@ -308,7 +308,7 @@ void ___drm_dbg(enum drm_debug_category category, const char *format, ...) struct va_format vaf; va_list args; - if (!drm_debug_enabled(category)) + if (!__drm_debug_enabled(category)) return; va_start(args, format); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index dfdd81c3287c..7631b5fb669e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -321,11 +321,39 @@ enum drm_debug_category { DRM_UT_DRMRES }; +/* + * 3 name flavors of drm_debug_enabled: + * drm_debug_enabled - public/legacy, always checks bits + * _drm_debug_enabled - instrumented to observe call-rates, est overheads. + * __drm_debug_enabled - privileged - knows jump-label state, can short-circuit + */ static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & BIT(category)); } +/* + * Wrap fn in macro, so that the pr_debug sees the actual caller, not + * the inline fn. Using this name creates a callsite entry / control + * point in /proc/dynamic_debug/control. + */ +#define _drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + drm_debug_enabled(category); \ + }) + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +/* + * dyndbg is wrapping the drm.debug API, so as to avoid the runtime + * bit-test overheads of drm_debug_enabled() in those api calls. + * In this case, executed callsites are known enabled, so true. + */ +#define __drm_debug_enabled(category) true +#else +#define __drm_debug_enabled(category) drm_debug_enabled(category) +#endif + /* * struct device based logging * From patchwork Fri Aug 5 21:53:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937756 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED630C25B08 for ; Fri, 5 Aug 2022 21:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241751AbiHEV4a (ORCPT ); Fri, 5 Aug 2022 17:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241794AbiHEVzk (ORCPT ); Fri, 5 Aug 2022 17:55:40 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F0D07D1E6; Fri, 5 Aug 2022 14:54:54 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id q124so2870318iod.3; Fri, 05 Aug 2022 14:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MvvZaZyejoehIrFC0H4qDj9uQr4p5E/545dNTtoQgHQ=; b=fmm7BuKL86WTiFUqrM80q8fnvmCCxKQ+yfVo5u5GrNWEh1gPjy0ghMeQvxYOj0gvgN aIsy09O3Dx1evrp6fFuBHhveY8/HgH5P5ppwEDDOTdYgSMFgsvz1dPk7zwDSTd2oyY0J 3l1uXxEurXP9ikBeRlwZKtIzIhdTLmNbK/m9ymG9s44a/U7GLLoNaI0KFPcjTNcV9D1O xVUzqXQ+Mekqzt7vMUSAYC6lgHZkyOrAKirTTJDjeOTGA6dD7l/9LEgQjLDfwVMm+elK 3+uWixDadropzxSApgGocs25a+0Tqzx0o+X+uD12xDBCFI1EeDsPO3XEsF50kl+ysQfp 7Fvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MvvZaZyejoehIrFC0H4qDj9uQr4p5E/545dNTtoQgHQ=; b=JIE6JG/qXY4vmS2iTM2mXW3jEn1nFn3egTeh8wD9IFiS2BJKP7Snt77PCupC/u+uab p5Byf9ndOYEdd4E1Lm23S8oKVrPyIbRG2YbQdlTXJpeWkearBYJuVh8E2mg8Mzi5fT7T zB/FsCDmB+tggboLp1GcSfrKvNtsZJsnxB6AkGkWc4CcS17u0BlhVq84sFZRwqkCFzx/ 3I/bk8F1YUysqzUTYwBwrnTzVqroneIo4U1nl+b1Lj3caEax8BTr7Fqlq+uFIcZx9bkx h7sGYfh7fdqmKuA3GHRJH0b8EXz2nvEXALq4LAdO5VJcoj22eHRfGWtc8ARObCFLhAb9 THJw== X-Gm-Message-State: ACgBeo0FvbGXI1f3jKzQxOWDfmo3EDNrd7oSwpQHZuHHUk6TErnd4GQG 9eEpbQD02otCILwfqCqCHp5pSE5nFPmfxA== X-Google-Smtp-Source: AA6agR4LQNNuWcd+Ya1Hiu/OdFHDikxjmg4O2JeCbTNPgEZO0+Mkpasd1ZrjCNDwbo7G5ke9Mk8F+A== X-Received: by 2002:a05:6638:441a:b0:342:91c9:ccf9 with SMTP id bp26-20020a056638441a00b0034291c9ccf9mr3855766jab.123.1659736493050; Fri, 05 Aug 2022 14:54:53 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:52 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 29/33] drm_print: prefer bare printk KERN_DEBUG on generic fn Date: Fri, 5 Aug 2022 15:53:51 -0600 Message-Id: <20220805215355.3509287-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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. it is soft-wired on currently by #define DEBUG could accidentally: #> echo -p > /proc/dynamic_debug/control 2- optional "decorations" by dyndbg are unhelpful/misleading here, they describe only the generic site, not end users IOW, 1,2 are unhelpful at best, and possibly confusing. reverting yields a nominal data and text shrink: text data bss dec hex filename 462583 36604 54592 553779 87333 /kernel/drivers/gpu/drm/drm.ko 462515 36532 54592 553639 872a7 -dirty/kernel/drivers/gpu/drm/drm.ko Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cb203d63b286..ec477c44a784 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -23,8 +23,6 @@ * Rob Clark */ -#define DEBUG /* for pr_debug() */ - #include #include @@ -185,7 +183,8 @@ EXPORT_SYMBOL(__drm_printfn_info); void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) { - pr_debug("%s %pV", p->prefix, vaf); + /* pr_debug callsite decorations are unhelpful here */ + printk(KERN_DEBUG "%s %pV", p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_debug); From patchwork Fri Aug 5 21:53:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937744 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC23FC25B08 for ; Fri, 5 Aug 2022 21:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241541AbiHEV4O (ORCPT ); Fri, 5 Aug 2022 17:56:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241798AbiHEVzk (ORCPT ); Fri, 5 Aug 2022 17:55:40 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7267D1F5; Fri, 5 Aug 2022 14:54:54 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id z8so680774ile.0; Fri, 05 Aug 2022 14:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=rhstsuI95lREfusErhrTk68nX+Dr7udLDeW32bVJVIQ=; b=XGnW/7bt8k5/WnH1ZJrhaNks82fne43rzLfggY++cfGqGkNO7N04Q6pM/aefcAwSnz bhx4eA4Kg+Rx33oCassystD9UIlUfL307qMl2xJ+/sBlW6jLib81QvUk4p8X2jcWi5XU lcKnIb2onIcPeRmc8TUFn75ty2IegRXoSGHnppJPzqhmfFnGBkQYQqcAmu+SxYtoLTHX TT1doWwOHbOyhvFpX05x+oIN8nynn7nypjQpEsKWAk+R1IRi7GWQmS5Oj+LHbwlz4n2t nFD0FUzGlMoe+5+JX6OVu2P8Fl4n5GfW6B0hlwpadFQzuGl8MVBz3FQOyDpe0B24EHLd oYGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=rhstsuI95lREfusErhrTk68nX+Dr7udLDeW32bVJVIQ=; b=l6YpN24ulrEiE9QUztFc58862Lgu0EP1R18mbbW/OFvu52imOQyLz/hFWRsDdaDiyL ChA8o0kMm4AwJ16ZAvyWVsUP8FpCrWbnjbWYey3n8JU/kKbiS9OCLW8Zv1zt6HpbcEVB ipnbJ5A5A2zrNpZNz1c0mzl4fP1UAAJypIhSGrf0EN+TwDTE0FdfRhHo1Y0G05N2rues bvPN5QmnaFxQx5T/WlDf1Q0OKuZaU0BL//+NVFSmDLCrRp0HsaABNXdHVCXulJviCEY5 hlyvwpgveuAJLdAUdAUy2DpRZCdhPgx40QbGoPNRqUZFmCxxDQIsG7AyQyaCAlWc03vv /kNQ== X-Gm-Message-State: ACgBeo0T0SygIfQulh14g9nFPg0plGbJXYF91AFqFaPu0K5mLKhigyU8 tdIlbMe6zn1HtrZu6B0V16REaKcYmO3vUA== X-Google-Smtp-Source: AA6agR4X7Nq9JKgyjKcqMdMxGSP8stb+bWFZn/5Vd2W4x67FwUhYwsBWRuuqGgUfbUhlier1eqdSow== X-Received: by 2002:a05:6e02:1847:b0:2dd:18c7:51c3 with SMTP id b7-20020a056e02184700b002dd18c751c3mr4127528ilv.29.1659736494120; Fri, 05 Aug 2022 14:54:54 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:53 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 30/33] drm_print: add _ddebug descriptor to drm_*dbg prototypes Date: Fri, 5 Aug 2022 15:53:52 -0600 Message-Id: <20220805215355.3509287-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org upgrade the callchain to drm_dbg() and drm_dev_dbg(); add a struct _ddebug ptr parameter to them, and supply that additional param by replacing the '_no_desc' flavor of dyndbg Factory macro currently used with the flavor that supplies the descriptor. NOTES: The descriptor gives these fns access to the decorator flags, but does none of the dynamic-prefixing done by __dynamic_emit_prefix(). DRM already has conventions for logging/messaging; just tossing optional decorations on top may not help. Instead, existing flags (or new ones) can be used to make current conventions optional. For CONFIG_DRM_USE_DYNAMIC_DEBUG=N, just pass null. Note: desc->class_id is redundant with category parameter, but its availability is dependent on desc. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 8 +++++--- include/drm/drm_print.h | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ec477c44a784..5b93c11895bb 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -278,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -287,6 +288,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, if (!__drm_debug_enabled(category)) return; + /* we know we are printing for either syslog, tracefs, or both */ va_start(args, format); vaf.fmt = format; vaf.va = &args; @@ -302,7 +304,7 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } EXPORT_SYMBOL(__drm_dev_dbg); -void ___drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 7631b5fb669e..46f14cfb401e 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -363,9 +363,10 @@ static inline bool drm_debug_enabled(enum drm_debug_category category) __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); -__printf(3, 4) -void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...); +struct _ddebug; +__printf(4, 5) +void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, + enum drm_debug_category category, const char *format, ...); /** * DRM_DEV_ERROR() - Error output. @@ -415,11 +416,11 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) #define drm_dev_dbg(dev, cat, fmt, ...) \ - __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) + __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__) #else #define drm_dev_dbg(dev, cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ - dev, cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ + dev, cat, fmt, ##__VA_ARGS__) #endif /** @@ -523,17 +524,17 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * Prefer drm_device based logging over device or prink based logging. */ -__printf(2, 3) -void ___drm_dbg(enum drm_debug_category category, const char *format, ...); +__printf(3, 4) +void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) -#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) +#define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) #else #define __drm_dbg(cat, fmt, ...) \ - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ - cat, fmt, ##__VA_ARGS__) + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ + cat, fmt, ##__VA_ARGS__) #endif /* Macros to make printk easier */ From patchwork Fri Aug 5 21:53:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937747 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC63C25B0F for ; Fri, 5 Aug 2022 21:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241665AbiHEV4R (ORCPT ); Fri, 5 Aug 2022 17:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241806AbiHEVzl (ORCPT ); Fri, 5 Aug 2022 17:55:41 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D77A7D788; Fri, 5 Aug 2022 14:54:56 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id c185so2857640iof.7; Fri, 05 Aug 2022 14:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8Di3KlCpKKLc83SvAaF4ufqdssAuqHwTNN+eiKiYlTw=; b=KMSBPxec0CZihP4SWoEQ8H+eUfnM6dpBj0CRtlFtLTYwb4BV0yDmo61reX1hHnGkp7 S3V+E1OgM4UDp2ijXiPwTxvb5x/X23N+NRQsTJ6wrtQ7MF1xar01ugxg8JVIga5vuHtt EQapkyCoIWiVlU55niDWItnMQjycBO/b6kV4CX3GPUz6dMNFnGdTIrsCRJfVm2ybrLdf y/DWjeZpAyibNZrId6OjLyipoBONfLMyXKs18Vmo6ncq7x0wkZa+ZiCDQ3ykC/wUeoKF TQpFfiZuVsEMPNw/DilCduphak4xGdB4GPaVLDIZE0i80vY2GETKEVTfnmfykp92kaMR KQVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=8Di3KlCpKKLc83SvAaF4ufqdssAuqHwTNN+eiKiYlTw=; b=tXSUSQxnTYrWLOjNiE/juQ5pCwdfwdOW9IDvd6eAFYIqOVIJs5BuAGNthHVRw94sqK 9DG1yviuXKPbA/uYzfcygtC840C73WbPiiBKrRqhhfb+I6kxnQ/QNrQ3yAeoV87nVwbr g6lwtsi2lRpF4ijn/6suqFzNGfcUoDgZsrpv7fNnASLIM0h0O1mcuTsRJOSHedG6bL/C VrxUHEyWobraqOFkYw8ByMiJ5Bcsn44ErFMlnfcrotrpF7AkHLDmTH/+KASxechKHSq9 eHYKoZI/AEvWFIaj7XPitlViVsERz19R6fXi+AWlPY330cXZNYIqoZYIF+28HCo0/d3z 0wNA== X-Gm-Message-State: ACgBeo1rbkzTohM1D+3NerAK7G8DzsI8ORiXEYRPxrtU0B5FT66/t1Se FRE7R16fuFo97ZVoIi/tLulKmlC+ltXyPw== X-Google-Smtp-Source: AA6agR4O2kdgTkTSTjS3wkx/1NG+MBZqECClAcHMDs/7cRn6A/ixRnTDTJEjOKioFT/ts6fhOTAU2A== X-Received: by 2002:a05:6638:d45:b0:340:5c58:51f4 with SMTP id d5-20020a0566380d4500b003405c5851f4mr3839718jak.280.1659736495160; Fri, 05 Aug 2022 14:54:55 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:54 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 31/33] nouveau: change nvkm_debug/trace to use dev_dbg POC Date: Fri, 5 Aug 2022 15:53:53 -0600 Message-Id: <20220805215355.3509287-32-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org These 2 macros formerly used dev_info, and they still check subdev->debug to gate the printing. So dyndbg control is redundant ATM (and possibly confusing, since its off by default). prdbg count is up from 3, or from 65 (with VMM_DEBUG here) [ 7.765379] dyndbg: 516 debug prints in module nouveau Its possible to control error, warn, info callsites too, but they're usually on, and the .data overheads on ~450 more callsites (56 bytes each) would just be wasted. $ for l in fatal error warn info debug trace spam; do echo $l; ack nvkm_$l drivers/gpu |wc; done fatal 3 19 335 error 289 1956 30651 warn 84 513 8860 info 14 88 1502 debug 387 2339 40844 trace 31 219 3368 spam 1 7 123 bash-5.1# echo $(( 516-65-387-31-1 )) 32 Thats approximate; not accounting #defines and doc/comment mentions. NOTE: this patch changes the log-level of the macro-issued messages from KERN_INFO to KERN_DEBUG. Adding a .kern_lvl field to struct _ddebug could fix that. RFC: dyndbg & subdev->debug Separate class-maps for each subdev are possible; except for the coordinated use of _base, each is independent, including choice of DISJOINT or LEVELS, as long as class-names don't conflict. So theres some flexibility. Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h index 96113c8bee8c..065d07ccea87 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -59,8 +59,8 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a) +#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) #define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a) From patchwork Fri Aug 5 21:53:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937749 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76D80C25B0E for ; Fri, 5 Aug 2022 21:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241695AbiHEV4T (ORCPT ); Fri, 5 Aug 2022 17:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241810AbiHEVzl (ORCPT ); Fri, 5 Aug 2022 17:55:41 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD257D78D; Fri, 5 Aug 2022 14:54:57 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id p82so2865397iod.2; Fri, 05 Aug 2022 14:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=biCdDG3hgO3jLiBuVTkyAcrTfguva6XGgr+3k3kyQtA=; b=pHnMQq3haUq9GMLZ0ynr5l3syQtI6afCrVEI6lsWXN81GTRcVJy5Cn5+BSQeHOJ4o2 9gZqTfnSpDehgvg/rGF5irUFyjyxfzLmZUR+Eha8hJBP9DuHTmPK6X+ndg4HKd15q1JS sCS+iaTIxAIBXM/d/yqQOcV2Wic1kg1qjTsLdnMCK4uUQ46j9b2c41zHAShKJKRC7/8Q 0/bJav19LeFkkifQi2og+BnCOWIRgDfFEVmcyRgFXmKHggODr+d4k1vSrxLtT5YN9D9D 8xTVooc+6ro8Kz6O+2CSLdhD+hk1I2lefgilIfI61+huZYmAOZXha4ZiAn5QO/KRv+fP Q9dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=biCdDG3hgO3jLiBuVTkyAcrTfguva6XGgr+3k3kyQtA=; b=Q55JDGihTnFpwmHs0wZRuQpim7md60q7eAcN8SaNR/Yf23v1WtcBcSbwV3JfusNxD0 NSyPrDXGIubGMlKw1SbDdSSBWn/v8qbpJx4OuSCYVUKjguZ3HEp1XsK3oOClTvSRvOnX lgsU8oMHXZ/BW32fY4LGe20uqpyf6b6fa+PiFPrfeb005EJOhKvjv7tJKxr64Phe0diZ ST3QsfRl7R6CXQJRD1CSJclnodUtx5DHum8DAvgsT8SbPQgX/CFTcjMwXNqGhB8EOtmI 74E1rPYPbHHbHttFkPU8FalHoLmNPQc7P1oAf5qkqSbifX9qyjTb/Tpw82pNV2OzJZlz 9BHg== X-Gm-Message-State: ACgBeo1nfExEDb2FOFosZwdSwrvlz6Kr9ZfFzNPx9ITNiKMf1n5HzBpt QsQqWJT40TgO8tfOOCtQfrH1Ffyuh/k7lQ== X-Google-Smtp-Source: AA6agR7o9yyEcyXzO2ABPft0K9eQpztTLUpOdyg5+NkeVd4bjtaZXLFgtityexVYW5cT+1534AxQqQ== X-Received: by 2002:a6b:5f03:0:b0:67b:ef4d:e3ed with SMTP id t3-20020a6b5f03000000b0067bef4de3edmr3759281iob.45.1659736496145; Fri, 05 Aug 2022 14:54:56 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:55 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 32/33] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug Date: Fri, 5 Aug 2022 15:53:54 -0600 Message-Id: <20220805215355.3509287-33-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC} respectively, replace those with drm_dbg_##cat invocations. this results in new class'd prdbg callsites: :#> grep nouveau /proc/dynamic_debug/control | grep class | wc 116 1130 15584 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc 74 704 9709 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc 31 307 4237 :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc 11 119 1638 the KMS entries are due to existing uses of drm_dbg_kms(). Signed-off-by: Jim Cromie --- drivers/gpu/drm/nouveau/nouveau_drv.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index b2a970aa9bf4..f266cd6b0405 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -39,6 +39,7 @@ */ #include +#include #include #include @@ -264,13 +265,16 @@ void nouveau_drm_device_remove(struct drm_device *dev); #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a) #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a) -#define NV_DEBUG(drm,f,a...) do { \ - if (drm_debug_enabled(DRM_UT_DRIVER)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ +#define NV_DRMDBG(cat,c,f,a...) do { \ + struct nouveau_cli *_cli = (c); \ + drm_dbg_##cat(_cli->drm->dev, "%s: "f, _cli->name, ##a); \ } while(0) -#define NV_ATOMIC(drm,f,a...) do { \ - if (drm_debug_enabled(DRM_UT_ATOMIC)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ + +#define NV_DEBUG(drm,f,a...) do { \ + NV_DRMDBG(driver, &(drm)->client, f, ##a); \ +} while(0) +#define NV_ATOMIC(drm,f,a...) do { \ + NV_DRMDBG(atomic, &(drm)->client, f, ##a); \ } while(0) #define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a) From patchwork Fri Aug 5 21:53:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937754 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF5D9C25B08 for ; Fri, 5 Aug 2022 21:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241721AbiHEV40 (ORCPT ); Fri, 5 Aug 2022 17:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241824AbiHEVzp (ORCPT ); Fri, 5 Aug 2022 17:55:45 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 868751181A; Fri, 5 Aug 2022 14:54:58 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id s16so1983877ilp.3; Fri, 05 Aug 2022 14:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=mTUAniGKH6fmmV5gDTiJdss5/weYhXTwv9+PDNZ3RQI=; b=S/33lfMSw5q9gypQJIkplRl00GGe67RJ9xa8zCdLhQ0f51/eF5ILkTJXz1xEcGCCKP PFby/Cmf3NBTYgJW6LVwYyZSfP0X/1AWFtllsC4tOCudOX0JQXM3v4JpTNrpNEqj6Ne9 ZeJB0MOUrFC0g5i1hoCbjWgNSHy2m/2h0orKLnqjj6pNxpNFTfcLTT9pdZS/yrAd0W9b ZZWZsPjMmNeJkCrdNY/6LSYtmvqbaiBL/3ahA0IkoMu/5gMtxJcBU6ErfuAs/zNFAy51 GMzU+fGiKPfwpmqz83c4rsCzNcBinBpkwZo0L40634trC5TvFwS/ds9XGXobW185p2h0 6FHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=mTUAniGKH6fmmV5gDTiJdss5/weYhXTwv9+PDNZ3RQI=; b=c1Bbm/sqJC5wCzQShT+ACBOz/W5JXKTUQ4EDg7JtmZD/dTe96JdKkR4MjQW41zY+xk P1Dii29YlucV5TC4GMdRyGzzM7zRPORkpbLR50kYl7LVggSBdrWX4FwvKgw8xOyl0fZ6 FfsQ0208/owiVjyBHzxGLyiLx1207XhIHKXntCMkbSiw2QStui/ubCNo0hyCp31FROWn DCGuj2I2owaC+gHZtvAFr3JRU2DaLXMbeGz+T0QE8qSSKw2PgH/40TRhgmKel6tVTl1E vfL6Bzt7ra6g/I/IVb5iEquLo4y+vMju2MhvHXghNwt20hVgy45p0weLyRgn2SSsrU+H y59Q== X-Gm-Message-State: ACgBeo0Z8VDXQIrz9FOB492/mXGuuVTDakMDhBxA9Me+XzHCgUujBRNY 7d/BfiRXLuR+HBbZVeU76X2+8ETSL/hwRQ== X-Google-Smtp-Source: AA6agR7p8aLV4AMCuCW7/ITwvchFsSHG706nUxBbukte1XKyqNILQgaJYQtx7T13yN+8siYTRtw0iQ== X-Received: by 2002:a05:6e02:1a65:b0:2de:fbaf:ada7 with SMTP id w5-20020a056e021a6500b002defbafada7mr3969694ilv.180.1659736497241; Fri, 05 Aug 2022 14:54:57 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:56 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 33/33] nouveau: WIP add 2 LEVEL_NUM classmaps for CLI, SUBDEV Date: Fri, 5 Aug 2022 15:53:55 -0600 Message-Id: <20220805215355.3509287-34-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org clone the nvkm_printk,_,__ macro ladder into nvkm_drmdbg,_,__. And alter the debug, trace, spam macros to use the renamed ladder. This *sets-up* (not done yet) to remove the _subdev->debug >= (l) condition, once the bitmap-param is wired up correctly, and figured into dyndbg's jump-label enablement. WIP. Then undo the 1-line change that reduced count of prdbgs from 632 to 119. ie: s/NV_SUBDEV_DBG_##l/NV_DBG_##l/ So heres what happened: new symbol is 15 (or 10), and fails this macro test, so gets compiled out, and the dev_dbg is excluded. if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \ I could hack this, by doing (l + base), but base is pretty distant. OTOH, the whole CONFIG_NOUVEAU_DEBUG check could be reworked; given that trace is minumum recommended, theres not that many callsites elided (SPAM only iirc) at compile-time, and dyndbg means keeping them has "zero" run-cost (and 56 bytes per callsite). So this config item doesnt do much when DRM_USE_DYNAMIC_DEBUG=y. So this is a useful place to stop and look around, try to guess which trail to take.. nouveau has additional debug variables to consider: drivers/gpu/drm/nouveau/include/nvkm/core/device.h 131: if (_device->debug >= (l)) \ drivers/gpu/drm/nouveau/include/nvkm/core/client.h 39: if (_client->debug >= NV_DBG_##l) \ drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h 54: if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ This is another baby-step, that seems not to break, so lets get a snapshot. whats done here: In nouveau_drm.c, do DECLARE_DYNDBG_CLASSMAP(LEVEL_NUM type) 2x more, for cli and subdev, right after the drm DECLARE. Adjust base for each, to share the 0..30 classid-space. These declare class-names: NV_CLI_DBG_* NV_SUBDEV_DBG_* accordingly. Note: class-name-space is flat and wide, so super-generic names like INFO should be prefixed; who could predict what a generic V3 does across all modules. s should be included adjusting the base to avoid each other, and the 0-10 already mapped to drm-debug-categorys (just above this addition). In nvkm/core/debug.h, add enums to match the names, with initial values to match the bases. In nvkm/core/subdev.h, alter (recently added) nvkm_drmdbg_() to use NV_SUBDEV_DBG_* instead of NV_DBG_*. NB: in both classmaps, Ive left FATAL..WARN out, they're not really optional the way INFO..SPAM are; dyndbg shouldn't be able to turn them off. bash-5.1# modprobe nouveau [ 966.107833] dyndbg: 3 debug prints in module wmi [ 966.342188] dyndbg: class[0]: module:nouveau base:15 len:5 ty:1 [ 966.342873] dyndbg: 15: 0 NV_SUBDEV_DBG_OFF [ 966.343352] dyndbg: 16: 1 NV_SUBDEV_DBG_INFO [ 966.343912] dyndbg: 17: 2 NV_SUBDEV_DBG_DEBUG [ 966.344443] dyndbg: 18: 3 NV_SUBDEV_DBG_TRACE [ 966.344938] dyndbg: 19: 4 NV_SUBDEV_DBG_SPAM [ 966.345402] dyndbg: class[1]: module:nouveau base:10 len:5 ty:1 [ 966.346011] dyndbg: 10: 0 NV_CLI_DBG_OFF [ 966.346477] dyndbg: 11: 1 NV_CLI_DBG_INFO [ 966.346989] dyndbg: 12: 2 NV_CLI_DBG_DEBUG [ 966.347442] dyndbg: 13: 3 NV_CLI_DBG_TRACE [ 966.347875] dyndbg: 14: 4 NV_CLI_DBG_SPAM [ 966.348284] dyndbg: class[2]: module:nouveau base:0 len:10 ty:0 [ 966.348888] dyndbg: 0: 0 DRM_UT_CORE [ 966.349310] dyndbg: 1: 1 DRM_UT_DRIVER [ 966.349694] dyndbg: 2: 2 DRM_UT_KMS [ 966.350083] dyndbg: 3: 3 DRM_UT_PRIME [ 966.350482] dyndbg: 4: 4 DRM_UT_ATOMIC [ 966.351016] dyndbg: 5: 5 DRM_UT_VBL [ 966.351475] dyndbg: 6: 6 DRM_UT_STATE [ 966.351899] dyndbg: 7: 7 DRM_UT_LEASE [ 966.352309] dyndbg: 8: 8 DRM_UT_DP [ 966.352678] dyndbg: 9: 9 DRM_UT_DRMRES [ 966.353104] dyndbg: module:nouveau attached 3 classes [ 966.353759] dyndbg: 119 debug prints in module nouveau NOTE: it was 632 with previous commit, switching NV_DEBUG to use NV_SUBDEV_DBG_DEBUG instead of NV_DBG_DEBUG may be the cause. Signed-off-by: Jim Cromie --- .../gpu/drm/nouveau/include/nvkm/core/debug.h | 16 +++++++++++++ .../drm/nouveau/include/nvkm/core/subdev.h | 17 ++++++++++---- drivers/gpu/drm/nouveau/nouveau_drm.c | 7 ++++++ drivers/gpu/drm/nouveau/nvkm/core/subdev.c | 23 +++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h index b4a9c7d991ca..6a155a23a3d1 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h @@ -9,4 +9,20 @@ #define NV_DBG_TRACE 5 #define NV_DBG_PARANOIA 6 #define NV_DBG_SPAM 7 + +enum nv_cli_dbg_verbose { + NV_CLI_DBG_OFF = 10, + NV_CLI_DBG_INFO, + NV_CLI_DBG_DEBUG, + NV_CLI_DBG_TRACE, + NV_CLI_DBG_SPAM +}; +enum nv_subdev_dbg_verbose { + NV_SUBDEV_DBG_OFF = 15, + NV_SUBDEV_DBG_INFO, + NV_SUBDEV_DBG_DEBUG, + NV_SUBDEV_DBG_TRACE, + NV_SUBDEV_DBG_SPAM +}; + #endif diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h index 065d07ccea87..ce33c82e5c75 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -2,6 +2,7 @@ #ifndef __NVKM_SUBDEV_H__ #define __NVKM_SUBDEV_H__ #include +#include enum nvkm_subdev_type { #define NVKM_LAYOUT_ONCE(t,s,p,...) t, @@ -18,7 +19,7 @@ struct nvkm_subdev { enum nvkm_subdev_type type; int inst; char name[16]; - u32 debug; + unsigned long debug; struct list_head head; void **pself; @@ -59,9 +60,17 @@ void nvkm_subdev_intr(struct nvkm_subdev *); #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) -#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, dbg, f, ##a) -#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, dbg, f, ##a) -#define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) + +#define nvkm_drmdbg__(s,l,p,f,a...) do { \ + const struct nvkm_subdev *_subdev = (s); \ + if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \ + dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \ +} while(0) +#define nvkm_drmdbg_(s,l,f,a...) nvkm_drmdbg__((s), NV_SUBDEV_DBG_##l, dbg, f, ##a) +#define nvkm_debug(s,f,a...) nvkm_drmdbg_((s), DEBUG, f, ##a) +#define nvkm_trace(s,f,a...) nvkm_drmdbg_((s), TRACE, f, ##a) +#define nvkm_spam(s,f,a...) nvkm_drmdbg_((s), SPAM, f, ##a) #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a) + #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index fd99ec0f4257..864750451dc8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -83,6 +83,13 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, "DRM_UT_DP", "DRM_UT_DRMRES"); +DECLARE_DYNDBG_CLASSMAP(nv_cli_debug_verbose, DD_CLASS_TYPE_LEVEL_NUM, 10, + "NV_CLI_DBG_OFF", + "NV_CLI_DBG_INFO", + "NV_CLI_DBG_DEBUG", + "NV_CLI_DBG_TRACE", + "NV_CLI_DBG_SPAM"); + MODULE_PARM_DESC(config, "option string to pass to driver core"); static char *nouveau_config; module_param_named(config, nouveau_config, charp, 0400); diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c index a74b7acb6832..20cd99cce2a4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c @@ -26,6 +26,27 @@ #include #include +#include +#include + +#define DEBUG + +DECLARE_DYNDBG_CLASSMAP(nv_subdev_debug_verbose, DD_CLASS_TYPE_LEVEL_NAMES, 15, + "NV_SUBDEV_DBG_OFF", + "NV_SUBDEV_DBG_INFO", + "NV_SUBDEV_DBG_DEBUG", + "NV_SUBDEV_DBG_TRACE", + "NV_SUBDEV_DBG_SPAM"); + +static struct ddebug_class_param nv_subdev_verbose = { + .bits = NULL, // wants &_subdev->debug + .flags = "p", + .map = &nv_subdev_debug_verbose, +}; +module_param_cb(debug_subdev, ¶m_ops_dyndbg_classes, &nv_subdev_verbose, 0600); + + + const char * nvkm_subdev_type[NVKM_SUBDEV_NR] = { #define NVKM_LAYOUT_ONCE(type,data,ptr,...) [type] = #ptr, @@ -180,6 +201,8 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func, struct nvkm_device *device else strscpy(subdev->name, nvkm_subdev_type[type], sizeof(subdev->name)); subdev->debug = nvkm_dbgopt(device->dbgopt, subdev->name); + nv_subdev_verbose.bits = &subdev->debug; + pr_debug("updated bitmap: %px\n", &nv_subdev_verbose.bits); list_add_tail(&subdev->head, &device->subdev); }