All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
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 <jim.cromie@gmail.com>
Subject: [RFC PATCH 09/10] dyndbg: add dd_clear_range to prune mtrees
Date: Thu, 12 Oct 2023 13:48:33 -0600	[thread overview]
Message-ID: <20231012194834.3288085-10-jim.cromie@gmail.com> (raw)
In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com>

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 <Liam.Howlett@Oracle.com>
cc: linux-mm@kvack.org
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 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, const struct _ddebug *start,
 		v4pr_info("  ok %s at %lx\n", val, first);
 }
 
+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 == mod_name) {
+			/* free mtree entries on descs */
+			dd_clear_range(dt->ddebugs);
 			ddebug_table_free(dt);
 			ret = 0;
 			break;
-- 
2.41.0


  parent reply	other threads:[~2023-10-12 19:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 19:48 [RFC PATCH 00/10] how to reclaim unneeded vmlinux memory ? Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 01/10] dyndbg: prep to isolate 3 repetetive fields Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 02/10] dyndbg: split __dyndbg_sites section out from __dyndbg Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 03/10] dyndbg: add 2nd cursor pair to init-fn Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 04/10] dyndbg: save _ddebug_site mod,file,func fields into maple-trees Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 05/10] dyndbg: avoid _ddebug.site in ddebug_condense_sites Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 06/10] dyndbg: add site_*() macros to avoid using _ddebug.site Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 07/10] dyndbg: wire in __desc_*() functions Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 08/10] dyndbg: drop _ddebug.site member Jim Cromie
2023-10-12 19:48 ` Jim Cromie [this message]
2023-10-12 19:48 ` [RFC PATCH 10/10] dyndbg: cache the dynamically generated prefixes per callsite Jim Cromie
  -- strict thread matches above, loose matches on Subject: below --
2023-10-12 19:47 [RFC PATCH 00/10] how to reclaim unneeded vmlinux memory ? Jim Cromie
2023-10-12 19:47 ` [RFC PATCH 09/10] dyndbg: add dd_clear_range to prune mtrees Jim Cromie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231012194834.3288085-10-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=Liam.Howlett@Oracle.com \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=joe@perches.com \
    --cc=lb@semihalf.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.