Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp533862rdg; Thu, 12 Oct 2023 12:48:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtqfJ8UMo1ZV7iwgvyiAMn/CvEZyeh8kIYHvFTxnPC08YoS8y8goQMMZ3Fd7pss6y+jOk4 X-Received: by 2002:a05:6358:4415:b0:135:6d9:2399 with SMTP id z21-20020a056358441500b0013506d92399mr22967228rwc.30.1697140096553; Thu, 12 Oct 2023 12:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697140096; cv=none; d=google.com; s=arc-20160816; b=L7my3OHdSclCfB13Upqo3Y3VmK9K4pi9IieU+vJNDg0nflMLdp318DuUQjpzinfsEU D77aThUdCpZRG24aGBUgRklUlM80C/eQdO5WPaq5k6h2HtciBEDNWBub0CEANp0VByJg RHHFCoVGTlvnBTgdfyyQSFIVg6d3Nrr/q4gm+MjPJnx3AHP1TAO4ZRi+MrKitKIfSFlA VmSVuZ28F/xSLF8UzVOa+ay62+c5BnZLS1Aivg0RZTdO39GWzYU44+uwD6YwW9tiQVlM p4z60nD55x5Iypx7Go0DwJTv0bl4GunPoY2WrQFnKoQ8vhXa3AiVra+bhWDg1LOF8hfD 046w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jr8tQe/cDXue74QN3U0cEdutzIhNedVe/s3FJQcenu4=; fh=7ljCN0LusJ7JrIo0b2q68gdLb7KZwh2dqCYB6NR0RGQ=; b=sk2rv77Np16SVwFFaleSgMGDQgkyTUfDy60RoY4OOOaZegIzomF7+bHoUsz00XyDGD 0BlTOHoM2pztInOCq9iEDxLS13ctFB+864RIUCIj8bRFN60rDoDxHXTYHsQUE7mkjb+1 FVsm+F2Jhg5SgTeSRLW2habbBWqvo+KXRFsQwwBn7q4pQNkiECFksuKctYRAXrUm3q9L gXeZLRon/PO+3Zul0HbQCKGCKr0Ig4xpYnCHtQazjxI0ePLEu4wue5X4QGl1kMUHyzfR lcwYLLM9VjSl1scoO6thX3w3/j4OaVwHg6zdflU5T/RB57M4yitpsLvqV79G+8GJD+p/ p5OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YHVWKxIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cv9-20020a056a0044c900b0068fdeb84453si14910878pfb.265.2023.10.12.12.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YHVWKxIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EB27082972E1; Thu, 12 Oct 2023 12:48:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442241AbjJLTsA (ORCPT + 99 others); Thu, 12 Oct 2023 15:48:00 -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-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: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 12:48:14 -0700 (PDT) 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, 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