mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>
Subject: [PATCH 11/12] maple_tree: Don't find node end in mtree_lookup_walk()
Date: Wed,  1 Nov 2023 13:16:28 -0400	[thread overview]
Message-ID: <20231101171629.3612299-12-Liam.Howlett@oracle.com> (raw)
In-Reply-To: <20231101171629.3612299-1-Liam.Howlett@oracle.com>

Since the pivot being set is now reliable, the optimized loop no longer
needs to find the node end.  The redundant check for a dead node can
also be avoided as there is no danger of using the wrong pivot since the
results will be thrown out in the case of a dead node by the later
check.

This patch also adds a benchmark test for the function to the maple tree
test framework.  The benchmark shows an average increase performance of
5.98% over 3 runs with this commit.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 lib/maple_tree.c      | 12 +++---------
 lib/test_maple_tree.c | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index e45734676471..a91adaf17306 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3732,23 +3732,17 @@ static inline void *mtree_lookup_walk(struct ma_state *mas)
 	enum maple_type type;
 	void __rcu **slots;
 	unsigned char end;
-	unsigned long max;
 
 	next = mas->node;
-	max = ULONG_MAX;
 	do {
-		offset = 0;
 		node = mte_to_node(next);
 		type = mte_node_type(next);
 		pivots = ma_pivots(node, type);
-		end = ma_data_end(node, type, pivots, max);
-		if (unlikely(ma_dead_node(node)))
-			goto dead_node;
+		end = mt_pivots[type];
+		offset = 0;
 		do {
-			if (pivots[offset] >= mas->index) {
-				max = pivots[offset];
+			if (pivots[offset] >= mas->index)
 				break;
-			}
 		} while (++offset < end);
 
 		slots = ma_slots(node, type);
diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
index b82c02f15380..d36dc64a93e4 100644
--- a/lib/test_maple_tree.c
+++ b/lib/test_maple_tree.c
@@ -42,6 +42,7 @@ atomic_t maple_tree_tests_passed;
 /* #define BENCH_NODE_STORE */
 /* #define BENCH_AWALK */
 /* #define BENCH_WALK */
+/* #define BENCH_LOAD */
 /* #define BENCH_MT_FOR_EACH */
 /* #define BENCH_FORK */
 /* #define BENCH_MAS_FOR_EACH */
@@ -1753,6 +1754,19 @@ static noinline void __init bench_walk(struct maple_tree *mt)
 }
 #endif
 
+#if defined(BENCH_LOAD)
+static noinline void __init bench_load(struct maple_tree *mt)
+{
+	int i, max = 2500, count = 550000000;
+
+	for (i = 0; i < max; i += 10)
+		mtree_store_range(mt, i, i + 5, xa_mk_value(i), GFP_KERNEL);
+
+	for (i = 0; i < count; i++)
+		mtree_load(mt, 1470);
+}
+#endif
+
 #if defined(BENCH_MT_FOR_EACH)
 static noinline void __init bench_mt_for_each(struct maple_tree *mt)
 {
@@ -3606,6 +3620,13 @@ static int __init maple_tree_seed(void)
 	mtree_destroy(&tree);
 	goto skip;
 #endif
+#if defined(BENCH_LOAD)
+#define BENCH
+	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
+	bench_load(&tree);
+	mtree_destroy(&tree);
+	goto skip;
+#endif
 #if defined(BENCH_FORK)
 #define BENCH
 	mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
-- 
2.40.1


  parent reply	other threads:[~2023-11-01 17:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 17:16 [PATCH 00/12] maple_tree: iterator state changes Liam R. Howlett
2023-11-01 17:16 ` [PATCH 01/12] maple_tree: Remove unnecessary default labels from switch statements Liam R. Howlett
2023-11-01 17:16 ` [PATCH 02/12] maple_tree: Make mas_erase() more robust Liam R. Howlett
2023-11-01 17:16 ` [PATCH 03/12] maple_tree: Move debug check to __mas_set_range() Liam R. Howlett
2023-11-01 17:16 ` [PATCH 04/12] maple_tree: Add end of node tracking to the maple state Liam R. Howlett
2023-11-01 17:16 ` [PATCH 05/12] maple_tree: Use cached node end in mas_next() Liam R. Howlett
2023-11-01 17:16 ` [PATCH 06/12] maple_tree: Use cached node end in mas_destroy() Liam R. Howlett
2023-11-01 17:16 ` [PATCH 07/12] maple_tree: Clean up inlines for some functions Liam R. Howlett
2023-11-01 17:16 ` [PATCH 08/12] maple_tree: Separate ma_state node from status Liam R. Howlett
2023-11-02  8:42   ` kernel test robot
2023-11-02 17:39     ` Liam R. Howlett
2023-11-06 15:41   ` [PATCH] maple_tree: Fix comments about MAS_* Liam R. Howlett
2023-11-06 15:45   ` [PATCH] maple_tree: Update forking to separate maple state and node Liam R. Howlett
2025-04-03  0:33   ` [PATCH] test suite: Use %zu to print size_t Liam R. Howlett
2025-04-03  2:53     ` Liam R. Howlett
2023-11-01 17:16 ` [PATCH 09/12] maple_tree: Remove mas_searchable() Liam R. Howlett
2023-11-01 17:16 ` [PATCH 10/12] maple_tree: Use maple state end for write operations Liam R. Howlett
2023-11-01 17:16 ` Liam R. Howlett [this message]
2023-11-01 17:16 ` [PATCH 12/12] maple_tree: mtree_range_walk() clean up Liam R. Howlett

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=20231101171629.3612299-12-Liam.Howlett@oracle.com \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®