mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 10:39:02 -04:00
mm/vma: convert miscellaneous uses of VMA flags in core mm
Update various uses of legacy flags in vma.c and mmap.c to the new vma_flags_t type, updating comments alongside them to be consistent. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-10-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Lance Yang <lance.yang@linux.dev> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
8e7501a361
commit
df751fe672
39
mm/mmap.c
39
mm/mmap.c
@@ -557,8 +557,8 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
|
||||
}
|
||||
|
||||
/*
|
||||
* Set 'VM_NORESERVE' if we should not account for the
|
||||
* memory use of this mapping.
|
||||
* Set VMA_NORESERVE_BIT if we should not account for the memory use
|
||||
* of this mapping.
|
||||
*/
|
||||
if (flags & MAP_NORESERVE) {
|
||||
/* We honor MAP_NORESERVE if allowed to overcommit */
|
||||
@@ -985,7 +985,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
|
||||
return NULL;
|
||||
if (expand_stack_locked(prev, addr))
|
||||
return NULL;
|
||||
if (prev->vm_flags & VM_LOCKED)
|
||||
if (vma_test(prev, VMA_LOCKED_BIT))
|
||||
populate_vma_page_range(prev, addr, prev->vm_end, NULL);
|
||||
return prev;
|
||||
}
|
||||
@@ -1009,7 +1009,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
|
||||
start = vma->vm_start;
|
||||
if (expand_stack_locked(vma, addr))
|
||||
return NULL;
|
||||
if (vma->vm_flags & VM_LOCKED)
|
||||
if (vma_test(vma, VMA_LOCKED_BIT))
|
||||
populate_vma_page_range(vma, addr, start, NULL);
|
||||
return vma;
|
||||
}
|
||||
@@ -1134,18 +1134,18 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
|
||||
*/
|
||||
vma = vma_lookup(mm, start);
|
||||
|
||||
if (!vma || !(vma->vm_flags & VM_SHARED)) {
|
||||
if (!vma || !vma_test(vma, VMA_SHARED_BIT)) {
|
||||
mmap_read_unlock(mm);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
|
||||
prot |= vma->vm_flags & VM_WRITE ? PROT_WRITE : 0;
|
||||
prot |= vma->vm_flags & VM_EXEC ? PROT_EXEC : 0;
|
||||
prot |= vma_test(vma, VMA_READ_BIT) ? PROT_READ : 0;
|
||||
prot |= vma_test(vma, VMA_WRITE_BIT) ? PROT_WRITE : 0;
|
||||
prot |= vma_test(vma, VMA_EXEC_BIT) ? PROT_EXEC : 0;
|
||||
|
||||
flags &= MAP_NONBLOCK;
|
||||
flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
|
||||
if (vma->vm_flags & VM_LOCKED)
|
||||
if (vma_test(vma, VMA_LOCKED_BIT))
|
||||
flags |= MAP_LOCKED;
|
||||
|
||||
/* Save vm_flags used to calculate prot and flags, and recheck later. */
|
||||
@@ -1271,7 +1271,7 @@ unsigned long tear_down_vmas(struct mm_struct *mm, struct vma_iterator *vmi,
|
||||
mmap_assert_write_locked(mm);
|
||||
vma_iter_set(vmi, vma->vm_end);
|
||||
do {
|
||||
if (vma->vm_flags & VM_ACCOUNT)
|
||||
if (vma_test(vma, VMA_ACCOUNT_BIT))
|
||||
nr_accounted += vma_pages(vma);
|
||||
vma_mark_detached(vma);
|
||||
remove_vma(vma);
|
||||
@@ -1420,7 +1420,7 @@ static int special_mapping_split(struct vm_area_struct *vma, unsigned long addr)
|
||||
{
|
||||
/*
|
||||
* Forbid splitting special mappings - kernel has expectations over
|
||||
* the number of pages in mapping. Together with VM_DONTEXPAND
|
||||
* the number of pages in mapping. Together with VMA_DONTEXPAND_BIT
|
||||
* the size of vma should stay the same over the special mapping's
|
||||
* lifetime.
|
||||
*/
|
||||
@@ -1692,7 +1692,7 @@ bool mmap_read_lock_maybe_expand(struct mm_struct *mm,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(new_vma->vm_flags & VM_GROWSDOWN))
|
||||
if (!vma_test(new_vma, VMA_GROWSDOWN_BIT))
|
||||
return false;
|
||||
|
||||
mmap_write_lock(mm);
|
||||
@@ -1742,7 +1742,7 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
|
||||
retval = vma_start_write_killable(mpnt);
|
||||
if (retval < 0)
|
||||
goto loop_out;
|
||||
if (mpnt->vm_flags & VM_DONTCOPY) {
|
||||
if (vma_test(mpnt, VMA_DONTCOPY_BIT)) {
|
||||
retval = vma_iter_clear_gfp(&vmi, mpnt->vm_start,
|
||||
mpnt->vm_end, GFP_KERNEL);
|
||||
if (retval)
|
||||
@@ -1752,7 +1752,7 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
|
||||
continue;
|
||||
}
|
||||
charge = 0;
|
||||
if (mpnt->vm_flags & VM_ACCOUNT) {
|
||||
if (vma_test(mpnt, VMA_ACCOUNT_BIT)) {
|
||||
unsigned long len = vma_pages(mpnt);
|
||||
|
||||
if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
|
||||
@@ -1770,16 +1770,19 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
|
||||
retval = dup_userfaultfd(tmp, &uf);
|
||||
if (retval)
|
||||
goto fail_nomem_anon_vma_fork;
|
||||
if (tmp->vm_flags & VM_WIPEONFORK) {
|
||||
|
||||
if (vma_test(tmp, VMA_WIPEONFORK_BIT)) {
|
||||
/*
|
||||
* VM_WIPEONFORK gets a clean slate in the child.
|
||||
* VMA_WIPEONFORK_BIT gets a clean slate in the child.
|
||||
* Don't prepare anon_vma until fault since we don't
|
||||
* copy page for current vma.
|
||||
*/
|
||||
tmp->anon_vma = NULL;
|
||||
} else if (anon_vma_fork(tmp, mpnt))
|
||||
goto fail_nomem_anon_vma_fork;
|
||||
vm_flags_clear(tmp, VM_LOCKED_MASK);
|
||||
|
||||
vma_start_write(tmp);
|
||||
vma_clear_flags_mask(tmp, VMA_LOCKED_MASK);
|
||||
/*
|
||||
* Copy/update hugetlb private vma information.
|
||||
*/
|
||||
@@ -1812,7 +1815,7 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
|
||||
i_mmap_unlock_write(mapping);
|
||||
}
|
||||
|
||||
if (!(tmp->vm_flags & VM_WIPEONFORK))
|
||||
if (!vma_test(tmp, VMA_WIPEONFORK_BIT))
|
||||
retval = copy_page_range(tmp, mpnt);
|
||||
|
||||
if (retval) {
|
||||
|
||||
13
mm/vma.c
13
mm/vma.c
@@ -3419,17 +3419,20 @@ struct vm_area_struct *__install_special_mapping(
|
||||
vm_flags_t vm_flags, void *priv,
|
||||
const struct vm_operations_struct *ops)
|
||||
{
|
||||
int ret;
|
||||
vma_flags_t vma_flags = legacy_to_vma_flags(vm_flags);
|
||||
struct vm_area_struct *vma;
|
||||
int ret;
|
||||
|
||||
vma = vm_area_alloc(mm);
|
||||
if (unlikely(vma == NULL))
|
||||
if (unlikely(!vma))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
vm_flags |= vma_flags_to_legacy(mm->def_vma_flags) | VM_DONTEXPAND;
|
||||
vma_flags_set_mask(&vma_flags, mm->def_vma_flags);
|
||||
vma_flags_set(&vma_flags, VMA_DONTEXPAND_BIT);
|
||||
if (pgtable_supports_soft_dirty())
|
||||
vm_flags |= VM_SOFTDIRTY;
|
||||
vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK);
|
||||
vma_flags_set(&vma_flags, VMA_SOFTDIRTY_BIT);
|
||||
vma_flags_clear_mask(&vma_flags, VMA_LOCKED_MASK);
|
||||
vma->flags = vma_flags;
|
||||
vma->vm_page_prot = vma_get_page_prot(vma);
|
||||
|
||||
vma->vm_ops = ops;
|
||||
|
||||
Reference in New Issue
Block a user