Skip to content

Commit

Permalink
maple_tree: avoid ascending when mas->min is also the parent's minimum
Browse files Browse the repository at this point in the history
When the child node is the first child of its parent node, mas->min does
not need to be updated. This can reduce the number of ascending times
in some cases.

Link: https://lkml.kernel.org/r/20231120070937.35481-3-zhangpeng.00@bytedance.com
Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Peng Zhang authored and Andrew Morton committed Dec 12, 2023
1 parent 2e783f0 commit 3f05fcd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/maple_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,16 @@ static int mas_ascend(struct ma_state *mas)
return 0;
}

if (!mas->min)
min = 0;
max = ULONG_MAX;
if (!mas->offset) {
min = mas->min;
set_min = true;
}

if (mas->max == ULONG_MAX)
set_max = true;

min = 0;
max = ULONG_MAX;
do {
p_enode = a_enode;
a_type = mas_parent_type(mas, p_enode);
Expand Down

0 comments on commit 3f05fcd

Please sign in to comment.