mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
mm: introduce vma_flags_can_grow() and vma_can_grow()
Patch series "mm: convert more vm_flags_t users to vma_flags_t", v2. This series makes further progress in converting usage of the deprecated vm_flags_t type to its replacement, vma_flags_t. It focuses on mm, though updates some users of mm APIs also. It updates: * The core do_mmap() code path for VMA mapping. * Unmapped area logic. * The usage of mm->def_vma_flags. * VMA page protection bit logic. * General usage of VMA flags in core mm code, mlock, mprotect, mremap. This patch (of 13): These test whether the VMA has stack semantics, i.e. is able to grow upwards or downwards depending on the architecture. In order to account for arches which do not support upward-growing stacks, introduce VMA_GROWSUP whose definition depends on the architecture supporting it, and use vma_flags_test_single_mask() in vma_flags_can_grow() to account for this. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-1-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Lance Yang <lance.yang@linux.dev> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Zi Yan <ziy@nvidia.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
ee8945ab65
commit
a3cb16d80f
+18
-3
@@ -474,6 +474,7 @@ enum {
|
||||
#define VM_SAO INIT_VM_FLAG(SAO)
|
||||
#elif defined(CONFIG_PARISC)
|
||||
#define VM_GROWSUP INIT_VM_FLAG(GROWSUP)
|
||||
#define VMA_GROWSUP mk_vma_flags(VMA_GROWSUP_BIT)
|
||||
#elif defined(CONFIG_SPARC64)
|
||||
#define VM_SPARC_ADI INIT_VM_FLAG(SPARC_ADI)
|
||||
#define VM_ARCH_CLEAR INIT_VM_FLAG(ARCH_CLEAR)
|
||||
@@ -485,6 +486,7 @@ enum {
|
||||
#endif
|
||||
#ifndef VM_GROWSUP
|
||||
#define VM_GROWSUP VM_NONE
|
||||
#define VMA_GROWSUP EMPTY_VMA_FLAGS
|
||||
#endif
|
||||
#ifdef CONFIG_ARM64_MTE
|
||||
#define VM_MTE INIT_VM_FLAG(MTE)
|
||||
@@ -1578,11 +1580,24 @@ static inline bool vma_is_initial_stack(const struct vm_area_struct *vma)
|
||||
vma->vm_end >= vma->vm_mm->start_stack;
|
||||
}
|
||||
|
||||
static inline bool vma_flags_can_grow(const vma_flags_t *flags)
|
||||
{
|
||||
if (vma_flags_test_single_mask(flags, VMA_GROWSUP))
|
||||
return true;
|
||||
if (vma_flags_test(flags, VMA_GROWSDOWN_BIT))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool vma_can_grow(const struct vm_area_struct *vma)
|
||||
{
|
||||
return vma_flags_can_grow(&vma->flags);
|
||||
}
|
||||
|
||||
static inline bool vma_is_temporary_stack(const struct vm_area_struct *vma)
|
||||
{
|
||||
int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);
|
||||
|
||||
if (!maybe_stack)
|
||||
if (!vma_can_grow(vma))
|
||||
return false;
|
||||
|
||||
if ((vma->vm_flags & VM_STACK_INCOMPLETE_SETUP) ==
|
||||
|
||||
Reference in New Issue
Block a user