Liam R. Howlett
cf51e86dfb
mm/mmap: don't use __vma_adjust() in shift_arg_pages()
...
Introduce shrink_vma() which uses the vma_prepare() and vma_complete()
functions to reduce the vma coverage.
Convert shift_arg_pages() to use expand_vma() and the new shrink_vma()
function. Remove support from __vma_adjust() to reduce a vma size since
shift_arg_pages() is the only user that shrinks a VMA in this way.
Link: https://lkml.kernel.org/r/20230120162650.984577-46-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:38 -08:00
Liam R. Howlett
7c9813e886
mm/mremap: convert vma_adjust() to vma_expand()
...
Stop using vma_adjust() in preparation for removing the function. Export
vma_expand() to use instead.
Link: https://lkml.kernel.org/r/20230120162650.984577-45-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
b2b3b88673
mm: don't use __vma_adjust() in __split_vma()
...
Use the abstracted locking and maple tree operations. Since __split_vma()
is the only user of the __vma_adjust() function to use the insert
argument, drop that argument. Remove the NULL passed through from
fs/exec's shift_arg_pages() and mremap() at the same time.
Link: https://lkml.kernel.org/r/20230120162650.984577-44-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
68cefec539
mm/mmap: introduce init_vma_prep() and init_multi_vma_prep()
...
Add init_vma_prep() and init_multi_vma_prep() to set up the struct
vma_prepare. This is to abstract the locking when adjusting the VMAs.
Also change __vma_adjust() variable remove_next int in favour of a pointer
to the VMA to remove. Rename next_next to remove2 since this better
reflects its use.
Link: https://lkml.kernel.org/r/20230120162650.984577-43-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
9303d3e1c3
mm/mmap: use vma_prepare() and vma_complete() in vma_expand()
...
Use the new locking functions for vma_expand(). This reduces code
duplication.
At the same time change VM_BUG_ON() to VM_WARN_ON()
Link: https://lkml.kernel.org/r/20230120162650.984577-42-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
440703e082
mm/mmap: refactor locking out of __vma_adjust()
...
Move the locking into vma_prepare() and vma_complete() for use elsewhere
Link: https://lkml.kernel.org/r/20230120162650.984577-41-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
e3d73f848e
mm/mmap: move anon_vma setting in __vma_adjust()
...
Move the anon_vma setting & warn_no up the function. This is done to
clear up the locking later.
Link: https://lkml.kernel.org/r/20230120162650.984577-40-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:37 -08:00
Liam R. Howlett
6b73cff239
mm: change munmap splitting order and move_vma()
...
Splitting can be more efficient when the order is not of concern. Change
do_vmi_align_munmap() to reduce walking of the tree during split
operations.
move_vma() must also be altered to remove the dependency of keeping the
original VMA as the active part of the split. Transition to using vma
iterator to look up the prev and/or next vma after munmap.
[Liam.Howlett@oracle.com: fix vma iterator initialization]
Link: https://lkml.kernel.org/r/20230126212011.980350-1-Liam.Howlett@oracle.com
Link: https://lkml.kernel.org/r/20230120162650.984577-39-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
cc8d1b097d
mmap: clean up mmap_region() unrolling
...
Move logic of unrolling to the error path as apposed to duplicating it
within the function body. This reduces the potential of missing an update
to one path when making changes.
Link: https://lkml.kernel.org/r/20230120162650.984577-38-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Cc: Li Zetao <lizetao1@huawei.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
b373037fa9
mm: add vma iterator to vma_adjust() arguments
...
Change the vma_adjust() function definition to accept the vma iterator and
pass it through to __vma_adjust().
Update fs/exec to use the new vma_adjust() function parameters.
Update mm/mremap to use the new vma_adjust() function parameters.
Revert the __split_vma() calls back from __vma_adjust() to vma_adjust()
and pass through the vma iterator.
Link: https://lkml.kernel.org/r/20230120162650.984577-37-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
0fd5a9e2b0
mm: pass vma iterator through to __vma_adjust()
...
Pass the iterator through to be used in __vma_adjust(). The state of the
iterator needs to be correct for the operation that will occur so make the
adjustments.
Link: https://lkml.kernel.org/r/20230120162650.984577-36-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
c465be97a4
mm: remove unnecessary write to vma iterator in __vma_adjust()
...
If the vma start address is going to change due to an insert, then it is
safe to not write the vma to the tree. The write of the insert vma will
alter the tree as necessary.
Link: https://lkml.kernel.org/r/20230120162650.984577-35-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
85ab779e34
madvise: use split_vma() instead of __split_vma()
...
The split_vma() wrapper is specifically for this use case, so use it.
[Liam.Howlett@oracle.com: fix VMA_ITERATOR start position]
Link: https://lkml.kernel.org/r/20230125135809.85262-1-Liam.Howlett@oracle.com
Link: https://lkml.kernel.org/r/20230120162650.984577-34-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:36 -08:00
Liam R. Howlett
9e56044625
mm: pass through vma iterator to __vma_adjust()
...
Pass the vma iterator through to __vma_adjust() so the state can be
updated.
Link: https://lkml.kernel.org/r/20230120162650.984577-33-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
fbcc3104b8
mmap: convert __vma_adjust() to use vma iterator
...
Use the vma iterator internally for __vma_adjust(). Avoid using the maple
tree interface directly for type safety.
Link: https://lkml.kernel.org/r/20230120162650.984577-32-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
34403fa579
mm/damon/vaddr-test.h: stop using vma_mas_store() for maple tree store
...
Prepare for the removal of the vma_mas_store() function by open coding the
maple tree store in this test code. Set the range of the maple state and
call the store function directly.
Link: https://lkml.kernel.org/r/20230120162650.984577-31-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Reported-by: kernel test robot <lkp@intel.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
9760ebffbf
mm: switch vma_merge(), split_vma(), and __split_vma to vma iterator
...
Drop the vmi_* functions and transition all users to use the vma iterator
directly.
Link: https://lkml.kernel.org/r/20230120162650.984577-30-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
07f1bc5ad7
nommu: pass through vma iterator to shrink_vma()
...
Rename the function to vmi_shrink_vma() indicate it takes the vma
iterator. Use the iterator to preallocate and drop the delete function.
The maple tree is able to do the modification easier than the linked list
and rbtree, so just clear the necessary area in the tree.
add_vma_to_mm() is no longer used, so drop this function.
vmi_add_vma_to_mm() is now only used once, so inline this function into
do_mmap().
Link: https://lkml.kernel.org/r/20230120162650.984577-29-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
47d9644de9
nommu: convert nommu to using the vma iterator
...
Gain type safety in nommu by using the vma_iterator and not the maple tree
directly.
Link: https://lkml.kernel.org/r/20230120162650.984577-28-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:35 -08:00
Liam R. Howlett
a27a11f92f
mm/mremap: use vmi version of vma_merge()
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-27-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
076f16bf76
mmap: use vmi version of vma_merge()
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-26-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
0c0c5bffd0
mmap: pass through vmi iterator to __split_vma()
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-25-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
178e22ac20
madvise: use vmi iterator for __split_vma() and vma_merge()
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-24-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
214dbc4281
sched: convert to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-23-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
250cb40f0a
task_mmu: convert to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Update the comments to how the vma iterator works. The vma iterator will
keep track of the last vm_end and start the search from vm_end + 1.
Link: https://lkml.kernel.org/r/20230120162650.984577-22-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:34 -08:00
Liam R. Howlett
f10c2abcda
mempolicy: convert to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-21-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
e552cdb853
coredump: convert to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-20-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
37598f5a9d
mlock: convert mlock to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-19-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
2286a6914c
mm: change mprotect_fixup to vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-18-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
11a9b90274
userfaultfd: use vma iterator
...
Use the vma iterator so that the iterator can be invalidated or updated to
avoid each caller doing so.
Link: https://lkml.kernel.org/r/20230120162650.984577-17-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
27b2670112
ipc/shm: introduce new do_vma_munmap() to munmap
...
The shm already has the vma iterator in position for a write.
do_vmi_munmap() searches for the correct position and aligns the write, so
it is not the right function to use in this case.
The shm VMA tree modification is similar to the brk munmap situation, the
vma iterator is in position and the VMA is already known. This patch
generalizes the brk munmap function do_brk_munmap() to be used for any
other callers with the vma iterator already in position to munmap a VMA.
Link: https://lkml.kernel.org/r/20230126212049.980501-1-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Reported-by: Sven Schnelle <svens@linux.ibm.com >
Link: https://lore.kernel.org/linux-mm/yt9dh6wec21a.fsf@linux.ibm.com/
Cc: Arnd Bergmann <arnd@arndb.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:33 -08:00
Liam R. Howlett
d60beb1f69
ipc/shm: use the vma iterator for munmap calls
...
Pass through the vma iterator to do_vmi_munmap() to handle the iterator
state internally
Link: https://lkml.kernel.org/r/20230120162650.984577-16-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
f2ebfe43ba
mm: add temporary vma iterator versions of vma_merge(), split_vma(), and __split_vma()
...
These wrappers are short-lived in this patch set so that each user can be
converted on its own. In the end, these functions are renamed in one
commit.
Link: https://lkml.kernel.org/r/20230120162650.984577-15-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
3c441ab7d0
mmap: convert vma_expand() to use vma iterator
...
Use the vma iterator instead of the maple state for type safety and for
consistency through the mm code.
Link: https://lkml.kernel.org/r/20230120162650.984577-14-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
183654ce26
mmap: change do_mas_munmap and do_mas_aligned_munmap() to use vma iterator
...
Start passing the vma iterator through the mm code. This will allow for
reuse of the state and cleaner invalidation if necessary.
Link: https://lkml.kernel.org/r/20230120162650.984577-13-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
0378c0a0e9
mm/mmap: remove preallocation from do_mas_align_munmap()
...
In preparation of passing the vma state through split, the pre-allocation
that occurs before the split has to be moved to after. Since the
preallocation would then live right next to the store, just call store
instead of preallocating. This effectively restores the potential error
path of splitting and not munmap'ing which pre-dates the maple tree.
Link: https://lkml.kernel.org/r/20230120162650.984577-12-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
79e4f2caa4
mmap: convert vma_link() vma iterator
...
Avoid using the maple tree interface directly.
Link: https://lkml.kernel.org/r/20230120162650.984577-11-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:32 -08:00
Liam R. Howlett
3b9dbd5e91
kernel/fork: convert forking to using the vmi iterator
...
Avoid using the maple tree interface directly. This gains type safety.
Link: https://lkml.kernel.org/r/20230120162650.984577-10-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
92fed82047
mm/mmap: convert brk to use vma iterator
...
Use the vma iterator API for the brk() system call. This will provide
type safety at compile time.
Link: https://lkml.kernel.org/r/20230120162650.984577-9-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
b62b633e04
mm: expand vma iterator interface
...
Add wrappers for the maple tree to the vma iterator. This will provide
type safety at compile time.
Link: https://lkml.kernel.org/r/20230120162650.984577-8-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
17dc622c7b
maple_tree: fix mas_prev() and mas_find() state handling
...
When mas_prev() does not find anything, set the state to MAS_NONE.
Handle the MAS_NONE in mas_find() like a MAS_START.
Link: https://lkml.kernel.org/r/20230120162650.984577-7-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Reported-by: <syzbot+502859d610c661e56545@syzkaller.appspotmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
1202700c3f
maple_tree: fix handle of invalidated state in mas_wr_store_setup()
...
If an invalidated maple state is encountered during write, reset the maple
state to MAS_START. This will result in a re-walk of the tree to the
correct location for the write.
Link: https://lore.kernel.org/all/20230107020126.1627-1-sj@kernel.org/
Link: https://lkml.kernel.org/r/20230120162650.984577-6-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Reported-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
5159d64b33
test_maple_tree: test modifications while iterating
...
Add a testcase to ensure the iterator detects bad states on modifications
and does what the user expects
Link: https://lkml.kernel.org/r/20230120162650.984577-5-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:31 -08:00
Liam R. Howlett
50e81c82ad
maple_tree: reduce user error potential
...
When iterating, a user may operate on the tree and cause the maple state
to be altered and left in an unintuitive state. Detect this scenario and
correct it by setting to the limit and invalidating the state.
Link: https://lkml.kernel.org/r/20230120162650.984577-4-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:30 -08:00
Liam R. Howlett
65be6f058b
maple_tree: fix potential rcu issue
...
Ensure the node isn't dead after reading the node end.
Link: https://lkml.kernel.org/r/20230120162650.984577-3-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:30 -08:00
Liam R. Howlett
e7f43ca99f
maple_tree: add mas_init() function
...
Patch series "VMA tree type safety and remove __vma_adjust()", v4.
This patchset does two things: 1. Clean up, including removal of
__vma_adjust() and 2. Extends the VMA iterator API to provide type safety
to the VMA operations using the maple tree, as requested by Linus [1].
It also addresses another issue of usability brought up by Linus about
needing to modify the maple state within the loops. The maple state has
been replaced by the VMA iterator and the iterator is now modified within
the MM code so the caller should not need to worry about doing the work
themselves when tree modifications occur.
This brought up a potential inconsistency of the iterator state and what
the user expects, so the inconsistency is addressed to keep the VMA
iterator safe for use after the looping over a VMA range. This is
addressed in patch 3 ("maple_tree: Reduce user error potential") and 4
("test_maple_tree: Test modifications while iterating").
While cleaning up the state, the duplicate locking code in mm/mmap.c
introduced by the maple tree has been address by abstracting it to two
functions: vma_prepare() and vma_complete(). These abstractions allowed
for a much simpler __vma_adjust(), which eventually leads to the removal
of the __vma_adjust() function by placing the logic into the vma_merge()
function itself.
1. https://lore.kernel.org/linux-mm/CAHk-=wg9WQXBGkNdKD2bqocnN73rDswuWsavBB7T-tekykEn_A@mail.gmail.com/
This patch (of 49):
Add a function that will zero out the maple state struct and set some
basic defaults.
Link: https://lkml.kernel.org/r/20230120162650.984577-1-Liam.Howlett@oracle.com
Link: https://lkml.kernel.org/r/20230120162650.984577-2-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:30 -08:00
Matthew Wilcox (Oracle)
c643e6ebed
mm: fix memcpy_from_file_folio() integer underflow
...
If we have a HIGHMEM system with a large folio, 'offset' may be larger
than PAGE_SIZE, and so min_t will cap at 'len' instead of the intended
end-of-page. That can overflow into the next page which is likely to be
unmapped and fault, but could theoretically copy the wrong data.
Link: https://lkml.kernel.org/r/Y919vmSrtAgsf6K3@casper.infradead.org
Fixes: 00cdf76012 ("mm: add memcpy_from_file_folio()")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com >
Cc: Ira Weiny <ira.weiny@intel.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:30 -08:00
David Hildenbrand
6f74c0ec20
arm/mm: fix swp type masking in __swp_entry()
...
We're masking with the number of type bits instead of the type mask, which
is obviously wrong.
Link: https://lkml.kernel.org/r/39fd91e3-c93b-23c6-afc6-cbe473bb0ca9@redhat.com
Fixes: 20aae9eff5 ("arm/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE")
Signed-off-by: David Hildenbrand <david@redhat.com >
Reported-by: Mark Brown <broonie@kernel.org >
Tested-by: Mark Brown <broonie@kernel.org >
Cc: Russell King (Oracle) <rmk+kernel@armlinux.org.uk >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-09 16:51:30 -08:00
Matthew Wilcox (Oracle)
9160cffd45
mpage: convert __mpage_writepage() to use a folio more fully
...
This is just a conversion to the folio API. While there are some nods
towards supporting multi-page folios in here, the blocks array is still
sized for one page's worth of blocks, and there are other assumptions such
as the blocks_per_page variable.
[willy@infradead.org: fix accidentally-triggering WARN_ON_ONCE]
Link: https://lkml.kernel.org/r/Y9kuaBgXf9lKJ8b0@casper.infradead.org
Link: https://lkml.kernel.org/r/20230126201255.1681189-3-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Jan Kara <jack@suse.cz >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-02 22:33:34 -08:00
Matthew Wilcox (Oracle)
d585bdbeb7
fs: convert writepage_t callback to pass a folio
...
Patch series "Convert writepage_t to use a folio".
More folioisation. I split out the mpage work from everything else
because it completely dominated the patch, but some implementations I just
converted outright.
This patch (of 2):
We always write back an entire folio, but that's currently passed as the
head page. Convert all filesystems that use write_cache_pages() to expect
a folio instead of a page.
Link: https://lkml.kernel.org/r/20230126201255.1681189-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20230126201255.1681189-2-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Christoph Hellwig <hch@infradead.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-02-02 22:33:34 -08:00