Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

maple_tree: add cp_is_new_root() helper

Add a helper to do what is needed when the maple copy node contains a new
root node. This is useful for future commits and is self-documenting
code.

[Liam.Howlett@oracle.com: remove warnings on older compilers]
Link: https://lkml.kernel.org/r/malwmirqnpuxqkqrobcmzfkmmxipoyzwfs2nwc5fbpxlt2r2ej@wchmjtaljvw3
[akpm@linux-foundation.org: s/cp->slot[0]/&cp->slot[0]/, per Liam]
Link: https://lkml.kernel.org/r/20260130205935.2559335-22-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>

authored by

Liam R. Howlett and committed by
Andrew Morton
b00a1804 62e9d349

+38 -32
+38 -32
lib/maple_tree.c
··· 3337 3337 mas_spanning_rebalance_loop(mas, mast, count); 3338 3338 } 3339 3339 3340 + static inline bool cp_is_new_root(struct maple_copy *cp, struct ma_state *mas) 3341 + { 3342 + if (cp->min || cp->max != ULONG_MAX) 3343 + return false; 3344 + 3345 + if (cp->d_count != 1) { 3346 + enum maple_type mt = maple_arange_64; 3347 + 3348 + if (!mt_is_alloc(mas->tree)) 3349 + mt = maple_range_64; 3350 + 3351 + cp->data = cp->d_count; 3352 + cp->s_count = 0; 3353 + dst_setup(cp, mas, mt); 3354 + init_cp_src(cp); 3355 + node_copy(mas, cp->src[0].node, 0, cp->data, cp->max, maple_copy, 3356 + cp->dst[0].node, 0, mt); 3357 + node_finalise(cp->dst[0].node, mt, cp->end + 1); 3358 + /* 3359 + * Warning, see cp_leaf_init() comment and rcu_assign_pointer() 3360 + * documentation. Since this is a new root, there are no 3361 + * read-side operations that can view it until it is insert into 3362 + * the tree after an rcu_assign_pointer() call. 3363 + */ 3364 + ma_init_slot(&cp->slot[0], cp->dst[0].node, mt); 3365 + cp->height++; 3366 + } 3367 + WARN_ON_ONCE(cp->dst[0].node != mte_to_node( 3368 + mt_slot_locked(mas->tree, cp->slot, 0))); 3369 + cp->dst[0].node->parent = ma_parent_ptr(mas_tree_parent(mas)); 3370 + mas->min = 0; 3371 + mas->max = ULONG_MAX; 3372 + mas->depth = 0; 3373 + mas->node = mas_root_locked(mas); 3374 + return true; 3375 + } 3376 + 3340 3377 /* 3341 3378 * spanning_ascend() - See if a spanning store operation has to keep walking up 3342 3379 * the tree ··· 3396 3359 } 3397 3360 3398 3361 cp_dst_to_slots(cp, l_wr_mas->mas->min, r_wr_mas->mas->max, mas); 3399 - if (!cp->min && cp->max == ULONG_MAX) { 3400 - /* New root */ 3401 - if (cp->d_count != 1) { 3402 - enum maple_type mt = maple_arange_64; 3403 - 3404 - if (!mt_is_alloc(mas->tree)) 3405 - mt = maple_range_64; 3406 - 3407 - cp->data = cp->d_count; 3408 - cp->s_count = 0; 3409 - dst_setup(cp, mas, mt); 3410 - init_cp_src(cp); 3411 - node_copy(mas, cp->src[0].node, 0, cp->data, cp->max, maple_copy, 3412 - cp->dst[0].node, 0, mt); 3413 - node_finalise(cp->dst[0].node, mt, cp->end + 1); 3414 - /* 3415 - * Warning, see cp_leaf_init() comment and rcu_assign_pointer() 3416 - * documentation. Since this is a new root, there are no 3417 - * read-side operations that can view it until it is insert into 3418 - * the tree after an rcu_assign_pointer() call. 3419 - */ 3420 - ma_init_slot(&cp->slot[0], cp->dst[0].node, mt); 3421 - cp->height++; 3422 - } 3423 - WARN_ON_ONCE(cp->dst[0].node != mte_to_node( 3424 - mt_slot_locked(mas->tree, cp->slot, 0))); 3425 - cp->dst[0].node->parent = ma_parent_ptr(mas_tree_parent(mas)); 3426 - mas->min = 0; 3427 - mas->max = ULONG_MAX; 3428 - mas->depth = 0; 3429 - mas->node = mas_root_locked(mas); 3362 + if (cp_is_new_root(cp, mas)) 3430 3363 return false; 3431 - } 3432 3364 3433 3365 /* Converged and has a single destination */ 3434 3366 if ((cp->d_count == 1) &&