mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
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>
This commit is contained in:
parent
06531d2bf3
commit
e8d464f4a9
|
|
@ -1042,13 +1042,11 @@ static __always_inline void vma_flags_set_flag(vma_flags_t *flags,
|
|||
__set_bit((__force int)bit, bitmap);
|
||||
}
|
||||
|
||||
static __always_inline vma_flags_t __mk_vma_flags(size_t count,
|
||||
const vma_flag_t *bits)
|
||||
static __always_inline vma_flags_t __mk_vma_flags(vma_flags_t flags,
|
||||
size_t count, const vma_flag_t *bits)
|
||||
{
|
||||
vma_flags_t flags;
|
||||
int i;
|
||||
|
||||
vma_flags_clear_all(&flags);
|
||||
for (i = 0; i < count; i++)
|
||||
vma_flags_set_flag(&flags, bits[i]);
|
||||
return flags;
|
||||
|
|
@ -1064,8 +1062,18 @@ static __always_inline vma_flags_t __mk_vma_flags(size_t count,
|
|||
* The compiler cleverly optimises away all of the work and this ends up being
|
||||
* equivalent to aggregating the values manually.
|
||||
*/
|
||||
#define mk_vma_flags(...) __mk_vma_flags(COUNT_ARGS(__VA_ARGS__), \
|
||||
(const vma_flag_t []){__VA_ARGS__})
|
||||
#define mk_vma_flags(...) __mk_vma_flags(EMPTY_VMA_FLAGS, \
|
||||
COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__})
|
||||
|
||||
/*
|
||||
* Helper macro which acts like mk_vma_flags, only appending to a copy of the
|
||||
* specified flags rather than establishing new flags. E.g.:
|
||||
*
|
||||
* vma_flags_t flags = append_vma_flags(VMA_STACK_DEFAULT_FLAGS, VMA_STACK_BIT,
|
||||
* VMA_ACCOUNT_BIT);
|
||||
*/
|
||||
#define append_vma_flags(flags, ...) __mk_vma_flags(flags, \
|
||||
COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__})
|
||||
|
||||
/*
|
||||
* Test whether a specific VMA flag is set, e.g.:
|
||||
|
|
|
|||
|
|
@ -854,21 +854,21 @@ static inline void vm_flags_clear(struct vm_area_struct *vma,
|
|||
vma_flags_clear_word(&vma->flags, flags);
|
||||
}
|
||||
|
||||
static __always_inline vma_flags_t __mk_vma_flags(size_t count,
|
||||
const vma_flag_t *bits)
|
||||
static __always_inline vma_flags_t __mk_vma_flags(vma_flags_t flags,
|
||||
size_t count, const vma_flag_t *bits)
|
||||
{
|
||||
vma_flags_t flags;
|
||||
int i;
|
||||
|
||||
vma_flags_clear_all(&flags);
|
||||
for (i = 0; i < count; i++)
|
||||
vma_flags_set_flag(&flags, bits[i]);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
#define mk_vma_flags(...) __mk_vma_flags(COUNT_ARGS(__VA_ARGS__), \
|
||||
(const vma_flag_t []){__VA_ARGS__})
|
||||
#define mk_vma_flags(...) __mk_vma_flags(EMPTY_VMA_FLAGS, \
|
||||
COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__})
|
||||
|
||||
#define append_vma_flags(flags, ...) __mk_vma_flags(flags, \
|
||||
COUNT_ARGS(__VA_ARGS__), (const vma_flag_t []){__VA_ARGS__})
|
||||
|
||||
static __always_inline bool vma_flags_test(const vma_flags_t *flags,
|
||||
vma_flag_t bit)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user