From nobody Sat Apr 11 10:48:01 2026 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 DDD83C19F2A for ; Thu, 11 Aug 2022 17:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236445AbiHKRgA (ORCPT ); Thu, 11 Aug 2022 13:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236490AbiHKRfz (ORCPT ); Thu, 11 Aug 2022 13:35:55 -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 3EE9B6A48D for ; Thu, 11 Aug 2022 10:35:54 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id o2so15188667iof.8 for ; Thu, 11 Aug 2022 10:35: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=8o46kS926x+QNuy5c4uBrvlsDlM/ABLoibmgwB6shD8=; b=U6UOu+ihAb2JTfwfKtFLGsAM5//yojM/EfxSJg1oSpNRwMmWCAKD6ad6mx1KbfzOOd h13rHKkT0IktAVFiXb4kQEEsnAfleLXx7Vqr9lu2L2KtZOGYWSfiuJ0p/zWOphTUU5WD gtS3fcpge3mmi4Dta/Cjq9P9AgCadxNP2NA+YUdHGeM8aJmHjY20IBOPsiwi/rUVHnug VSLo9v0yu9ca5PCkKK+K5Pxk3Rg8ptP/AA1fACgzgw9JxUUaWjCDJnsUi/txCrzbaKX/ 9sggavFA7EnP63UQGOCSGU0fUuaXdr6s6PvoRd2kj/gxKVcvIhnjBdAWtko4hqD9pN94 KnFA== 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=LAIaKmtn8yWxF2G92B1tF0njUZE3va0mwsn1N52CtnD9uQBH0AGUpguGkjERFhE/gc 8Bk/53px9qa6VI/DMzSQ9UPn9jGe7dFp/oczSaWeOtlvqnHbMc/7Eoz3ogSLpKyGuLxu bMPq4fkYE80xNaT89keT7UmWlmCCYv05pAufis692Ws8Af+dDpNHozGLHLjEW01YXgV9 OsSk9CGUdhw8sxrHZ+dVMZ8/VC9mLe0AJezXJpSTfFs+gtYDlkhjGDMIsp8jBu3pvPte FMGIk/QZSiQvnipaY9BASMcvRE0QJwR43djfvdNl7ojekEIhqzB8QXqIJO7y5gILktjD QNoA== X-Gm-Message-State: ACgBeo1TItASLuxSzIjhV5pKTmICognVCAfOx7T+Tt0GXYsoCsES82vd WKUgZ46gFRificZcyMmmsUPi/3vqFxA= X-Google-Smtp-Source: AA6agR75o8hqLLPSwEMM+0RAW4piNtgIvz2GqtLLtUL08G5TuwqU52b+3AxKOsC4QnNmt6RFGUsB3g== X-Received: by 2002:a02:b799:0:b0:343:390a:4f66 with SMTP id f25-20020a02b799000000b00343390a4f66mr180392jam.222.1660239352513; Thu, 11 Aug 2022 10:35: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 n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:52 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie , vincent.whitchurch@axis.com Subject: [PATCH 01/11] dyndbg: fix static_branch manipulation Date: Thu, 11 Aug 2022 11:35:31 -0600 Message-Id: <20220811173541.2901122-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D"module tcp" # just one callsite echo " $site =3D_ " > /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 wi= th 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 *q= uery, 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 =3D newflags; v4pr_info("changed %s:%d [%s]%s =3D%s\n", --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 60751C19F2A for ; Thu, 11 Aug 2022 17:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236523AbiHKRgD (ORCPT ); Thu, 11 Aug 2022 13:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbiHKRf4 (ORCPT ); Thu, 11 Aug 2022 13:35:56 -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 4DAB76A48D for ; Thu, 11 Aug 2022 10:35:56 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id 68so8534775iou.2 for ; Thu, 11 Aug 2022 10:35: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=dW/qowRKwpSX+eB9zQgpcFjLzbW7/9zpGPg2Go1FHeI=; b=NJ9PcskJy7nr2SjTCl4gvdy0wSBjPffJjU2h/Z2dYq1Phl9+gYPeVXo4DIqTOSSG4S 4G9wuzt2TjUxrQXI5TYSOQ28Qtwy09xK7BYDDxBP4IPub7lczOuQ97P7VVf4YLQDJh0m JS3ukgNVw2+2O3nIREoCKYXbnmaB+aPZ4Qf7DM2OECxKEVWQBFg0rIJPZVw8SU8M7hw7 UjgsMOma2HU+IucUoSZSCI4SAb/xEzQtsPXXW57rJFgn82KpTLxXw6e0uOjZqRZg5G2u mwxB5lItFR2s3zTXHlSthyXpbP1BmdOzsQm64PgkmV7qVDrIU+8gQLf8utHmDsRRhnuZ QHdQ== 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=rXfjzhCE+opvhtLXponBEmvQtymJ0fCI20wA0ny5NhzYCKWk/WQ9EYMHwkvMrVvgig 2L8/efuJX4ySn2Q47YUuJkyfBVd+dAF5a9z3w8iOkWGK2llJwxhyYUG61rSwH5JsGsH/ A0EgK+lv6yu3WuIHXrRCTsMBUueiX7Ho+u6ZfPSlO9s+eORXeba9PjuDXNT6TLYdnT74 fdwSta1hBiJblcDt0PojdGP2VzVC6tyC/EknQ3zTD2tKcsFpy5lNWHYQtIgjnEZP5oKH DVU7EAJHLLTrsGr0eCaVp1I+VnG7sA4aO5qgaHVJINWQC9VIg4c5ZNObAQPbVAspPO4S mJFQ== X-Gm-Message-State: ACgBeo2HylGwhervXrMTAAtvjXLD7xELtw+BR/y9ensDlbSZJAiUvQUN uy1OhaOFZfgDMpMuy7VVxw4FStwkhv8= X-Google-Smtp-Source: AA6agR6k0UFYv17BoW0YB3vq8lKhQKXYQ/mv+AHacBINfJyqF4kt5lsxoWDQYzq/gziVWoeDm2amQw== X-Received: by 2002:a05:6638:25cb:b0:341:6546:1534 with SMTP id u11-20020a05663825cb00b0034165461534mr182370jat.308.1660239355483; Thu, 11 Aug 2022 10:35: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 n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:55 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie , Rasmus Villemoes Subject: [PATCH 02/11] dyndbg: fix module.dyndbg handling Date: Thu, 11 Aug 2022 11:35:32 -0600 Message-Id: <20220811173541.2901122-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For CONFIG_DYNAMIC_DEBUG=3DN, 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 initi= alization 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"); --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 67E77C19F2A for ; Thu, 11 Aug 2022 17:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235244AbiHKRgH (ORCPT ); Thu, 11 Aug 2022 13:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236044AbiHKRf6 (ORCPT ); Thu, 11 Aug 2022 13:35:58 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626776A48D for ; Thu, 11 Aug 2022 10:35:57 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id x64so15216792iof.1 for ; Thu, 11 Aug 2022 10:35: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=66tB9GURiJGDaXzm2IfI1R+C6P9N6jM87DtEYp8w9s8=; b=LHNuQSl/JLN/8xG1Ng6NDXJSooMN+HxNs52JDN/aGZkxyvMArWvQr818nDXXDfvrLy jVKlYAym6enmXF9MFzCrNma1M98Gq1XHUTL2m80F+FJxt88IAq/KeEXedS35oRfR1Axk IGu8fsi+dHPQbS7WV/d6VKGK4DItc2E+FmgF2+MSph1cPht9GeZNf2nO/k5ZUxwvO5LO mq61+m+CNl4a/YxP2BJOSYiQ9Pi7jHv6+i098KLdtMbZ7DTkPSiO2qqSeoWeOjou/UqY 68Qaiqf5X5e28pioTXMWFEn47fAveE7/fSqjmmJ19h3BC5bBK8E3ecnQqEyGMy8f1YoE LF4w== 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=Y/Ymj9ldNk++JYADV1Oa6jQiGs+RTbWn7V3YnAJfpLVxp6l3ivz2n9UKvigXrNt5nG NszA7L65n8sUUtuay/wMmIzQyjlW0rKB/7xfw/wBvlp71JWiwNoAyADxo/C6IKWjXB7O RidShXuLDxDfnqt53294mIhy9qgkUyseESj5Zj+dVntZKUNG3RByK9YiWZGraflCJGO8 xBJuUj0RGfMH263LrRuDuEz4T1HWDetFEa8/iJFQXAHbl4uo0ulHsiji7yv+nPgI2rBB pKoaApqdWkHHJecxUfEM+peNYM5Ep7ctcpI5vVtg75Z4TvUqq2olwaBydyJ2amNIcEis Wwbg== X-Gm-Message-State: ACgBeo0upCdCP+6a7m1oFRo3iXxUuIjV50R1B6+9fn+BBWohbrNaOaTd o2T1vQmsL1cNo5Tmpr9nZW2nwD0H95A= X-Google-Smtp-Source: AA6agR45kbmTMXQWqGjPtZgg9ZFvk16Op2qVYEeVm8ju6DVbo5szux1govHUPtEjVhezgToPXMHpBQ== X-Received: by 2002:a05:6638:3015:b0:341:de68:602c with SMTP id r21-20020a056638301500b00341de68602cmr201109jak.10.1660239356342; Thu, 11 Aug 2022 10:35: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 n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:56 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 03/11] dyndbg: show both old and new in change-info Date: Thu, 11 Aug 2022 11:35:33 -0600 Message-Id: <20220811173541.2901122-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" print "old =3D> 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 *que= ry, struct ddebug_table *dt; unsigned int newflags; unsigned int nfound =3D 0; - struct flagsbuf fbuf; + struct flagsbuf fbuf, nbuf; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -217,11 +217,12 @@ static int ddebug_change(const struct ddebug_query *q= uery, static_branch_enable(&dp->key.dd_key_true); } #endif + v4pr_info("changed %s:%d [%s]%s %s =3D> %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 =3D newflags; - v4pr_info("changed %s:%d [%s]%s =3D%s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &fbuf)); } } mutex_unlock(&ddebug_lock); --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 D8C15C19F2A for ; Thu, 11 Aug 2022 17:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235770AbiHKRgM (ORCPT ); Thu, 11 Aug 2022 13:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236264AbiHKRf7 (ORCPT ); Thu, 11 Aug 2022 13:35:59 -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 6E7646B15F for ; Thu, 11 Aug 2022 10:35:58 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id g14so10299783ile.11 for ; Thu, 11 Aug 2022 10:35: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=uAM2bHt8Z4xuRTvJFeLRexags7bboegRrLg3WgQNpl4=; b=ii4VkUoA6F32PRQBQUwOPojiHvt0PrVuYDunF42/VkxHg9+3RJfUzGcusx4Ds/F0vJ Fx00G6swXTCJfgfwhWLj6KtJaMMhybcLUOANyAJxp7zX1nY4B9o6NWTABl7FoLHgrUHO Ph/OOeHyLwLY94W6rTuDTE28HFO3GXrjXZDQAD1j1LSrV1AObbxSL5lggiHS8BA1+bpH QgVuW39C5gejOnmPbvKb4otziow0TA8THJBBBqRQ13wVHeCzDMO0UN6l0JwPl5wdKIR5 47G+SyMSfb8XArc70d7VLNucqfqAHhffwK6tRKGaonHcDMqoJ6KnKNYvzPWzE1qUiTKJ +8FQ== 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=gvnlmBBDrQ6rbd03dw18atyLofdyYXEA2YjDkpkhii6o/20bOEaAZ90TuoudvTAs43 iHKeq/dTvK2p9iM2vHbaVqB3POQU5wYnp+QgF+Pyk5ZW1txXYzTkLVieKhWzdkNIM8kk Wgp94Z84ap8h47jtUrmE4xLgg+RKsyG9aNuMPJpdCmDaO13nv3hD/bOfV6hNf1Uq0sbm 0pr/8o5yNgYHZTZvyd81sfLj7CwIysPH8MNceb1KMZQF2Wm2Z5RvT170bG2BVThOSRDE 7shsFR+Ak4k7GbRHUwqmb9J0d6I50F9BWG+XqvUkRycLdzvXK9G+2TgM1Gtwx8pd4Y25 aYMw== X-Gm-Message-State: ACgBeo0irg6o8SmsLjckSlcUhjELY0vnKqz1Q9B8RfC5/cgE+hfCUTDC L3ZwKdeOWGg6OUvOaT82pKWV7kPuze0= X-Google-Smtp-Source: AA6agR773fBmmtSnCwo3EB5i9LD8tnjJz7n3ytBGEbs/AY8QwkldH4ybtX5UedgjiGxUhkZ69W9L4w== X-Received: by 2002:a05:6e02:178d:b0:2de:9179:85e9 with SMTP id y13-20020a056e02178d00b002de917985e9mr126261ilu.308.1660239357406; Thu, 11 Aug 2022 10:35: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 n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:56 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 04/11] dyndbg: reverse module walk in cat control Date: Thu, 11 Aug 2022 11:35:34 -0600 Message-Id: <20220811173541.2901122-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" /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 =3D tab; =20 mutex_lock(&ddebug_lock); - list_add(&dt->link, &ddebug_tables); + list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 26B58C19F2A for ; Thu, 11 Aug 2022 17:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbiHKRgP (ORCPT ); Thu, 11 Aug 2022 13:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236395AbiHKRgA (ORCPT ); Thu, 11 Aug 2022 13:36:00 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EAF6DF8D for ; Thu, 11 Aug 2022 10:35:59 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id e69so15195934iof.5 for ; Thu, 11 Aug 2022 10:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8oKEUq0EPzmllL1JKxsnzcEjeLeYCN2EOuzsBk4Lakg=; b=QP2qAzAS7+Ydg+rd9bTIECTxRQts5ANDfs7JIVWR+befZECCVD3fgy+F4AiHyyCxTD 6bgIb43ZS1HrCHRrwV+Xj9QmH/GPGX6zYsZVwk/KAeyywUwZOLK9DHxMZMSXG3/vHQ8X lWI7a+lVcEViQrO8CkxukR7bbWIMyFuKYKNfFcJCEwSRmKNNLSW1PvKPopU9olr2zOUh INYQGr+14DVws3nUswQnITOLkIklqjMqrLkHjOz1vtgKEFi7UzVG1tHq/EYsoZbA4dp7 MH5f9iWH0o0eKA+Q5ezHYieBu1NGId/c31OaaBylfbe7kxqbn3D2DQCzIjEKyLl2zGM+ 25cQ== 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=pJ/yQ4rtnshCanoXpG/WHLqVX3+3vK2Aj8qZGOcuhBpg1xwVoxWL5riDBI4aPvFs58 tHtB10T/pe5MV5vUI+76FeqJsT52Lsj7wK6k0Y2UM4dIpEmCwkoLoSKIS9w3woPTbEEB 31dTPj3gDD9bGbvx08/W4tBv+vMMqYnX/BxuePjec5KoUqRz8tYkuvBABzRBMkbilz0V vK1/PElqf42YNeh6EQHLxqVIQ0WpoTNmHmkdJGJvodXwfSY3tiplFyiiL1jFEmApAFxh zElNMrZIdWch8DAA23SH3n5zqUy4S32mn3uEBzz9B57R1gZeNGysg4MOXQisI7Q2L80I Z8Ng== X-Gm-Message-State: ACgBeo3x5uc5j3FW1DN+hpEKViyVFwoZco882zraZZ5771lHF0HacL9Q QxnudiN+h4ZNkNurmGJ2TbxLTiu9JHs= X-Google-Smtp-Source: AA6agR7P3OTO9QykDtdny6uNlBz4xfruevgARPLgoRXdcCi9y73Q1QuyfF9CxagkIcvws7doZ0a3CA== X-Received: by 2002:a05:6638:1301:b0:342:c20d:3b15 with SMTP id r1-20020a056638130100b00342c20d3b15mr186682jad.59.1660239358576; Thu, 11 Aug 2022 10:35:58 -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 n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:58 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 05/11] dyndbg: reverse module.callsite walk in cat control Date: Thu, 11 Aug 2022 11:35:35 -0600 Message-Id: <20220811173541.2901122-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D_ "blacklisting initcall %s\= 012" init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blacklisted= \012" init/main.c:1424 [main]run_init_process =3D_ " with arguments:\012" init/main.c:1426 [main]run_init_process =3D_ " %s\012" init/main.c:1427 [main]run_init_process =3D_ " with environment:\012" init/main.c:1429 [main]run_init_process =3D_ " %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 { =20 struct ddebug_iter { struct ddebug_table *table; - unsigned int idx; + int idx; }; =20 struct flag_settings { @@ -805,13 +805,12 @@ static struct _ddebug *ddebug_iter_first(struct ddebu= g_iter *iter) { if (list_empty(&ddebug_tables)) { iter->table =3D NULL; - iter->idx =3D 0; return NULL; } iter->table =3D list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx =3D 0; - return &iter->table->ddebugs[iter->idx]; + iter->idx =3D iter->table->num_ddebugs; + return &iter->table->ddebugs[--iter->idx]; } =20 /* @@ -824,15 +823,16 @@ static struct _ddebug *ddebug_iter_next(struct ddebug= _iter *iter) { if (iter->table =3D=3D NULL) return NULL; - if (++iter->idx =3D=3D iter->table->num_ddebugs) { + if (--iter->idx < 0) { /* iterate to next table */ - iter->idx =3D 0; if (list_is_last(&iter->table->link, &ddebug_tables)) { iter->table =3D NULL; return NULL; } iter->table =3D list_entry(iter->table->link.next, struct ddebug_table, link); + iter->idx =3D iter->table->num_ddebugs; + --iter->idx; } return &iter->table->ddebugs[iter->idx]; } --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 7F122C19F2A for ; Thu, 11 Aug 2022 17:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236845AbiHKRgS (ORCPT ); Thu, 11 Aug 2022 13:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236490AbiHKRgC (ORCPT ); Thu, 11 Aug 2022 13:36:02 -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 ED7006B156 for ; Thu, 11 Aug 2022 10:36:00 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id r5so15181294iod.10 for ; Thu, 11 Aug 2022 10:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=J+XMFiNX/q3LQYLLDUo59QkX1sLIyVqPUPsR4ifBrfo=; b=k/uGzsEE9brEtITCglwRm8+ZCeF34mLrXNhdbENp6TWjeb2bbcXxRHndBbVlx5w2ZZ KVQ5fM/iUo/raYXrkPy8fuCzFDffKd5f74d8eekORzGrGsyxoUx1mDUrUWV7x2DkGXC1 xcyPDTm9CBkgEqo757rRrNjMTmY9AkPbDaLXE0oC7UQcWFlFosTG1igL/RdPfck1/Vk0 d7SIQI3XN0LhYLtzyXq/iM1zrnUXjInAUBnja6KezvBknVXHyij1hMvt4LXlmejq6fou 6G90+xvg23/cYLbsQYaIHGiEeOL7tIEGphKMCqS9+FsVC2d/50p6q7n9CuBuSaUVBxwm Itdg== 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=agaJLwV8IGQ+/vDlCgX/t/9lMWjXBajxPVWuVsLHi/3N6jjPkadF3PUvVYzoPiR+kS y+OJuEWxdIrBHPEb2s86QuYHoo/KdaIRBB7Kryqsy/EqL4HEcdaLeM9MIrpOKrvLVI43 kqFT9EySqc9vboc+osxj0L4fOmye1bBe3hQx5k7VEMJrIQnbuUWXPQXfEL52CSiscHl0 YxVr6cFwt6GUIm3yOYGyHkOswS8u4mzNY/PLwcZKEeE5whrtimD4KJLTvQSu8yGjEKox 4au8xXvMmohWGnGSoxpwD0aC3YZdHnm7sRAK/3Nzo7I+8BX2CHeB76zSkLMVldMTxd5d yikw== X-Gm-Message-State: ACgBeo09oSyJlPVigdCbps05aXzOyi6d8M4eYK7oLyD7g6P+XpSW3iEV SmGyrYqMg806Z1n7dlv7AeU9qVwh8/4= X-Google-Smtp-Source: AA6agR7UkkkeZPWzL08mYyDCs0ONvUCyyCq7oDwdgZnEay5MEM3TR2zGVmjCXrMkagXjcwy543GoFA== X-Received: by 2002:a05:6638:2652:b0:343:d46:58e7 with SMTP id n18-20020a056638265200b003430d4658e7mr191389jat.134.1660239359447; Thu, 11 Aug 2022 10:35:59 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:59 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 06/11] dyndbg: use ESCAPE_SPACE for cat control Date: Thu, 11 Aug 2022 11:35:36 -0600 Message-Id: <20220811173541.2901122-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" `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 =3D_ "blacklisting initcall %s= \n" init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\n" init/main.c:1424 [main]run_init_process =3D_ " with arguments:\n" init/main.c:1426 [main]run_init_process =3D_ " %s\n" init/main.c:1427 [main]run_init_process =3D_ " with environment:\n" init/main.c:1429 [main]run_init_process =3D_ " %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"); =20 return 0; --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 CA841C19F2A for ; Thu, 11 Aug 2022 17:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235709AbiHKRgY (ORCPT ); Thu, 11 Aug 2022 13:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235456AbiHKRgF (ORCPT ); Thu, 11 Aug 2022 13:36:05 -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 194656FA0C for ; Thu, 11 Aug 2022 10:36:01 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id 68so8534938iou.2 for ; Thu, 11 Aug 2022 10:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Ip7G03GeGcrZkSaeVkjkXUMKYERuJTa3x3HVuceUBd4=; b=jkvp6ypAI7wmjuLyIm6zfQW7XgupXVr6/yxNKX+AiI/z6XQPh8raO880pk6CRYoNDT 75YB+dVDMVqmv1Wnt1NEp1n9xwA/zA7qOvS2qWB/f3jazRfia8HuNCfiXy6SvxNzimmI XpLW05KgRbso2g07iJhXlDwvmSbHb+KykZqlOh6sb9F/RCQQK2PA6wl5pRDF6z7VFnSo QWFQW5uxSJcOHIWUFCVpw5UrpZH8BwmPBbDDpe8D/FRDhLgkSeIOklt0lq3HOtR4CtnZ mTTXYjBwfy/WRfzgfI0tAyXF5lWIyZzXOsFyhzBcC5T1+ny/iLF8VdmGI03kz9RoyOGT Nv3g== 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=D4mceOQR8WAk0IGb+Mh1A/JuMiAw6jLm25A5dl65yGlbGGdIhmqgigvjzwVYVf0NcO S4vZdVMxQz00ziEbMWipBMburJQmcoyKCUEnwiDOoc1qIaRTrWchErd3sSP996GLgZ8R nH2ks4Rk4WUFbcV0n6a0UoYsQZm/eGgZvukPQX2T/s6KaS4QE3hDbcXBXBA46SCPxiYr tiJNCGuQz8fedKRmV9U3x566HgtcUJDTPJ2wq94AZzEwTo57JupdmmYGEe8r5Hm00rfQ jX+is/jheO8Ud3Q25aGqWZokGyrIcxLAmBOe+ccS8nkCa6M6JHuBCjenjg6bHa7vz4hX oVSw== X-Gm-Message-State: ACgBeo2sa6Fkh8KtolP15zlVAMHTqHmQqjRLwQXtQ/zJ66vEAfn2FAuI VDXTRX3E6nL7WLYiyASxiaOa8FIwqVY= X-Google-Smtp-Source: AA6agR5fDHZdIb6S54Ju2g6cePa4/XJS8UFUlqUYCk6NArZK5ieZdZTo4QpD2R+XyS1qaLf+kZREVQ== X-Received: by 2002:a02:9f8a:0:b0:342:f254:6ede with SMTP id a10-20020a029f8a000000b00342f2546edemr189240jam.35.1660239360400; Thu, 11 Aug 2022 10:36:00 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:35:59 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 07/11] dyndbg: let query-modname override actual module name Date: Thu, 11 Aug 2022 11:35:37 -0600 Message-Id: <20220811173541.2901122-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D"class DRM_UT_CORE +p" # get drm_helper too modprobe drm dyndbg=3D"class DRM_UT_CORE module drm* +p" # get everything that knows DRM_UT_CORE modprobe drm dyndbg=3D"class DRM_UT_CORE module * +p" # also for boot-args: drm.dyndbg=3D"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 nword= s, return -EINVAL; } =20 - if (modname) - /* support $modname.dyndbg=3D */ - query->module =3D modname; - for (i =3D 0; i < nwords; i +=3D 2) { char *keyword =3D words[i]; char *arg =3D words[i+1]; @@ -429,6 +425,13 @@ static int ddebug_parse_query(char *words[], int nword= s, if (rc) return rc; } + if (!query->module && modname) + /* + * support $modname.dyndbg=3D, when + * not given in the query itself + */ + query->module =3D modname; + vpr_info_dq(query, "parsed"); return 0; } --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 B2F33C19F2A for ; Thu, 11 Aug 2022 17:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236009AbiHKRgc (ORCPT ); Thu, 11 Aug 2022 13:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236628AbiHKRgF (ORCPT ); Thu, 11 Aug 2022 13:36:05 -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 C465F7436B for ; Thu, 11 Aug 2022 10:36:02 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id d187so8428562iof.4 for ; Thu, 11 Aug 2022 10:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=J3hK7bUI023BnYR4sokXeCwLdQ8v4VG+y38uaGcbPRI=; b=hSowz9/2jsMCZlK2hxcyHg+ly/WMitvlPhPgvi48wXW+wp9apszWtaE7CmE3FdkeX7 /Ct/1I+GK6VNgjVcqHN2FERRy7+GEdYwVoAWtEO8QSeWZY1mHwx7QxPSWPfHkeIqWZ8v rENttebV32dxfjhvadFhwdFKZCVAhhznGKjPtMOuU4DGgAtoBPHAWS701JRXJbJkXJlU sBgp13wx5262WeJlUVHgit78gNU+LC59uJq3CaAFg6+RiHVyMtxCwQT47jwqaiXSazBH tODUBokISJquzVxb1qgsBCg4IOMQqqQpoidXKA3quemzP6y/4kY++yaWITXOzrKvs6mn M7sw== 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=HiUl7s3OBh5SvRTpaHVMdJN0TP5/FHKNiQ6hY++PVue+sjd00U9Oa4XOJcYEZRatyA BJRreeT0fPVB1etZ1T9pi0u0HYimxIEl2qt/t5fDP0FX3lRIDDF4yTP6R8S1xW38RymY IQXY17MoLRgkyKb8NGpTy0rsD2oDvSEQlC0x2lM/HtK6Gj9bFacAtSt890GIzHbfyvav TuG2l/LMOQubtdtenX6uGKiY99kQZVxDuBWMI02ggJtavcnq545RJ98yvOIsr8sogg6/ nW/QNqlWPHkHmH0rU7SVKlgfy6zmf+upfmVjUXGVGyor23ftfvYRNIuQR+eoXqvijDFA 5TJQ== X-Gm-Message-State: ACgBeo37iViV4iV+OhtkKPfYY0cNo9pPZbK4+8HpcySFdzM31/odWvqJ 37J1umIzdxyrxVyqAn5Ea4BdRxeAKHU= X-Google-Smtp-Source: AA6agR7k8Vjqm6J1QbziFiPV2MC1HNzjJwAlXNTWMI2nBZoxym4QRvKDZMfJt2YUfOUx+64k6GR2ew== X-Received: by 2002:a05:6602:2dc9:b0:67c:410:29f5 with SMTP id l9-20020a0566022dc900b0067c041029f5mr151929iow.39.1660239361646; Thu, 11 Aug 2022 10:36:01 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:36:01 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 08/11] dyndbg: add test_dynamic_debug module Date: Thu, 11 Aug 2022 11:35:38 -0600 Message-Id: <20220811173541.2901122-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D+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 =20 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 =20 If unsure, say N. =20 +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) +=3D test_sort.o obj-$(CONFIG_TEST_USER_COPY) +=3D test_user_copy.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_base.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o obj-$(CONFIG_TEST_BITMAP) +=3D 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_para= m *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 =3D { + .set =3D param_set_do_prints, + .get =3D 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"); --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 348CAC19F2A for ; Thu, 11 Aug 2022 17:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235348AbiHKRgh (ORCPT ); Thu, 11 Aug 2022 13:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236649AbiHKRgG (ORCPT ); Thu, 11 Aug 2022 13:36:06 -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 BDE276DFA3 for ; Thu, 11 Aug 2022 10:36:03 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id i84so15187628ioa.6 for ; Thu, 11 Aug 2022 10:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=5COrt8+UBE4dlO0UmlrrMAl6VEmhHXEe2GHU1HbZD24=; b=JaAuy9N5LSnFjIqLNRXXph+mheQVDE5xCZ87t3QrzwgreDl97oNVVaYGHwShJnYfSI BmP1dm0C+Db/uFvP3TDzPsP9LL8L3Kc+SZUqQWcsOIzB2TAu4RoZsLecNWIIDAXgxhXA 0Rjxgvyx+FC1CEbyNoFr/MW6wb42nWgUu3mHbXIKH5p6I9e5FbfeQnoyDoVHu1ZE1TUw DL8b8B5XxK/nzK6ZKtkjR1cxop617jeZtj4BIHHVDjfE7ammSQJKMkJ5sOcrctVWDl9r +18abGYC8SCgv8wxLGvRxG6ap7F/WT/EMcLD4b/YjeyK37xOJRIoSGeUI7EHNM/Qyx6D vp2Q== 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=JrtNYR2p2/AII/gLOji/DHuuc06HDHRXFmqowMDKvu4ao5DEe9tQ0U7zGOBi0Be/ch rpkbv67UjMhAisR/y2zgIzHOHQojHBNaqDexS+UWAvfPvWybpa3Q86BK4wus2ScNMv68 59mUEYGVlHg4Q4/vmgQ5hgXRwUn6qwDpy+gfJ+jeNWXcUIWomGWAlk0pfhAQnKjUYZ9g JYr8vI52+aGed5bPhEjwaWKAuCLdGTBiMTOf2VG2iQqahbBLQ1w/b0hjoM7PayS3SVAL 4ZoNjVUJ96QY6JwKgb5qg++B4QzGKKF2s/x4LgKEvpIvZmcuwLlyU5OcPX8ShKGeUfJI vipg== X-Gm-Message-State: ACgBeo3jYLmKeTy9QiIaQsanLGk791JMramw3oLojV95ac8AcFnzOcSi bqhJeKPSu1I0VAYTZerinTp2WoSnxMs= X-Google-Smtp-Source: AA6agR5LrGLtUpqabTS2wMV0IF1pey1TbmuUxEaqeLKA6ZR0SiP1sNIrIJb79bXIv/1R5XlbVvcvjQ== X-Received: by 2002:a05:6602:2dd0:b0:684:8efd:6a26 with SMTP id l16-20020a0566022dd000b006848efd6a26mr169133iow.116.1660239362571; Thu, 11 Aug 2022 10:36:02 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:36:02 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 09/11] dyndbg: drop EXPORTed dynamic_debug_exec_queries Date: Thu, 11 Aug 2022 11:35:39 -0600 Message-Id: <20220811173541.2901122-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_q= ueries()") 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 { =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 -/* 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) =20 -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 */ =20 #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; } =20 -/** - * 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 =3D kstrndup(query, PAGE_SIZE, GFP_KERNEL); - if (!qry) - return -ENOMEM; - - rc =3D ddebug_exec_queries(qry, modname); - kfree(qry); - return rc; -} -EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); - #define PREFIX_SIZE 64 =20 static int remaining(int wrote) --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 7DD25C25B0C for ; Thu, 11 Aug 2022 17:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235984AbiHKRgn (ORCPT ); Thu, 11 Aug 2022 13:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236785AbiHKRgK (ORCPT ); Thu, 11 Aug 2022 13:36:10 -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 3BDFE844FD for ; Thu, 11 Aug 2022 10:36:04 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id v185so15159916ioe.11 for ; Thu, 11 Aug 2022 10:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=OD3thvJspbjKpd00bhtO6kDknAInrQ6Lun7qGbHZH1Q=; b=c/GYeQcyfv69PSJKLMN+mNwJLgIF82/e3GHJV5TCzt/e0/BTDgIoOPvpnv1QEJZ6EA ajkQhDiBlyR9PcqMO4/CgYDgNgeZkMKFudZ12/0ZOH+woJDdR+hqS5EbOiPHUwKmoX/2 ZtytZI6bFnZP9zTXLYSXP7pb5FPPClx5JGJAjU5ruM9NVVp8+lofi0pp8ejqMX79Fw7P PaeUH48PJB+hTzt8N5SjWkz4BioCCDNuTY3BTy90LZbo2KtQrgafWWXZ30Vg4NGCPNfO KdgiXWg1R1SyR2IoN6Vk/B12kWncX3E8Z9VOiQzOce8SphUObp7o+3TDalb8hlSCTbDH fseA== 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=OD3thvJspbjKpd00bhtO6kDknAInrQ6Lun7qGbHZH1Q=; b=8LuAlNDuvQYisCY5A0pdlSsO0y1hPzesLxKB2Ys7PMVX0LFwOabyRE610DSPKg8nAz BRpd9VEuRlXeOcrnJM+DKHmblJsF5t4bT0m7+nMoW747+UEvHB3u3eYzOq4deCY2gU2S B2uyLYbyyvogTsPBg98C1PR8jaK6aBjacHJeLF6jR9payljBsDN0FeGjmd/jhjW3EQkw 3q5Mdvqf2XaQ1BrUmbg03/Z6L6qEoSFJA1yQbxoqFuri9uCHoMFtIQA0KgTMhSpx1Ki6 PYfIWgFpqQW149PDEkZMlPEDNyJEqF+4F5AOhOsyBLaMjGXuorJMBcQiBzdX/yhVsdMa GHXg== X-Gm-Message-State: ACgBeo2gJiLzpzONPOYSvo4pvOZ1dZSye3GBuF9VZGDdXxp5wTnNAQeA 4ilX1y1jgE9WOEZTwsZscGP1eX5w09A= X-Google-Smtp-Source: AA6agR4ELAAJgAsso0m3DmVnlEjvIYKTvu9w9JzjOreer4QYk48WOYW4E6ScJaUE+Wf/XwZEUT2nEw== X-Received: by 2002:a6b:1d5:0:b0:682:6df8:afc0 with SMTP id 204-20020a6b01d5000000b006826df8afc0mr160451iob.76.1660239363700; Thu, 11 Aug 2022 10:36:03 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:36:03 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie Subject: [PATCH 10/11] dyndbg: cleanup auto vars in dynamic_debug_init Date: Thu, 11 Aug 2022 11:35:40 -0600 Message-Id: <20220811173541.2901122-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" rework var-names for clarity, regularity rename variables - n to mod_sites - it counts sites-per-module - entries to i - display only - iter_start to iter_mod_start - marks start of each module's subrange - modct to mod_ct - stylistic new iterator var: - site - cursor parallel to iter 1st step towards 'demotion' of iter->site, for removal later treat vars as iters: - drop init at top init just above for-loop, in a textual block Signed-off-by: Jim Cromie --- 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) =20 static int __init dynamic_debug_init(void) { - struct _ddebug *iter, *iter_start; - const char *modname =3D NULL; + struct _ddebug *iter, *iter_mod_start; + int ret, i, mod_sites, mod_ct; + const char *modname; char *cmdline; - int ret =3D 0; - int n =3D 0, entries =3D 0, modct =3D 0; =20 if (&__start___dyndbg =3D=3D &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1074,30 +1073,32 @@ static int __init dynamic_debug_init(void) ddebug_init_success =3D 1; return 0; } - iter =3D __start___dyndbg; + + iter =3D iter_mod_start =3D __start___dyndbg; modname =3D iter->modname; - iter_start =3D iter; - for (; iter < __stop___dyndbg; iter++) { - entries++; + i =3D mod_sites =3D mod_ct =3D 0; + + for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + if (strcmp(modname, iter->modname)) { - modct++; - ret =3D ddebug_add_module(iter_start, n, modname); + mod_ct++; + ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; - n =3D 0; + + mod_sites =3D 0; modname =3D iter->modname; - iter_start =3D iter; + iter_mod_start =3D iter; } - n++; } - ret =3D ddebug_add_module(iter_start, n, modname); + ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); if (ret) goto out_err; =20 ddebug_init_success =3D 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)); =20 /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. --=20 2.37.1 From nobody Sat Apr 11 10:48:01 2026 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 20BB9C19F2A for ; Thu, 11 Aug 2022 17:36:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235511AbiHKRgr (ORCPT ); Thu, 11 Aug 2022 13:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234961AbiHKRgK (ORCPT ); Thu, 11 Aug 2022 13:36:10 -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 F016A6CF54 for ; Thu, 11 Aug 2022 10:36:05 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id z145so15181621iof.9 for ; Thu, 11 Aug 2022 10:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Gia1w3Dp2zEfxEzad+9CAcTqHJ7ru207Rscme2dIBl8=; b=pMCdqrocfucaYbsa3wxbODeRLJ84EYnW/5POItGcPE6gY1ai2AFKTHKCghSKmOY3B4 cB9sSWYGkuMrTklGUiGXFJSKtupGmyUPwy/Eh50qY0KtSzqQ97xIDXInZeeqAT9WQgvb sV9+twxAzD8X+nR8QPxlSobEzUrBP1UxBwGVUyKh2hrW7noXsjpOJhgI2hDxKKi71p/t fXmijkXwkg+oQWF/KcQQg2OBLpeKsxDo6mLAPm9dYGOWfP0bvWdIEWhrm8Ckx5gm0FeY Yx6h0RBpcRf5lDOMVx/4gBij7OyD89Pntc22gW96T4OUT6YwoAfN63yhtuBlFosOVUS0 B/2A== 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=Gia1w3Dp2zEfxEzad+9CAcTqHJ7ru207Rscme2dIBl8=; b=mYWUdj6/yVLHtSomAks2Dya+YFYcMQH9ielUSJvls6exP7CT2oaMJypSXAHFrTOX9g /elveb4hqqnS4b5JPyRi2zdPIpglAnSH5qH6Da/C1JgY2+8k7+woDNxnwv2AlBT1cwIE PtWLpeyTjwNzKrqNQJ+unOYK5ZnCIJydVDCwUvEwrMqKepJWLmJueCyHiGFVmH2wo8gz fqIzKv80GCHWbrDPUA9NmVaoHwWPH9GSnAtx2onuDy7Dfavb8jYDJGHLDZ5s9FcHg9NO qSLOcUZoPerLNznCW3jnMFbEub5dd9aknXZSF5/vNI+/lODo0apYnl0cQAQ9DG2zGc44 +Q6w== X-Gm-Message-State: ACgBeo2phFXMJeOJk51VGWohGcmTYY7eoxtxlfU6JLRnw7kS0RWqr+Hr 02GWtPXU5UaavVf/rqS7ZxcZlL+kouU= X-Google-Smtp-Source: AA6agR6tqK6PXU5XsVDUpp/9pOm2Xg9ZowN7LFolM7AqpKB64mRege6gD2/RXYjrt0QrD0dplHQ/8A== X-Received: by 2002:a05:6638:1496:b0:342:873b:a07c with SMTP id j22-20020a056638149600b00342873ba07cmr187696jak.236.1660239364646; Thu, 11 Aug 2022 10:36:04 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id n9-20020a056638110900b003435e8635bbsm27928jal.77.2022.08.11.10.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:36:04 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: Jim Cromie , Luis Chamberlain Subject: [PATCH 11/11] dyndbg: create and use struct _ddebug_info Date: Thu, 11 Aug 2022 11:35:41 -0600 Message-Id: <20220811173541.2901122-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811173541.2901122-1-jim.cromie@gmail.com> References: <20220811173541.2901122-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 an explicit by-module walk thru 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))); =20 - +/* encapsulate linker provided built-in (or module) dyndbg data */ +struct _ddebug_info { + struct _ddebug *descs; + unsigned int num_descs; +}; =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 -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 =20 -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[]; =20 +#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) } } =20 -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 *d= yndbg) { - if (!debug) + if (!dyndbg->num_descs) return; - ddebug_add_module(debug, num, mod->name); + ddebug_add_module(dyndbg, mod->name); } =20 -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); } =20 @@ -2093,8 +2093,8 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) if (section_addr(info, "__obsparm")) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); =20 - info->debug =3D section_objs(info, "__dyndbg", - sizeof(*info->debug), &info->num_debug); + info->dyndbg.descs =3D section_objs(info, "__dyndbg", + sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); =20 return 0; } @@ -2783,7 +2783,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, } =20 init_build_id(mod, info); - dynamic_debug_setup(mod, info->debug, info->num_debug); + dynamic_debug_setup(mod, &info->dyndbg); =20 /* 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, =20 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 =3D { * 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; =20 + 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 =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D 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 i= nt n, * member of struct module, which lives at least as long as * this struct ddebug_table. */ - dt->mod_name =3D name; - dt->num_ddebugs =3D n; - dt->ddebugs =3D tab; + dt->mod_name =3D modname; + dt->ddebugs =3D di->descs; + dt->num_ddebugs =3D di->num_descs; + + INIT_LIST_HEAD(&dt->link); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - 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; } =20 +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; =20 + struct _ddebug_info di =3D { + .descs =3D __start___dyndbg, + .num_descs =3D __stop___dyndbg - __start___dyndbg, + }; + if (&__start___dyndbg =3D=3D &__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) =20 if (strcmp(modname, iter->modname)) { mod_ct++; - ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs =3D mod_sites; + di.descs =3D iter_mod_start; + ret =3D __ddebug_add_module(&di, i, modname); if (ret) goto out_err; =20 @@ -1091,7 +1111,9 @@ static int __init dynamic_debug_init(void) iter_mod_start =3D iter; } } - ret =3D ddebug_add_module(iter_mod_start, mod_sites, modname); + di.num_descs =3D mod_sites; + di.descs =3D iter_mod_start; + ret =3D __ddebug_add_module(&di, i, modname); if (ret) goto out_err; =20 --=20 2.37.1