From nobody Tue Dec 16 19:54:04 2025 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 CDC99C46CA1 for ; Thu, 12 Oct 2023 19:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442548AbjJLTtO (ORCPT ); Thu, 12 Oct 2023 15:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442716AbjJLTtB (ORCPT ); Thu, 12 Oct 2023 15:49:01 -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 40A56FD for ; Thu, 12 Oct 2023 12:48:39 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fb64b5265so55330939f.1 for ; Thu, 12 Oct 2023 12:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140118; x=1697744918; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZM5rYwdrlUHJ3qGgxecEnebBAR86FDciuES39cltGkM=; b=aj+KRwpC1cmoM6NSANYphNSYheZ62vD3JBs7HcGpT8pTLp6y0zcRFxbpAZiwOzjAOr cQ9V0nPuR96UMh7E1Sy00rdUCYmrzlKyfkG18sQdhievHuWta/+dp78uj3XqMAz9NYLd WccHaC1wh+CtaG6LUQ8u1yP6/YvtRuX51dB5Up+N4cXjUtbaZ+c0NJAGZfPbQ36LRxNj xsEQpJkVXgyq2To3KzGwhPxNMcahWzNK+DNK5c3Zd99Bl370oLYLWFX+WEyxdeFdyMCX YAPVGhJzamTOVaxTUpzMsP4TIOIyHPtkx3/u9kZvAXaWdRHwnIj/xVUIUrYLxSp2X+5a ZR+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140118; x=1697744918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZM5rYwdrlUHJ3qGgxecEnebBAR86FDciuES39cltGkM=; b=YUT7i9KJh4iacGmWjd3OUyJGPhsq30/lL6ft+X12gjuoA0MgCLn3v0ReWdCqtkVDrP amis28nhXmKitCCalYZUBZjaFmDsFHJmRe4gTVJmNILhpjTFmH7f6kkdCM8/vYw1fl0A WcYUW8LQOAEBaZ8AOeU29P15xfquUh2HP38ceQ69KUwVlcNPv2BqEQnqVBEckWJ8IFq8 h8KzOY/zd/4oD9fLBq4uyuSyd/GDM5xWwqY/tFGix8sSb8CuPB5RAELc74wJxsJxYIRe a3ppJpkkPkseKbxUke8HcQyEcqi/fy3cEC3zmPU+LaMWVhWL7DhfIa7Bylb2Ut1UkQf3 A2tw== X-Gm-Message-State: AOJu0YxXXJFk5CoItv1p0VmDwKOIa3U+fmv0dNjX52NrnKueJcCZCqus gK6IQmr8xp3jrmjRfbO5I2q0G1bCvH4mTw== X-Google-Smtp-Source: AGHT+IHJQgyemV60d0TtSM5gRZcC8BOKY9QEWfAWdNthxj5Xm9QnZob6Y9eoYwqr1EmvKzVb/INxVg== X-Received: by 2002:a05:6602:211a:b0:792:43b4:dc2 with SMTP id x26-20020a056602211a00b0079243b40dc2mr28000700iox.3.1697140118215; Thu, 12 Oct 2023 12:48:38 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:37 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 01/10] dyndbg: prep to isolate 3 repetetive fields Date: Thu, 12 Oct 2023 13:48:25 -0600 Message-ID: <20231012194834.3288085-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" Move 3 fields: modname, filename, function into an anonymous struct, and rename with '_' prefix to catch stale uses. Add 3 desc_*() macros to abstract the field refs. Add DYNAMIC_DEBUG_SITE_INIT() to initialize the fields. no functional change. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 22 ++++++++++++++++------ lib/dynamic_debug.c | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2237d454bc19..aacfafc466c0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -13,14 +13,17 @@ * ELF section at every dynamic debug callsite. At runtime, * the special section is treated as an array of these. */ + struct _ddebug { /* * These fields are used to drive the user interface * for selecting and displaying debug callsites. */ - const char *modname; - const char *function; - const char *filename; + struct /* _ddebug_site */ { + const char *_modname; + const char *_function; + const char *_filename; + }; const char *format; unsigned int lineno:18; #define CLS_BITS 6 @@ -61,6 +64,10 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 +#define desc_modname(d) (d)->modname +#define desc_filename(d) (d)->filename +#define desc_function(d) (d)->function + enum ddebug_class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, /** @@ -213,12 +220,15 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); =20 +#define DYNAMIC_DEBUG_SITE_INIT() \ + ._modname =3D KBUILD_MODNAME, \ + ._function =3D __func__, \ + ._filename =3D __FILE__ + #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name =3D { \ - .modname =3D KBUILD_MODNAME, \ - .function =3D __func__, \ - .filename =3D __FILE__, \ + DYNAMIC_DEBUG_SITE_INIT(), \ .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3dc512fb1d66..c0e595483cb9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -235,16 +235,16 @@ static int ddebug_change(const struct ddebug_query *q= uery, =20 /* match against the source filename */ if (query->filename && - !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, desc_filename(dp)) && !match_wildcard(query->filename, - kbasename(dp->filename)) && + kbasename(desc_filename(dp))) && !match_wildcard(query->filename, - trim_prefix(dp->filename))) + trim_prefix(desc_filename(dp)))) continue; =20 /* match against the function */ if (query->function && - !match_wildcard(query->function, dp->function)) + !match_wildcard(query->function, desc_function(dp))) continue; =20 /* match against the format */ @@ -281,8 +281,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, } #endif v4pr_info("changed %s:%d [%s]%s %s =3D> %s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + trim_prefix(desc_filename(dp)), dp->lineno, + dt->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags =3D newflags; @@ -781,13 +781,13 @@ static int __dynamic_emit_prefix(const struct _ddebug= *desc, char *buf, int pos) { if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", - desc->modname); + desc_modname(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", - desc->function); + desc_function(desc)); if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", - trim_prefix(desc->filename)); + trim_prefix(desc_filename(desc))); return pos; } =20 @@ -1110,8 +1110,8 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) } =20 seq_printf(m, "%s:%u [%s]%s =3D%s \"", - trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + trim_prefix(desc_filename(dp)), dp->lineno, + iter->table->mod_name, desc_function(dp), ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\""); @@ -1528,12 +1528,12 @@ static int __init dynamic_debug_init(void) } =20 iter =3D iter_mod_start =3D __start___dyndbg; - modname =3D iter->modname; + modname =3D desc_modname(iter); i =3D mod_sites =3D mod_ct =3D 0; =20 for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { =20 - if (strcmp(modname, iter->modname)) { + if (strcmp(modname, desc_modname(iter))) { mod_ct++; di.num_descs =3D mod_sites; di.descs =3D iter_mod_start; @@ -1542,7 +1542,7 @@ static int __init dynamic_debug_init(void) goto out_err; =20 mod_sites =3D 0; - modname =3D iter->modname; + modname =3D desc_modname(iter); iter_mod_start =3D iter; } } --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 D588CCDB47E for ; Thu, 12 Oct 2023 19:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442899AbjJLTtR (ORCPT ); Thu, 12 Oct 2023 15:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442747AbjJLTtB (ORCPT ); Thu, 12 Oct 2023 15:49:01 -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 214F1D5F for ; Thu, 12 Oct 2023 12:48:40 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-7a2bfd584f0so57768139f.0 for ; Thu, 12 Oct 2023 12:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140119; x=1697744919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qUViZFu6qDP+V9dlTKCnuIaJi78i9uWOlvfP3OhngjY=; b=gTu8D84BmO90nRjN/r3WVRhXhVA9HWlAQ0z3yGM8P5N87Nx82GSWPJuA84sMCjkNxw SQaF4cX6gLwc+VhcqbgzHGLhjTasWNREQoDglBHomwrDby7KwsbcIQYWagAd09pmUPg7 XGpGMXxE6AQiGPE8lixEk8KfS1exUKAGEhJ+F/R4o/h3j6iF/uaIqViEWYTNEhmWRS+G ZojTSw2RtTZCmYwt1Yky42balU/aSPQBbmlNLY0mpz1+5FkclabZHlZlafxP9TgTXVbl mwUoLYekGZj0NyjE1wIPYyb0PVivND7zjMxwqUovxVKbFpTIqxRxWJeZni7PsW0bt1tt OT+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140119; x=1697744919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qUViZFu6qDP+V9dlTKCnuIaJi78i9uWOlvfP3OhngjY=; b=uarD/4Tx177UlUndjwdoFLbBcTZkEGPRucjOhrzNrbXU9v5aaDRnhRg1fwjyEkyghf Xds3HBd5ri+DnfmGWC5jUOjeJDTorvIVWQsvyv3yatqCcEI5AKSHsrzblGZb0xoKGJsP A+soZ/2s6MLWu2rL70nhnzHFZcWYJ70bPJnuEXRlbpl+rpg3c1FPtavy/VQ/MoOs3icm 5vbeB/sJODCjW4wrg3Ffg1EPwT1Wo+5YSUyr21TLOHURKHtvL6S6QeADKu7EMjqo246L RY9EmeIOx2noi9ekjnZYwoiiLDyxUTtaDW7iFxRPsJhDFtBvn7mwRGFA+vTqikKHhRFi pgKA== X-Gm-Message-State: AOJu0YwbqIdrVkYJTs7xZAtsuswAv6ob3xpOAy/bM5laX+TDcR84JfSL /ITqGxfN20Sh9Yf07cy03esY3WvQazjP4Q== X-Google-Smtp-Source: AGHT+IEIAuL545uphGsUTelNzl/EYkM+08iRqpJX2+URkY+jsN1KrPbPfSqrYVohS7AgKwAvd/zf1w== X-Received: by 2002:a6b:fd01:0:b0:790:c3d0:8f87 with SMTP id c1-20020a6bfd01000000b00790c3d08f87mr26613731ioi.19.1697140119145; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:38 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 02/10] dyndbg: split __dyndbg_sites section out from __dyndbg Date: Thu, 12 Oct 2023 13:48:26 -0600 Message-ID: <20231012194834.3288085-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" split struct _ddebug_site out from struct _ddebug (adding a site ptr), and add new __dyndbg_sites section placement to vmlinux.lds.h This is an implementation detail to isolate the redundant columns into a separate section, so it specifically excludes lineno. This allows (later) to copy and compress the info into a better (more compact) representation thats still fast enough. Then we can just reclaim the whole __dyndbg_sites section. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 1 + include/linux/dynamic_debug.h | 40 ++++++++++++++++++------------- kernel/module/main.c | 3 +++ lib/dynamic_debug.c | 6 +++++ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 5451f926a753..1d128259e373 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -368,6 +368,7 @@ BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users) \ BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_sites, ___dyndbg_sites) \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index aacfafc466c0..5206a2cfdb37 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -9,21 +9,25 @@ #include =20 /* - * An instance of this structure is created in a special - * ELF section at every dynamic debug callsite. At runtime, - * the special section is treated as an array of these. + * A pair of these structs are created into 2 special ELF sections for + * each pr_debug callsite. At runtime, the special sections are + * treated as arrays. */ - -struct _ddebug { +struct _ddebug; +struct _ddebug_site { /* - * These fields are used to drive the user interface - * for selecting and displaying debug callsites. + * These fields are used to: + * - display callsites in the control file + * - query/select callsites by the code's organization + * - prefix/decorate pr_debug messages per user choices */ - struct /* _ddebug_site */ { - const char *_modname; - const char *_function; - const char *_filename; - }; + const char *_modname; + const char *_function; + const char *_filename; +}; + +struct _ddebug { + struct _ddebug_site *site; const char *format; unsigned int lineno:18; #define CLS_BITS 6 @@ -64,10 +68,6 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 -#define desc_modname(d) (d)->modname -#define desc_filename(d) (d)->filename -#define desc_function(d) (d)->function - enum ddebug_class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, /** @@ -139,9 +139,11 @@ struct ddebug_class_user { /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; + struct _ddebug_site *sites; struct ddebug_class_map *classes; struct ddebug_class_user *class_users; unsigned int num_descs; + unsigned int num_sites; unsigned int num_classes; unsigned int num_class_users; }; @@ -226,9 +228,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, ._filename =3D __FILE__ =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ + static struct _ddebug_site __aligned(8) \ + __section("__dyndbg_sites") name ##_site =3D { \ + DYNAMIC_DEBUG_SITE_INIT(), \ + }; \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name =3D { \ - DYNAMIC_DEBUG_SITE_INIT(), \ + .site =3D &(name ##_site), \ .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ diff --git a/kernel/module/main.c b/kernel/module/main.c index 6b0b0d82b5ab..43458184744d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2211,6 +2211,9 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) mod->dyndbg_info.descs =3D section_objs(info, "__dyndbg", sizeof(*mod->dyndbg_info.descs), &mod->dyndbg_info.num_descs); + mod->dyndbg_info.sites =3D section_objs(info, "__dyndbg_sites", + sizeof(*mod->dyndbg_info.sites), + &mod->dyndbg_info.num_sites); mod->dyndbg_info.classes =3D section_objs(info, "__dyndbg_classes", sizeof(*mod->dyndbg_info.classes), &mod->dyndbg_info.num_classes); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c0e595483cb9..0ad9f1bc00f0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -41,6 +41,8 @@ =20 extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct _ddebug_site __start___dyndbg_sites[]; +extern struct _ddebug_site __stop___dyndbg_sites[]; extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; extern struct ddebug_class_user __start___dyndbg_class_users[]; @@ -191,6 +193,10 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons return NULL; } =20 +#define desc_modname(d) (d)->site->_modname +#define desc_filename(d) (d)->site->_filename +#define desc_function(d) (d)->site->_function + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 899B3CDB46E for ; Thu, 12 Oct 2023 19:49:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442927AbjJLTtU (ORCPT ); Thu, 12 Oct 2023 15:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442748AbjJLTtB (ORCPT ); Thu, 12 Oct 2023 15:49:01 -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 F30BED60 for ; Thu, 12 Oct 2023 12:48:40 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-79fce245bf6so53220739f.1 for ; Thu, 12 Oct 2023 12:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140120; x=1697744920; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=071vttQwsRtHTk9tdWp1lQy+KTSRjIxShniNeq+GU3Y=; b=YP9WCCUPD3xLbCS1byqspoYlcu640BonoiUex3iSArjbquqRDyZeuGIihLURzg8IyK JX1PxWE3CNYryK7JBU1fBjckc2IZPWRJhpHK/TvwWZohwO+Eyhedm37HFyqjws5HIDf+ +x3OCKyTk0t/1IsHElBt45anTdy9v19I3oLMwFHbysuBQFcvQsKDCNe8A9E36UxGlVyQ mR8HLKx7MrCCp4D+TBTfpQNrF6msy2GxG8NZ1AnfMTy4/oQZefAHYuyyQ+LWsWqdteFu LpOY66xBiyrJKAKi7rPwD1+CU5/atbdPuOM5end9eBdjoLqwPtZXId1xlYArJy5cmOB6 XIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140120; x=1697744920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=071vttQwsRtHTk9tdWp1lQy+KTSRjIxShniNeq+GU3Y=; b=McfCikM8bZZMfGc//noC6jRNyku/gGQ8Npn/v+J4iYv9IL4Q1qhG7kGtOCa1mpDMzF w/8QbZTTA4uQKaiwfPeesHca3xiRqGfrRfNFGZX0bpcMcR2RC4hkQ3ZUcEQiFx01ac1r ZrcbwjKbxdzACYgYlpRHui/hRbAesni4rLwa/baqNDnWTmnMGI9ngxPX5RcUZGA/OYsS IgxA9ykYMgxBJMgS4d82+LFJCP+96Rc4ARUqZZG9bSTOFGc2sx8ZguhrwVY2IlqJYRFO 2DgRr5ekraY2EgYtEf+g6DnvCzdZdu1WDMqgVevE8+GcEZ4sW5hBySD4f9gmnUxwDbAI 8m3w== X-Gm-Message-State: AOJu0YwlfOeVil60g7/vS7JAMqqPnTZUSdsQOZhLsc8SKOW4PcQVarzu uqoH/HnJzFrjDOY29hHidgx2CTbxKweoFw== X-Google-Smtp-Source: AGHT+IECRXAFW385uWrPn0wiuesUrL7Wi11XXQJywiummqTkx/9vrEOfgiOGgMFRJ0iACAXIrGO8vw== X-Received: by 2002:a5d:990f:0:b0:794:d833:4a8a with SMTP id x15-20020a5d990f000000b00794d8334a8amr26752167iol.0.1697140120027; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:39 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 03/10] dyndbg: add 2nd cursor pair to init-fn Date: Thu, 12 Oct 2023 13:48:27 -0600 Message-ID: <20231012194834.3288085-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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 dynamic_debug_init(), add 2nd cursor pair to walk the __dyndbg_sites section in parallel with the __dyndbg section. This avoids using the _ddebug.site pointer during initialization, which is a 1st step towards dropping the member entirely, and reducing the struct size and section footprint. no functional change Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0ad9f1bc00f0..51af6a75ae92 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1501,6 +1501,7 @@ static int __init dynamic_debug_init_control(void) =20 static int __init dynamic_debug_init(void) { + struct _ddebug_site *site, *site_mod_start; struct _ddebug *iter, *iter_mod_start; int ret, i, mod_sites, mod_ct; const char *modname; @@ -1508,9 +1509,11 @@ static int __init dynamic_debug_init(void) =20 struct _ddebug_info di =3D { .descs =3D __start___dyndbg, + .sites =3D __start___dyndbg_sites, .classes =3D __start___dyndbg_classes, .class_users =3D __start___dyndbg_class_users, .num_descs =3D __stop___dyndbg - __start___dyndbg, + .num_sites =3D __stop___dyndbg_sites - __start___dyndbg_sites, .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, .num_class_users =3D __stop___dyndbg_class_users - __start___dyndbg_clas= s_users, }; @@ -1533,16 +1536,19 @@ static int __init dynamic_debug_init(void) return 0; } =20 + site =3D site_mod_start =3D di.sites; iter =3D iter_mod_start =3D __start___dyndbg; modname =3D desc_modname(iter); i =3D mod_sites =3D mod_ct =3D 0; =20 - for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { =20 if (strcmp(modname, desc_modname(iter))) { mod_ct++; di.num_descs =3D mod_sites; + di.num_sites =3D mod_sites; di.descs =3D iter_mod_start; + di.sites =3D site_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1550,10 +1556,13 @@ static int __init dynamic_debug_init(void) mod_sites =3D 0; modname =3D desc_modname(iter); iter_mod_start =3D iter; + site_mod_start =3D site; } } di.num_descs =3D mod_sites; + di.num_sites =3D mod_sites; di.descs =3D iter_mod_start; + di.sites =3D site_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 1B76ACDB46E for ; Thu, 12 Oct 2023 19:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442952AbjJLTt1 (ORCPT ); Thu, 12 Oct 2023 15:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442789AbjJLTtD (ORCPT ); Thu, 12 Oct 2023 15:49:03 -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 DDC12D61 for ; Thu, 12 Oct 2023 12:48:41 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79fce245bf6so53221239f.1 for ; Thu, 12 Oct 2023 12:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140121; x=1697744921; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=te8bxAntMAIcUysxac/XF+SiTDKrojbnDxZw68jqwCo=; b=DxmPRx4UiAZlzBSXiZ2shoT9t033IefvbTTXhhNsoooGn7KhIfGv5CBjz4s9cFiyYw 7QXPd/sLGVFKzVbkeVVk09ClaKKIhkMEvxaEzfUrcCfpUzSTsnUIVNelEKvdI/bj3+T7 +rVktLl1IVg842mF3LeGHsK6irZFY9/b76Gc803iMiZDKCUae2hV8KcZgXai4MVVJt89 d4WP+bUc5Hc9s6SN4PcmqfLzCMTGyXxY4sdO1YjirRZs//cwOsvI7/hHqotyEnH1erae grOV+yNEaoQ1bqKUsocwCkO5QR/obpHl4yt4yLAnZpeaeIQbb9II+kwHqiZh8f+stK0L HNmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140121; x=1697744921; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=te8bxAntMAIcUysxac/XF+SiTDKrojbnDxZw68jqwCo=; b=PGzta50/QYsk4oZA7uvkfgwFIW3835yX3df9L2KfLLMJddbHaAkn5tyLDna8WbvZE/ b1bKdo9eAeZZ3hPKSAZe4FJr09MTEwsmNgnhh3ml24TthOSZXRkdQwEqybwuo7E0uM4Z VJQifLH0tPJWWZjOfgJT8AfPUEWwpxoFZDhi2m8Q1xi7hMb+eQpSLbITZN9K3ZHMCDMY z1malddFwldX8pY76S329kOq5sVkVsvc3VXAOw7ltYPGPpPMAX58smc6BNLR9CBUvs0Y dwgRWXiW5Ccxx39ru4P/WUNjb4JA/D//j0HyoqMiKlLeKSYaneooPM1AvQf4rmegRsO3 h7LA== X-Gm-Message-State: AOJu0YwWkI1nz+/0MigosyqjlqPNyWcKcYSp+rkkZtXEsaJJDPDtLhk3 VF7OWgjQWie0FnjzzLVU3xCdlSBKhRPwcw== X-Google-Smtp-Source: AGHT+IH7Q0tZJDS4rnV1h1A7dfwtAKU66e0auNCbZdhdzYU7yxzCJw57bGNtF534Ne+eXLim0uw81A== X-Received: by 2002:a6b:7e05:0:b0:79f:cb49:f476 with SMTP id i5-20020a6b7e05000000b0079fcb49f476mr26160758iom.21.1697140120888; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:40 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie , Matthew Wilcox Subject: [RFC PATCH 04/10] dyndbg: save _ddebug_site mod,file,func fields into maple-trees Date: Thu, 12 Oct 2023 13:48:28 -0600 Message-ID: <20231012194834.3288085-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" The __dyndbg_sites section contains the "code organization" hierarchical callsite info used to select & alter pr_debugs. The table's 3 columns: modname, filename, function have substantial repetition; this can be efficiently represented with intervals/ranges. So this add 3 private maple trees, and ddebug_add_module() now calls new ddebug_condense_sites() to scan the module's ddebug_sites, find the 3 intervals, and call dd_store_range() to save them into their respective trees. dd_mt_scan() iterates thru these 3 trees and prints to syslog, it is exposed via /sys/module/dynamic_debug/parameters/do_scan to give some observability/testability. 3 accessors are coded, but unused atm. Some Invariants (not all are relevant): the pr_debugs are strictly "sorted" by linkage order; that is by module, filename, function, line. The 1st 3 are pointers into some string table(s)? somewhere. repeating column values are identical pointers, not just strcmp equal. the descriptors (for builtin modules' or a loadable module) are all in narrow/high memory ranges. They wont conflict with maple-tree's 0-4096 value constraints. the string table also has a knowable limited address range, or there could be 3 tables, one for each column. The table(s) contents may also be sorted by linkage order. Again, this might be useful. the lineno is not repeating, except for some rare nested macro expansions (amdgpu iirc, its not important). NOTES: I tried, but didnt succeed, to combine all 3 nested intervals into one tree. This is what I thought: ISTM (1/2 baked WAG): - the 3 columns could be compactly rep'd with run-length-encoding. - the repeating blocks are intervals. - the linker guarantees full ordering. - maple-tree is good at these kind of intervals. - using &descriptor (align-8) as insertion index provides gaps. - inserting markers at those gaps allows "nesting" intervals. The nested intervals of the columns' repetitions could be carefully packed into a maple-tree, and efficiently retrieved. So this tries: adds a maple-tree field: _ddebug_info.sites_mt, to hold a compressed copy of the .sites table. ddebug_add_module() calls new ddebug_condense_sites(*_ddebug_info), which scans the descriptors, finds the spans for each function, and stores it as a range into the maple-tree, with 1st descriptor as index. Some of those intervals also start larger filename and module intervals, we mark these by inserting the file/module value just "before" the function-range just stored. This depends upon the align(8) of all descriptor pointers to afford the -1 and -2 offsets for the= modname and filename en [ 2.340903] dyndbg: add-module: i2c_designware_core 10 sites 0.0 classes= .refs [ 2.341161] dyndbg: mod name: i2c_designware_core ffffffff8311a43d [ 2.342045] dyndbg: file name: drivers/i2c/busses/i2c-designware-common= .c ffffffff8311a43e [ 2.342155] dyndbg: function: i2c_dw_handle_tx_abort, 1 debugs ffffffff= 8311a440-ffffffff8311a468 [ 2.343151] dyndbg: function: i2c_dw_set_sda_hold, 1 debugs ffffffff831= 1a468-ffffffff8311a490 [ 2.344155] dyndbg: file name: drivers/i2c/busses/i2c-designware-master= .c ffffffff8311a48e [ 2.345150] dyndbg: function: i2c_dw_init_recovery_info, 1 debugs fffff= fff8311a490-ffffffff8311a4b8 [ 2.346151] dyndbg: function: i2c_dw_isr, 1 debugs ffffffff8311a4b8-fff= fffff8311a4e0 [ 2.347151] dyndbg: function: i2c_dw_xfer, 1 debugs ffffffff8311a4e0-ff= ffffff8311a508 [ 2.348151] dyndbg: function: i2c_dw_set_timings_master, 4 debugs fffff= fff8311a508-ffffffff8311a5a8 [ 2.349165] dyndbg: file name: drivers/i2c/busses/i2c-designware-slave.= c ffffffff8311a5a6 [ 2.350152] dyndbg: function: i2c_dw_isr_slave, 1 debugs ffffffff8311a5= a8-ffffffff8311a5d0 [ 2.351154] dyndbg: 10 debug prints in module i2c_designware_core intervals of those called by a , to scan the .sites table, and do mtree_insert() to save each new module, filename, or function found. The insert index is offset by -N=3D3,2,1 for the respective columns. TODO: use mtree_store_range(), with 0 offset, for function blocks. This does a few things: - it encodes the kind of interval (function, filename, modname). - it yields a pre-order, top-down traversal: modname, filename, function this is ddebug_condense_sites() in action: [ 1.506878] dyndbg: add-module: kobject 10 sites 0.0 [ 1.507383] dyndbg: modname: kobject [ 1.507763] dyndbg: filename: lib/kobject.c [ 1.507877] dyndbg: function: kset_release [ 1.508305] dyndbg: function: dynamic_kobj_release [ 1.508803] dyndbg: function: kobject_cleanup [ 1.508880] dyndbg: function: __kobject_del [ 1.509313] dyndbg: function: kobject_add_internal [ 1.509817] dyndbg: function: fill_kobj_path [ 1.509882] dyndbg: 10 debug prints in module kobject [ 1.529907] dyndbg: 3424 prdebugs in 307 modules, 19 KiB .... And heres the tail of the test-mod's do_print traversal of the tree. kobject is the last builtin, i2c-piix4 is 1st loaded module. 2864 is #intervals, deduplicated from 3424 * 3 fields. Looks like a 62% shrink, if you squint. [ 142.226760] test_dd: 2854: kobject [ 142.227013] test_dd: 2855: lib/kobject.c [ 142.227285] test_dd: 2856: kset_release [ 142.227568] test_dd: 2857: dynamic_kobj_release [ 142.227885] test_dd: 2858: kobject_cleanup [ 142.228180] test_dd: 2859: __kobject_del [ 142.228456] test_dd: 2860: kobject_add_internal [ 142.228780] test_dd: 2861: fill_kobj_path [ 142.229069] test_dd: 2862: kobject_uevent [ 142.229356] test_dd: 2863: lib/kobject_uevent.c [ 142.229687] test_dd: 2864: kobject_uevent_env [ 142.229998] test_dd: 2865: i2c_piix4 [ 142.230253] test_dd: 2866: drivers/i2c/busses/i2c-piix4.c [ 142.230632] test_dd: 2867: piix4_transaction [ 142.230936] test_dd: 2868: piix4_setup_aux [ 142.231227] test_dd: 2869: piix4_setup_sb800 [ 142.231527] test_dd: 2870: piix4_setup [ 142.231806] test_dd: 2871: serio_raw [ 142.232066] test_dd: 2872: drivers/input/serio/serio_raw.c [ 142.232447] test_dd: 2873: serio_raw_reconnect [ 142.232769] test_dd: 2874: serio_raw_connect [ 142.233079] test_dd: 2875: intel_rapl_common [ 142.233375] test_dd: 2876: drivers/powercap/intel_rapl_common.c [ 142.233788] test_dd: 2877: rapl_remove_package [ 142.234107] test_dd: 2878: rapl_detect_domains [ 142.234417] test_dd: 2879: rapl_package_register_powercap [ 142.234798] test_dd: 2880: rapl_update_domain_data [ 142.235145] test_dd: 2881: rapl_check_unit_tpmi [ 142.235469] test_dd: 2882: rapl_check_unit_atom [ 142.235804] test_dd: 2883: rapl_check_unit_core [ 142.236131] test_dd: 2884: rapl_read_data_raw [ 142.236445] test_dd: 2885: contraint_to_pl [ 142.236756] test_dd: 2886: intel_rapl_msr [ 142.237053] test_dd: 2887: drivers/powercap/intel_rapl_msr.c [ 142.237446] test_dd: 2888: rapl_msr_probe [ 142.237742] test_dd: 2889: rapl_msr_read_raw [ 142.238048] test_dd: 2890: test_dynamic_debug [ 142.238355] test_dd: 2891: lib/test_dynamic_debug.c [ 142.238720] test_dd: 2892: test_dynamic_debug_exit [ 142.239058] test_dd: 2893: test_dynamic_debug_init [ 142.239395] test_dd: 2894: do_prints [ 142.239660] test_dd: 2895: do_levels [ 142.239924] test_dd: 2896: do_cats [ 142.240168] test_dd: 2897: test_dynamic_debug_submod [ 142.240521] test_dd: 2898: lib/test_dynamic_debug.c [ 142.240871] test_dd: 2899: test_dynamic_debug_exit [ 142.241183] test_dd: 2900: test_dynamic_debug_init [ 142.241484] test_dd: 2901: do_prints [ 142.241725] test_dd: 2902: do_levels [ 142.241962] test_dd: 2903: do_cats If this proves practical for accessors to traverse well (seems likely), it will be simple to: - move the 3 columns to _debug_site, linked from _ddebug - scan them at boot, copy to the tree - reclaim the whole memory block, which is all ptrs into a (one, or more/segmented) string.symbol table - store the &tree into struct _ddebug_info, for both builtins and modules Its slightly inconvenient that the fn-ptr is a string, with align(1), but the "encoding" done in ddebug_condense_sites() could force the insertion of an end-of-function-array token (marked by N, in &desc - N). With N=3D4, we'd get a marker ahead of module, yielding a proper "framing". The tree would be basically read-only for its respective lifetime, its presumed virtue for this app is primarily size, speed is bonus. (I probably need to look at advanced api...) I added the MT_FLAGS_ALLOC_RANGE flag to the tree, thinking maybe I could stuff the nested interval starters (each distinct function, filename, modname) into the internal RANGE containing nodes. Thats probably nonsense, but it helped me figure out the N option. (this needs further thinking) Then magically, an augmented _find would return a vector of modname, filename, function when needed. Or maybe a sequence of calls to mtree_find_upper_range() could collect the internal node values of the nested intervals {module, filename, function} a descriptor is part of. And thats about where the souffle collapses. Any suggestions ? And how to get the maple-tree size ? cc: Liam R. Howlett cc: Matthew Wilcox (Oracle) cc: linux-mm@kvack.org Cc: jbaron@akamai.com Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 142 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 51af6a75ae92..3dc17922a1d1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -25,6 +25,9 @@ #include #include #include + +#include + #include #include #include @@ -83,6 +86,32 @@ module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 =3D off (default), 1 =3D module add/rm, 2 =3D >control summary, 3 = =3D parsing, 4 =3D per-site changes)"); =20 +/* fill from __dyndbg_sites */ +static DEFINE_MTREE(mt_funcs); +static DEFINE_MTREE(mt_files); +static DEFINE_MTREE(mt_mods); + +static void dd_mt_scan(struct maple_tree *mt, const char *kind); +static int param_set_do_scan(const char *instr, const struct kernel_param = *kp) +{ + dd_mt_scan(&mt_funcs, "funcs"); + dd_mt_scan(&mt_files, "files"); + dd_mt_scan(&mt_mods, "mods"); + return 0; +} +static int param_get_do_scan(char *buffer, const struct kernel_param *kp) +{ + dd_mt_scan(&mt_funcs, "funcs"); + dd_mt_scan(&mt_files, "files"); + dd_mt_scan(&mt_mods, "mods"); + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); +} +static const struct kernel_param_ops param_ops_do_scan =3D { + .set =3D param_set_do_scan, + .get =3D param_get_do_scan, +}; +module_param_cb(do_scan, ¶m_ops_do_scan, NULL, 0600); + /* Return the path relative to source root */ static inline const char *trim_prefix(const char *path) { @@ -132,6 +161,7 @@ do { \ #define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__) #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) #define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) +#define v5pr_info(fmt, ...) vnpr_info(5, fmt, ##__VA_ARGS__) =20 static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { @@ -196,6 +226,48 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons #define desc_modname(d) (d)->site->_modname #define desc_filename(d) (d)->site->_filename #define desc_function(d) (d)->site->_function +/* + * tmp accessors, they cheat and seek a match in builtins. Obviously + * this wont work for loaded modules, but doesnt work at all yet. + */ +static const char * __desc_function(struct _ddebug const *dp) +{ + struct maple_tree *mt =3D &mt_funcs; + + void *ret =3D mtree_load(mt, (unsigned long)dp); + + if (ret !=3D desc_function(dp)) + pr_err("mt-load func %lx got %s want %s\n", + (unsigned long)dp, (char*)ret, desc_function(dp)); + + return ret; +} + +static const char * __desc_filename(struct _ddebug const *dp) +{ + struct maple_tree *mt =3D &mt_files; + + void *ret =3D mtree_load(mt, (unsigned long)dp); + + if (ret !=3D desc_filename(dp)) + pr_err("mt-load file %lx got %s want %s\n", + (unsigned long)dp, (char*)ret, desc_filename(dp)); + + return ret; +} + +static const char * __desc_modname(struct _ddebug const *dp) +{ + struct maple_tree *mt =3D &mt_mods; + + void *ret =3D mtree_load(mt, (unsigned long)dp); + + if (ret !=3D desc_modname(dp)) + pr_err("mt-load mod %lx got %s want %s\n", + (unsigned long)dp, (char*)ret, desc_modname(dp)); + + return ret; +} =20 /* * Search the tables for _ddebug's which match the given `query' and @@ -1314,6 +1386,74 @@ static void ddebug_attach_user_module_classes(struct= ddebug_table *dt, vpr_dt_info(dt, "attach-client-module: "); } =20 +/* + * use a maple-tree to hold the intervals in all 3 columns of the + * __dyndbg_sites section (struct _ddebug_sites table[]) + */ + +static void dd_mt_scan(struct maple_tree *mt, const char *kind) +{ + long unsigned int idx =3D 0; + void * ent; + int ct =3D 0; + + mt_for_each(mt, ent, idx, ULONG_MAX) { + v3pr_info(" %d: %lx %s\n", ct, idx, (char*)ent); + ct++; + } + v2pr_info("mt-%s has %d entries\n", kind, ct); +} + +static void dd_store_range(struct maple_tree *mt, const struct _ddebug *st= art, + const struct _ddebug *next, const char *kind, const char *name) +{ + unsigned long first =3D (unsigned long)start; + unsigned long last =3D (unsigned long)(next - 1); /* cast after decrement= */ + int rc, reps =3D next - start; + char *val; + + v3pr_info(" %s: %s,\t%d debugs %lx-%lx\n", kind, name, reps, first, last= ); + rc =3D mtree_insert_range(mt, first, last, (void*)name, GFP_KERNEL); + if (rc) + pr_err("%s:%s range store failed: %d\n", kind, name, rc); + else + v4pr_info(" OK %s: %s, %d debugs %lx-%lx\n", kind, name, reps, first, l= ast); + + val =3D (char*) mtree_load(mt, first); + if (!val) + pr_err("%s:%s find on range store failed\n", kind, name); + else + v4pr_info(" ok %s at %lx\n", val, first); +} + +static void ddebug_condense_sites(struct _ddebug_info *di) +{ + struct _ddebug *cur, *funcp, *filep, *modp; + int i; + + funcp =3D filep =3D modp =3D di->descs; + for_each_boxed_vector(di, descs, num_descs, i, cur) { + + if (!strcmp(desc_function(cur), desc_function(funcp))) + continue; + dd_store_range(&mt_funcs, funcp, cur, "func", desc_function(funcp)); + funcp =3D cur; + + if (!strcmp(desc_filename(cur), desc_filename(filep))) + continue; + dd_store_range(&mt_files, filep, cur, "file", desc_filename(filep)); + filep =3D cur; + + if (!strcmp(desc_modname(cur), desc_modname(modp))) + continue; + dd_store_range(&mt_mods, modp, cur, "mod", desc_modname(modp)); + modp =3D cur; + } + dd_store_range(&mt_funcs, funcp, cur, "func:", desc_function(funcp)); + dd_store_range(&mt_files, filep, cur, "file:", desc_filename(filep)); + dd_store_range(&mt_mods, modp, cur, "mod:", desc_modname(modp)); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1346,6 +1486,8 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) =20 INIT_LIST_HEAD(&dt->link); =20 + ddebug_condense_sites(di); + for_each_boxed_vector(di, descs, num_descs, i, iter) if (iter->class_id !=3D _DPRINTK_CLASS_DFLT) class_ct++; --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 87A5FCDB46E for ; Thu, 12 Oct 2023 19:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442845AbjJLTtX (ORCPT ); Thu, 12 Oct 2023 15:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442770AbjJLTtC (ORCPT ); Thu, 12 Oct 2023 15:49:02 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D537BD63 for ; Thu, 12 Oct 2023 12:48:42 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7a26fd82847so54099739f.3 for ; Thu, 12 Oct 2023 12:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140122; x=1697744922; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EdFWb7R/lDvUnWmGrNZ1doFLmbR1Cvf7k7ETF/HiAfA=; b=IaEYe1nTZEaIpCA9se3MpoM+juo8R3nesta7QigkJ4JNvr0oS2k60IH5V9bvUBzagV lZGzqKAN93ujVxk0TCBAlk6Dcik8Np+YjRU5gZmbGo9T3KtRN6YzGYJl1KLGhuIhrwCN p6QRHMGcLwgRwxmQHSgerbD2mmXwXKys43rEpRkJ8ebLP50+/kuyjqB0IvAXnRRri4PU rbYL/5zInDGFX3Y2QfSxv9MAqIYpF/cjSC9Quz0VHCuWs4GZ0MaL26I6iqH5v5WZ0o0D dIKZ+LUQIV+XaTnKJDLWhe50jNgD/VeDHxq2lI5nzm2/lxhk9bEV/fNOnMwHScHKkVx1 pnbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140122; x=1697744922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EdFWb7R/lDvUnWmGrNZ1doFLmbR1Cvf7k7ETF/HiAfA=; b=a/Dhv5FkQfrW3bH5IFRMjCQX+O3hlvy5/gMSBB115IR0dW5Zg9Wf4+lW42Xfb3YNfc a21FEIA0n9zoUdqdgAeA4RKSy/SPstl0qalE4h3AWSo5sIQADnKtw4KqoyyAXg1vOe89 Je33rDggfWDUzv7PYM+5i+ZgKsYDHeGrYJanWb5qMjEYxgTMapbbfXVFa6ILd42oN0zl pXv2cxSSQ3IvDhXLQhw4K/MrieZr1guGuKpeTrbp29TKe1+QvdId7MZ32xzpMEWRdh/B lSRTXzJqJAWFZY/cgdoPoFvKWeVEDhPISiGEH6esNviTBOXF2m3tlbgdht5Ragt6HpMN m4Aw== X-Gm-Message-State: AOJu0YwMgorF4tvZRdIEKGwSZXhcUmfObFWUTwVyvAtg/RK4pEvgt+hp AX0X/lY0BGigIT80dM2xE8Dir3kzHqtufA== X-Google-Smtp-Source: AGHT+IHB8Dgmlza+u38qD643ri3DiUTOqK9L6CK0JVBufkfHlFy0t26xGOhQZRYBrjCa8x/2Wi/a0g== X-Received: by 2002:a5d:9cd5:0:b0:79f:d4e6:5175 with SMTP id w21-20020a5d9cd5000000b0079fd4e65175mr28324749iow.16.1697140121898; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:41 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 05/10] dyndbg: avoid _ddebug.site in ddebug_condense_sites Date: Thu, 12 Oct 2023 13:48:29 -0600 Message-ID: <20231012194834.3288085-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" Modify the for-loop in ddebug_condense_sites() to walk thru both vectors: descs, sites in parallel. This requires a 2nd set of cursor variables (*_ds) that mark the start-of-range in the sites vector for the intervals to be dd_store_range()d. So also rename the old cursors (*_dd) for better consistency and readability. This is a partial step. It still uses the desc_*() macros to provide the values, and the macros use the site pointer. Next, we replace the macros with site_*(), passing the *_ds vars. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3dc17922a1d1..563d373224ba 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1426,32 +1426,41 @@ static void dd_store_range(struct maple_tree *mt, c= onst struct _ddebug *start, v4pr_info(" ok %s at %lx\n", val, first); } =20 + static void ddebug_condense_sites(struct _ddebug_info *di) { - struct _ddebug *cur, *funcp, *filep, *modp; + struct _ddebug_site *cur_ds, *func_ds, *file_ds, *mod_ds; + struct _ddebug *cur_dd, *func_dd, *file_dd, *mod_dd; int i; =20 - funcp =3D filep =3D modp =3D di->descs; - for_each_boxed_vector(di, descs, num_descs, i, cur) { + cur_dd =3D func_dd =3D file_dd =3D mod_dd =3D di->descs; + cur_ds =3D func_ds =3D file_ds =3D mod_ds =3D di->sites; + i =3D 0; + for (; i < di->num_descs; i++, cur_dd++, cur_ds++) { + + BUG_ON(site_function(cur_ds) !=3D desc_function(cur_dd)); =20 - if (!strcmp(desc_function(cur), desc_function(funcp))) + if (!strcmp(desc_function(cur_dd), desc_function(func_dd))) continue; - dd_store_range(&mt_funcs, funcp, cur, "func", desc_function(funcp)); - funcp =3D cur; + dd_store_range(&mt_funcs, func_dd, cur_dd, "func", desc_function(func_dd= )); + func_dd =3D cur_dd; + func_ds =3D cur_ds; =20 - if (!strcmp(desc_filename(cur), desc_filename(filep))) + if (!strcmp(desc_filename(cur_dd), desc_filename(file_dd))) continue; - dd_store_range(&mt_files, filep, cur, "file", desc_filename(filep)); - filep =3D cur; + dd_store_range(&mt_files, file_dd, cur_dd, "file", desc_filename(file_dd= )); + file_dd =3D cur_dd; + file_ds =3D cur_ds; =20 - if (!strcmp(desc_modname(cur), desc_modname(modp))) + if (!strcmp(desc_modname(cur_dd), desc_modname(mod_dd))) continue; - dd_store_range(&mt_mods, modp, cur, "mod", desc_modname(modp)); - modp =3D cur; + dd_store_range(&mt_mods, mod_dd, cur_dd, "mod", desc_modname(mod_dd)); + mod_dd =3D cur_dd; + mod_ds =3D cur_ds; } - dd_store_range(&mt_funcs, funcp, cur, "func:", desc_function(funcp)); - dd_store_range(&mt_files, filep, cur, "file:", desc_filename(filep)); - dd_store_range(&mt_mods, modp, cur, "mod:", desc_modname(modp)); + dd_store_range(&mt_funcs, func_dd, cur_dd, "func:", desc_function(func_dd= )); + dd_store_range(&mt_files, file_dd, cur_dd, "file:", desc_filename(file_dd= )); + dd_store_range(&mt_mods, mod_dd, cur_dd, "mod:", desc_modname(mod_dd)); } =20 /* --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 781DACDB46E for ; Thu, 12 Oct 2023 19:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442966AbjJLTtb (ORCPT ); Thu, 12 Oct 2023 15:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442434AbjJLTtE (ORCPT ); Thu, 12 Oct 2023 15:49:04 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AADC7BB for ; Thu, 12 Oct 2023 12:48:43 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fe6da0049so55267339f.1 for ; Thu, 12 Oct 2023 12:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140122; x=1697744922; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aeZlT3fWkSsRBBC0KH8nwdyunCgP5eGN9Bq/f3gwBO4=; b=V/v2dyJRdLMTggpwruH4K9XrHfEkCTLAqWlCyOMkdgwjUkNjOCIIqccC/qoqXSNf2c XNkv9sYmZKwCIxXQZ6cyBwgLZARmo+kf9YYNMeUQ3QTLHAxcycmHtfoUc6mnhnFfYqiv ZXGSZ3LFLm2voWs9aq5QgIFnLyEQgCPFOBeqSYqPQtq0kDZzhh5rIRmmyI3K48r6JU3R hYOxPcn5nI/wYYZiV8AZo8HYcgzFq1YJaOz/VKELkX+fes4x2NYGdc0A52mzAMpfd9hX n4OnG61M/VMC+2e7V3wuW/mTodGuJPHiKXLGcUMmv0U1Q6XarAiYXocZjGE+NA/pZhIw wjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140122; x=1697744922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aeZlT3fWkSsRBBC0KH8nwdyunCgP5eGN9Bq/f3gwBO4=; b=WNe+5/bz4r52wYs9GWSZITzhKHVUYDuXYgEDk2nWfoPsTNUSRNityldDGTFhfVt7hJ asyF5ydA/aOGhbB7ILcWLKngJs0MFHTpcjWTyUDtyZnBdXpA65tXhQDCSTTPQPbX/kY0 S0aO2CcTd6qCspEriByNBwzWnDRcm84gkHOvDiugTamFs3J60WHS+NV82tJi9JS4jGO+ O6sjcwvNtYEbNdW1aKNA8RUnoqb8Dfud56jBoVOloy6lu0kYZgjOLqJPRphBtxgd/JVZ qGxeBJ2UWGkoHq+GJzHCg0MRR2uzJ85EsnCMJVhBpZjbisTsJiKvpS6ZvZfD1XWBPPLb epfQ== X-Gm-Message-State: AOJu0Yyednk+ENoJOYsASZQQMxvmoI/RJflAQUurKQB2xNTyZGcxLDFD snjOZ8sY97eP7bbwIp3PR9IXQNcr7sV2BQ== X-Google-Smtp-Source: AGHT+IFFhJf/S6gN8jP4a20rhHTQC/HvlBHfDKD0Jy1c5AB7c08SdgSogYnGLzu7Mmjg+FissnHXPA== X-Received: by 2002:a5e:8c0c:0:b0:794:efb0:83d6 with SMTP id n12-20020a5e8c0c000000b00794efb083d6mr30403278ioj.12.1697140122710; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:42 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 06/10] dyndbg: add site_*() macros to avoid using _ddebug.site Date: Thu, 12 Oct 2023 13:48:30 -0600 Message-ID: <20231012194834.3288085-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" adjust ddebug_condense_sites() and dynamic_debug_init() to replace desc_*() uses with new site_*() macros which avoid the _ddebug.site pointers by relying upon site* cursors instead. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 563d373224ba..48564625a37e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1426,6 +1426,9 @@ static void dd_store_range(struct maple_tree *mt, con= st struct _ddebug *start, v4pr_info(" ok %s at %lx\n", val, first); } =20 +#define site_function(s) (s)->_function +#define site_filename(s) (s)->_filename +#define site_modname(s) (s)->_modname =20 static void ddebug_condense_sites(struct _ddebug_info *di) { @@ -1440,27 +1443,27 @@ static void ddebug_condense_sites(struct _ddebug_in= fo *di) =20 BUG_ON(site_function(cur_ds) !=3D desc_function(cur_dd)); =20 - if (!strcmp(desc_function(cur_dd), desc_function(func_dd))) + if (!strcmp(site_function(cur_ds), site_function(func_ds))) continue; - dd_store_range(&mt_funcs, func_dd, cur_dd, "func", desc_function(func_dd= )); + dd_store_range(&mt_funcs, func_dd, cur_dd, "func", site_function(func_ds= )); func_dd =3D cur_dd; func_ds =3D cur_ds; =20 - if (!strcmp(desc_filename(cur_dd), desc_filename(file_dd))) + if (!strcmp(site_filename(cur_ds), site_filename(file_ds))) continue; - dd_store_range(&mt_files, file_dd, cur_dd, "file", desc_filename(file_dd= )); + dd_store_range(&mt_files, file_dd, cur_dd, "file", site_filename(file_ds= )); file_dd =3D cur_dd; file_ds =3D cur_ds; =20 - if (!strcmp(desc_modname(cur_dd), desc_modname(mod_dd))) + if (!strcmp(site_modname(cur_ds), site_modname(mod_ds))) continue; - dd_store_range(&mt_mods, mod_dd, cur_dd, "mod", desc_modname(mod_dd)); + dd_store_range(&mt_mods, mod_dd, cur_dd, "mod", site_modname(mod_ds)); mod_dd =3D cur_dd; mod_ds =3D cur_ds; } - dd_store_range(&mt_funcs, func_dd, cur_dd, "func:", desc_function(func_dd= )); - dd_store_range(&mt_files, file_dd, cur_dd, "file:", desc_filename(file_dd= )); - dd_store_range(&mt_mods, mod_dd, cur_dd, "mod:", desc_modname(mod_dd)); + dd_store_range(&mt_funcs, func_dd, cur_dd, "func:", site_function(func_ds= )); + dd_store_range(&mt_files, file_dd, cur_dd, "file:", site_filename(file_ds= )); + dd_store_range(&mt_mods, mod_dd, cur_dd, "mod:", site_modname(mod_ds)); } =20 /* @@ -1688,13 +1691,13 @@ static int __init dynamic_debug_init(void) } =20 site =3D site_mod_start =3D di.sites; - iter =3D iter_mod_start =3D __start___dyndbg; - modname =3D desc_modname(iter); + iter =3D iter_mod_start =3D di.descs; + modname =3D site_modname(site); i =3D mod_sites =3D mod_ct =3D 0; =20 for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) { =20 - if (strcmp(modname, desc_modname(iter))) { + if (strcmp(modname, site_modname(site))) { mod_ct++; di.num_descs =3D mod_sites; di.num_sites =3D mod_sites; @@ -1705,7 +1708,7 @@ static int __init dynamic_debug_init(void) goto out_err; =20 mod_sites =3D 0; - modname =3D desc_modname(iter); + modname =3D site_modname(site); iter_mod_start =3D iter; site_mod_start =3D site; } --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 95211CDB46E for ; Thu, 12 Oct 2023 19:49:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442585AbjJLTtt (ORCPT ); Thu, 12 Oct 2023 15:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442241AbjJLTtE (ORCPT ); Thu, 12 Oct 2023 15:49:04 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B3AEEA for ; Thu, 12 Oct 2023 12:48:44 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7a5a746e355so34119039f.0 for ; Thu, 12 Oct 2023 12:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140123; x=1697744923; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mIhMRd3PEDx8wYJmsgE6KV38zHdcvoV+qxdam6F9QaA=; b=f10FnZJ6oT5AtiE5JmcGHWt/EkOOVPUZ+pea27CHhT2KSZ2VmVloRtsrdCXWw5gwXc GwnrVy5iZiCPzK+xzo9i/+1CdmXd35IunjqEeK+dTsgPWfPksQsj0w19HTFCW+vA623o BnDqCZfhnCFoDEMXiTrI4pe/Z2iOM/Hmy/wnOr/2elXDmNRl+6mynac5PUd/6hul08xi zPbu7E3pJTpkCZZOOGApAgso/PWAWIOOTT9aMLNYZgKfHH0ChtOSktOVEfa1YRdaOYMK YWoCUlQkNL4E9HDNlX2f1d66Z227crMPPQessRkFj5SFTx2kAEv7uSTYcmSVx5aFlkKZ bYEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140123; x=1697744923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mIhMRd3PEDx8wYJmsgE6KV38zHdcvoV+qxdam6F9QaA=; b=I6/yoIpjr5Y+zZ+B+j7Yzf6aJW/tahLc8UHrr5TPt1zuanOf9BXGOk29pV5JGEwGwr fHIaeaQqNNzbxDxeRXXTmwQCsqLJ0hs0qUjalhMXufFIT1vgV2gMhzGucI97uGO/vYVy u8+RGb63G1NgzeQ3jJHlgDRLNPCIvSa+KiJ+vlE6ZbVarCKX9hJyoq/RLxrBQ2RWuLGQ UUkwXEjVc0qUkuUEE3igr8B6FMtvZpAIigTB7osdDvGhDWLU6W7DzXk4fEeVW/n8CO0R vONzips6j6J6gX7OF1l5mK7Ax2Zy1MMczwieO0Y9TfOE4AZ/TRYvmxeK+92mGhmx5XHB r1Lw== X-Gm-Message-State: AOJu0YwNIN+Sd+3k8v5iscFR8PTD/sRLQZWpowZSKw1ZTZViBjUZFTR8 wYLEhhKInl4cFOLV1UW1XVxryUbaJxwb/Q== X-Google-Smtp-Source: AGHT+IHqH6cUbDs8xrXZJT4gDhu6yQsXMA72pQaQVz1Yklqvjqho03n48wy4VfixJtREREl3H41tPA== X-Received: by 2002:a05:6602:2014:b0:791:8f62:31ef with SMTP id y20-20020a056602201400b007918f6231efmr17972840iod.5.1697140123589; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:43 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 07/10] dyndbg: wire in __desc_*() functions Date: Thu, 12 Oct 2023 13:48:31 -0600 Message-ID: <20231012194834.3288085-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" change desc_*() macros to call __desc_*() functions, and #if 0 the comparisons to the site->_* ref. This makes the _ddebug.site pointer unneccesary. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 48564625a37e..fb72a7b05b01 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -223,9 +223,9 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return NULL; } =20 -#define desc_modname(d) (d)->site->_modname -#define desc_filename(d) (d)->site->_filename -#define desc_function(d) (d)->site->_function +#define desc_modname(d) __desc_modname(d) +#define desc_filename(d) __desc_filename(d) +#define desc_function(d) __desc_function(d) /* * tmp accessors, they cheat and seek a match in builtins. Obviously * this wont work for loaded modules, but doesnt work at all yet. @@ -235,11 +235,11 @@ static const char * __desc_function(struct _ddebug co= nst *dp) struct maple_tree *mt =3D &mt_funcs; =20 void *ret =3D mtree_load(mt, (unsigned long)dp); - +#if 0 if (ret !=3D desc_function(dp)) pr_err("mt-load func %lx got %s want %s\n", (unsigned long)dp, (char*)ret, desc_function(dp)); - +#endif return ret; } =20 @@ -248,11 +248,11 @@ static const char * __desc_filename(struct _ddebug co= nst *dp) struct maple_tree *mt =3D &mt_files; =20 void *ret =3D mtree_load(mt, (unsigned long)dp); - +#if 0 if (ret !=3D desc_filename(dp)) pr_err("mt-load file %lx got %s want %s\n", (unsigned long)dp, (char*)ret, desc_filename(dp)); - +#endif return ret; } =20 @@ -261,11 +261,11 @@ static const char * __desc_modname(struct _ddebug con= st *dp) struct maple_tree *mt =3D &mt_mods; =20 void *ret =3D mtree_load(mt, (unsigned long)dp); - +#if 0 if (ret !=3D desc_modname(dp)) pr_err("mt-load mod %lx got %s want %s\n", (unsigned long)dp, (char*)ret, desc_modname(dp)); - +#endif return ret; } =20 @@ -1441,7 +1441,7 @@ static void ddebug_condense_sites(struct _ddebug_info= *di) i =3D 0; for (; i < di->num_descs; i++, cur_dd++, cur_ds++) { =20 - BUG_ON(site_function(cur_ds) !=3D desc_function(cur_dd)); + //BUG_ON(site_function(cur_ds) !=3D desc_function(cur_dd)); =20 if (!strcmp(site_function(cur_ds), site_function(func_ds))) continue; --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 4C351CDB46E for ; Thu, 12 Oct 2023 19:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442972AbjJLTte (ORCPT ); Thu, 12 Oct 2023 15:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442495AbjJLTtE (ORCPT ); Thu, 12 Oct 2023 15:49:04 -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 EC279D66 for ; Thu, 12 Oct 2023 12:48:45 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-79fa5d9f3a2so54899639f.3 for ; Thu, 12 Oct 2023 12:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140124; x=1697744924; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Iuwbt1McOcGdkIO7L8zjw1pQxOK6ynndpanb3dr/E5o=; b=hBdC0aeRhkFt6qFdVdZrUldD0geIWMvkPWvEdY+8+wKvzk/N42lapeJXf0eKEp2Y4/ cEr5kEJhNxnxnuMImO4IVWgkxnoAzcRK/dZA79XqKNTamzOvYakgr46vzBGcgDHP6eMl AqculhA/pZY4di+v+riFCqDf6Drxqn1JjLcXLtLsKDFQEm+fG+yc5louOman+nM9OVC/ qE9btNapd5dPb0wrtCPvpaYMuDRs6kdZ8b35YqoeirtjrYexClOwmTVSEUq8jFmcMoEX 427F6gZOCzY4nemT9BQk1cjMAXfmGjER8oFTeBpljQqV4SLMWN6Tk9hFoz7cXI/tAwYJ KCVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140124; x=1697744924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iuwbt1McOcGdkIO7L8zjw1pQxOK6ynndpanb3dr/E5o=; b=QYpzLOKTRB7I/Urex7sXYAv1l/6HzVtEfRTUUV1ElpGTe1v+IGzIQvMeP47X+u8joP i/8aJ9aiucEON6S/CIv3s0wcPwl6F5U+S56/gdx/JdEDqaQ4OXgXg9O/t2EBNeNr76p3 qlaD4jEjm40PAyPF3Xsh5Ls2nhcDfnoV0qnIImB1cM13tfLl6fRqY9uO74fNnrpJ9Rz+ B/XoNYGf4339a96gWvtJUch2r1PirQPMKFFAvQtX0yjdOh/Jp78BBy7iACSq/6YBVwV8 ulWH0y7txD0iaRXLSWUFLW8N4nNnqehnvOPyQTaHrlYwZWqqp4F/fBC/7VDMZbpyU1Ri YK9Q== X-Gm-Message-State: AOJu0YxQcBvd4xNNRhmOYgMDPdhYEXFpc32ml0zLHkf8VA5q/sMAdAlc iWFHD66aWe4H+aij7t8nv82nFjEKh495lw== X-Google-Smtp-Source: AGHT+IHlxTW+J6rW7Zd2Pq9sVXFhxqom9NxXG/NPLrr0aum2XInHvnhwAk/EyR/uZTaVq9k5JHvdXg== X-Received: by 2002:a6b:d81a:0:b0:792:82f8:749d with SMTP id y26-20020a6bd81a000000b0079282f8749dmr30579249iob.10.1697140124637; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:44 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 08/10] dyndbg: drop _ddebug.site member Date: Thu, 12 Oct 2023 13:48:32 -0600 Message-ID: <20231012194834.3288085-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" drop site ptr, and rely upon the maple-tree intervals loaded by ddebug_condense_sites(). In DEFINE_DYNAMIC_DEBUG_METADATA_CLS(), which creates a pair of _ddebug & _ddebug_site structs, add '__used' to the latter, because it is no longer linked from the former, and then also to the former, so they both have the same number of entries. Replace the BUG_ON with a pr_warn that shows the size of the mismatch. TODO: sort out where the extra records are coming from. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 5206a2cfdb37..406b30d8eb98 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -27,7 +27,6 @@ struct _ddebug_site { }; =20 struct _ddebug { - struct _ddebug_site *site; const char *format; unsigned int lineno:18; #define CLS_BITS 6 @@ -228,13 +227,12 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, ._filename =3D __FILE__ =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ - static struct _ddebug_site __aligned(8) \ + static struct _ddebug_site __used __aligned(8) \ __section("__dyndbg_sites") name ##_site =3D { \ DYNAMIC_DEBUG_SITE_INIT(), \ }; \ - static struct _ddebug __aligned(8) \ + static struct _ddebug __used __aligned(8) \ __section("__dyndbg") name =3D { \ - .site =3D &(name ##_site), \ .format =3D (fmt), \ .lineno =3D __LINE__, \ .flags =3D _DPRINTK_FLAGS_DEFAULT, \ --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 7E734CDB46E for ; Thu, 12 Oct 2023 19:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442815AbjJLTtp (ORCPT ); Thu, 12 Oct 2023 15:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442498AbjJLTtE (ORCPT ); Thu, 12 Oct 2023 15:49: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 A5A75F2 for ; Thu, 12 Oct 2023 12:48:46 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-79f8e4108c3so56712339f.3 for ; Thu, 12 Oct 2023 12:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140125; x=1697744925; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jr8tQe/cDXue74QN3U0cEdutzIhNedVe/s3FJQcenu4=; b=e7ehBdN0Hj7qDVEmvjtpYo8SwEzPtQYh7dyo0Joy6xXbBNpBAXWJJsXrrQejQMZwLZ m+DzVhlanc+uzLVdKnILthdQtdF/Zci59hUSsoVY78To2CMubHU0no12t605way0wi30 1TrVkLFLg+6zGtQU9uRoCTjbmRwFx3IZt1wlyHiaOa8VAkdGFZCdz/y/z7MnOHbpiaOE wItot+Jrcy+LvHuixIYZxEGE/T+IqYCir1yf1DrqEnqGE/1QWgUthQG1IY6m0SO7kS9j 4GsVN1xc8fnSE+UtCvzQV1cZE7RNX6YZC9VIjZZrw4aVpmvJ28fDWOSalLyAXdInX7u6 Nm1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140125; x=1697744925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jr8tQe/cDXue74QN3U0cEdutzIhNedVe/s3FJQcenu4=; b=KBrXaw3SfcxKQpwjWRO+xDgP5lQSl1QOxGZ5OCBbIGIiR0G5Hd1pjqUuoBwOrowQ0k 1xkW6nVkjRJXbUzYu3LBQ3h0Fn42pZCIQwlQEEOEtkl6kOKLkiBiMQVkhKD95rIM5sOh LnFEZHiyYaYSqNksvcj0irY5A4FiX01aEFYWpWNiuGL163FiHIRuYBLem8+Rko8+Q9nC V1M1dGBNrGQN3ItjLPFhOMyqBbACpPlahXBNIjpBQZdWA1fkf0QBoWD8nl/8z8eGc6jU 3cNf4M55HvVnxDN5LoX9Rv8UIShVEs1wFTGMi+WaPVDEbpWHUIvvEvr/YjUGnCeupPYW QDGQ== X-Gm-Message-State: AOJu0YyuTTJ7UZctFixhngk9wBzjOcj8QQtSKAnyMiNBqMM1HbLvSw+x yMZal2wxVpcJV3+wC3i8kYoDSpaUyB9yEg== X-Google-Smtp-Source: AGHT+IHSgCsSwzNOOD//3NxBGQTn9DS6okKVdysyhOSJ8KPygFQuinuZSyiQbCPBvDKULEXLusF2+g== X-Received: by 2002:a5d:9ac4:0:b0:79f:d195:5384 with SMTP id x4-20020a5d9ac4000000b0079fd1955384mr27521944ion.17.1697140125638; Thu, 12 Oct 2023 12:48:45 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:45 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 09/10] dyndbg: add dd_clear_range to prune mtrees Date: Thu, 12 Oct 2023 13:48:33 -0600 Message-ID: <20231012194834.3288085-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" Call new dd_clear_range() from ddebug_remove_module(). It calls mtree_erase() on the trees storing the function, filename, modname intervals, and passing the 1st descriptor of the interval (ie the index used on the insert). dd_clear_range() should properly undo the 3 mtree_insert_ranges done by dd_store_range. RFC: it doesnt work as I expected. What am I missing ? The following log shows that 'rmmod amdgpu' only removes 1 entry from each maple-tree, not the whole interval. My index is the 1st descriptor in each interval. ISTM (naive reader) this contradicts the documented behavior. void *mtree_erase(struct maple_tree *mt, unsigned long index) Find an index and erase the entire range. what is my "entire range" ? bash-5.2# modprobe amdgpu .... [ 74.256006] dyndbg: attach-client-module: module:amdgpu nd:4652 nc:0 nu= :1 [ 74.256968] dyndbg: 4652 debug prints in module amdgpu bash-5.2# echo 2 > /sys/module/dynamic_debug/parameters/do_scan [ 81.370509] dyndbg: cache: funcs has 3741 entries [ 81.371233] dyndbg: cache: files has 911 entries [ 81.371819] dyndbg: cache: mods has 323 entries bash-5.2# rmmod amdgpu [ 102.325851] dyndbg: removed module "amdgpu" bash-5.2# echo 2 > /sys/module/dynamic_debug/parameters/do_scan [ 105.277439] dyndbg: cache: funcs has 3740 entries [ 105.278163] dyndbg: cache: files has 910 entries [ 105.278756] dyndbg: cache: mods has 322 entries cc: Liam R. Howlett cc: linux-mm@kvack.org Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fb72a7b05b01..92ffd70a07de 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1426,6 +1426,14 @@ static void dd_store_range(struct maple_tree *mt, co= nst struct _ddebug *start, v4pr_info(" ok %s at %lx\n", val, first); } =20 +static void dd_clear_range(const struct _ddebug *start) +{ + v3pr_info("clearing %px\n", start); + mtree_erase(&mt_funcs, (unsigned long)start); + mtree_erase(&mt_files, (unsigned long)start); + mtree_erase(&mt_mods, (unsigned long)start); +} + #define site_function(s) (s)->_function #define site_filename(s) (s)->_filename #define site_modname(s) (s)->_modname @@ -1578,6 +1586,8 @@ static int ddebug_remove_module(const char *mod_name) mutex_lock(&ddebug_lock); list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { if (dt->mod_name =3D=3D mod_name) { + /* free mtree entries on descs */ + dd_clear_range(dt->ddebugs); ddebug_table_free(dt); ret =3D 0; break; --=20 2.41.0 From nobody Tue Dec 16 19:54:04 2025 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 AE6C8CDB46E for ; Thu, 12 Oct 2023 19:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442881AbjJLTtl (ORCPT ); Thu, 12 Oct 2023 15:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442582AbjJLTtF (ORCPT ); Thu, 12 Oct 2023 15:49:05 -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 E7617C9 for ; Thu, 12 Oct 2023 12:48:47 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7a2a9e5451bso55475239f.1 for ; Thu, 12 Oct 2023 12:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140127; x=1697744927; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q6n2IA/eHEf6LdvM5ZmMrOftNFYznxmP1Ujq1nl5xlM=; b=ltMEbFLkfKUnvfbMJ0YNOCO3bEbsAjJrVlLkE0NspCBl1IhQ5KSDJt2Mq0GTzkjCaV H2V1TT8bfHHPsq9g9WJxTUwHaMHs0GEs4cNUBAXmm/JVk1JxyAnbNCAQijtm9i6WsZwP lYge+IHeozBI1d7MApuLRXaKVyhLn0WfNn6N3w8AQI3lMa5DHnMQ0Sq0/6plxhZIOvpg TItZjKPdUKhva7gyDC8vX7CqsNIDlypRiJJqkLKVNAUHBOdvHS7P9qYHZFj32sRFujac Y+20Xx7SNVQuYWkN+tJFegLNWvtnQHlglc8Rkyl/dQ0MFr7ADGHl5izN+hqD6rcRl3PQ LOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140127; x=1697744927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q6n2IA/eHEf6LdvM5ZmMrOftNFYznxmP1Ujq1nl5xlM=; b=Imsn6FmFQs689EIIxCYYE2P6PN0OwJb0nbdiuubnGhIHAtGDxWmcjG/A70KgCjH4bN K8tfC81g4bx1nqI3jz/22NL9sG5A07m2qNkD3w13hSAzK4tUE0XMwEvg2D+3UqubOWbh +IlsIz6JT2UjcMQA82wLAcdTflbrcREut1B2+qOIAzwXMup44+LZcJMOGWhrSrBSQc6W JNVPhTDHlB29Yp9AWy0a+vbpua1dSeW47RXoJYZ3Uh/pt25O1yTyXFVSRN4Jce1AFoUv BUk8W2S1X9ljV3+RS0ZOQZITGippZBM9i8fBEl6FVGfAKmOWbTBoKm4oexb2kq1A166p XCTA== X-Gm-Message-State: AOJu0YzC+XBNTTRrRlX63jiiMCgr7JsOTmljmHlmHfWFQ2JupjNzikSy tOfuTTS19UF+yPD9w/z7C1XC/sFyWK0kWw== X-Google-Smtp-Source: AGHT+IEnq0smZ7G8P5z5vC02OT8MB+EcSRtbm1qklN4D/7Ye4KzZyrfDlCDnug/mqix5MN36Nab6Uw== X-Received: by 2002:a05:6602:29a3:b0:785:d4f5:2225 with SMTP id u3-20020a05660229a300b00785d4f52225mr28824779ios.19.1697140127022; Thu, 12 Oct 2023 12:48: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 h6-20020a5d9e06000000b007a25540c49bsm4307891ioh.27.2023.10.12.12.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:46 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH 10/10] dyndbg: cache the dynamically generated prefixes per callsite Date: Thu, 12 Oct 2023 13:48:34 -0600 Message-ID: <20231012194834.3288085-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com> References: <20231012194834.3288085-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" Add a private maple-tree to cache any prefix strings required (and then generated) for any enabled pr_debug callsites. And delete any cache entries if any flags are changed afterwards. This cache is strictly per-callsite, so if a function has 20 pr_debugs, all enabled with the same flags: echo function foo +pmfs > /proc/dynamic_debug/control there will be 20 separate, identical cache items created. Maybe this can be trivially improved later. Or lineno could be folded in too, so the %d is rendered once. NB: +tl flags are added outside the cache; the thread-id doesnt belong in the cache, the lineno could be added, esp if the 20:1 sharing isnt trivial enough. NBB: lineno:18 is enormously "sparse". At this point its not so far to pack it into something else. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 92ffd70a07de..02df61ab6403 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -90,6 +90,8 @@ MODULE_PARM_DESC(verbose, " dynamic_debug/control process= ing " static DEFINE_MTREE(mt_funcs); static DEFINE_MTREE(mt_files); static DEFINE_MTREE(mt_mods); +/* cache of composed prefixes for enabled pr_debugs */ +static DEFINE_MTREE(pr_prefixes); =20 static void dd_mt_scan(struct maple_tree *mt, const char *kind); static int param_set_do_scan(const char *instr, const struct kernel_param = *kp) @@ -112,6 +114,11 @@ static const struct kernel_param_ops param_ops_do_scan= =3D { }; module_param_cb(do_scan, ¶m_ops_do_scan, NULL, 0600); =20 +void ddebug_clear_prefix_cache(const struct _ddebug *dp) +{ + mtree_erase(&pr_prefixes, (unsigned long)dp); +} + /* Return the path relative to source root */ static inline const char *trim_prefix(const char *path) { @@ -350,6 +357,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, newflags =3D (dp->flags & modifiers->mask) | modifiers->flags; if (newflags =3D=3D dp->flags) continue; + ddebug_clear_prefix_cache(dp); #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { if (!(newflags & _DPRINTK_FLAGS_PRINT)) @@ -855,8 +863,18 @@ static int remaining(int wrote) return 0; } =20 -static int __dynamic_emit_prefix(const struct _ddebug *desc, char *buf, in= t pos) +static int __dynamic_emit_prefix(struct _ddebug *desc, char *buf, int pos) { + char *prefix, *cpy; + + if (desc->flags & _DPRINTK_FLAGS_PREFIX_CACHED) { + prefix =3D (char*) mtree_load(&pr_prefixes, (unsigned long)desc); + if (prefix) { + pos +=3D snprintf(buf + pos, remaining(pos), "%s", prefix); + v4pr_info("using prefix cache:%px %s", buf, buf + pos); + return pos; + } + } if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", desc_modname(desc)); @@ -866,6 +884,13 @@ static int __dynamic_emit_prefix(const struct _ddebug = *desc, char *buf, int pos) if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) pos +=3D snprintf(buf + pos, remaining(pos), "%s:", trim_prefix(desc_filename(desc))); + + /* save dup of buf to cache */ + cpy =3D kstrdup(buf + pos, GFP_KERNEL); + mtree_store(&pr_prefixes, (unsigned long)desc, (void*)cpy, GFP_KERNEL); + desc->flags |=3D _DPRINTK_FLAGS_PREFIX_CACHED; + v3pr_info("filling prefix cache:%px %s", desc, cpy); + return pos; } =20 --=20 2.41.0