maple_tree: start using maple copy node for destination

Stop using the maple subtree state and big node in favour of using three
destinations in the maple copy node.  That is, expand the way leaves were
handled to all levels of the tree and use the maple copy node to track the
new nodes.

Extract out the sibling init into the data calculation since this is where
the insufficient data can be detected.  The remainder of the sibling code
to shift the next iteration is moved to the spanning_ascend() function,
since it is not always needed.

Next introduce the dst_setup() function which will decide how many nodes
are needed to contain the data at this level.  Using the destination
count, populate the copy node's dst array with the new nodes and set
d_count to the correct value.  Note that this can be tricky in the case of
a leaf node with exactly enough room because of the rule against NULLs at
the end of leaves.

Once the destinations are ready, copy the data by altering the
cp_data_write() function to copy from the sources to the destinations
directly.  This eliminates the use of the big node in this code path.  On
node completion, node_finalise() will zero out the remaining area and set
the metadata, if necessary.

spanning_ascend() is used to decide if the operation is complete.  It may
create a new root, converge into one destination, or continue upwards by
ascending the left and right write maple states.

One test case setup needed to be tweaked so that the targeted node was
surrounded by full nodes.

[akpm@linux-foundation.org: coding-style cleanups]
Link: https://lkml.kernel.org/r/20260130205935.2559335-18-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Kujau <lists@nerdbynature.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: SeongJae Park <sj@kernel.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Liam R. Howlett
2026-04-05 13:52:55 -07:00
committed by Andrew Morton
parent 20b20162e1
commit a9c6716e08
3 changed files with 458 additions and 182 deletions
+14
View File
@@ -156,6 +156,17 @@ enum store_type {
};
struct maple_copy {
/*
* min, max, and pivots are values
* start, end, split are indexes into arrays
* data is a size
*/
struct {
struct maple_node *node;
unsigned long max;
enum maple_type mt;
} dst[3];
struct {
struct maple_node *node;
unsigned long max;
@@ -178,7 +189,10 @@ struct maple_copy {
/*Avoid passing these around */
unsigned char s_count;
unsigned char d_count;
unsigned char split;
unsigned char data;
unsigned char height;
};
/**
+443 -181
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -35508,7 +35508,7 @@ static noinline void __init check_spanning_write(struct maple_tree *mt)
/* Store a value across a node boundary that causes a 3 way split */
if (MAPLE_32BIT)
i = 49590; /* 0xc1b6 */
i = 49430; /* 0xc116 */
else
i = 49670; /* 0xC206 */