Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: make vm_area_desc utilise vma_flags_t only

Now we have eliminated all uses of vm_area_desc->vm_flags, eliminate this
field, and have mmap_prepare users utilise the vma_flags_t
vm_area_desc->vma_flags field only.

As part of this change we alter is_shared_maywrite() to accept a
vma_flags_t parameter, and introduce is_shared_maywrite_vm_flags() for use
with legacy vm_flags_t flags.

We also update struct mmap_state to add a union between vma_flags and
vm_flags temporarily until the mmap logic is also converted to using
vma_flags_t.

Also update the VMA userland tests to reflect this change.

Link: https://lkml.kernel.org/r/fd2a2938b246b4505321954062b1caba7acfc77a.1769097829.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Yury Norov <ynorov@nvidia.com>
Cc: Chris Mason <clm@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
53f1d936 5bd2c065

+25 -16
+7 -2
include/linux/mm.h
··· 1290 1290 return vma->vm_flags & VM_ACCESS_FLAGS; 1291 1291 } 1292 1292 1293 - static inline bool is_shared_maywrite(vm_flags_t vm_flags) 1293 + static inline bool is_shared_maywrite_vm_flags(vm_flags_t vm_flags) 1294 1294 { 1295 1295 return (vm_flags & (VM_SHARED | VM_MAYWRITE)) == 1296 1296 (VM_SHARED | VM_MAYWRITE); 1297 1297 } 1298 1298 1299 + static inline bool is_shared_maywrite(const vma_flags_t *flags) 1300 + { 1301 + return vma_flags_test_all(flags, VMA_SHARED_BIT, VMA_MAYWRITE_BIT); 1302 + } 1303 + 1299 1304 static inline bool vma_is_shared_maywrite(const struct vm_area_struct *vma) 1300 1305 { 1301 - return is_shared_maywrite(vma->vm_flags); 1306 + return is_shared_maywrite(&vma->flags); 1302 1307 } 1303 1308 1304 1309 static inline
+1 -4
include/linux/mm_types.h
··· 887 887 /* Mutable fields. Populated with initial state. */ 888 888 pgoff_t pgoff; 889 889 struct file *vm_file; 890 - union { 891 - vm_flags_t vm_flags; 892 - vma_flags_t vma_flags; 893 - }; 890 + vma_flags_t vma_flags; 894 891 pgprot_t page_prot; 895 892 896 893 /* Write-only fields. */
+1 -1
mm/filemap.c
··· 4012 4012 4013 4013 int generic_file_readonly_mmap_prepare(struct vm_area_desc *desc) 4014 4014 { 4015 - if (is_shared_maywrite(desc->vm_flags)) 4015 + if (is_shared_maywrite(&desc->vma_flags)) 4016 4016 return -EINVAL; 4017 4017 return generic_file_mmap_prepare(desc); 4018 4018 }
+1 -1
mm/util.c
··· 1154 1154 1155 1155 .pgoff = vma->vm_pgoff, 1156 1156 .vm_file = vma->vm_file, 1157 - .vm_flags = vma->vm_flags, 1157 + .vma_flags = vma->flags, 1158 1158 .page_prot = vma->vm_page_prot, 1159 1159 1160 1160 .action.type = MMAP_NOTHING, /* Default */
+7 -4
mm/vma.c
··· 15 15 unsigned long end; 16 16 pgoff_t pgoff; 17 17 unsigned long pglen; 18 - vm_flags_t vm_flags; 18 + union { 19 + vm_flags_t vm_flags; 20 + vma_flags_t vma_flags; 21 + }; 19 22 struct file *file; 20 23 pgprot_t page_prot; 21 24 ··· 2372 2369 2373 2370 desc->pgoff = map->pgoff; 2374 2371 desc->vm_file = map->file; 2375 - desc->vm_flags = map->vm_flags; 2372 + desc->vma_flags = map->vma_flags; 2376 2373 desc->page_prot = map->page_prot; 2377 2374 } 2378 2375 ··· 2653 2650 map->file_doesnt_need_get = true; 2654 2651 map->file = desc->vm_file; 2655 2652 } 2656 - map->vm_flags = desc->vm_flags; 2653 + map->vma_flags = desc->vma_flags; 2657 2654 map->page_prot = desc->page_prot; 2658 2655 /* User-defined fields. */ 2659 2656 map->vm_ops = desc->vm_ops; ··· 2826 2823 return -EINVAL; 2827 2824 2828 2825 /* Map writable and ensure this isn't a sealed memfd. */ 2829 - if (file && is_shared_maywrite(vm_flags)) { 2826 + if (file && is_shared_maywrite_vm_flags(vm_flags)) { 2830 2827 int error = mapping_map_writable(file->f_mapping); 2831 2828 2832 2829 if (error)
+1 -2
mm/vma.h
··· 309 309 vma->vm_pgoff = desc->pgoff; 310 310 if (desc->vm_file != vma->vm_file) 311 311 vma_set_file(vma, desc->vm_file); 312 - if (desc->vm_flags != vma->vm_flags) 313 - vm_flags_set(vma, desc->vm_flags); 312 + vma->flags = desc->vma_flags; 314 313 vma->vm_page_prot = desc->page_prot; 315 314 316 315 /* User-defined fields. */
+7 -2
tools/testing/vma/vma_internal.h
··· 1009 1009 #define vma_desc_clear_flags(desc, ...) \ 1010 1010 vma_desc_clear_flags_mask(desc, mk_vma_flags(__VA_ARGS__)) 1011 1011 1012 - static inline bool is_shared_maywrite(vm_flags_t vm_flags) 1012 + static inline bool is_shared_maywrite_vm_flags(vm_flags_t vm_flags) 1013 1013 { 1014 1014 return (vm_flags & (VM_SHARED | VM_MAYWRITE)) == 1015 1015 (VM_SHARED | VM_MAYWRITE); 1016 1016 } 1017 1017 1018 + static inline bool is_shared_maywrite(const vma_flags_t *flags) 1019 + { 1020 + return vma_flags_test_all(flags, VMA_SHARED_BIT, VMA_MAYWRITE_BIT); 1021 + } 1022 + 1018 1023 static inline bool vma_is_shared_maywrite(struct vm_area_struct *vma) 1019 1024 { 1020 - return is_shared_maywrite(vma->vm_flags); 1025 + return is_shared_maywrite(&vma->flags); 1021 1026 } 1022 1027 1023 1028 static inline struct vm_area_struct *vma_next(struct vma_iterator *vmi)