Commit f72cf24a authored by Liam R. Howlett's avatar Liam R. Howlett Committed by Andrew Morton

mm: use vma_iter_clear_gfp() in nommu

Move the definition of vma_iter_clear_gfp() from mmap.c to internal.h so
it can be used in the nommu code.  This will reduce node preallocations
in nommu.

Link: https://lkml.kernel.org/r/20230724183157.3939892-10-Liam.Howlett@oracle.comSigned-off-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c108df76
...@@ -1064,6 +1064,18 @@ static inline void vma_iter_clear(struct vma_iterator *vmi, ...@@ -1064,6 +1064,18 @@ static inline void vma_iter_clear(struct vma_iterator *vmi,
mas_store_prealloc(&vmi->mas, NULL); mas_store_prealloc(&vmi->mas, NULL);
} }
static inline int vma_iter_clear_gfp(struct vma_iterator *vmi,
unsigned long start, unsigned long end, gfp_t gfp)
{
vmi->mas.index = start;
vmi->mas.last = end - 1;
mas_store_gfp(&vmi->mas, NULL, gfp);
if (unlikely(mas_is_err(&vmi->mas)))
return -ENOMEM;
return 0;
}
static inline struct vm_area_struct *vma_iter_load(struct vma_iterator *vmi) static inline struct vm_area_struct *vma_iter_load(struct vma_iterator *vmi)
{ {
return mas_walk(&vmi->mas); return mas_walk(&vmi->mas);
......
...@@ -154,18 +154,6 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi, ...@@ -154,18 +154,6 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi,
return mas_prev(&vmi->mas, min); return mas_prev(&vmi->mas, min);
} }
static inline int vma_iter_clear_gfp(struct vma_iterator *vmi,
unsigned long start, unsigned long end, gfp_t gfp)
{
vmi->mas.index = start;
vmi->mas.last = end - 1;
mas_store_gfp(&vmi->mas, NULL, gfp);
if (unlikely(mas_is_err(&vmi->mas)))
return -ENOMEM;
return 0;
}
/* /*
* check_brk_limits() - Use platform specific check of range & verify mlock * check_brk_limits() - Use platform specific check of range & verify mlock
* limits. * limits.
......
...@@ -1396,17 +1396,13 @@ static int vmi_shrink_vma(struct vma_iterator *vmi, ...@@ -1396,17 +1396,13 @@ static int vmi_shrink_vma(struct vma_iterator *vmi,
/* adjust the VMA's pointers, which may reposition it in the MM's tree /* adjust the VMA's pointers, which may reposition it in the MM's tree
* and list */ * and list */
if (vma_iter_prealloc(vmi)) {
pr_warn("Allocation of vma tree for process %d failed\n",
current->pid);
return -ENOMEM;
}
if (from > vma->vm_start) { if (from > vma->vm_start) {
vma_iter_clear(vmi, from, vma->vm_end); if (vma_iter_clear_gfp(vmi, from, vma->vm_end, GFP_KERNEL))
return -ENOMEM;
vma->vm_end = from; vma->vm_end = from;
} else { } else {
vma_iter_clear(vmi, vma->vm_start, to); if (vma_iter_clear_gfp(vmi, vma->vm_start, to, GFP_KERNEL))
return -ENOMEM;
vma->vm_start = to; vma->vm_start = to;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment