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: always inline __mk_vma_flags() and invoked functions

Be explicit about __mk_vma_flags() (which is used by the mk_vma_flags()
macro) always being inline, as we rely on the compiler to evaluate the
loop in this function and determine that it can replace the code with the
an equivalent constant value, e.g. that:

__mk_vma_flags(2, (const vma_flag_t []){ VMA_WRITE_BIT, VMA_EXEC_BIT });

Can be replaced with:

(1UL << VMA_WRITE_BIT) | (1UL << VMA_EXEC_BIT)

= (1UL << 1) | (1UL << 2) = 6

Most likely an 'inline' will suffice for this, but be explicit as we can
be.

Also update all of the functions __mk_vma_flags() ultimately invokes to be
always inline too.

Note that test_bitmap_const_eval() asserts that the relevant bitmap
functions result in build time constant values.

Additionally, vma_flag_set() operates on a vma_flags_t type, so it is
inconsistently named versus other VMA flags functions.

We only use vma_flag_set() in __mk_vma_flags() so we don't need to worry
about its new name being rather cumbersome, so rename it to
vma_flags_set_flag() to disambiguate it from vma_flags_set().

Also update the VMA test headers to reflect the changes.

Link: https://lkml.kernel.org/r/241f49c52074d436edbb9c6a6662a8dc142a8f43.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
a5eee112 0b3ed2a4

+12 -8
+5 -3
include/linux/mm.h
··· 1030 1030 } 1031 1031 1032 1032 /* Set an individual VMA flag in flags, non-atomically. */ 1033 - static inline void vma_flag_set(vma_flags_t *flags, vma_flag_t bit) 1033 + static __always_inline void vma_flags_set_flag(vma_flags_t *flags, 1034 + vma_flag_t bit) 1034 1035 { 1035 1036 unsigned long *bitmap = flags->__vma_flags; 1036 1037 1037 1038 __set_bit((__force int)bit, bitmap); 1038 1039 } 1039 1040 1040 - static inline vma_flags_t __mk_vma_flags(size_t count, const vma_flag_t *bits) 1041 + static __always_inline vma_flags_t __mk_vma_flags(size_t count, 1042 + const vma_flag_t *bits) 1041 1043 { 1042 1044 vma_flags_t flags; 1043 1045 int i; 1044 1046 1045 1047 vma_flags_clear_all(&flags); 1046 1048 for (i = 0; i < count; i++) 1047 - vma_flag_set(&flags, bits[i]); 1049 + vma_flags_set_flag(&flags, bits[i]); 1048 1050 return flags; 1049 1051 } 1050 1052
+1 -1
include/linux/mm_types.h
··· 1056 1056 } __randomize_layout; 1057 1057 1058 1058 /* Clears all bits in the VMA flags bitmap, non-atomically. */ 1059 - static inline void vma_flags_clear_all(vma_flags_t *flags) 1059 + static __always_inline void vma_flags_clear_all(vma_flags_t *flags) 1060 1060 { 1061 1061 bitmap_zero(flags->__vma_flags, NUM_VMA_FLAG_BITS); 1062 1062 }
+3 -2
tools/testing/vma/include/custom.h
··· 102 102 refcount_set(&vma->vm_refcnt, 0); 103 103 } 104 104 105 - static inline vma_flags_t __mk_vma_flags(size_t count, const vma_flag_t *bits) 105 + static __always_inline vma_flags_t __mk_vma_flags(size_t count, 106 + const vma_flag_t *bits) 106 107 { 107 108 vma_flags_t flags; 108 109 int i; ··· 115 114 vma_flags_clear_all(&flags); 116 115 for (i = 0; i < count; i++) 117 116 if (bits[i] < NUM_VMA_FLAG_BITS) 118 - vma_flag_set(&flags, bits[i]); 117 + vma_flags_set_flag(&flags, bits[i]); 119 118 return flags; 120 119 }
+3 -2
tools/testing/vma/include/dup.h
··· 780 780 *bitmap &= ~value; 781 781 } 782 782 783 - static inline void vma_flags_clear_all(vma_flags_t *flags) 783 + static __always_inline void vma_flags_clear_all(vma_flags_t *flags) 784 784 { 785 785 bitmap_zero(ACCESS_PRIVATE(flags, __vma_flags), NUM_VMA_FLAG_BITS); 786 786 } 787 787 788 - static inline void vma_flag_set(vma_flags_t *flags, vma_flag_t bit) 788 + static __always_inline void vma_flags_set_flag(vma_flags_t *flags, 789 + vma_flag_t bit) 789 790 { 790 791 unsigned long *bitmap = ACCESS_PRIVATE(flags, __vma_flags); 791 792