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: avoid checking other gaps after getting the largest gap

The last range stored in maple tree is typically quite large. By checking
if it exceeds the sum of the remaining ranges in that node, it is possible
to avoid checking all other gaps.

Running the maple tree test suite in user mode almost always results in a
near 100% hit rate for this optimization.

Link: https://lkml.kernel.org/r/20231215074632.82045-1-zhangpeng.00@bytedance.com
Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Peng Zhang and committed by
Andrew Morton
7e552dcd f7ef5fe7

+3
+3
lib/maple_tree.c
··· 1518 1518 gap = ULONG_MAX - pivots[max_piv]; 1519 1519 if (gap > max_gap) 1520 1520 max_gap = gap; 1521 + 1522 + if (max_gap > pivots[max_piv] - mas->min) 1523 + return max_gap; 1521 1524 } 1522 1525 1523 1526 for (; i <= max_piv; i++) {