]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
4 years agobroken maple_wip
Liam R. Howlett [Fri, 5 Mar 2021 14:33:47 +0000 (09:33 -0500)]
broken

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Optimize mmap_region() use of maple states
Liam R. Howlett [Tue, 2 Mar 2021 15:15:35 +0000 (10:15 -0500)]
mm/mmap: Optimize mmap_region() use of maple states

Only walk down once after the tree was modified with the munmap call.  Copy mas
to find prev and next.  Only reset mas if the address changed.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoFix ipc/shm for nommu.
Liam R. Howlett [Mon, 1 Mar 2021 21:01:05 +0000 (16:01 -0500)]
Fix ipc/shm for nommu.

Define mas for nommu and mmu builds

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix mas_find for a single entry, add test
Liam R. Howlett [Mon, 1 Mar 2021 19:36:59 +0000 (14:36 -0500)]
maple_tree: Fix mas_find for a single entry, add test

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/test_maple_tree: Rename zero() to not_empty(), use mas_set(), add more allocation...
Liam R. Howlett [Mon, 1 Mar 2021 19:36:18 +0000 (14:36 -0500)]
lib/test_maple_tree: Rename zero() to not_empty(), use mas_set(), add more allocation tests

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Clean up node allocations
Liam R. Howlett [Mon, 1 Mar 2021 19:34:11 +0000 (14:34 -0500)]
lib/maple_tree: Clean up node allocations

Remove extra parenthesis, etc

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mempolicy: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:30:58 +0000 (14:30 -0500)]
mm/mempolicy: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/memory.c: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:30:38 +0000 (14:30 -0500)]
mm/memory.c: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoarch/powerpc/oprofile/cell/spu_task_sync: Use vma_lookup() instead of find_vma_inters...
Liam R. Howlett [Mon, 1 Mar 2021 19:30:00 +0000 (14:30 -0500)]
arch/powerpc/oprofile/cell/spu_task_sync: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoarch/powerpc/kvm/book3s_hv_uvmem: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:29:29 +0000 (14:29 -0500)]
arch/powerpc/kvm/book3s_hv_uvmem: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoarch/mips/kernel/traps: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:29:09 +0000 (14:29 -0500)]
arch/mips/kernel/traps: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoarch/arm64/kvm: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:28:44 +0000 (14:28 -0500)]
arch/arm64/kvm: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agodrivers/oprofile: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:28:00 +0000 (14:28 -0500)]
drivers/oprofile: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agovfio: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:27:28 +0000 (14:27 -0500)]
vfio: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agovirt/kvm: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:26:37 +0000 (14:26 -0500)]
virt/kvm: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoarch/arc/kernel/troubleshoot: use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:25:27 +0000 (14:25 -0500)]
arch/arc/kernel/troubleshoot: use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/framge_vector: Use vma_lookup() instead of find_vma_intersection()
Liam R. Howlett [Mon, 1 Mar 2021 19:24:29 +0000 (14:24 -0500)]
mm/framge_vector: Use vma_lookup() instead of find_vma_intersection()

vma_lookup() is more efficient

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix mmap_region() maple state
Liam R. Howlett [Mon, 1 Mar 2021 19:23:26 +0000 (14:23 -0500)]
mm/mmap: Fix mmap_region() maple state

When finding next, tmp must be reset to mas to ensure the correct slot is
used for writing

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix whitespace in expand_upwards()
Liam R. Howlett [Mon, 1 Mar 2021 19:22:39 +0000 (14:22 -0500)]
mm/mmap: Fix whitespace in expand_upwards()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Add vma_lookup()
Liam R. Howlett [Mon, 1 Mar 2021 19:01:06 +0000 (14:01 -0500)]
mm: Add vma_lookup()

Walk the maple tree to find the requested address.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoi915_vma: Rename vma_lookup to i915_vma_lookup
Liam R. Howlett [Mon, 1 Mar 2021 18:59:43 +0000 (13:59 -0500)]
i915_vma: Rename vma_lookup to i915_vma_lookup

Use i915 prefix to avoid name collision with future vma_lookup() in mm.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add 32 bit support
Liam R. Howlett [Wed, 24 Feb 2021 20:30:13 +0000 (15:30 -0500)]
maple_tree: Add 32 bit support

Add the defines for the size of nodes, etc to support 32 bit kernels.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agonommu: remove cache
Liam R. Howlett [Tue, 23 Feb 2021 16:35:27 +0000 (11:35 -0500)]
nommu: remove cache

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/nommu and fs/proc/task_nommu: convert to maple tree
Liam R. Howlett [Tue, 23 Feb 2021 16:24:23 +0000 (11:24 -0500)]
mm/nommu and fs/proc/task_nommu: convert to maple tree

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agonommu: linked list fix
Liam R. Howlett [Tue, 23 Feb 2021 16:23:44 +0000 (11:23 -0500)]
nommu: linked list fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Restore rb_node to vm_region.
Liam R. Howlett [Tue, 23 Feb 2021 15:52:01 +0000 (10:52 -0500)]
mm: Restore rb_node to vm_region.

nommu uses the rb tree for overlapped shared regions

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Move mm_populate_vma to internal header.
Liam R. Howlett [Tue, 23 Feb 2021 15:51:13 +0000 (10:51 -0500)]
mm: Move mm_populate_vma to internal header.

mm_populate_vma is only internal to mm code

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Move vma_mas_store()/vma_mas_erase() to internal header.
Liam R. Howlett [Tue, 23 Feb 2021 15:49:13 +0000 (10:49 -0500)]
mm: Move vma_mas_store()/vma_mas_erase() to internal header.

These are used in nommu case as well

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: add mtree_store() to header
Liam R. Howlett [Mon, 22 Feb 2021 01:05:26 +0000 (20:05 -0500)]
maple_tree: add mtree_store() to header

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add static where necessary.
Liam R. Howlett [Mon, 22 Feb 2021 01:04:48 +0000 (20:04 -0500)]
maple_tree: Add static where necessary.

Add static to anywhere sparse reports necessary.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change do_mas_align_munmap() to static
Liam R. Howlett [Mon, 22 Feb 2021 00:55:52 +0000 (19:55 -0500)]
mm/mmap: Change do_mas_align_munmap() to static

Add static to the declaration as reported by sparse

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Fix rcu annotations
Matthew Wilcox (Oracle) [Sun, 21 Feb 2021 04:46:45 +0000 (23:46 -0500)]
lib/maple_tree: Fix rcu annotations

Add all the missing __rcu annotations reported by sparse.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
4 years agomm/mmap: Lock maple tree when using mas_store_gfp()
Liam R. Howlett [Sat, 20 Feb 2021 17:56:07 +0000 (12:56 -0500)]
mm/mmap: Lock maple tree when using mas_store_gfp()

When storing to the maple tree, take the write lock to avoid
entering/exiting the use of RCU during a write operation.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Fix mas_pop_node() zeroing.
Liam R. Howlett [Sat, 20 Feb 2021 17:52:56 +0000 (12:52 -0500)]
lib/maple_tree: Fix mas_pop_node() zeroing.

When using a single allocation in the node, zero out slot 0 of the node
being returned.

Also, small whitespace fix in mas_push

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/ksm: Fix compile warning and whitespace for 3fd77bfa4f25fa
Liam R. Howlett [Thu, 18 Feb 2021 14:51:08 +0000 (09:51 -0500)]
mm/ksm: Fix compile warning and whitespace for 3fd77bfa4f25fa

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Fix mas_store_gfp() on spanning store.
Liam R. Howlett [Thu, 18 Feb 2021 14:27:48 +0000 (09:27 -0500)]
lib/maple_tree: Fix mas_store_gfp() on spanning store.

Spanning store detection needs to be more robust than checking if it spans the end of
a node.  Fix the detection by using mas_is_span_wr().  Also ensure it's not MAS_NONE.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Add check for dead nodes in mt_validate()
Liam R. Howlett [Thu, 18 Feb 2021 14:26:45 +0000 (09:26 -0500)]
lib/maple_tree: Add check for dead nodes in mt_validate()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: __insert_vm_struct() only needs to mas_reset()
Liam R. Howlett [Thu, 18 Feb 2021 14:26:07 +0000 (09:26 -0500)]
mm/mmap: __insert_vm_struct() only needs to mas_reset()

vma_mas_store() will set the range again.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mprotect: Use vma_next() of prev.
Liam R. Howlett [Thu, 18 Feb 2021 14:24:49 +0000 (09:24 -0500)]
mm/mprotect: Use vma_next() of prev.

The linked list used to use prev->next.  the maple state may be invalidated
by the mprotect_fixup call which may alter the tree.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mprotect: Use vma_next() instead of mas_next().
Liam R. Howlett [Wed, 17 Feb 2021 22:15:37 +0000 (17:15 -0500)]
mm/mprotect: Use vma_next() instead of mas_next().

mas is in the wrong state and would potentially return the current vma twice.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix mmap_region() maple tree store.
Liam R. Howlett [Wed, 17 Feb 2021 22:03:35 +0000 (17:03 -0500)]
mm/mmap: Fix mmap_region() maple tree store.

mas_set_range() before vma_mas_link() as the address may have changed
as commented above in the code.

Do the same in the error path.

This forces a reset of the mas->node to MA_START.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: ULONG_MAX in exit_mmap
Liam R. Howlett [Wed, 17 Feb 2021 14:19:55 +0000 (09:19 -0500)]
mm/mmap: ULONG_MAX in exit_mmap

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: ULONG_MAX in do_brk_munmap
Liam R. Howlett [Wed, 17 Feb 2021 14:19:38 +0000 (09:19 -0500)]
mm/mmap: ULONG_MAX in do_brk_munmap

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: ULONG_MAX in detach_range
Liam R. Howlett [Wed, 17 Feb 2021 14:19:25 +0000 (09:19 -0500)]
mm/mmap: ULONG_MAX in detach_range

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: ULONG_MAX in remove_mt
Liam R. Howlett [Wed, 17 Feb 2021 14:19:08 +0000 (09:19 -0500)]
mm/mmap: ULONG_MAX in remove_mt

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mprotect: Change do_mprotect_pkey() -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:17:40 +0000 (09:17 -0500)]
mm/mprotect: Change do_mprotect_pkey()  -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomempolicy: Fix mbind_range -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:16:52 +0000 (09:16 -0500)]
mempolicy: Fix mbind_range -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/sched/fair: Change -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:16:24 +0000 (09:16 -0500)]
kernel/sched/fair: Change -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/acct: Change -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:16:07 +0000 (09:16 -0500)]
kernel/acct: Change -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotask_mmu: Change -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:15:53 +0000 (09:15 -0500)]
task_mmu: Change -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoppc book3s32: Change -1 to ULONG_MAX
Liam R. Howlett [Wed, 17 Feb 2021 14:15:37 +0000 (09:15 -0500)]
ppc book3s32: Change -1 to ULONG_MAX

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Reset request_count to 0 of old head on push
Liam R. Howlett [Tue, 16 Feb 2021 18:33:24 +0000 (13:33 -0500)]
lib/maple_tree: Reset request_count to 0 of old head on push

Just to be safe

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Add validate_mm() to __vma_adjust() start
Liam R. Howlett [Tue, 16 Feb 2021 15:49:09 +0000 (10:49 -0500)]
mm/mmap: Add validate_mm() to __vma_adjust() start

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mprotect: Fix adcfbd7698558a linked list removal
Liam R. Howlett [Wed, 10 Feb 2021 14:33:59 +0000 (09:33 -0500)]
mm/mprotect: Fix adcfbd7698558a linked list removal

Use mas_find() in do_mprotect_pkey to find the next vma to better align
with what happened with the old API

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agokernel/sched/fair: Fix linked list fallout 4acb2b9560cd8f
Liam R. Howlett [Wed, 10 Feb 2021 14:30:51 +0000 (09:30 -0500)]
kernel/sched/fair: Fix linked list fallout 4acb2b9560cd8f

When searching for the vma, use mas_find, not mas_walk() to better do what was happening before

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mempolicy: fix adcfbd7698558a
Liam R. Howlett [Tue, 9 Feb 2021 19:37:24 +0000 (14:37 -0500)]
mm/mempolicy: fix adcfbd7698558a

When removing the linked list, a bug was introduced in maple state
iterator used for the mbind_range() function.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: do_brk_munmap() whitespace fix
Liam R. Howlett [Tue, 9 Feb 2021 14:45:09 +0000 (09:45 -0500)]
mm/mmap: do_brk_munmap() whitespace fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: use ma_is_root() in mas_replace().
Liam R. Howlett [Tue, 9 Feb 2021 00:34:00 +0000 (19:34 -0500)]
maple_tree: use ma_is_root() in mas_replace().

Instead of using mte_is_root(), use ma_is_root() directly since the maple node
is known already.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Find next vma in do_brk_munmap() prior to updating tree.
Liam R. Howlett [Tue, 9 Feb 2021 00:33:02 +0000 (19:33 -0500)]
mm/mmap: Find next vma in do_brk_munmap() prior to updating tree.

The tree update may invalidate the location and cause a longer search if the VMA does not
preceed a NULL entry

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix do_brk_munmap() when munmapping an entire VMA or more
Liam R. Howlett [Tue, 9 Feb 2021 00:31:53 +0000 (19:31 -0500)]
mm/mmap: Fix do_brk_munmap() when munmapping an entire VMA or more

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Add more validate_mm() calls
Liam R. Howlett [Tue, 9 Feb 2021 00:24:58 +0000 (19:24 -0500)]
mm/mmap: Add more validate_mm() calls

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Return a bool from anon_vma_interval_tree_verify()
Liam R. Howlett [Sun, 7 Feb 2021 00:47:59 +0000 (19:47 -0500)]
mm: Return a bool from anon_vma_interval_tree_verify()

Added to allow printing which vma has the issue

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: expand_upwards() shouldn't call validate_mm()
Liam R. Howlett [Sun, 7 Feb 2021 00:47:17 +0000 (19:47 -0500)]
mm/mmap: expand_upwards() shouldn't call validate_mm()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: mmap_region() fixes for when expanding vma as well as anon
Liam R. Howlett [Sun, 7 Feb 2021 00:46:38 +0000 (19:46 -0500)]
mm/mmap: mmap_region() fixes for when expanding vma as well as anon

When expanding a vma, call khugepaged_enter_vma_merge() with correct vma.

Also, set the vm_pgoff to the correct value when adding an anon mapping.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix detach_range() and do_mas_align_munmap()
Liam R. Howlett [Sun, 7 Feb 2021 00:44:50 +0000 (19:44 -0500)]
mm/mmap: Fix detach_range() and do_mas_align_munmap()

When searching for the first entry overlapp in do_mas_align_munmap(), the mas->last
will be modified if one is found, and if the maple state isn't reset for splitting,
then the wrong end will be past to detach_range() in the maple state.

detach_range() no longer needs both vma and vm_area_struct last, so make that change
too.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: vma_expand() Cleanup code a bit
Liam R. Howlett [Sun, 7 Feb 2021 00:41:29 +0000 (19:41 -0500)]
mm/mmap: vma_expand() Cleanup code a bit

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix linked list damage from e40a951e09ed0e
Liam R. Howlett [Thu, 4 Feb 2021 19:23:45 +0000 (14:23 -0500)]
mm/mmap: Fix linked list damage from e40a951e09ed0e

Drop unnecessary while() after mas_for_each()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agofs/proc/task_mmu: Fix linked list damage from c4e6b1dfcb6f99
Liam R. Howlett [Thu, 4 Feb 2021 19:20:09 +0000 (14:20 -0500)]
fs/proc/task_mmu: Fix linked list damage from c4e6b1dfcb6f99

Fix reset of mas and initialize vma_start.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/ksm: Fix error introduced in 3fd77bfa4f25fa
Liam R. Howlett [Thu, 4 Feb 2021 19:06:58 +0000 (14:06 -0500)]
mm/ksm: Fix error introduced in 3fd77bfa4f25fa

mm may be uninitialized during the first loop.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Set next to NULL in mmap_region()
Liam R. Howlett [Thu, 4 Feb 2021 18:59:30 +0000 (13:59 -0500)]
mm/mmap: Set next to NULL in mmap_region()

When following cannot_expand goto, next would not be set

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Remove validate from expand() as the lock isn't held.
Liam R. Howlett [Thu, 4 Feb 2021 01:15:18 +0000 (20:15 -0500)]
mm/mmap: Remove validate from expand() as the lock isn't held.

Add validate_mm() to many other locations.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Don't reset ma_neighbour in brk() as it won't be used
Liam R. Howlett [Thu, 4 Feb 2021 01:13:38 +0000 (20:13 -0500)]
mm/mmap: Don't reset ma_neighbour in brk() as it won't be used

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix alignment mess of gap searching
Liam R. Howlett [Thu, 4 Feb 2021 01:07:37 +0000 (20:07 -0500)]
mm/mmap: Fix alignment mess of gap searching

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Assert lock is held before running validate_mm()
Liam R. Howlett [Thu, 4 Feb 2021 01:06:44 +0000 (20:06 -0500)]
mm/mmap: Assert lock is held before running validate_mm()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Drop unused ma_lock from remap_file_pages
Liam R. Howlett [Wed, 3 Feb 2021 15:41:25 +0000 (10:41 -0500)]
mm/mmap: Drop unused ma_lock from remap_file_pages

The variable is not used.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix error path not checking anon_vma for null
Liam R. Howlett [Wed, 3 Feb 2021 15:28:44 +0000 (10:28 -0500)]
mm/mmap: Fix error path not checking anon_vma for null

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rework mas_replace()
Liam R. Howlett [Wed, 3 Feb 2021 14:35:43 +0000 (09:35 -0500)]
maple_tree: Rework mas_replace()

Drop ma_set_slot() and mte_set_slot() in favour of just setting the slot
value in the parent.  This is the only function using those two
functions and they are not necessary.

Drop check for replacing the node with itself as that doesn't happen -
confirmed by running the test suite with a BUG_ON instead of the swap.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mempolicy: Fix mas_for_each() loop
Liam R. Howlett [Wed, 3 Feb 2021 01:21:11 +0000 (20:21 -0500)]
mm/mempolicy: Fix mas_for_each() loop

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agolib/maple_tree: Fix allocation walk iterators.
Liam R. Howlett [Tue, 2 Feb 2021 14:19:43 +0000 (09:19 -0500)]
lib/maple_tree: Fix allocation walk iterators.

Do not reset mas->node or mas->offset and advance the slot on
continuing.

This also drops mas_rev_awalk() and instead pulls it into
mas_empty_area_rev().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix exit_mmap() maple state.
Liam R. Howlett [Tue, 2 Feb 2021 14:17:16 +0000 (09:17 -0500)]
mm/mmap: Fix exit_mmap() maple state.

Do not reset the maple state prior to unmap_vmas().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fux do_mas_align_munmap() search for vma.
Liam R. Howlett [Tue, 2 Feb 2021 14:16:20 +0000 (09:16 -0500)]
mm/mmap: Fux do_mas_align_munmap() search for vma.

Use find instead of walk to search for the VMA to ensure a VMA is found
if the start does not fall on a VMA

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Change gap calculations
Liam R. Howlett [Tue, 2 Feb 2021 14:14:41 +0000 (09:14 -0500)]
mm/mmap: Change gap calculations

When calculating the gaps, make sure the alignment is okay.

This needs further analysis.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/memory: Fix zap_page_range
Liam R. Howlett [Tue, 2 Feb 2021 14:12:34 +0000 (09:12 -0500)]
mm/memory: Fix zap_page_range

Use mas_for_each to avoid calling unmap_single_vma for the start VMA twice.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/memory: Whitespace fix
Liam R. Howlett [Tue, 2 Feb 2021 14:11:59 +0000 (09:11 -0500)]
mm/memory: Whitespace fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Fix validate_mm() warning
Liam R. Howlett [Mon, 1 Feb 2021 19:25:38 +0000 (14:25 -0500)]
mm/mmap: Fix validate_mm() warning

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Remove rb and vma_link() comment on bug.
Liam R. Howlett [Mon, 1 Feb 2021 19:02:47 +0000 (14:02 -0500)]
mm/mmap: Remove rb and vma_link() comment on bug.

This bug does not exist for maple tree

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Use mtree_init() in mt_destroy_walk()
Liam R. Howlett [Mon, 1 Feb 2021 18:48:20 +0000 (13:48 -0500)]
mm/mmap: Use mtree_init() in mt_destroy_walk()

Don't use MTREE_INIT()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Use mtree_init() in do_mas_align_munmap()
Liam R. Howlett [Mon, 1 Feb 2021 18:47:49 +0000 (13:47 -0500)]
mm/mmap: Use mtree_init() in do_mas_align_munmap()

Don't use MTREE_INIT()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mmap: Convert __insert_vm_struct to use mas, convert vma_link to use vma_mas_link() howlett/maple_spf/20210129
Liam R. Howlett [Mon, 4 Jan 2021 18:55:29 +0000 (13:55 -0500)]
mm/mmap: Convert __insert_vm_struct to use mas, convert vma_link to use vma_mas_link()

Drop unused vma_store()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm: Remove vma linked list.
Liam R. Howlett [Mon, 4 Jan 2021 20:15:50 +0000 (15:15 -0500)]
mm: Remove vma linked list.

The vma linked list has been replaced by the maple tree iterators and
vma_next() vma_prev() functions.

A part of this change is also the iterators free_pgd_range(),
zap_page_range(), and unmap_single_vma()

The internal _vma_next() has been dropped.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/util: Remove __vma_link_list() and __vma_unlink_list()
Liam R. Howlett [Mon, 4 Jan 2021 20:10:54 +0000 (15:10 -0500)]
mm/util: Remove __vma_link_list() and __vma_unlink_list()

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/nommu: Stop inserting into the vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:10:18 +0000 (15:10 -0500)]
mm/nommu: Stop inserting into the vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/swapfile: Use maple tree iterator instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:07:11 +0000 (15:07 -0500)]
mm/swapfile: Use maple tree iterator instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/pagewalk: Use vma_next() instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:06:47 +0000 (15:06 -0500)]
mm/pagewalk: Use vma_next() instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/oom_kill: Use maple tree iterators instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:06:25 +0000 (15:06 -0500)]
mm/oom_kill: Use maple tree iterators instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/nommu: Use maple tree iterators instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:04:42 +0000 (15:04 -0500)]
mm/nommu: Use maple tree iterators instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/msync: Use vma_next() instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:04:14 +0000 (15:04 -0500)]
mm/msync: Use vma_next() instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mremap: Use vma_next() instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:03:49 +0000 (15:03 -0500)]
mm/mremap: Use vma_next() instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mprotect: Use maple tree navigation instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:02:28 +0000 (15:02 -0500)]
mm/mprotect: Use maple tree navigation instead of vma linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomm/mlock: Use maple tree iterators instead of vma linked list
Liam R. Howlett [Mon, 4 Jan 2021 20:00:14 +0000 (15:00 -0500)]
mm/mlock: Use maple tree iterators instead of vma linked list

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