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/vma: add append_vma_flags() helper

In order to be able to efficiently combine VMA flag masks with additional
VMA flag bits we need to extend the concept introduced in mk_vma_flags()
and __mk_vma_flags() by allowing the specification of a VMA flag mask to
append VMA flag bits to.

Update __mk_vma_flags() to allow for this and update mk_vma_flags()
accordingly, and also provide append_vma_flags() to allow for the caller
to specify which VMA flags mask to append to.

Finally, update the VMA flags tests to reflect the change.

Link: https://lkml.kernel.org/r/9f928cd4688270002f2c0c3777fcc9b49cc7a8ea.1774034900.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Kees Cook <kees@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Ondrej Mosnacek <omosnace@redhat.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Cc: xu xin <xu.xin16@zte.com.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
e8d464f4 06531d2b

+21 -13
+14 -6
include/linux/mm.h
··· 1042 1042 __set_bit((__force int)bit, bitmap); 1043 1043 } 1044 1044 1045 - static __always_inline vma_flags_t __mk_vma_flags(size_t count, 1046 - const vma_flag_t *bits) 1045 + static __always_inline vma_flags_t __mk_vma_flags(vma_flags_t flags, 1046 + size_t count, const vma_flag_t *bits) 1047 1047 { 1048 - vma_flags_t flags; 1049 1048 int i; 1050 1049 1051 - vma_flags_clear_all(&flags); 1052 1050 for (i = 0; i < count; i++) 1053 1051 vma_flags_set_flag(&flags, bits[i]); 1054 1052 return flags; ··· 1062 1064 * The compiler cleverly optimises away all of the work and this ends up being 1063 1065 * equivalent to aggregating the values manually. 1064 1066 */ 1065 - #define mk_vma_flags(...) __mk_vma_flags(COUNT_ARGS(__VA_ARGS__), \ 1066 - (const vma_flag_t []){__VA_ARGS__}) 1067 + #define mk_vma_flags(...) __mk_vma_flags(EMPTY_VMA_FLAGS, \ 1068 + COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__}) 1069 + 1070 + /* 1071 + * Helper macro which acts like mk_vma_flags, only appending to a copy of the 1072 + * specified flags rather than establishing new flags. E.g.: 1073 + * 1074 + * vma_flags_t flags = append_vma_flags(VMA_STACK_DEFAULT_FLAGS, VMA_STACK_BIT, 1075 + * VMA_ACCOUNT_BIT); 1076 + */ 1077 + #define append_vma_flags(flags, ...) __mk_vma_flags(flags, \ 1078 + COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__}) 1067 1079 1068 1080 /* 1069 1081 * Test whether a specific VMA flag is set, e.g.:
+7 -7
tools/testing/vma/include/dup.h
··· 854 854 vma_flags_clear_word(&vma->flags, flags); 855 855 } 856 856 857 - static __always_inline vma_flags_t __mk_vma_flags(size_t count, 858 - const vma_flag_t *bits) 857 + static __always_inline vma_flags_t __mk_vma_flags(vma_flags_t flags, 858 + size_t count, const vma_flag_t *bits) 859 859 { 860 - vma_flags_t flags; 861 860 int i; 862 861 863 - vma_flags_clear_all(&flags); 864 862 for (i = 0; i < count; i++) 865 863 vma_flags_set_flag(&flags, bits[i]); 866 - 867 864 return flags; 868 865 } 869 866 870 - #define mk_vma_flags(...) __mk_vma_flags(COUNT_ARGS(__VA_ARGS__), \ 871 - (const vma_flag_t []){__VA_ARGS__}) 867 + #define mk_vma_flags(...) __mk_vma_flags(EMPTY_VMA_FLAGS, \ 868 + COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__}) 869 + 870 + #define append_vma_flags(flags, ...) __mk_vma_flags(flags, \ 871 + COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__}) 872 872 873 873 static __always_inline bool vma_flags_test(const vma_flags_t *flags, 874 874 vma_flag_t bit)