]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Maple Tree: add new data structure
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 14 Apr 2022 06:07:12 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 May 2022 00:26:48 +0000 (17:26 -0700)
commit6957ed8b6686d44076d661136229d4525d95ad12
treef50af1c4c6e190793d615f2e0d1e409784086331
parent2a265b6062c752ad290a6edcce53c30709f9c3d9
Maple Tree: add new data structure

The maple tree is an RCU-safe range based B-tree designed to use modern
processor cache efficiently.  There are a number of places in the kernel that a
non-overlapping range-based tree would be beneficial, especially one with a
simple interface.  If you use an rbtree with other data structures to improve
performance or an interval tree to track non-overlapping ranges, then this is
for you.

The tree has a branching factor of 10 for non-leaf nodes and 16 for leaf nodes.
With the increased branching factor, it is significantly shorter than the
rbtree so it has fewer cache misses.  The removal of the linked list between
subsequent entries also reduces the cache misses and the need to pull in the
previous and next VMA during many tree alterations.

The first user that is covered in this patch set is the vm_area_struct, where
three data structures are replaced by the maple tree: the augmented rbtree, the
vma cache, and the linked list of VMAs in the mm_struct.  The long term goal is
to reduce or remove the mmap_lock contention.

The plan is to get to the point where we use the maple tree in RCU mode.
Readers will not block for writers.  A single write operation will be allowed
at a time.  A reader re-walks if stale data is encountered. VMAs would be RCU
enabled and this mode would be entered once multiple tasks are using the
mm_struct.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: David Howells <dhowells@redhat.com>
14 files changed:
Documentation/core-api/index.rst
Documentation/core-api/maple_tree.rst [new file with mode: 0644]
MAINTAINERS
include/linux/maple_tree.h [new file with mode: 0644]
include/trace/events/maple_tree.h [new file with mode: 0644]
init/main.c
lib/Kconfig.debug
lib/Makefile
lib/maple_tree.c [new file with mode: 0644]
tools/testing/radix-tree/.gitignore
tools/testing/radix-tree/generated/autoconf.h
tools/testing/radix-tree/linux/maple_tree.h [new file with mode: 0644]
tools/testing/radix-tree/maple.c [new file with mode: 0644]
tools/testing/radix-tree/trace/events/maple_tree.h [new file with mode: 0644]