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: introduce [vma_flags,legacy]_to_[legacy,vma_flags]() helpers

While we are still converting VMA flags from vma_flags_t to vm_flags_t,
introduce helpers to convert between the two to allow for iterative
development without having to 'change the world' in a single commit'.

Also update VMA flags tests to reflect the change.

Finally, refresh vma_flags_overwrite_word(),
vma_flag_overwrite_word_once(), vma_flags_set_word() and
vma_flags_clear_word() in the VMA tests to reflect current kernel
implementations - this should make no functional difference, but keeps the
logic consistent between the two.

Link: https://lkml.kernel.org/r/d3569470dbb3ae79134ca7c3eb3fc4df7086e874.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
c8555bc9 3ee58453

+58 -4
+26
include/linux/mm_types.h
··· 1070 1070 } 1071 1071 1072 1072 /* 1073 + * Helper function which converts a vma_flags_t value to a legacy vm_flags_t 1074 + * value. This is only valid if the input flags value can be expressed in a 1075 + * system word. 1076 + * 1077 + * Will be removed once the conversion to VMA flags is complete. 1078 + */ 1079 + static __always_inline vm_flags_t vma_flags_to_legacy(vma_flags_t flags) 1080 + { 1081 + return (vm_flags_t)flags.__vma_flags[0]; 1082 + } 1083 + 1084 + /* 1073 1085 * Copy value to the first system word of VMA flags, non-atomically. 1074 1086 * 1075 1087 * IMPORTANT: This does not overwrite bytes past the first system word. The ··· 1092 1080 unsigned long *bitmap = flags->__vma_flags; 1093 1081 1094 1082 bitmap[0] = value; 1083 + } 1084 + 1085 + /* 1086 + * Helper function which converts a legacy vm_flags_t value to a vma_flags_t 1087 + * value. 1088 + * 1089 + * Will be removed once the conversion to VMA flags is complete. 1090 + */ 1091 + static __always_inline vma_flags_t legacy_to_vma_flags(vm_flags_t flags) 1092 + { 1093 + vma_flags_t ret = EMPTY_VMA_FLAGS; 1094 + 1095 + vma_flags_overwrite_word(&ret, flags); 1096 + return ret; 1095 1097 } 1096 1098 1097 1099 /*
+32 -4
tools/testing/vma/include/dup.h
··· 766 766 */ 767 767 static inline void vma_flags_overwrite_word(vma_flags_t *flags, unsigned long value) 768 768 { 769 - *ACCESS_PRIVATE(flags, __vma_flags) = value; 769 + unsigned long *bitmap = flags->__vma_flags; 770 + 771 + bitmap[0] = value; 770 772 } 771 773 772 774 /* ··· 779 777 */ 780 778 static inline void vma_flags_overwrite_word_once(vma_flags_t *flags, unsigned long value) 781 779 { 782 - unsigned long *bitmap = ACCESS_PRIVATE(flags, __vma_flags); 780 + unsigned long *bitmap = flags->__vma_flags; 783 781 784 782 WRITE_ONCE(*bitmap, value); 785 783 } ··· 787 785 /* Update the first system word of VMA flags setting bits, non-atomically. */ 788 786 static inline void vma_flags_set_word(vma_flags_t *flags, unsigned long value) 789 787 { 790 - unsigned long *bitmap = ACCESS_PRIVATE(flags, __vma_flags); 788 + unsigned long *bitmap = flags->__vma_flags; 791 789 792 790 *bitmap |= value; 793 791 } ··· 795 793 /* Update the first system word of VMA flags clearing bits, non-atomically. */ 796 794 static inline void vma_flags_clear_word(vma_flags_t *flags, unsigned long value) 797 795 { 798 - unsigned long *bitmap = ACCESS_PRIVATE(flags, __vma_flags); 796 + unsigned long *bitmap = flags->__vma_flags; 799 797 800 798 *bitmap &= ~value; 801 799 } ··· 803 801 static __always_inline void vma_flags_clear_all(vma_flags_t *flags) 804 802 { 805 803 bitmap_zero(ACCESS_PRIVATE(flags, __vma_flags), NUM_VMA_FLAG_BITS); 804 + } 805 + 806 + /* 807 + * Helper function which converts a vma_flags_t value to a legacy vm_flags_t 808 + * value. This is only valid if the input flags value can be expressed in a 809 + * system word. 810 + * 811 + * Will be removed once the conversion to VMA flags is complete. 812 + */ 813 + static __always_inline vm_flags_t vma_flags_to_legacy(vma_flags_t flags) 814 + { 815 + return (vm_flags_t)flags.__vma_flags[0]; 816 + } 817 + 818 + /* 819 + * Helper function which converts a legacy vm_flags_t value to a vma_flags_t 820 + * value. 821 + * 822 + * Will be removed once the conversion to VMA flags is complete. 823 + */ 824 + static __always_inline vma_flags_t legacy_to_vma_flags(vm_flags_t flags) 825 + { 826 + vma_flags_t ret = EMPTY_VMA_FLAGS; 827 + 828 + vma_flags_overwrite_word(&ret, flags); 829 + return ret; 806 830 } 807 831 808 832 static __always_inline void vma_flags_set_flag(vma_flags_t *flags,