From nobody Tue Dec 16 19:55:00 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 BAE32CDB46E for ; Thu, 12 Oct 2023 19:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442351AbjJLTrb (ORCPT ); Thu, 12 Oct 2023 15:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442384AbjJLTrZ (ORCPT ); Thu, 12 Oct 2023 15:47:25 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21B63CC for ; Thu, 12 Oct 2023 12:47:23 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-79fa2dbd793so56866339f.2 for ; Thu, 12 Oct 2023 12:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140042; x=1697744842; 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=BZSrpsKT+iXyEjxwx8qExQ5jbJURE1tIaq6sbZa88iYC2LxcIDV7mGsVoRmmGcgJVT lPcn9zFqF0kQOUFvJlkdDW+oDLVf8B2pQudENR05VD0Aim7mzkismDX4d9gZ4jIOQhfl 25ikzh6xGkUL/fsnLGplxHW2V/t0UtILKH3wcwR4zshIuqf0xGQEvpx8bi5VqdWhgkpf u1ofaoSGcwbD0GJ1tIplsA+X1enn7Tmv8ZzTZ9hJ3OSCnH8Q6bOSYm4Tq2VrzgurV8nF K62jhyOgbWiMYkB4CiL6ovr8bdncTSOZsZerSifreanchHAVCHP4XEAqGRB3hmhy4VzU CNWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140042; x=1697744842; 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=HRNu8HT2BYnkZlCId2fajmDIBX/4J6aKRbS955VYLknimA0xqiTpdwaKqASDd9VeIs kqe/FQmWDHRH5bp0HrthB/IL7HO8dySIZitYyCq7f/TisV8cfjKYUkZlE74UHdvuq6Ol P+9+A0jnxNM66gwXRhaS7/Fklcn/PDUhhct20o3Q20whjHqOM4gvNmrZNAh3tYP1/AD9 /JO4PCfgUVJYFLzfhLSWwbYmA1059pPUnfrPke8k8psYRqJMt+Mw2buxbASIyf6njWn3 ogI1ozxnqIYvFJ7v2rDAkC3TySvf4RZmj7udJnR2ps2XtnrD/kp9U4040jPamhXV96h9 pMwQ== X-Gm-Message-State: AOJu0YyDiofkH3dyTY2FqwLU1XjNnVuwCY0BYnkjFPpvT2ISoHldit+6 IoOkaUDO8/kyzb3HQexaD0pfG0vZk9+iyw== X-Google-Smtp-Source: AGHT+IGceM5gIpg13Xxjob+QcvLQXenti4VC6/T4P9oMFLg7p3XFso04Nihjee/j89Bz47ENyasfaw== X-Received: by 2002:a6b:fd01:0:b0:790:c3d0:8f87 with SMTP id c1-20020a6bfd01000000b00790c3d08f87mr26611201ioi.19.1697140042119; Thu, 12 Oct 2023 12:47:22 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:21 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:02 -0600 Message-ID: <20231012194711.3288031-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 23DF3CDB46E for ; Thu, 12 Oct 2023 19:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442624AbjJLTre (ORCPT ); Thu, 12 Oct 2023 15:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442490AbjJLTr0 (ORCPT ); Thu, 12 Oct 2023 15:47:26 -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 1D8B0CA for ; Thu, 12 Oct 2023 12:47:24 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79faba5fe12so50359439f.3 for ; Thu, 12 Oct 2023 12:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140043; x=1697744843; 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=asV4D3VDIcoFs14TDMo+umxWesa7DOb5lWJRw78cID4TkbBGE5ia03diFHQRkVjgxs SZISY4ykGmmsh8E1Njz9rNtsmoV67otGLBStoturNb/EVAKCdcNKIV4OiwCozcz1mCM/ ZNnzW8AdsludFXWcV0jhFFm38Bz5Mat82UnJXQZAdr/AacN7MVEv0Zt1LMq9s5kQqh/b JIvi4/rJko4hfEZeCtVuOVbF/Rk2Kg4g8wtS12/SCOIosn+p5ByIkPcr6NcXdAXOetbb AOq4JJiXudAz8CSXhgtEH5lpTx6b/DjjQGT+2QLAGTleASS19vdOTf+TRIvnIbRQE/cd bhPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140043; x=1697744843; 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=PSxdHVuRUa3q5YH5rhjvyiDW6JHce0j9a8LG6YNkFc1s3znyZAq9t+2iWWKEmZCz4t IUFDLPmhE9jFdCF0zhe6/MlUVtFhLO8CvUpWK8nM+ls3VakrEud63wdl/F1MP1irCJIC aoS4lCVEeeMBTo1NU3TyA49WAHT0xU92Z2fjMZyFSGyOvrpkqDBCwQIXHCJGlAzOpANx J09dkkHrM3LL+lYyhfMW51v94O7hJ3G+sTo8A7fcsSmu49DlxALJIu+mhGqnSXn6rR4q n5c9q8VmOdEBQJ04YZAFB+EJakBnCP8BJQ4MH32VLJidzyEpYxV/hnHSXO4YWPImcnDk MLrA== X-Gm-Message-State: AOJu0YxkxLmyM5Ot8d4LtrFhdPAVF5hmcAH0yxoq9aMG8sK2k4/PVR6D XhqvTZVgGkxcLfNJwLgxZYeaP+WOkucPOA== X-Google-Smtp-Source: AGHT+IEy5LUrHNrM8PB7Uq+J/5nUEH5hYYFEbdVHzf05PX1Vsvj59Q/FEZF7mdKvVdrY8dZihBpf9g== X-Received: by 2002:a5d:9943:0:b0:79f:d194:d6e2 with SMTP id v3-20020a5d9943000000b0079fd194d6e2mr28680189ios.10.1697140043212; Thu, 12 Oct 2023 12:47:23 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:22 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:03 -0600 Message-ID: <20231012194711.3288031-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 27C5ECDB483 for ; Thu, 12 Oct 2023 19:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442628AbjJLTrh (ORCPT ); Thu, 12 Oct 2023 15:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442416AbjJLTr0 (ORCPT ); Thu, 12 Oct 2023 15:47:26 -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 2AEE1D7 for ; Thu, 12 Oct 2023 12:47:25 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79fe87cd74eso53624839f.3 for ; Thu, 12 Oct 2023 12:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140044; x=1697744844; 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=dEdQySNxeH6BRAk/+ev1J5ZuaWr49h7kURh6eKxxY7YH6HS+yEJywgZEK3u0evpHlg N9P8zFw92jppvQm0JUE3rlN8BBUAmLwsmgCCy7RuzYFl+tPejRqqUzP4O5gbEi7eQUl6 8o4bp7U5uweqtv38huuAx67Tetxpwy4IhPJ0lgvULP+drbs1YmM7fr5WKljZiww8x75W B0hMrE+iKrI/Edu3lhrANGMO9uyhCCrmhUC54l8tusu19oAajZRQLsV0ig7WYN01TYeG NAdSH7IJlRP0m02GiuMIeum/i77kMJ3GdzItVi+lyMFDafzL/ztCzdajMuI2JEjOp+Dn 9AMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140044; x=1697744844; 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=D+0gjpSYSUbEa9lbhkVpPG8Q2Cy5RfvudYqPvLcmby7/L202npc6k7KF5M+1lJ3kqI Sz9mzo4avexZ8BRceR9y7dto07nly3n1II3NxP7o7JQi7YcBNbpYtHgt5h9Lm0B/cSYZ 9pDDu68+z/AqGp2w20hKiHxrXwbqafJPcubSKeyTktN5H0V6+LmnID3Yp2fzu7oFQNxw 5nOrdYAtwuX5q7lsa8eD2Nt75ObxoaUlo602/JPF1VOhaDPEFj/nXkRJOG5s+yAsIly3 A8Kd6ATKwsluvZ09fSxME91133Ch+J/DrVmfesIZ37K67VEjwatqeL3S0528kxazvejG Xn7w== X-Gm-Message-State: AOJu0YycA77ZVLsjPwqvFRVc+bbtA76Rg4FaUnOt2Eay/0pZ3ZbLGKFm bG675rXvqAtedqPkahOmeFiQbYU4YKH9Tg== X-Google-Smtp-Source: AGHT+IHZHagMWy2HPI0YrF34ye0IkVkYy10h1jWIvdho+KQVHFHRQjT4ByRa26XBH6udfT+GuQvITg== X-Received: by 2002:a5e:8f4d:0:b0:791:2db5:c779 with SMTP id x13-20020a5e8f4d000000b007912db5c779mr31016076iop.10.1697140044235; Thu, 12 Oct 2023 12:47:24 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:23 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:04 -0600 Message-ID: <20231012194711.3288031-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 C2B0BCDB482 for ; Thu, 12 Oct 2023 19:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442589AbjJLTrp (ORCPT ); Thu, 12 Oct 2023 15:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442498AbjJLTr3 (ORCPT ); Thu, 12 Oct 2023 15:47:29 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45FE2D8 for ; Thu, 12 Oct 2023 12:47:26 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-79fa387fb96so54566739f.1 for ; Thu, 12 Oct 2023 12:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140045; x=1697744845; 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=LXjxWyOGz7s6pWhxmk4p15LQxW7AuGiLg/l2A/4dBR2zkqXnoGtBDCWxObvcJ85kuO 1FUg2V+uWt72n5gIFoI1C0ZFYAgSSBYV/qc548JV+c9t8aoWrG1aNo4R1YwEs6bf2z1r xJwhpUmHAglEoELFTvVCfI9r5Ey0hmfCajqXq8W4EFIMNtW4mKUFuZ6mIUdBVpQfZ4J6 sCL3gi0I9VuitqGodVdGIgmYL2SHvoppIHoJo+EfHoF8SOnynykzz7XTNYhNFcuNgnBC w4SCJ0Xo7Wov9KH9lDhT7kVMynf7+tvus0VBHNvkSYpSOgkFaXkLKEFpUJmIN86a3hLp AXow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140045; x=1697744845; 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=PTVKZbffMGKFP6+E9CDxo3PeTjNuGpvY7QRAaT4tkE95nbnWHnG44ThAXZ4UX8MgWR 1RZ7+sdA/nSMx4scGWt7+rjqbPVat9Bcbq34vYLAmYxNcnrpJnQMfpQ0ffkg7dm0+a/r x5w126c7eP02q21+irQ+DXufxzu7gJWcJNxVrb2kNYfycsjIt+x0pIjLgebRBZ366FUN jlh9TKVmJbH7JzNfmCZyC9y1MO+Xw6LJQ6TNn9tqXa+s8UGK8nEcHC1GKAZfV1CQo9CL ybKfIcj/ljIdDXeEKxphkysPDxpXq5CsIn7/nFvWr1HBOvsejZ3R4SZXyhatpp4K8JKB 3Qlg== X-Gm-Message-State: AOJu0Ywx7xjSBVinsJvHsbT4imyHXaT80XEUXBTZzSI7w99kZwCYDnw/ z3rQtaC8igtSHoRwMYG8YpKzewIlku6Ypw== X-Google-Smtp-Source: AGHT+IEOG5SpG4KCKE7NUisGRmS8wO+XpQ/XPVhRI6E30r3W/baXLgOOywsCK0/rxHdk7QOhpFzIIA== X-Received: by 2002:a5e:8f4d:0:b0:791:2db5:c779 with SMTP id x13-20020a5e8f4d000000b007912db5c779mr31016114iop.10.1697140045282; Thu, 12 Oct 2023 12:47:25 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:24 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, Liam.Howlett@Oracle.com, linux-mm@kvack.org, Jim Cromie , Matthew Wilcox , jbaron@akamai.com Subject: [RFC PATCH 04/10] dyndbg: save _ddebug_site mod,file,func fields into maple-trees Date: Thu, 12 Oct 2023 13:47:05 -0600 Message-ID: <20231012194711.3288031-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 C1932CDB482 for ; Thu, 12 Oct 2023 19:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442644AbjJLTrk (ORCPT ); Thu, 12 Oct 2023 15:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442412AbjJLTr3 (ORCPT ); Thu, 12 Oct 2023 15:47:29 -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 72BD8DA for ; Thu, 12 Oct 2023 12:47:27 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fa2dbd793so56869439f.2 for ; Thu, 12 Oct 2023 12:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140046; x=1697744846; 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=aAyPZf4aITbV46VAzmJnxmgzIjkI7iFozBrX1LhNMd9PX9qpy7KksZMuOs8Gxafz2A zOWJHiVTEfNMS5WSLsehJCAj/eTHsgpsg9xBes8oUP0EheYmrKUyanyJkjWk/05S+JgQ 4I4RkgO/1erEBkb5IsfpFGlrnNIEJO45sgeWbs7qq19GRQWgQVo823XBuI9HqHF5Besl Zsg/cBq9OGuSFGWNdFPVlsDP9INtQTIL43fd9JawBUiWDzQHQDNuE8OW4xWulZJ5/Rec 90LAWnQOkjj5IScBobpIZzvT/0zVlY7XQPWMz9XL5NW2iJqBD4qcAeksk3AwBdUANZuJ nsuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140046; x=1697744846; 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=iTN2m6uafHNcwaXncD4NopbWXU9gNJSUR1JtGr+WbUJUgXeeZHOaSaX5FjGz8k7ZxW PJOaJ+27nM5YMiLRygCp0N4vmCcSR/YnDbZXi4kycUZw26EtEZ8mN/ytwU6Ard3L+y+m NGZ8uv0ANEok/heu7oljIWKCHGSxnGOGlec0VwrtH7GH7CtYNGLvTe+NtniXGdih05F1 +veBbMmoPWbXhS1T/duiTbBOsGShz1wIB12tgyXyDyzzFODpTZjJBIPFwXADhP+3dHKD ZWIGR/KXKrGpWwe5fcybMB8SHB5Nz2JJvq0AsxsnZERKS0JAFSK58Wtnbs7ej9yfnJfp gO5g== X-Gm-Message-State: AOJu0Yzo8H0jsUE6c/qeMy/XPk7dD9cRgoFST+3DzjURTe7+nlykInKj AOp0SvRFksTT5iCemGrYFMYQBQdO6/c4Pg== X-Google-Smtp-Source: AGHT+IH0UOfRQ4ikz9Hk4rM8RmqNySf3YxcTrIhFIo+68DbLkG/CP9qB7HHORAuGhOuprlMeJ8JdHQ== X-Received: by 2002:a05:6602:2012:b0:787:1568:5df7 with SMTP id y18-20020a056602201200b0078715685df7mr27961322iod.9.1697140046416; Thu, 12 Oct 2023 12:47:26 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:25 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:06 -0600 Message-ID: <20231012194711.3288031-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 41764CDB46E for ; Thu, 12 Oct 2023 19:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442724AbjJLTrz (ORCPT ); Thu, 12 Oct 2023 15:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442512AbjJLTra (ORCPT ); Thu, 12 Oct 2023 15:47:30 -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 8107BE0 for ; Thu, 12 Oct 2023 12:47:28 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fa2125e19so49776739f.0 for ; Thu, 12 Oct 2023 12:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140047; x=1697744847; 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=DZd4FW2YTxozpL1GyBzPAx27G7hnEMyvApYewJ56wGo0nL3yGowG2KxRmjlzVqjNis GSP6I4Bu4XhfwuZum2P6mIqipoo//3vGqw1JzcFh8e3kixFHm+DKN5Tm2RNZp4A1uM9G xPh12+PskUcyXDXGUtalU+CVjZoihSfRD+y0cB9r9VKF2pmEgWMThwXSDhAb/QvUOYxh K28WpDCVLjR1jw1DrDhdCgoiAVlQJj13nHDPr+0efjGaH7+Qyj/jQegHGqvPtFLN4972 xD6h+pgjAtLt26Njkjgb68nD9Ntya/0WQJB2RGuGSWPiYXJUZ4H8BRl4mWHEj7/UQkSh NdDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140047; x=1697744847; 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=dSaZC6whJS1/7Gbv+9pngL4ccADWbJgW40bw4mJ1L3tm31+2K/rsf6y4C2MfAwTZFi L/VlcRlLVgm+QyG9vnrZ8iPItJdd6bZv6T0aE5AwLpICv8Kafacj8AbPgPtPjAWmg60F W4pM1j11UFpc0gE9+4DqLNuygjBzk8uKVN0ATSLTsGNCyVCEYBy+qwdzNgmry7JdfDTf 7KW6JJFbv5HF7PDUlZEi6S0l5sPAmhjtAhVjk8dUFpEbnG47FZr3sZMIc0r//JKLjWmF MIfKBwDhyyvhL2eQE5BcAdndMjrwPR+P2GG0dLVzi9ouf3XXjSI9WvHzayv0Iu4xBT97 CcUw== X-Gm-Message-State: AOJu0Yw1/8jPiyb8OfZ9HGkzIieq6c/fLOq9+ONjLFPLxrEAFzJBhfFx 7TW+XIhElLY9QaZ9cq+b61CDwrIqMv0/Pg== X-Google-Smtp-Source: AGHT+IHn7mDbO0S9A1+0b66S1qg4vsjED53qQ+O/oQTsPg5mse541WjW5llcVGB1QOru72YgI0Y3oA== X-Received: by 2002:a6b:f30b:0:b0:794:e015:585e with SMTP id m11-20020a6bf30b000000b00794e015585emr27649805ioh.21.1697140047466; Thu, 12 Oct 2023 12:47:27 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:26 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:07 -0600 Message-ID: <20231012194711.3288031-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 747DBCDB46E for ; Thu, 12 Oct 2023 19:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442604AbjJLTru (ORCPT ); Thu, 12 Oct 2023 15:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442547AbjJLTrd (ORCPT ); Thu, 12 Oct 2023 15:47:33 -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 7151CE3 for ; Thu, 12 Oct 2023 12:47:29 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-79fb78e297bso55715839f.0 for ; Thu, 12 Oct 2023 12:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140048; x=1697744848; 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=FC4QLyOJRlysc3HjghprjDJxMGT6XL9QQJ+XPhay431QhiHkI8nFNDJSCvOSvnoKkD RWRdaiYUWUmoq0SvkdN8ZlC58LdqR40fPH1Z5FnbDs/6pCgldwUU1rJpbBgvTKGycIf7 SqRjZKqUg2ayv5mG9/cg57BWwO2vQRFJlSxxyvDEtb2RIWzrZ5kWhN7F7GqgntAb/U9V pfPwyxmBzpVt3HmqPfuSB4dq96KSDILE8AqTnEEsx6btjRGznX/IlRNQMJ3eVYQUZOp9 PZ5cSOAZEkt1PQbaWH60iU1WJVTZfpj/ySWQZzXvc2P07e5wRbZgNJKLzwb4s8Y2teIr kcFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140048; x=1697744848; 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=jpfaxrEC25t9JAUnfXEhkmhWBfidO0xyjgWDe5tHu72yvYIwjpQSfeqjik4ZUdv+TG Ul8QhbAo3AbCYYCM4OWmw9ZuWRmiG7C051rrKphNp7l22IfpTCU35KSHwRkmywGbd4Q2 DJRTbFqCaCOt0YGJjkqlUrczqK+Hq7RXmmAdq0lydMWQadszeSwcVzfIBej0a9CKq27f x+TVxRHh9B8EhhmnSKSRm3/nhRN1IWDYkWFNXNxzyBJS1sog5raVDZxtV1DrBhvgbrG1 7734b6l47YplVIz1uC5fhwx57gvCwu5yJvP3QdfTr5LLjAjq5aMGK4Uz9dKFoumAhKAI FKww== X-Gm-Message-State: AOJu0YzcS2CKFg8L1A1uHER6r78LinEsv67DKUizzl4fX2L8mB2hFsjo wKHeCF6LLyO8xOfFvby7m3VKAFMkDPlUow== X-Google-Smtp-Source: AGHT+IHwXqweWhb1lxAAh/8nmrZo53I7KZ+f3cHS+05xFDAlJj11wM8cG2c9g1NHaGlPQ1kNha+MpQ== X-Received: by 2002:a5e:de4a:0:b0:794:eb37:b0c4 with SMTP id e10-20020a5ede4a000000b00794eb37b0c4mr24029604ioq.21.1697140048511; Thu, 12 Oct 2023 12:47:28 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:27 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:08 -0600 Message-ID: <20231012194711.3288031-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 1108ACDB46E for ; Thu, 12 Oct 2023 19:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442737AbjJLTr5 (ORCPT ); Thu, 12 Oct 2023 15:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442560AbjJLTrd (ORCPT ); Thu, 12 Oct 2023 15:47:33 -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 A338CF0 for ; Thu, 12 Oct 2023 12:47:30 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-79fb78e297bso55716139f.0 for ; Thu, 12 Oct 2023 12:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140049; x=1697744849; 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=MjsHGH0KcyHM9yh2BwpUgxQi3Vfa9WG/ty5Ea8lSq9yzqZNw5xDk/9ki9K87No8ZUG qG5MeKsDVy8jr2bZhF+76xcP9ksw7qg+qlgoChDneDxrJsUpE3XMwDwzBcHLEc1aVblp CvWFXpS8sowf7TYLE9jisRDmyNh1r4suBfBif4cro/xrrM24BxdcRFAIi5eXiKoffSDD fuY9xeV9X7nOFbkqCKiOsdds6PpP9pkQfnc2y3aREwa5w9RgR0085iRjkrG39bb0PbTs 9GK2F2HVSy1eUP6TfGKPg7kG2BbSQgQ10gxqjj5HwogNZOxB8jg+Bv9viI60tkpMTxbT hq+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140049; x=1697744849; 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=cNtCen140xha191ucEXIkKhzIs6t02fb8JiBwWLcG/si3tpY9EW+k2aO4ooIrAGbD5 ZfOoHFm3JW7GPK9x30mTqdKiwKLamtNBUzbqLLzdVwQaKbMiQ2NcURS/rrRIfH0xm1MS HrxsmXUVPu/e+xfye6QqtgJSmcTyx0e64V2RQ3T89DHfWK2trc1ngtrdgjyW402EjMqa CRmf6JfIVY3KWtmFuHHF/HEpcsGOOGJVRTGZ/dzFq52R1Q58B3gmAxQCDlpmhl97EUyj NYpQldUS7jfV+q/HkTE+c/rsXExzTxCsSv8Mi7pbQSFfkgcyFSjS88YuQE4sH78YgtZA Wlqg== X-Gm-Message-State: AOJu0YzmLm0mmlnuet2asyoBbW1cmVbWBNBd7LbryFq9c3BgzF1xZVm7 pRaw566PjZJKnDvvwIAo68tT//RlsOW8Vw== X-Google-Smtp-Source: AGHT+IHCeodG2zR7qXJvGMWnDUytuto++Y0+52RDtBpPMwO267PxqNwztcmT278yMiBWKoD4h72RcA== X-Received: by 2002:a6b:ea15:0:b0:790:a010:4c42 with SMTP id m21-20020a6bea15000000b00790a0104c42mr28325512ioc.13.1697140049529; Thu, 12 Oct 2023 12:47:29 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:28 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:09 -0600 Message-ID: <20231012194711.3288031-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 E46A6CDB46E for ; Thu, 12 Oct 2023 19:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442632AbjJLTsC (ORCPT ); Thu, 12 Oct 2023 15:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442529AbjJLTre (ORCPT ); Thu, 12 Oct 2023 15:47:34 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5332F7 for ; Thu, 12 Oct 2023 12:47:31 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7a25040faffso57245439f.1 for ; Thu, 12 Oct 2023 12:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140050; x=1697744850; 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=YHVWKxIhT0CcKHm18j/EJlwqsMGKQlX6RfscPwPuLzQAdRcDbwugzX5RvnuFT4Bk5C TUaYrYn3XSSSRUlPenLuiMV0s6okybH1XW6KMoEcpYrcnGLGqNHojO8/svv2Ebay9/TN Wdr0OoRge9+Lj3Auj7EjQAe2yz/htyHKVvJzSRshhwxkmZRw8iO5zcyAVhAkk41/zBNo H3MYBXkwWgfB3r2evraA3p9PTslHOazEO0it9/9Pqk+QjePDKKHJC1JPdxnLKVn9psfZ 3zdbve5IDsJ34ca5U67rKJVtT0OeuyBnfRDkc0up+8El/AbCo2gG8ZViqoAMWcLTA2Ms e9TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140050; x=1697744850; 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=vvneRmHY8c//pO7nCXH5chbMFBtUwprIg2ub/GzHIEjj/NjlT4sjS12eV0Tf4ZRMDy vMXnklxNOVfzWDU4e38LQ8Nh2au1/IWtELRCLe7J3cuRZU0XmA4amNheUtksWrxWs3aZ k5a5OiH2Bse44FoxNVYbUrvWKBw5eVwgkNMegouXkVQtn6JgdCAufMOt4Lq56YqD/OvM WjrSvvkfRfj3liyPiIkdMlaLx8kHOjfqtHi7erF7pCmdADVqrFeq32W+x6OrvqnUc0MJ 4svFt7+yXfhl9O/T26eLAI2PFaAWXGyeoDtT7AuF77Bux+Ft/4uSpZ3k9nWROVQRbbbE Wytw== X-Gm-Message-State: AOJu0YwgH4CvGFz5K2BQ5HGH5fl+JQ3ThudjxV5Z+Jyuib0DvH+wFhVO TDqphKYwgcvVhnY10SaeogTbPXAUbkakxg== X-Google-Smtp-Source: AGHT+IHU6/UwAxmm5iYu+krC4jYwWl30+9Laj14aUjTrmQt6Cnwhp5cwnYiXxGdgbdS9u1QcuHlA7A== X-Received: by 2002:a6b:da06:0:b0:783:4e11:76d7 with SMTP id x6-20020a6bda06000000b007834e1176d7mr24140049iob.21.1697140050527; Thu, 12 Oct 2023 12:47:30 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:29 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:10 -0600 Message-ID: <20231012194711.3288031-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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:55:00 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 02B6FCDB46E for ; Thu, 12 Oct 2023 19:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442785AbjJLTsJ (ORCPT ); Thu, 12 Oct 2023 15:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442640AbjJLTrk (ORCPT ); Thu, 12 Oct 2023 15:47:40 -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 E5980DA for ; Thu, 12 Oct 2023 12:47:32 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fe6da0049so55216739f.1 for ; Thu, 12 Oct 2023 12:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697140051; x=1697744851; 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=Q7Oe7F/zJLL8IR7TW7SSCog9l0h8zrRSR3WWxOnkfhxVrsnVBO97J2v70BwVEBFDmN TtzER+z/8WuU89ReRwNYBcJ6COxYiZCaJvVPvBr3bUJsYnnm82GjpfMP2fmq3UY1RD71 IIGwlY57BrVbuzyrZo0PXOEYPEVDCaF3TX52tBWNoJeuJ1XMGjNyuY7A8ai6Fqyg0tmN nL1keobWjIgif98loQkAjhLfIhvPDQHUnmvTXe487DflOtzUZRT8BV91TiKoXBzyXS+n C/j5XpqPOW5ZYKBnFguTsDuXL0A6fqb8JsQtWTyITt0V/n0kpIIo3J67Mh1IIBE0B0xn wkzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697140051; x=1697744851; 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=rJXNmFmLDotG8WfzjrtkQcd/OjLJI7WMDSvYSz6Z9H4u7b3Iu6Dfe7Y5cpuLLiN6T+ kTHYSnHxuPFhkMspkx1Vq8FAU/VSQC9M+7iVn0+XTdZCz7T4ivELbFEAJ1e9TPD05l4Y TGV6N+Sh+PSrkDYf8K/Qw7ds/hPxrMwA8v3PcfNIsNnRmMb38WMC3P6o/+VoKFTHHw0G 6WEQqjeLlenvLoRDnjU0uZaRpFWPcOKz/64Auz7kJ4+2a5dxus03nOqJIOwPdmJdvBOh lbmdgp9MwbtMHnmjmanvR3kc0flPrpphBWaLpeA6HLVZpSPud9/wiQHx7zJaIyUhOYsM V0UQ== X-Gm-Message-State: AOJu0YwXNTOllAGBJTf6+tIuT2hSfFKHi8KbIawF5ssifqRZqhH99JZ6 5n1bn5a9je4TUmVhZhtkDgl7ySvmQjh+zg== X-Google-Smtp-Source: AGHT+IGFZRnX/2jEPkfFaY6CF3iLQdJpD5uSzZ8sAWGpNzzXtIHRrYje0mKyf+N3fhni1GhvWfWi0w== X-Received: by 2002:a5d:9cd5:0:b0:79f:d4e6:5175 with SMTP id w21-20020a5d9cd5000000b0079fd4e65175mr28322159iow.16.1697140051534; Thu, 12 Oct 2023 12:47:31 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z7-20020a5ec907000000b0079fbb834232sm4351002iol.19.2023.10.12.12.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:47:30 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: david@redhat.com, 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:47:11 -0600 Message-ID: <20231012194711.3288031-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012194711.3288031-1-jim.cromie@gmail.com> References: <20231012194711.3288031-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