]> www.infradead.org Git - users/jedix/linux-maple.git/commit
kernel/fork: Use maple tree for dup_mmap() during forking
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 22 Oct 2021 17:53:01 +0000 (13:53 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 30 Oct 2021 03:37:29 +0000 (23:37 -0400)
commitb8df04729103b6f09f24bf554317dd8907d1b463
treec86b0ccde7265af66f3bf201267d90f5a9dd7e83
parentafe3fd02e0a1ed959b1ebde508ec76550951d5d5
kernel/fork: Use maple tree for dup_mmap() during forking

The maple tree was already tracking VMAs in this function by an earlier
commit, but the rbtree iterator was being used to iterate the list.
Change the iterator to use a maple tree native iterator and switch to
the maple tree advanced API to avoid multiple walks of the tree during
insert operations.  Unexport the now-unused vma_store() function.

We track whether we need to free the VMAs and tree nodes through RCU
(ie whether there have been multiple threads that can see the mm_struct
simultaneously; by pthread(), ptrace() or looking at /proc/$pid/maps).
This setting is sticky because it's too tricky to decide when it's safe
to exit RCU mode.

For performance reasons we bulk allocate the maple tree nodes.  The node
calculations are done internally to the tree and use the VMA count and
assume the worst-case node requirements.  The VM_DONT_COPY flag does
not allow for the most efficient copy method of the tree and so a bulk
loading algorithm is used.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/mm.h
include/linux/sched/mm.h
kernel/fork.c