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: reintroduce vma_desc_test() as a singular flag test

Similar to vma_flags_test(), we have previously renamed vma_desc_test() to
vma_desc_test_any(). Now that is in place, we can reintroduce
vma_desc_test() to explicitly check for a single VMA flag.

As with vma_flags_test(), this is useful as often flag tests are against a
single flag, and vma_desc_test_any(flags, VMA_READ_BIT) reads oddly and
potentially causes confusion.

As with vma_flags_test() a combination of sparse and vma_flags_t being a
struct means that users cannot misuse this function without it getting
flagged.

Also update the VMA tests to reflect this change.

Link: https://lkml.kernel.org/r/3a65ca23defb05060333f0586428fe279a484564.1772704455.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Babu Moger <babu.moger@amd.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Chatre, Reinette <reinette.chatre@intel.com>
Cc: Chunhai Guo <guochunhai@vivo.com>
Cc: Damien Le Maol <dlemoal@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Dave Martin <dave.martin@arm.com>
Cc: Gao Xiang <xiang@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hongbo Li <lihongbo22@huawei.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naohiro Aota <naohiro.aota@wdc.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Sandeep Dhavale <dhavale@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Yue Hu <zbestahu@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
0c2aa663 5e6d45d7

+29 -12
+1 -1
drivers/char/mem.c
··· 520 520 #ifndef CONFIG_MMU 521 521 return -ENOSYS; 522 522 #endif 523 - if (vma_desc_test_any(desc, VMA_SHARED_BIT)) 523 + if (vma_desc_test(desc, VMA_SHARED_BIT)) 524 524 return shmem_zero_setup_desc(desc); 525 525 526 526 desc->action.success_hook = mmap_zero_private_success;
+1 -1
fs/hugetlbfs/inode.c
··· 164 164 goto out; 165 165 166 166 ret = 0; 167 - if (vma_desc_test_any(desc, VMA_WRITE_BIT) && inode->i_size < len) 167 + if (vma_desc_test(desc, VMA_WRITE_BIT) && inode->i_size < len) 168 168 i_size_write(inode, len); 169 169 out: 170 170 inode_unlock(inode);
+1 -1
fs/ntfs3/file.c
··· 276 276 struct file *file = desc->file; 277 277 struct inode *inode = file_inode(file); 278 278 struct ntfs_inode *ni = ntfs_i(inode); 279 - const bool rw = vma_desc_test_any(desc, VMA_WRITE_BIT); 279 + const bool rw = vma_desc_test(desc, VMA_WRITE_BIT); 280 280 int err; 281 281 282 282 /* Avoid any operation if inode is bad. */
+1 -1
fs/resctrl/pseudo_lock.c
··· 1044 1044 * Ensure changes are carried directly to the memory being mapped, 1045 1045 * do not allow copy-on-write mapping. 1046 1046 */ 1047 - if (!vma_desc_test_any(desc, VMA_SHARED_BIT)) { 1047 + if (!vma_desc_test(desc, VMA_SHARED_BIT)) { 1048 1048 mutex_unlock(&rdtgroup_mutex); 1049 1049 return -EINVAL; 1050 1050 }
+2 -2
include/linux/dax.h
··· 69 69 const struct inode *inode, 70 70 struct dax_device *dax_dev) 71 71 { 72 - if (!vma_desc_test_any(desc, VMA_SYNC_BIT)) 72 + if (!vma_desc_test(desc, VMA_SYNC_BIT)) 73 73 return true; 74 74 if (!IS_DAX(inode)) 75 75 return false; ··· 115 115 const struct inode *inode, 116 116 struct dax_device *dax_dev) 117 117 { 118 - return !vma_desc_test_any(desc, VMA_SYNC_BIT); 118 + return !vma_desc_test(desc, VMA_SYNC_BIT); 119 119 } 120 120 static inline size_t dax_recovery_write(struct dax_device *dax_dev, 121 121 pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i)
+11
include/linux/mm.h
··· 1192 1192 #define vma_set_flags(vma, ...) \ 1193 1193 vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__)) 1194 1194 1195 + /* 1196 + * Test whether a specific VMA flag is set in a VMA descriptor, e.g.: 1197 + * 1198 + * if (vma_desc_test(desc, VMA_READ_BIT)) { ... } 1199 + */ 1200 + static __always_inline bool vma_desc_test(const struct vm_area_desc *desc, 1201 + vma_flag_t bit) 1202 + { 1203 + return vma_flags_test(&desc->vma_flags, bit); 1204 + } 1205 + 1195 1206 /* Helper to test any VMA flags in a VMA descriptor. */ 1196 1207 static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc, 1197 1208 vma_flags_t flags)
+6 -6
mm/hugetlb.c
··· 1194 1194 static void set_vma_desc_resv_map(struct vm_area_desc *desc, struct resv_map *map) 1195 1195 { 1196 1196 VM_WARN_ON_ONCE(!is_vma_hugetlb_flags(&desc->vma_flags)); 1197 - VM_WARN_ON_ONCE(vma_desc_test_any(desc, VMA_MAYSHARE_BIT)); 1197 + VM_WARN_ON_ONCE(vma_desc_test(desc, VMA_MAYSHARE_BIT)); 1198 1198 1199 1199 desc->private_data = map; 1200 1200 } ··· 1202 1202 static void set_vma_desc_resv_flags(struct vm_area_desc *desc, unsigned long flags) 1203 1203 { 1204 1204 VM_WARN_ON_ONCE(!is_vma_hugetlb_flags(&desc->vma_flags)); 1205 - VM_WARN_ON_ONCE(vma_desc_test_any(desc, VMA_MAYSHARE_BIT)); 1205 + VM_WARN_ON_ONCE(vma_desc_test(desc, VMA_MAYSHARE_BIT)); 1206 1206 1207 1207 desc->private_data = (void *)((unsigned long)desc->private_data | flags); 1208 1208 } ··· 6602 6602 * to reserve the full area even if read-only as mprotect() may be 6603 6603 * called to make the mapping read-write. Assume !desc is a shm mapping 6604 6604 */ 6605 - if (!desc || vma_desc_test_any(desc, VMA_MAYSHARE_BIT)) { 6605 + if (!desc || vma_desc_test(desc, VMA_MAYSHARE_BIT)) { 6606 6606 /* 6607 6607 * resv_map can not be NULL as hugetlb_reserve_pages is only 6608 6608 * called for inodes for which resv_maps were created (see ··· 6636 6636 if (err < 0) 6637 6637 goto out_err; 6638 6638 6639 - if (desc && !vma_desc_test_any(desc, VMA_MAYSHARE_BIT) && h_cg) { 6639 + if (desc && !vma_desc_test(desc, VMA_MAYSHARE_BIT) && h_cg) { 6640 6640 /* For private mappings, the hugetlb_cgroup uncharge info hangs 6641 6641 * of the resv_map. 6642 6642 */ ··· 6673 6673 * consumed reservations are stored in the map. Hence, nothing 6674 6674 * else has to be done for private mappings here 6675 6675 */ 6676 - if (!desc || vma_desc_test_any(desc, VMA_MAYSHARE_BIT)) { 6676 + if (!desc || vma_desc_test(desc, VMA_MAYSHARE_BIT)) { 6677 6677 add = region_add(resv_map, from, to, regions_needed, h, h_cg); 6678 6678 6679 6679 if (unlikely(add < 0)) { ··· 6737 6737 hugetlb_cgroup_uncharge_cgroup_rsvd(hstate_index(h), 6738 6738 chg * pages_per_huge_page(h), h_cg); 6739 6739 out_err: 6740 - if (!desc || vma_desc_test_any(desc, VMA_MAYSHARE_BIT)) 6740 + if (!desc || vma_desc_test(desc, VMA_MAYSHARE_BIT)) 6741 6741 /* Only call region_abort if the region_chg succeeded but the 6742 6742 * region_add failed or didn't run. 6743 6743 */
+6
tools/testing/vma/include/dup.h
··· 922 922 #define vma_set_flags(vma, ...) \ 923 923 vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__)) 924 924 925 + static __always_inline bool vma_desc_test(const struct vm_area_desc *desc, 926 + vma_flag_t bit) 927 + { 928 + return vma_flags_test(&desc->vma_flags, bit); 929 + } 930 + 925 931 static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc, 926 932 vma_flags_t flags) 927 933 {