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: add vma_desc_test_all() and use it

erofs and zonefs are using vma_desc_test_any() twice to check whether all
of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add
vma_desc_test_all() to test all flags and update erofs and zonefs to use
it.

While we're here, update the helper function comments to be more
consistent.

Also add the same to the VMA test headers.

Link: https://lkml.kernel.org/r/568c8f8d6a84ff64014f997517cba7a629f7eed6.1772704455.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@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: Yue Hu <zbestahu@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
0b3ed2a4 e650bb30

+31 -8
+1 -2
fs/erofs/data.c
··· 473 473 if (!IS_DAX(file_inode(desc->file))) 474 474 return generic_file_readonly_mmap_prepare(desc); 475 475 476 - if (vma_desc_test_any(desc, VMA_SHARED_BIT) && 477 - vma_desc_test_any(desc, VMA_MAYWRITE_BIT)) 476 + if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT)) 478 477 return -EINVAL; 479 478 480 479 desc->vm_ops = &erofs_dax_vm_ops;
+1 -2
fs/zonefs/file.c
··· 333 333 * ordering between msync() and page cache writeback. 334 334 */ 335 335 if (zonefs_inode_is_seq(file_inode(file)) && 336 - vma_desc_test_any(desc, VMA_SHARED_BIT) && 337 - vma_desc_test_any(desc, VMA_MAYWRITE_BIT)) 336 + vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT)) 338 337 return -EINVAL; 339 338 340 339 file_accessed(file);
+20 -4
include/linux/mm.h
··· 1177 1177 #define vma_set_flags(vma, ...) \ 1178 1178 vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__)) 1179 1179 1180 - /* Helper to test all VMA flags in a VMA descriptor. */ 1180 + /* Helper to test any VMA flags in a VMA descriptor. */ 1181 1181 static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc, 1182 1182 vma_flags_t flags) 1183 1183 { ··· 1185 1185 } 1186 1186 1187 1187 /* 1188 - * Helper macro for testing VMA flags for an input pointer to a struct 1189 - * vm_area_desc object describing a proposed VMA, e.g.: 1188 + * Helper macro for testing whether any VMA flags are set in a VMA descriptor, 1189 + * e.g.: 1190 1190 * 1191 1191 * if (vma_desc_test_any(desc, VMA_IO_BIT, VMA_PFNMAP_BIT, 1192 1192 * VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT)) { ... } 1193 1193 */ 1194 1194 #define vma_desc_test_any(desc, ...) \ 1195 1195 vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__)) 1196 + 1197 + /* Helper to test all VMA flags in a VMA descriptor. */ 1198 + static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc, 1199 + vma_flags_t flags) 1200 + { 1201 + return vma_flags_test_all_mask(&desc->vma_flags, flags); 1202 + } 1203 + 1204 + /* 1205 + * Helper macro for testing whether ALL VMA flags are set in a VMA descriptor, 1206 + * e.g.: 1207 + * 1208 + * if (vma_desc_test_all(desc, VMA_READ_BIT, VMA_MAYREAD_BIT)) { ... } 1209 + */ 1210 + #define vma_desc_test_all(desc, ...) \ 1211 + vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__)) 1196 1212 1197 1213 /* Helper to set all VMA flags in a VMA descriptor. */ 1198 1214 static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc, ··· 1222 1206 * vm_area_desc object describing a proposed VMA, e.g.: 1223 1207 * 1224 1208 * vma_desc_set_flags(desc, VMA_IO_BIT, VMA_PFNMAP_BIT, VMA_DONTEXPAND_BIT, 1225 - * VMA_DONTDUMP_BIT); 1209 + * VMA_DONTDUMP_BIT); 1226 1210 */ 1227 1211 #define vma_desc_set_flags(desc, ...) \ 1228 1212 vma_desc_set_flags_mask(desc, mk_vma_flags(__VA_ARGS__))
+9
tools/testing/vma/include/dup.h
··· 922 922 #define vma_desc_test_any(desc, ...) \ 923 923 vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__)) 924 924 925 + static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc, 926 + vma_flags_t flags) 927 + { 928 + return vma_flags_test_all_mask(&desc->vma_flags, flags); 929 + } 930 + 931 + #define vma_desc_test_all(desc, ...) \ 932 + vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__)) 933 + 925 934 static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc, 926 935 vma_flags_t flags) 927 936 {