]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
4 years agomm: WIP, trying to avoid splitting is a mess. maple3_do_munmap
Liam R. Howlett [Tue, 24 Nov 2020 00:03:58 +0000 (19:03 -0500)]
mm: WIP, trying to avoid splitting is a mess.

If you split this VMA, then it is inserted into the tree.  Instead, we
try to create a dummy VMA and pass that along to handle freeing.  Unfortunately,
the hugetlb cases seem to require the file handle to be correctly processed
in the unmap_single_vma() call path.  There may be memory leaks in the cases
where we are not a hugetlb page, but I didn't see that.

The unfornate part is that we have to insert ourselves into the interval tree
when we try to do more with the VMA.

For now, let's just go back to something that is less of a mess

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix vm_pgoff in vma_shorten()
Liam R. Howlett [Sat, 21 Nov 2020 01:05:02 +0000 (20:05 -0500)]
mm/mmap: Fix vm_pgoff in vma_shorten()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix vma_shorten() to correctly set vm_pgoff and vm_flags
Liam R. Howlett [Fri, 20 Nov 2020 19:27:16 +0000 (14:27 -0500)]
mm/mmap: Fix vma_shorten() to correctly set vm_pgoff and vm_flags

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: __do_munmap() Add maple state support.
Liam R. Howlett [Fri, 20 Nov 2020 03:40:37 +0000 (22:40 -0500)]
mm/mmap: __do_munmap() Add maple state support.

Adding ma_state support means costly walks through the tree can be
avoided most of the time.  The write operation can simply store the
value at the location previously searched.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap.c: whitespace and brace fixes
Liam R. Howlett [Fri, 20 Nov 2020 03:54:50 +0000 (22:54 -0500)]
mm/mmap.c: whitespace and brace fixes

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Rewrite __do_munmap() to be more maple tree friendly
Liam R. Howlett [Fri, 20 Nov 2020 02:59:10 +0000 (21:59 -0500)]
mm/mmap: Rewrite __do_munmap() to be more maple tree friendly

Before going full-blown ma_state on __do_munmap(), do better on splits
by avoiding cloning a tmp VMA and just allocate one on the stack to be
discarded.  In the case of a double-adjust of the start and end vma,
then a duplication is unavoidable and handled in the slow path as
before.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change __do_munmap() to avoid unnecessary lookups.
Liam R. Howlett [Thu, 19 Nov 2020 17:57:23 +0000 (12:57 -0500)]
mm/mmap: Change __do_munmap() to avoid unnecessary lookups.

As there is no longer a vmacache, find_vma() is more expensive and so avoid doing them

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix __mas_next() when the limit is hit
Liam R. Howlett [Fri, 20 Nov 2020 03:43:40 +0000 (22:43 -0500)]
maple_tree: Fix __mas_next() when the limit is hit

When a search limit is hit, restore the previous location so that
mas_next() works on that particular ma_state.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Fix defines
Liam R. Howlett [Fri, 20 Nov 2020 19:26:15 +0000 (14:26 -0500)]
test_maple_tree: Fix defines

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotesting: radix-tree changes cleanup
Liam R. Howlett [Thu, 19 Nov 2020 17:15:39 +0000 (12:15 -0500)]
testing: radix-tree changes cleanup

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Code clean up
Liam R. Howlett [Thu, 19 Nov 2020 17:15:22 +0000 (12:15 -0500)]
maple_tree: Code clean up

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Clean up modifications
Liam R. Howlett [Thu, 19 Nov 2020 17:15:05 +0000 (12:15 -0500)]
mm: Clean up modifications

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Remove vmacache
Liam R. Howlett [Mon, 16 Nov 2020 19:50:20 +0000 (14:50 -0500)]
mm: Remove vmacache

The maple tree is able to find a VMA quick enough to no longer need the
vma cache.  Remove the vmacache to reduce work in keeping it up to date
and code complexity.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: More efficient rev_awalk and mas_next()
Liam R. Howlett [Mon, 16 Nov 2020 19:42:02 +0000 (14:42 -0500)]
maple_tree: More efficient rev_awalk and mas_next()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change vma->vm_mm to mm
Liam R. Howlett [Thu, 12 Nov 2020 00:30:47 +0000 (19:30 -0500)]
mm/mmap: Change vma->vm_mm to mm

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix unlock range un do_munmap
Liam R. Howlett [Wed, 11 Nov 2020 21:27:36 +0000 (16:27 -0500)]
mm/mmap: Fix unlock range un do_munmap

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Clean up mas_ascend() on root parent
Liam R. Howlett [Wed, 11 Nov 2020 18:39:10 +0000 (13:39 -0500)]
maple_tree: Clean up mas_ascend() on root parent

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: reset mas->node to MAS_START in mas_next() if it's MAS_NONE
Liam R. Howlett [Wed, 11 Nov 2020 18:36:14 +0000 (13:36 -0500)]
maple_tree: reset mas->node to MAS_START in mas_next() if it's MAS_NONE

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Drop munmap_vma_range()
Liam R. Howlett [Wed, 11 Nov 2020 18:32:57 +0000 (13:32 -0500)]
mm/mmap: Drop munmap_vma_range()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: When mas_walk() is called in mas->node == MAS_NONE, reset to MAS_START
Liam R. Howlett [Wed, 11 Nov 2020 18:27:54 +0000 (13:27 -0500)]
maple_tree: When mas_walk() is called in mas->node == MAS_NONE, reset to MAS_START

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change mmap_region to use maple tree state
Liam R. Howlett [Tue, 10 Nov 2020 18:37:40 +0000 (13:37 -0500)]
mm/mmap: Change mmap_region to use maple tree state

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix do_brk_munmap() multiple pages.
Liam R. Howlett [Mon, 9 Nov 2020 19:45:37 +0000 (14:45 -0500)]
mm/mmap: Fix do_brk_munmap() multiple pages.

This is rare, so just use the slower __do_munmap()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Call __do_munmap() on slow path of do_brk_munmap()
Liam R. Howlett [Mon, 9 Nov 2020 18:41:05 +0000 (13:41 -0500)]
mm/mmap: Call __do_munmap() on slow path of do_brk_munmap()

do_brk_munmap() would not handle the unmapping of multiple VMAs in the case of
mprotect'ed regions of a brk() so just use the full __do_munmap() in these
rare cases.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Finish converting brk() to using a maple state
Liam R. Howlett [Fri, 6 Nov 2020 21:54:02 +0000 (16:54 -0500)]
mm/mmap: Finish converting brk() to using a maple state

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add mas_store_gfp() and fix mas_prev() and mas_store()
Liam R. Howlett [Fri, 6 Nov 2020 21:52:59 +0000 (16:52 -0500)]
maple_tree: Add mas_store_gfp() and fix mas_prev() and mas_store()

When searching for the previous value, walk the node first.  Don't just assume we are looking for the
last entry if it's MAS_START.

mas_store() and mas_destroy() now workk better with MAS_START as well.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Optimizations and whitespace. nothing interesting
Liam R. Howlett [Fri, 6 Nov 2020 21:50:55 +0000 (16:50 -0500)]
maple_tree: Optimizations and whitespace.  nothing interesting

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: whitespace
Liam R. Howlett [Wed, 4 Nov 2020 02:41:52 +0000 (21:41 -0500)]
maple_tree: whitespace

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Make bench_slot_store() more realistic
Liam R. Howlett [Wed, 4 Nov 2020 02:39:33 +0000 (21:39 -0500)]
test_maple_tree: Make bench_slot_store() more realistic

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Optimize __mas_next a bit, I hope
Liam R. Howlett [Wed, 4 Nov 2020 02:33:58 +0000 (21:33 -0500)]
maple_tree: Optimize __mas_next a bit, I hope

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add metadata to arange nodes.
Liam R. Howlett [Wed, 4 Nov 2020 02:33:19 +0000 (21:33 -0500)]
maple_tree: Add metadata to arange nodes.

Add a metadata into the arange64 nodes to tell the end and the largest gap slot.

This is used to speed up various activities on the node, especially finding the
end of the data and updating the gap.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm_types: Drop more rb tree from vm_area
Liam R. Howlett [Mon, 2 Nov 2020 17:34:31 +0000 (12:34 -0500)]
mm_types: Drop more rb tree from vm_area

Note: Need to fix NOMMU code
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fux mm->map reference to mm->mmap after rebase
Liam R. Howlett [Mon, 2 Nov 2020 01:02:10 +0000 (20:02 -0500)]
mm/mmap: Fux mm->map reference to mm->mmap after rebase

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agommm/mmap: Fix differences after rebase
Liam R. Howlett [Fri, 30 Oct 2020 19:19:27 +0000 (15:19 -0400)]
mmm/mmap: Fix differences after rebase

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rework MA_STATE_BULK and MA_STATE_REBALANCE
Liam R. Howlett [Fri, 30 Oct 2020 01:45:01 +0000 (21:45 -0400)]
maple_tree: Rework MA_STATE_BULK and MA_STATE_REBALANCE

Set MA_STATE_BULK when setting the expected number of store events.

Only rebalance the end node when it is deficient.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Add bench_slot_store()
Liam R. Howlett [Thu, 29 Oct 2020 20:01:48 +0000 (16:01 -0400)]
test_maple_tree: Add bench_slot_store()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Drop 128B node support
Liam R. Howlett [Thu, 29 Oct 2020 19:45:43 +0000 (15:45 -0400)]
maple_tree: Drop 128B node support

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix _mas_store() expand null
Liam R. Howlett [Thu, 29 Oct 2020 19:11:39 +0000 (15:11 -0400)]
maple_tree: Fix _mas_store() expand null

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rename MA_STATE_ defines
Liam R. Howlett [Thu, 29 Oct 2020 18:35:26 +0000 (14:35 -0400)]
maple_tree: Rename MA_STATE_ defines

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Don't use mas_extend_null in _mas_store()
Liam R. Howlett [Thu, 29 Oct 2020 17:54:49 +0000 (13:54 -0400)]
maple_tree: Don't use mas_extend_null in _mas_store()

mas_extend_null() is too heavy when the nulls are contained within a single node.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Drop dump in check_ranges()
Liam R. Howlett [Wed, 28 Oct 2020 02:46:00 +0000 (22:46 -0400)]
test_maple_tree: Drop dump in check_ranges()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Reduce variables by using mas->offset directly.. more.
Liam R. Howlett [Wed, 28 Oct 2020 02:40:18 +0000 (22:40 -0400)]
maple_tree: Reduce variables by using mas->offset directly.. more.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Reduce variables by using mas->offset directly
Liam R. Howlett [Wed, 28 Oct 2020 02:16:23 +0000 (22:16 -0400)]
maple_tree: Reduce variables by using mas->offset directly

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Remove mas_offset() and mas_set_offset() now that offset is in ma_state...
Liam R. Howlett [Wed, 28 Oct 2020 01:54:25 +0000 (21:54 -0400)]
maple_tree: Remove mas_offset() and mas_set_offset() now that offset is in ma_state directly

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix vma locking on brk
Liam R. Howlett [Wed, 28 Oct 2020 00:25:17 +0000 (20:25 -0400)]
mm/mmap: Fix vma locking on brk

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Some optimizations, I hope
Liam R. Howlett [Wed, 28 Oct 2020 00:24:50 +0000 (20:24 -0400)]
maple_tree: Some optimizations, I hope

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix _mas_store() rmin expansion on null.
Liam R. Howlett [Tue, 27 Oct 2020 18:10:59 +0000 (14:10 -0400)]
maple_tree: Fix _mas_store() rmin expansion on null.

When the offset changes on expanding null, ensure the min slot value changes
as well.  This avoids a fall-through to the slow path and uses the
mas_node_store() instead.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/fork: Update maple tree interface.
Liam R. Howlett [Tue, 27 Oct 2020 16:54:10 +0000 (12:54 -0400)]
kernel/fork: Update maple tree interface.

Start using the number of entries directly, and mas_destroy().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Implement optimized fork splitting.
Liam R. Howlett [Tue, 27 Oct 2020 16:52:49 +0000 (12:52 -0400)]
maple_tree: Implement optimized fork splitting.

When using mas_for_each with pre-allocations, split so that there are
more slots available to the left.  If this results in an insufficient
node to the left, then rebalance on mas_destroy().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mas_alloc_push() overflow
Liam R. Howlett [Mon, 26 Oct 2020 22:23:36 +0000 (18:23 -0400)]
maple_tree: Fix mas_alloc_push() overflow

mas_alloc_push() was overflowing and writing the next node.  Add #define to
clean up the alloc slot calculations

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Add more allocation checks around overflow
Liam R. Howlett [Mon, 26 Oct 2020 00:31:56 +0000 (20:31 -0400)]
test_maple_tree: Add more allocation checks around overflow

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix allocation issues
Liam R. Howlett [Sun, 25 Oct 2020 02:50:19 +0000 (22:50 -0400)]
maple_tree: Fix allocation issues

Ensure no overflow on mas_alloc_nodes()
Use allocated instead of calling mas_allocated() multiple times
Fix mas_set_alloc_req() to set the value and not add it.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Test poping all pushed nodes to ensure mas_allocated is set correctly
Liam R. Howlett [Wed, 21 Oct 2020 19:38:48 +0000 (15:38 -0400)]
test_maple_tree: Test poping all pushed nodes to ensure mas_allocated is set correctly

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add better allocation testing and relax push_left to avoid jitters
Liam R. Howlett [Wed, 21 Oct 2020 19:23:50 +0000 (15:23 -0400)]
maple_tree: Add better allocation testing and relax push_left to avoid jitters

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Add check_forking()
Liam R. Howlett [Thu, 22 Oct 2020 19:38:31 +0000 (15:38 -0400)]
test_maple_tree: Add check_forking()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: clean up a few small things
Liam R. Howlett [Thu, 22 Oct 2020 18:46:42 +0000 (14:46 -0400)]
maple_tree: clean up a few small things

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mas_for_each limits on index when searching for first entry in node
Liam R. Howlett [Thu, 22 Oct 2020 18:46:13 +0000 (14:46 -0400)]
maple_tree: Fix mas_for_each limits on index when searching for first entry in node

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix unnecessary locking of anon_vma on expanding of a vma.
Liam R. Howlett [Tue, 20 Oct 2020 18:59:58 +0000 (14:59 -0400)]
mm/mmap: Fix unnecessary locking of anon_vma on expanding of a vma.

When expanding the end of a vma, it is unnecessary to loc the anon_vma tree for writing
because the spinlock on the vma tree ensures that there are no concurrent vma expansions

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree_test: Fix compile warnings
Liam R. Howlett [Tue, 20 Oct 2020 16:25:02 +0000 (12:25 -0400)]
maple_tree_test: Fix compile warnings

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mas_alloc_nodes() off by one in bulk alloc
Liam R. Howlett [Tue, 20 Oct 2020 16:24:51 +0000 (12:24 -0400)]
maple_tree: Fix mas_alloc_nodes() off by one in bulk alloc

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Switch to kmem_cache_alloc_bulk() instead of single node allocations
Liam R. Howlett [Sat, 17 Oct 2020 00:06:05 +0000 (20:06 -0400)]
maple_tree: Switch to kmem_cache_alloc_bulk() instead of single node allocations

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotools/testing/radix-tree: Add keme_cache_alloc_bulk() support
Liam R. Howlett [Sat, 17 Oct 2020 00:05:01 +0000 (20:05 -0400)]
tools/testing/radix-tree: Add keme_cache_alloc_bulk() support

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add mas_node_store() and fix issue with mas_slot_store()
Liam R. Howlett [Thu, 15 Oct 2020 17:08:44 +0000 (13:08 -0400)]
maple_tree: Add mas_node_store() and fix issue with mas_slot_store()

Add mas_node_store when alterations can be contained within a single node.

Rename mas_fast_store to mas_slot_store.
Fix issue with mas_fast_store getting the wrong range when expanding nulls back.  The range
max was not being updated.

Add testcases for benchmarking and fix forking benchmark

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: change cnt to count
Liam R. Howlett [Tue, 13 Oct 2020 20:31:53 +0000 (16:31 -0400)]
test_maple_tree: change cnt to count

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: cnt => count
Liam R. Howlett [Tue, 13 Oct 2020 18:13:02 +0000 (14:13 -0400)]
maple_tree: cnt => count

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add mas_free to push unused nodes
Liam R. Howlett [Tue, 13 Oct 2020 16:14:27 +0000 (12:14 -0400)]
maple_tree: Add mas_free to push unused nodes

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix memory leak by maple tree
Liam R. Howlett [Sun, 11 Oct 2020 03:35:05 +0000 (23:35 -0400)]
mm/mmap: Fix memory leak by maple tree

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Export mas_empty_alloc() for mas_for_each pre-allocations
Liam R. Howlett [Sun, 11 Oct 2020 18:18:05 +0000 (14:18 -0400)]
maple_tree: Export mas_empty_alloc() for mas_for_each pre-allocations

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix ltp shmt09 by checking if vma->vm_anon before locking in vma_mt_brk()
Liam R. Howlett [Sat, 10 Oct 2020 01:40:55 +0000 (21:40 -0400)]
maple_tree: Fix ltp shmt09 by checking if vma->vm_anon before locking in vma_mt_brk()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: brk fix
Liam R. Howlett [Sat, 10 Oct 2020 00:30:17 +0000 (20:30 -0400)]
mm/mmap: brk fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change vm_brk_flags() to use mm_populate_vma()
Liam R. Howlett [Fri, 9 Oct 2020 19:57:40 +0000 (15:57 -0400)]
mm/mmap: Change vm_brk_flags() to use mm_populate_vma()

Skip searching for the vma to populate after creating it by passing in a pointer.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change do_brk_munmap/do_brk_flags().
Liam R. Howlett [Fri, 9 Oct 2020 19:35:01 +0000 (15:35 -0400)]
mm/mmap: Change do_brk_munmap/do_brk_flags().

do_brk_munmap needs to call vma_adjust_trans_huge() when altering the
vma size.

do_brk_munmap needs to support userfaults on umap.

do_brk_flags needs to take a pointer as it could return a new value that
needs to be populated.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix find_vma_intersction() cache update with possible incorrect addr
Liam R. Howlett [Fri, 9 Oct 2020 19:12:59 +0000 (15:12 -0400)]
maple_tree: Fix find_vma_intersction() cache update with possible incorrect addr

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix vma_adjust in tracking maple tree
Liam R. Howlett [Fri, 9 Oct 2020 19:08:56 +0000 (15:08 -0400)]
mm/mmap: Fix vma_adjust in tracking maple tree

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/fork: Adjust maple calls
Liam R. Howlett [Fri, 9 Oct 2020 19:00:54 +0000 (15:00 -0400)]
kernel/fork: Adjust maple calls

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomas_entry_cnt() rename and cleanup
Liam R. Howlett [Fri, 9 Oct 2020 19:00:28 +0000 (15:00 -0400)]
mas_entry_cnt() rename and cleanup

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Return NULL on unlikely not found case.
Liam R. Howlett [Tue, 6 Oct 2020 19:38:38 +0000 (15:38 -0400)]
maple_tree: Return NULL on unlikely not found case.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Set offset out of range on mas_is_ptr in _mas_walk()
Liam R. Howlett [Tue, 6 Oct 2020 19:23:10 +0000 (15:23 -0400)]
maple_tree: Set offset out of range on mas_is_ptr in _mas_walk()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Return false if _mas_walk is a ptr and mas->index != 0
Liam R. Howlett [Tue, 6 Oct 2020 19:21:36 +0000 (15:21 -0400)]
maple_tree: Return false if _mas_walk is a ptr and mas->index != 0

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Drop span_enode to get ma_state to one cacheline
Liam R. Howlett [Tue, 6 Oct 2020 19:21:06 +0000 (15:21 -0400)]
maple_tree: Drop span_enode to get ma_state to one cacheline

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Change hard-coded 127 to MAPLE_NODE_MASK
Liam R. Howlett [Tue, 6 Oct 2020 19:20:27 +0000 (15:20 -0400)]
maple_tree: Change hard-coded 127 to MAPLE_NODE_MASK

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Clean up brk modifications
Liam R. Howlett [Mon, 5 Oct 2020 18:39:55 +0000 (14:39 -0400)]
mm/mmap: Clean up brk modifications

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix exit_mmap() call to unlock_range()
Liam R. Howlett [Mon, 5 Oct 2020 17:54:49 +0000 (13:54 -0400)]
mm/mmap: Fix exit_mmap() call to unlock_range()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/fork: Don't take spinlock of maple tree.
Liam R. Howlett [Thu, 1 Oct 2020 14:03:48 +0000 (10:03 -0400)]
kernel/fork: Don't take spinlock of maple tree.

You cannot take the spinlock of the maple tree and then allocate VMAs.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mte_destroy_walk() overwriting slots when spinlock debug is enabled.
Liam R. Howlett [Thu, 1 Oct 2020 14:03:22 +0000 (10:03 -0400)]
maple_tree: Fix mte_destroy_walk() overwriting slots when spinlock debug is enabled.

When spinlock debug is enabled, the size fo the spinlock expands and causes the anon union
in maple_node to overwrite slots.  Fix this by only passing through the maple flags.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Export find_vma_intersection to fix unresolved symbols in
Liam R. Howlett [Wed, 30 Sep 2020 16:27:32 +0000 (12:27 -0400)]
mm/mmap: Export find_vma_intersection to fix unresolved symbols in
modules

kvm was complaining that the static function has become an extern.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix double null
Liam R. Howlett [Tue, 29 Sep 2020 19:17:04 +0000 (15:17 -0400)]
maple_tree: Fix double null

Google reported a double null in Android.  The captured reproducer is in
set42.  Issue was a store spanning offsets, so the entry before the
start offset and the entry after the end offset needs to be checked
instead of assuming the entry being added would write to a single
offset.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mas_parent_gap() propigation upwards
Liam R. Howlett [Tue, 29 Sep 2020 14:37:37 +0000 (10:37 -0400)]
maple_tree: Fix mas_parent_gap() propigation upwards

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add missing mas_walk() which is part of the interface
Liam R. Howlett [Tue, 29 Sep 2020 13:35:46 +0000 (09:35 -0400)]
maple_tree: Add missing mas_walk() which is part of the interface

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Use ma_slots() instead of mas_get_slot() in _mas_awalk()
Liam R. Howlett [Tue, 29 Sep 2020 13:35:25 +0000 (09:35 -0400)]
maple_tree: Use ma_slots() instead of mas_get_slot() in _mas_awalk()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rename range_walk to _walk, clean up mas_node_walk
Liam R. Howlett [Tue, 29 Sep 2020 13:23:13 +0000 (09:23 -0400)]
maple_tree: Rename range_walk to _walk, clean up mas_node_walk

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: optimize root expand
Liam R. Howlett [Mon, 28 Sep 2020 20:27:00 +0000 (16:27 -0400)]
maple_tree: optimize root expand

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Drop dup_tree()
Liam R. Howlett [Mon, 28 Sep 2020 20:07:21 +0000 (16:07 -0400)]
maple_tree: Drop dup_tree()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Alter brk to be more maple tree efficient.
Liam R. Howlett [Mon, 28 Sep 2020 19:52:08 +0000 (15:52 -0400)]
mm/mmap: Alter brk to be more maple tree efficient.

Alter the brk, do_brk_flags() calls and add do_brk_munmap() to be more
efficient when using the maple tree.

kvm Benchmark on 8 core laptop:
./mmtests/work/sources/wis-0-installed/brk1_threads

rb_tree v5.9-rc1:
min:3633758 max:3633758 total:3633758
min:3604892 max:3604892 total:3604892
min:3589182 max:3589182 total:3589182
min:3581230 max:3581230 total:3581230

maple tree with this patch:
min:3673408 max:3673408 total:3673408
min:3659268 max:3659268 total:3659268
min:3624968 max:3624968 total:3624968
min:3613576 max:3613576 total:3613576

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Move find_vma_intersection to mmap.c and change implementation to maple tree.
Liam R. Howlett [Mon, 28 Sep 2020 19:50:19 +0000 (15:50 -0400)]
mm: Move find_vma_intersection to mmap.c and change implementation to maple tree.

When searching for a vma within a range, it is easier to use the maple tree interface.  This means
the find_vma() call changes to a special case of the find_vma_intersection()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/fork: Stop using dup tree and pre-allocate the nodes needed.
Liam R. Howlett [Mon, 28 Sep 2020 19:46:55 +0000 (15:46 -0400)]
kernel/fork: Stop using dup tree and pre-allocate the nodes needed.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Export mas_entry_cnt to setup external mas.
Liam R. Howlett [Mon, 28 Sep 2020 19:45:34 +0000 (15:45 -0400)]
maple_tree: Export mas_entry_cnt to setup external mas.

When the number of elements are know, this can pre-allocate the set
number.

4 years agomaple_tree: Fix validate on empty tree and some compile issue. crap.
Liam R. Howlett [Mon, 28 Sep 2020 19:26:07 +0000 (15:26 -0400)]
maple_tree: Fix validate on empty tree and some compile issue. crap.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix bug in mas_next_node and optimize _mas_next slightly
Liam R. Howlett [Mon, 28 Sep 2020 19:25:50 +0000 (15:25 -0400)]
maple_tree: Fix bug in mas_next_node and optimize _mas_next slightly

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add mas_root_locked() and mas_root(), rename protected() to locked()
Liam R. Howlett [Mon, 28 Sep 2020 19:25:20 +0000 (15:25 -0400)]
maple_tree: Add mas_root_locked() and mas_root(), rename protected() to locked()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix state for external mas
Liam R. Howlett [Mon, 28 Sep 2020 19:22:19 +0000 (15:22 -0400)]
maple_tree: Fix state for external mas

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>