Skip to content

Commit

Permalink
mmap: convert vma_expand() to use vma iterator
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Liam R. Howlett <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
howlett authored and akpm00 committed Feb 10, 2023
1 parent 183654c commit 3c441ab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
*
* Returns: 0 on success
*/
inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma,
inline int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma,
unsigned long start, unsigned long end, pgoff_t pgoff,
struct vm_area_struct *next)
{
Expand Down Expand Up @@ -556,7 +556,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma,
/* Only handles expanding */
VM_BUG_ON(vma->vm_start < start || vma->vm_end > end);

if (mas_preallocate(mas, GFP_KERNEL))
if (vma_iter_prealloc(vmi))
goto nomem;

vma_adjust_trans_huge(vma, start, end, 0);
Expand All @@ -581,8 +581,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma,
vma->vm_start = start;
vma->vm_end = end;
vma->vm_pgoff = pgoff;
/* Note: mas must be pointing to the expanding VMA */
vma_mas_store(vma, mas);
vma_iter_store(vmi, vma);

if (file) {
vma_interval_tree_insert(vma, root);
Expand Down Expand Up @@ -2600,7 +2599,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,

/* Actually expand, if possible */
if (vma &&
!vma_expand(&vmi.mas, vma, merge_start, merge_end, vm_pgoff, next)) {
!vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) {
khugepaged_enter_vma(vma, vm_flags);
goto expanded;
}
Expand Down

0 comments on commit 3c441ab

Please sign in to comment.