The patch titled Subject: maple_tree: use cached node end in mas_next() has been added to the -mm mm-unstable branch. Its filename is maple_tree-use-cached-node-end-in-mas_next.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/maple_tree-use-cached-node-end-in-mas_next.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx> Subject: maple_tree: use cached node end in mas_next() Date: Wed, 1 Nov 2023 13:16:22 -0400 When looking for the next entry, don't recalculate the node end as it is now tracked in the maple state. Link: https://lkml.kernel.org/r/20231101171629.3612299-6-Liam.Howlett@xxxxxxxxxx Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Cc: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/maple_tree.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/lib/maple_tree.c~maple_tree-use-cached-node-end-in-mas_next +++ a/lib/maple_tree.c @@ -4539,6 +4539,7 @@ static inline int mas_next_node(struct m unsigned long min; unsigned long *pivots; struct maple_enode *enode; + struct maple_node *tmp; int level = 0; unsigned char node_end; enum maple_type mt; @@ -4591,6 +4592,10 @@ static inline int mas_next_node(struct m pivots = ma_pivots(node, mt); mas->max = mas_safe_pivot(mas, pivots, mas->offset, mt); + tmp = mte_to_node(enode); + mt = mte_node_type(enode); + pivots = ma_pivots(tmp, mt); + mas->end = ma_data_end(tmp, mt, pivots, mas->max); if (unlikely(ma_dead_node(node))) return 1; @@ -4625,7 +4630,6 @@ static void *mas_next_slot(struct ma_sta unsigned long pivot; enum maple_type type; struct maple_node *node; - unsigned char data_end; unsigned long save_point = mas->last; void *entry; @@ -4633,12 +4637,11 @@ retry: node = mas_mn(mas); type = mte_node_type(mas->node); pivots = ma_pivots(node, type); - data_end = ma_data_end(node, type, pivots, mas->max); if (unlikely(mas_rewalk_if_dead(mas, node, save_point))) goto retry; if (mas->max >= max) { - if (likely(mas->offset < data_end)) + if (likely(mas->offset < mas->end)) pivot = pivots[mas->offset]; else goto overflow; @@ -4650,11 +4653,11 @@ retry: goto overflow; } - if (likely(mas->offset < data_end)) { + if (likely(mas->offset < mas->end)) { mas->index = pivots[mas->offset] + 1; again: mas->offset++; - if (likely(mas->offset < data_end)) + if (likely(mas->offset < mas->end)) mas->last = pivots[mas->offset]; else mas->last = mas->max; @@ -4691,7 +4694,6 @@ again: goto overflow; mas->index = mas->last + 1; - /* Node cannot end on NULL, so it's safe to short-cut here */ goto again; } _ Patches currently in -mm which might be from Liam.Howlett@xxxxxxxxxx are maple_tree-remove-unnecessary-default-labels-from-switch-statements.patch maple_tree-make-mas_erase-more-robust.patch maple_tree-move-debug-check-to-__mas_set_range.patch maple_tree-add-end-of-node-tracking-to-the-maple-state.patch maple_tree-use-cached-node-end-in-mas_next.patch maple_tree-use-cached-node-end-in-mas_destroy.patch maple_tree-clean-up-inlines-for-some-functions.patch maple_tree-separate-ma_state-node-from-status.patch maple_tree-separate-ma_state-node-from-status-fix-1.patch maple_tree-separate-ma_state-node-from-status-fix-2.patch maple_tree-remove-mas_searchable.patch maple_tree-use-maple-state-end-for-write-operations.patch maple_tree-dont-find-node-end-in-mtree_lookup_walk.patch maple_tree-mtree_range_walk-clean-up.patch