* [PATCH 00/13] mm: continue vma_flags_t conversion
@ 2026-11-05 21:30 Lorenzo Stoakes (ARM)
2026-11-05 21:30 ` [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t Lorenzo Stoakes (ARM)
` (12 more replies)
0 siblings, 13 replies; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Continue the conversion of legacy vm_flags_t flags to the new vma_flags_t
bitmap type.
Do some more core mm conversion (we really should be the first to
completely move to the new scheme :), but also update some mm-adjacent and
otherwise straightforward cases - /proc/$pid/maps and friends, the coredump
VMA dump size logic, uprobes, perf and LSM mmap/mprotect hooks.
This series only makes strictly mechanical changes to keep things gentle
during this very busy cycle.
No functional change intended.
Build tested on x86-64 (allmodconfig, each patch individually), i386,
arm64, riscv nommu and ppc64le.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
Lorenzo Stoakes (ARM) (13):
mm/gup: convert GUP code to use vma_flags_t
mm/filemap: convert fault and readahead logic to use vma_flags_t
mm/rmap: convert remaining VMA flag tests to use vma_flags_t
mm/migrate: convert VMA flag tests to use vma_flags_t
mm: convert THP VMA flag tests to use vma_flags_t
mm/ksm: convert VMA flag tests to use vma_flags_t
mm/madvise: convert madvise_vma_behavior() to use vma_flags_t
mm: convert miscellaneous VMA flag tests to use vma_flags_t
fs/proc/task_mmu: convert VMA flag tests to use vma_flags_t
fs/coredump: convert vma_dump_size() to use vma_flags_t
uprobes: convert VMA flag tests to use vma_flags_t
perf: convert VMA flag tests to use vma_flags_t
security: convert VMA flag tests to use vma_flags_t
arch/powerpc/kvm/book3s_hv_uvmem.c | 10 ++++----
fs/coredump.c | 16 ++++++-------
fs/proc/task_mmu.c | 43 +++++++++++++++++-----------------
include/linux/huge_mm.h | 4 ++--
include/linux/ksm.h | 4 ++--
include/linux/mm_inline.h | 2 +-
kernel/events/core.c | 26 +++++++++++----------
kernel/events/uprobes.c | 12 ++++++----
lib/test_hmm.c | 4 ++--
mm/damon/vaddr.c | 2 +-
mm/filemap.c | 24 ++++++++++---------
mm/gup.c | 45 +++++++++++++++++++-----------------
mm/hmm.c | 6 ++---
mm/huge_memory.c | 32 +++++++++++++-------------
mm/internal.h | 2 +-
mm/khugepaged.c | 18 ++++++++-------
mm/ksm.c | 22 ++++++++++--------
mm/madvise.c | 47 ++++++++++++++++++++------------------
mm/mempolicy.c | 4 ++--
mm/migrate.c | 5 ++--
mm/migrate_device.c | 8 +++----
mm/mmap_lock.c | 4 ++--
mm/mremap.c | 2 +-
mm/msync.c | 4 ++--
mm/oom_kill.c | 4 ++--
mm/pagewalk.c | 2 +-
mm/rmap.c | 8 ++++---
mm/vma.h | 4 ++--
security/apparmor/lsm.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/ipe/hooks.c | 2 +-
security/selinux/hooks.c | 14 ++++++------
32 files changed, 202 insertions(+), 182 deletions(-)
---
base-commit: b61fa14ce6bcbba2cb9a96feea31b760226d6b43
change-id: 20261101-late-2026-vma-flags-461731a636c3
Cheers,
--
Lorenzo Stoakes (ARM) <ljs@kernel.org>
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:38 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 02/13] mm/filemap: convert fault and readahead logic " Lorenzo Stoakes (ARM)
` (11 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values
throughout the GUP logic, both for the MMU and nommu variants.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/gup.c | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index 7d43ce717b24..dc232117b1ce 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -590,15 +590,15 @@ static inline bool can_follow_write_common(struct page *page,
return false;
/* But FOLL_FORCE has no effect on shared mappings */
- if (vma->vm_flags & (VM_MAYSHARE | VM_SHARED))
+ if (vma_test_any(vma, VMA_MAYSHARE_BIT, VMA_SHARED_BIT))
return false;
/* ... or read-only private ones */
- if (!(vma->vm_flags & VM_MAYWRITE))
+ if (!vma_test(vma, VMA_MAYWRITE_BIT))
return false;
/* ... or already writable ones that just need to take a write fault */
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
return false;
/*
@@ -1199,12 +1199,11 @@ static bool writable_file_mapping_allowed(struct vm_area_struct *vma,
static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
{
- vm_flags_t vm_flags = vma->vm_flags;
int write = (gup_flags & FOLL_WRITE);
int foreign = (gup_flags & FOLL_REMOTE);
bool vma_anon = vma_is_anonymous(vma);
- if (vm_flags & (VM_IO | VM_PFNMAP))
+ if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT))
return -EFAULT;
if ((gup_flags & FOLL_ANON) && !vma_anon)
@@ -1224,7 +1223,8 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
!writable_file_mapping_allowed(vma, gup_flags))
return -EFAULT;
- if (!(vm_flags & VM_WRITE) || (vm_flags & VM_SHADOW_STACK)) {
+ if (!vma_test(vma, VMA_WRITE_BIT) ||
+ vma_test_single_mask(vma, VMA_SHADOW_STACK)) {
if (!(gup_flags & FOLL_FORCE))
return -EFAULT;
/*
@@ -1239,14 +1239,14 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
if (!vma_is_cow_mapping(vma))
return -EFAULT;
}
- } else if (!(vm_flags & VM_READ)) {
+ } else if (!vma_test(vma, VMA_READ_BIT)) {
if (!(gup_flags & FOLL_FORCE))
return -EFAULT;
/*
* Is there actually any vma we can reach here which does not
* have VM_MAYREAD set?
*/
- if (!(vm_flags & VM_MAYREAD))
+ if (!vma_test(vma, VMA_MAYREAD_BIT))
return -EFAULT;
}
/*
@@ -1277,7 +1277,7 @@ static struct vm_area_struct *gup_vma_lookup(struct mm_struct *mm,
return vma;
/* Only warn for half-way relevant accesses */
- if (!(vma->vm_flags & VM_GROWSDOWN))
+ if (!vma_test(vma, VMA_GROWSDOWN_BIT))
return NULL;
if (vma->vm_start - addr > 65536)
return NULL;
@@ -1514,9 +1514,8 @@ static bool vma_permits_fault(struct vm_area_struct *vma,
{
bool write = !!(fault_flags & FAULT_FLAG_WRITE);
bool foreign = !!(fault_flags & FAULT_FLAG_REMOTE);
- vm_flags_t vm_flags = write ? VM_WRITE : VM_READ;
- if (!(vm_flags & vma->vm_flags))
+ if (!vma_test(vma, write ? VMA_WRITE_BIT : VMA_READ_BIT))
return false;
/*
@@ -1829,7 +1828,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
* Rightly or wrongly, the VM_LOCKONFAULT case has never used
* faultin_page() to break COW, so it has no work to do here.
*/
- if (vma->vm_flags & VM_LOCKONFAULT)
+ if (vma_test(vma, VMA_LOCKONFAULT_BIT))
return nr_pages;
/* ... similarly, we've never faulted in PROT_NONE pages */
@@ -1849,7 +1848,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
* Otherwise, do a read fault, and use FOLL_FORCE in case it's not
* readable (ie write-only or executable).
*/
- if ((vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT) && !vma_test(vma, VMA_SHARED_BIT))
gup_flags |= FOLL_WRITE;
else
gup_flags |= FOLL_FORCE;
@@ -1955,7 +1954,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
* range with the first VMA. Also, skip undesirable VMA types.
*/
nend = min(end, vma->vm_end);
- if (vma->vm_flags & (VM_IO | VM_PFNMAP))
+ if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT))
continue;
if (nstart < vma->vm_start)
nstart = vma->vm_start;
@@ -1986,7 +1985,7 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,
{
struct vm_area_struct *vma;
bool must_unlock = false;
- vm_flags_t vm_flags;
+ vma_flags_t vma_flags;
int ret, err = -EFAULT;
long i;
@@ -2011,10 +2010,14 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,
/* calculate required read or write permissions.
* If FOLL_FORCE is set, we only require the "MAY" flags.
*/
- vm_flags = (foll_flags & FOLL_WRITE) ?
- (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
- vm_flags &= (foll_flags & FOLL_FORCE) ?
- (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
+ if (foll_flags & FOLL_WRITE)
+ vma_flags = mk_vma_flags(VMA_WRITE_BIT, VMA_MAYWRITE_BIT);
+ else
+ vma_flags = mk_vma_flags(VMA_READ_BIT, VMA_MAYREAD_BIT);
+ if (foll_flags & FOLL_FORCE)
+ vma_flags_clear(&vma_flags, VMA_READ_BIT, VMA_WRITE_BIT);
+ else
+ vma_flags_clear(&vma_flags, VMA_MAYREAD_BIT, VMA_MAYWRITE_BIT);
for (i = 0; i < nr_pages; i++) {
vma = find_vma(mm, start);
@@ -2022,8 +2025,8 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,
break;
/* protect what we can, including chardevs */
- if ((vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
- !(vm_flags & vma->vm_flags))
+ if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT) ||
+ !vma_test_any_mask(vma, vma_flags))
break;
if (pages) {
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 02/13] mm/filemap: convert fault and readahead logic to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
2026-11-05 21:30 ` [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:41 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 03/13] mm/rmap: convert remaining VMA flag tests " Lorenzo Stoakes (ARM)
` (10 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
file fault and mmap readahead logic.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/filemap.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index b74bc1e5015c..d8b538bd1404 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3351,13 +3351,14 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
struct address_space *mapping = file->f_mapping;
DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff);
struct file *fpin = NULL;
- vm_flags_t vm_flags = vmf->vma->vm_flags;
+ struct vm_area_struct *vma = vmf->vma;
bool force_thp_readahead = false;
unsigned int thp_order = 0;
unsigned short mmap_miss;
/* Use the readahead code, even if readahead is disabled */
- if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && (vm_flags & VM_HUGEPAGE)) {
+ if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
+ vma_test(vma, VMA_HUGEPAGE_BIT)) {
/*
* Cap max THP order at 2MB: this is the common PMD-sized
* hugepage size, and it avoids memory pressure from very
@@ -3377,20 +3378,21 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
* If we don't want any read-ahead, don't bother.
* VM_EXEC case below is already intended for random access.
*/
- if ((vm_flags & (VM_RAND_READ | VM_EXEC)) == VM_RAND_READ)
+ if (vma_test(vma, VMA_RAND_READ_BIT) &&
+ !vma_test(vma, VMA_EXEC_BIT))
return fpin;
if (!ra->ra_pages)
return fpin;
- if (vm_flags & VM_SEQ_READ) {
+ if (vma_test(vma, VMA_SEQ_READ_BIT)) {
fpin = maybe_unlock_mmap_for_io(vmf, fpin);
page_cache_sync_ra(&ractl, ra->ra_pages);
return fpin;
}
}
- if (!(vm_flags & (VM_SEQ_READ | VM_EXEC))) {
+ if (!vma_test_any(vma, VMA_SEQ_READ_BIT, VMA_EXEC_BIT)) {
/* Avoid banging the cache line if not needed */
mmap_miss = READ_ONCE(ra->mmap_miss);
if (mmap_miss < MMAP_LOTSAMISS * 10)
@@ -3414,7 +3416,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
* Fetch two folios so we get the chance to actually
* readahead, unless we've been told not to.
*/
- if (!(vm_flags & VM_RAND_READ))
+ if (!vma_test(vma, VMA_RAND_READ_BIT))
ra->size *= 2;
ra->async_size = folio_nr_pages;
ra->order = thp_order;
@@ -3422,7 +3424,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
return fpin;
}
- if (vm_flags & VM_EXEC) {
+ if (vma_test(vma, VMA_EXEC_BIT)) {
/*
* Allow arch to request a preferred minimum folio order for
* executable memory. This can often be beneficial to
@@ -3477,7 +3479,7 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf,
unsigned short mmap_miss;
/* If we don't want any read-ahead, don't bother */
- if (vmf->vma->vm_flags & VM_RAND_READ || !ra->ra_pages)
+ if (vma_test(vmf->vma, VMA_RAND_READ_BIT) || !ra->ra_pages)
return fpin;
/*
@@ -3491,7 +3493,7 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf,
* keep the counter symmetric.
*/
if (likely(!folio_test_locked(folio)) &&
- !(vmf->vma->vm_flags & (VM_SEQ_READ | VM_EXEC))) {
+ !vma_test_any(vmf->vma, VMA_SEQ_READ_BIT, VMA_EXEC_BIT)) {
mmap_miss = READ_ONCE(ra->mmap_miss);
if (mmap_miss)
WRITE_ONCE(ra->mmap_miss, --mmap_miss);
@@ -3524,7 +3526,7 @@ static vm_fault_t filemap_fault_recheck_pte_none(struct vm_fault *vmf)
* scenarios. Recheck the PTE without PT lock firstly, thereby reducing
* the number of times we hold PT lock.
*/
- if (!(vma->vm_flags & VM_LOCKED))
+ if (!vma_test(vma, VMA_LOCKED_BIT))
return 0;
if (!(vmf->flags & FAULT_FLAG_ORIG_PTE_VALID))
@@ -4000,7 +4002,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
if ((map_ret & VM_FAULT_NOPAGE) &&
!(vmf->flags & FAULT_FLAG_TRIED) &&
!folio_test_workingset(folio) &&
- !(vma->vm_flags & (VM_SEQ_READ | VM_EXEC))) {
+ !vma_test_any(vma, VMA_SEQ_READ_BIT, VMA_EXEC_BIT)) {
unsigned short mmap_miss;
mmap_miss = READ_ONCE(file->f_ra.mmap_miss);
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 03/13] mm/rmap: convert remaining VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
2026-11-05 21:30 ` [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t Lorenzo Stoakes (ARM)
2026-11-05 21:30 ` [PATCH 02/13] mm/filemap: convert fault and readahead logic " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:37 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 04/13] mm/migrate: convert " Lorenzo Stoakes (ARM)
` (9 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace the remaining uses of the legacy vm_flags_t flags in the rmap logic
with vma_flags_t values.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/rmap.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 1131b76bbbc2..cdc97fec8586 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1196,7 +1196,7 @@ static bool page_mkclean_one(struct folio *folio, struct vm_area_struct *vma,
static bool invalid_mkclean_vma(struct vm_area_struct *vma, void *arg)
{
- if (vma->vm_flags & VM_SHARED)
+ if (vma_test(vma, VMA_SHARED_BIT))
return false;
return true;
@@ -1660,7 +1660,8 @@ void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma,
* VM_DROPPABLE mappings don't swap; instead they're just dropped when
* under memory pressure.
*/
- if (!folio_test_swapbacked(folio) && !(vma->vm_flags & VM_DROPPABLE))
+ if (!folio_test_swapbacked(folio) &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE))
__folio_set_swapbacked(folio);
__folio_set_anon(folio, vma, address, exclusive);
@@ -2094,7 +2095,8 @@ static bool ttu_anon_lazyfree_folio(struct vm_area_struct *vma,
*/
smp_rmb();
- if (folio_test_dirty(folio) && !(vma->vm_flags & VM_DROPPABLE)) {
+ if (folio_test_dirty(folio) &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE)) {
/*
* redirtied either using the page table or a previously
* obtained GUP reference.
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 04/13] mm/migrate: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (2 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 03/13] mm/rmap: convert remaining VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:39 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 05/13] mm: convert THP " Lorenzo Stoakes (ARM)
` (8 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
migration logic.
We retain the READ_ONCE() of vma->vm_flags in remove_migration_pte(), as
there is no vma_flags_t equivalent, and arch_make_huge_pte() continues to
take legacy flags for the time being.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/migrate.c | 5 +++--
mm/migrate_device.c | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 28a8d7734735..94033c222e04 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -310,7 +310,7 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
VM_BUG_ON_PAGE(pte_present(old_pte), page);
VM_WARN_ON_ONCE_FOLIO(folio_is_device_private(folio), folio);
- if (folio_test_mlocked(folio) || (pvmw->vma->vm_flags & VM_LOCKED) ||
+ if (folio_test_mlocked(folio) || vma_test(pvmw->vma, VMA_LOCKED_BIT) ||
mm_forbids_zeropage(pvmw->vma->vm_mm))
return false;
@@ -2711,7 +2711,8 @@ int migrate_misplaced_folio_prepare(struct folio *folio,
* See folio_maybe_mapped_shared() on possible imprecision
* when we cannot easily detect if a folio is shared.
*/
- if ((vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio))
+ if (vma_test(vma, VMA_EXEC_BIT) &&
+ folio_maybe_mapped_shared(folio))
return -EACCES;
/*
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 9e19fadfa65c..c26acbbd2e31 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -842,7 +842,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
if (folio_is_device_private(folio)) {
swp_entry_t swp_entry;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
swp_entry = make_writable_device_private_entry(
page_to_pfn(page));
else
@@ -855,7 +855,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
goto free_abort;
}
entry = folio_mk_pmd(folio, vma->vm_page_prot);
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
entry = pmd_mkwrite(pmd_mkdirty(entry), vma);
}
@@ -1043,7 +1043,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
if (folio_is_device_private(folio)) {
swp_entry_t swp_entry;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
swp_entry = make_writable_device_private_entry(
page_to_pfn(page));
else
@@ -1057,7 +1057,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
goto abort;
}
entry = mk_pte(page, vma->vm_page_prot);
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
entry = pte_mkwrite(pte_mkdirty(entry), vma);
}
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 05/13] mm: convert THP VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (3 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 04/13] mm/migrate: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:40 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 06/13] mm/ksm: convert " Lorenzo Stoakes (ARM)
` (7 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values where
VMA flags are tested directly in the THP and khugepaged logic.
The thp_vma_allowable_orders() family of functions, hugepage_madvise() and
khugepaged_enter_vma() continue to take legacy flags for the time being.
Also update BUG_ON()'s to VM_WARN_ON_ONCE() while here.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/huge_memory.c | 32 ++++++++++++++++----------------
mm/khugepaged.c | 8 +++++---
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 7e589a2fb02d..764e693b422f 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1257,7 +1257,7 @@ __setup("thp_anon=", setup_thp_anon);
pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma)
{
- if (likely(vma->vm_flags & VM_WRITE))
+ if (likely(vma_test(vma, VMA_WRITE_BIT)))
pmd = pmd_mkwrite(pmd, vma);
return pmd;
}
@@ -1517,7 +1517,7 @@ vm_fault_t do_huge_pmd_device_private(struct vm_fault *vmf)
*/
gfp_t vma_thp_gfp_mask(struct vm_area_struct *vma)
{
- const bool vma_madvised = vma && (vma->vm_flags & VM_HUGEPAGE);
+ const bool vma_madvised = vma && vma_test(vma, VMA_HUGEPAGE_BIT);
/* Always do synchronous compaction */
if (test_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags))
@@ -1716,10 +1716,9 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, unsigned long pfn,
* but we need to be consistent with PTEs and architectures that
* can't support a 'special' bit.
*/
- BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)));
- BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) ==
- (VM_PFNMAP|VM_MIXEDMAP));
- BUG_ON((vma->vm_flags & VM_PFNMAP) && vma_is_cow_mapping(vma));
+ VM_WARN_ON_ONCE(!vma_test_any(vma, VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT));
+ VM_WARN_ON_ONCE(vma_test_all(vma, VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT));
+ VM_WARN_ON_ONCE(vma_test(vma, VMA_PFNMAP_BIT) && vma_is_cow_mapping(vma));
if (unlikely(is_huge_zero_pfn(pfn)))
return VM_FAULT_SIGBUS;
@@ -1750,7 +1749,7 @@ EXPORT_SYMBOL_GPL(vmf_insert_folio_pmd);
#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
static pud_t maybe_pud_mkwrite(pud_t pud, struct vm_area_struct *vma)
{
- if (likely(vma->vm_flags & VM_WRITE))
+ if (likely(vma_test(vma, VMA_WRITE_BIT)))
pud = pud_mkwrite(pud);
return pud;
}
@@ -1827,10 +1826,9 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, unsigned long pfn,
* but we need to be consistent with PTEs and architectures that
* can't support a 'special' bit.
*/
- BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)));
- BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) ==
- (VM_PFNMAP|VM_MIXEDMAP));
- BUG_ON((vma->vm_flags & VM_PFNMAP) && vma_is_cow_mapping(vma));
+ VM_WARN_ON_ONCE(!vma_test_any(vma, VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT));
+ VM_WARN_ON_ONCE(vma_test_all(vma, VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT));
+ VM_WARN_ON_ONCE(vma_test(vma, VMA_PFNMAP_BIT) && vma_is_cow_mapping(vma));
pfnmap_setup_cachemode_pfn(pfn, &pgprot);
@@ -2262,7 +2260,7 @@ static inline bool can_change_pmd_writable(struct vm_area_struct *vma,
{
struct page *page;
- if (WARN_ON_ONCE(!(vma->vm_flags & VM_WRITE)))
+ if (WARN_ON_ONCE(!vma_test(vma, VMA_WRITE_BIT)))
return false;
/* Don't touch entries that are not even readable (NUMA hinting). */
@@ -2277,7 +2275,7 @@ static inline bool can_change_pmd_writable(struct vm_area_struct *vma,
if (userfaultfd_huge_pmd_wp(vma, pmd))
return false;
- if (!(vma->vm_flags & VM_SHARED)) {
+ if (!vma_test(vma, VMA_SHARED_BIT)) {
/* See can_change_pte_writable(). */
page = vm_normal_page_pmd(vma, addr, pmd);
return page && PageAnon(page) && PageAnonExclusive(page);
@@ -3568,7 +3566,8 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,
if (pmd_dirty(orig_pmd))
folio_set_dirty(folio);
- if (folio_test_dirty(folio) && !(vma->vm_flags & VM_DROPPABLE)) {
+ if (folio_test_dirty(folio) &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE)) {
folio_set_swapbacked(folio);
return false;
}
@@ -3600,7 +3599,8 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,
*/
if (pmd_dirty(orig_pmd))
folio_set_dirty(folio);
- if (folio_test_dirty(folio) && !(vma->vm_flags & VM_DROPPABLE)) {
+ if (folio_test_dirty(folio) &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE)) {
folio_set_swapbacked(folio);
set_pmd_at(mm, addr, pmdp, orig_pmd);
return false;
@@ -3614,7 +3614,7 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,
folio_remove_rmap_pmd(folio, pmd_page(orig_pmd), vma);
zap_deposited_table(mm, pmdp);
add_mm_counter(mm, MM_ANONPAGES, -HPAGE_PMD_NR);
- if (vma->vm_flags & VM_LOCKED)
+ if (vma_test(vma, VMA_LOCKED_BIT))
mlock_drain_local();
folio_put(folio);
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 0d3bd9e23613..a2c7c6a0768d 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -640,7 +640,8 @@ static enum scan_result __collapse_huge_page_isolate(struct vm_area_struct *vma,
* If the vma has the VM_DROPPABLE flag, the collapse will
* preserve the lazyfree property without needing to skip.
*/
- if (cc->policy.anon_skip_lazyfree && !(vma->vm_flags & VM_DROPPABLE) &&
+ if (cc->policy.anon_skip_lazyfree &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE) &&
folio_test_lazyfree(folio) && !pte_dirty(pteval)) {
result = SCAN_PAGE_LAZYFREE;
goto out;
@@ -1683,7 +1684,8 @@ static enum scan_result collapse_scan_anon(struct vm_area_struct *vma,
* If the vma has the VM_DROPPABLE flag, the collapse will
* preserve the lazyfree property without needing to skip.
*/
- if (cc->policy.anon_skip_lazyfree && !(vma->vm_flags & VM_DROPPABLE) &&
+ if (cc->policy.anon_skip_lazyfree &&
+ !vma_test_single_mask(vma, VMA_DROPPABLE) &&
folio_test_lazyfree(folio) && !pte_dirty(pteval)) {
result = SCAN_PAGE_LAZYFREE;
failed_pfn = folio_pfn(folio);
@@ -1948,7 +1950,7 @@ static enum scan_result try_collapse_pte_mapped_thp(struct mm_struct *mm, unsign
* So page lock of folio does not protect from it, so we must not drop
* ptl before pgt_pmd is removed, so uffd private needs pml taken now.
*/
- if (userfaultfd_armed(vma) && !(vma->vm_flags & VM_SHARED))
+ if (userfaultfd_armed(vma) && !vma_test(vma, VMA_SHARED_BIT))
pml = pmd_lock(mm, pmd);
start_pte = pte_offset_map_rw_nolock(mm, pmd, haddr, &pgt_pmd, &ptl);
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 06/13] mm/ksm: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (4 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 05/13] mm: convert THP " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:40 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() " Lorenzo Stoakes (ARM)
` (6 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values where
KSM tests VMA flags directly.
The ksm_madvise() interface continues to take legacy flags for the time
being.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/ksm.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index d6f736a1aa2f..61b772bba229 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -779,7 +779,7 @@ static struct vm_area_struct *find_mergeable_vma(struct mm_struct *mm,
if (ksm_test_exit(mm))
return NULL;
vma = vma_lookup(mm, addr);
- if (!vma || !(vma->vm_flags & VM_MERGEABLE) || !vma_has_anon_rmap(vma))
+ if (!vma || !vma_test(vma, VMA_MERGEABLE_BIT) || !vma_has_anon_rmap(vma))
return NULL;
return vma;
}
@@ -1243,7 +1243,8 @@ static int unmerge_and_remove_all_rmap_items(void)
goto mm_exiting;
for_each_vma(vmi, vma) {
- if (!(vma->vm_flags & VM_MERGEABLE) || !vma_has_anon_rmap(vma))
+ if (!vma_test(vma, VMA_MERGEABLE_BIT) ||
+ !vma_has_anon_rmap(vma))
continue;
err = break_ksm(vma, vma->vm_start, vma->vm_end, false);
if (err)
@@ -2698,7 +2699,7 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page)
goto no_vmas;
for_each_vma(vmi, vma) {
- if (!(vma->vm_flags & VM_MERGEABLE))
+ if (!vma_test(vma, VMA_MERGEABLE_BIT))
continue;
if (ksm_scan.address < vma->vm_start)
ksm_scan.address = vma->vm_start;
@@ -2890,7 +2891,7 @@ static int __ksm_del_vma(struct vm_area_struct *vma)
{
int err;
- if (!(vma->vm_flags & VM_MERGEABLE))
+ if (!vma_test(vma, VMA_MERGEABLE_BIT))
return 0;
if (vma_has_anon_rmap(vma)) {
@@ -3027,7 +3028,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
switch (advice) {
case MADV_MERGEABLE:
- if (vma->vm_flags & VM_MERGEABLE)
+ if (vma_test(vma, VMA_MERGEABLE_BIT))
return 0;
if (!vma_ksm_compatible(vma))
return 0;
@@ -3484,7 +3485,7 @@ bool ksm_process_mergeable(struct mm_struct *mm)
mmap_assert_locked(mm);
VMA_ITERATOR(vmi, mm, 0);
for_each_vma(vmi, vma)
- if (vma->vm_flags & VM_MERGEABLE)
+ if (vma_test(vma, VMA_MERGEABLE_BIT))
return true;
return false;
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (5 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 06/13] mm/ksm: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:43 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 08/13] mm: convert miscellaneous VMA flag tests " Lorenzo Stoakes (ARM)
` (5 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values
throughout the madvise logic.
In order to do so, update ksm_madvise() and hugepage_madvise() to take a
vma_flags_t pointer, and update their other callers in mremap and the
powerpc KVM ultravisor code accordingly.
In the latter case we replace vm_flags_reset() with vma_overwrite_flags().
The VMA is write locked at this point, so the atomic flags preserved by
vma_overwrite_flags() cannot differ from those copied, and the behaviour
is unchanged.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
arch/powerpc/kvm/book3s_hv_uvmem.c | 10 ++++----
include/linux/huge_mm.h | 4 ++--
include/linux/ksm.h | 4 ++--
mm/khugepaged.c | 10 ++++----
mm/ksm.c | 11 +++++----
mm/madvise.c | 47 ++++++++++++++++++++------------------
mm/mremap.c | 2 +-
7 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
index 463aef870c4e..0fa50bee2ffc 100644
--- a/arch/powerpc/kvm/book3s_hv_uvmem.c
+++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
@@ -393,7 +393,7 @@ static int kvmppc_memslot_page_merge(struct kvm *kvm,
{
unsigned long gfn = memslot->base_gfn;
unsigned long end, start = gfn_to_hva(kvm, gfn);
- vm_flags_t vm_flags;
+ vma_flags_t vma_flags;
int ret = 0;
struct vm_area_struct *vma;
int merge_flag = (merge) ? MADV_MERGEABLE : MADV_UNMERGEABLE;
@@ -411,15 +411,15 @@ static int kvmppc_memslot_page_merge(struct kvm *kvm,
break;
}
vma_start_write(vma);
- /* Copy vm_flags to avoid partial modifications in ksm_madvise */
- vm_flags = vma->vm_flags;
+ /* Copy flags to avoid partial modifications in ksm_madvise */
+ vma_flags = vma->flags;
ret = ksm_madvise(vma, vma->vm_start, vma->vm_end,
- merge_flag, &vm_flags);
+ merge_flag, &vma_flags);
if (ret) {
ret = H_STATE;
break;
}
- vm_flags_reset(vma, vm_flags);
+ vma_overwrite_flags(vma, vma_flags);
start = vma->vm_end;
} while (end > vma->vm_end);
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index c745f7ad2298..8b6f4101eabf 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -508,7 +508,7 @@ change_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma,
__split_huge_pud(__vma, __pud, __address); \
} while (0)
-int hugepage_madvise(struct vm_area_struct *vma, vm_flags_t *vm_flags,
+int hugepage_madvise(struct vm_area_struct *vma, vma_flags_t *vma_flags,
int advice);
int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
unsigned long end, bool *lock_dropped);
@@ -710,7 +710,7 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
do { } while (0)
static inline int hugepage_madvise(struct vm_area_struct *vma,
- vm_flags_t *vm_flags, int advice)
+ vma_flags_t *vma_flags, int advice)
{
return -EINVAL;
}
diff --git a/include/linux/ksm.h b/include/linux/ksm.h
index d39d0d5483a2..1ffc69a72a1a 100644
--- a/include/linux/ksm.h
+++ b/include/linux/ksm.h
@@ -16,7 +16,7 @@
#ifdef CONFIG_KSM
int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
- unsigned long end, int advice, vm_flags_t *vm_flags);
+ unsigned long end, int advice, vma_flags_t *vma_flags);
vma_flags_t ksm_vma_flags(struct mm_struct *mm, const struct file *file,
vma_flags_t vma_flags);
int ksm_enable_merge_any(struct mm_struct *mm);
@@ -139,7 +139,7 @@ static inline void collect_procs_ksm(const struct folio *folio,
#ifdef CONFIG_MMU
static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
- unsigned long end, int advice, vm_flags_t *vm_flags)
+ unsigned long end, int advice, vma_flags_t *vma_flags)
{
return 0;
}
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index a2c7c6a0768d..be1f779c8da5 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -363,16 +363,16 @@ static unsigned int collapse_max_ptes_swap(struct collapse_control *cc,
}
int hugepage_madvise(struct vm_area_struct *vma,
- vm_flags_t *vm_flags, int advice)
+ vma_flags_t *vma_flags, int advice)
{
switch (advice) {
case MADV_HUGEPAGE:
- *vm_flags &= ~VM_NOHUGEPAGE;
- *vm_flags |= VM_HUGEPAGE;
+ vma_flags_clear(vma_flags, VMA_NOHUGEPAGE_BIT);
+ vma_flags_set(vma_flags, VMA_HUGEPAGE_BIT);
break;
case MADV_NOHUGEPAGE:
- *vm_flags &= ~VM_HUGEPAGE;
- *vm_flags |= VM_NOHUGEPAGE;
+ vma_flags_clear(vma_flags, VMA_HUGEPAGE_BIT);
+ vma_flags_set(vma_flags, VMA_NOHUGEPAGE_BIT);
/*
* Setting VM_NOHUGEPAGE will prevent khugepaged from scanning
* this vma even if we leave the mm registered in khugepaged if
diff --git a/mm/ksm.c b/mm/ksm.c
index 61b772bba229..3eb9c1ec2f87 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -779,7 +779,8 @@ static struct vm_area_struct *find_mergeable_vma(struct mm_struct *mm,
if (ksm_test_exit(mm))
return NULL;
vma = vma_lookup(mm, addr);
- if (!vma || !vma_test(vma, VMA_MERGEABLE_BIT) || !vma_has_anon_rmap(vma))
+ if (!vma || !vma_test(vma, VMA_MERGEABLE_BIT) ||
+ !vma_has_anon_rmap(vma))
return NULL;
return vma;
}
@@ -3021,7 +3022,7 @@ int ksm_disable(struct mm_struct *mm)
}
int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
- unsigned long end, int advice, vm_flags_t *vm_flags)
+ unsigned long end, int advice, vma_flags_t *vma_flags)
{
struct mm_struct *mm = vma->vm_mm;
int err;
@@ -3039,11 +3040,11 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
return err;
}
- *vm_flags |= VM_MERGEABLE;
+ vma_flags_set(vma_flags, VMA_MERGEABLE_BIT);
break;
case MADV_UNMERGEABLE:
- if (!(*vm_flags & VM_MERGEABLE))
+ if (!vma_flags_test(vma_flags, VMA_MERGEABLE_BIT))
return 0; /* just ignore the advice */
if (vma_has_anon_rmap(vma)) {
@@ -3052,7 +3053,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
return err;
}
- *vm_flags &= ~VM_MERGEABLE;
+ vma_flags_clear(vma_flags, VMA_MERGEABLE_BIT);
break;
}
diff --git a/mm/madvise.c b/mm/madvise.c
index e9fa4f71efea..1b539e67b00d 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -148,11 +148,10 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,
* Update the vm_flags or anon_name on region of a vma, splitting it or merging
* it as necessary. Must be called with mmap_lock held for writing.
*/
-static int madvise_update_vma(vm_flags_t new_flags,
+static int madvise_update_vma(vma_flags_t new_vma_flags,
struct madvise_behavior *madv_behavior)
{
struct vm_area_struct *vma = madv_behavior->vma;
- vma_flags_t new_vma_flags = legacy_to_vma_flags(new_flags);
struct madvise_behavior_range *range = &madv_behavior->range;
struct anon_vma_name *anon_name = madv_behavior->anon_name;
bool set_new_anon_name = madv_behavior->behavior == __MADV_SET_ANON_VMA_NAME;
@@ -601,7 +600,8 @@ static void madvise_cold_page_range(struct mmu_gather *tlb,
static inline bool can_madv_lru_vma(struct vm_area_struct *vma)
{
- return !(vma->vm_flags & (VM_LOCKED|VM_PFNMAP|VM_HUGETLB));
+ return !vma_test_any(vma, VMA_LOCKED_BIT, VMA_PFNMAP_BIT,
+ VMA_HUGETLB_BIT);
}
static long madvise_cold(struct madvise_behavior *madv_behavior)
@@ -650,7 +650,7 @@ static long madvise_pageout(struct madvise_behavior *madv_behavior)
* further to pageout dirty anon pages.
*/
if (!vma_is_anonymous(vma) && (!can_do_file_pageout(vma) &&
- (vma->vm_flags & VM_MAYSHARE)))
+ vma_test(vma, VMA_MAYSHARE_BIT)))
return 0;
lru_add_drain();
@@ -881,12 +881,12 @@ bool madvise_dontneed_free_valid_vma(struct madvise_behavior *madv_behavior)
struct madvise_behavior_range *range = &madv_behavior->range;
if (!vma_is_hugetlb(vma)) {
- unsigned int forbidden = VM_PFNMAP;
+ vma_flags_t forbidden = mk_vma_flags(VMA_PFNMAP_BIT);
if (behavior != MADV_DONTNEED_LOCKED)
- forbidden |= VM_LOCKED;
+ vma_flags_set(&forbidden, VMA_LOCKED_BIT);
- return !(vma->vm_flags & forbidden);
+ return !vma_test_any_mask(vma, forbidden);
}
if (behavior != MADV_DONTNEED && behavior != MADV_DONTNEED_LOCKED)
@@ -1021,7 +1021,7 @@ static long madvise_remove(struct madvise_behavior *madv_behavior)
mark_mmap_lock_dropped(madv_behavior);
- if (vma->vm_flags & VM_LOCKED)
+ if (vma_test(vma, VMA_LOCKED_BIT))
return -EINVAL;
f = vma->vm_file;
@@ -1333,7 +1333,7 @@ static bool can_madvise_modify(struct madvise_behavior *madv_behavior)
return true;
/* If the user could write to the mapping anyway, then this is fine. */
- if ((vma->vm_flags & VM_WRITE) &&
+ if (vma_test(vma, VMA_WRITE_BIT) &&
arch_vma_access_permitted(vma, /* write= */ true,
/* execute= */ false, /* foreign= */ false))
return true;
@@ -1357,7 +1357,7 @@ static int madvise_vma_behavior(struct madvise_behavior *madv_behavior)
{
int behavior = madv_behavior->behavior;
struct vm_area_struct *vma = madv_behavior->vma;
- vm_flags_t new_flags = vma->vm_flags;
+ vma_flags_t new_flags = vma->flags;
struct madvise_behavior_range *range = &madv_behavior->range;
int error;
@@ -1388,44 +1388,47 @@ static int madvise_vma_behavior(struct madvise_behavior *madv_behavior)
/* The below behaviours update VMAs via madvise_update_vma(). */
case MADV_NORMAL:
- new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
+ vma_flags_clear(&new_flags, VMA_RAND_READ_BIT,
+ VMA_SEQ_READ_BIT);
break;
case MADV_SEQUENTIAL:
- new_flags = (new_flags & ~VM_RAND_READ) | VM_SEQ_READ;
+ vma_flags_clear(&new_flags, VMA_RAND_READ_BIT);
+ vma_flags_set(&new_flags, VMA_SEQ_READ_BIT);
break;
case MADV_RANDOM:
- new_flags = (new_flags & ~VM_SEQ_READ) | VM_RAND_READ;
+ vma_flags_clear(&new_flags, VMA_SEQ_READ_BIT);
+ vma_flags_set(&new_flags, VMA_RAND_READ_BIT);
break;
case MADV_DONTFORK:
- new_flags |= VM_DONTCOPY;
+ vma_flags_set(&new_flags, VMA_DONTCOPY_BIT);
break;
case MADV_DOFORK:
if (!vma_is_mm_backed(vma) || vma_is_hugetlb(vma))
return -EINVAL;
- new_flags &= ~VM_DONTCOPY;
+ vma_flags_clear(&new_flags, VMA_DONTCOPY_BIT);
break;
case MADV_WIPEONFORK:
/* MADV_WIPEONFORK is only supported on anonymous memory. */
- if (vma->vm_file || new_flags & VM_SHARED)
+ if (vma->vm_file || vma_flags_test(&new_flags, VMA_SHARED_BIT))
return -EINVAL;
- new_flags |= VM_WIPEONFORK;
+ vma_flags_set(&new_flags, VMA_WIPEONFORK_BIT);
break;
case MADV_KEEPONFORK:
- if (new_flags & VM_DROPPABLE)
+ if (vma_flags_test_single_mask(&new_flags, VMA_DROPPABLE))
return -EINVAL;
- new_flags &= ~VM_WIPEONFORK;
+ vma_flags_clear(&new_flags, VMA_WIPEONFORK_BIT);
break;
case MADV_DONTDUMP:
- new_flags |= VM_DONTDUMP;
+ vma_flags_set(&new_flags, VMA_DONTDUMP_BIT);
break;
case MADV_DODUMP:
/* Only mm-backed memory can be meaningfully dumped. */
if (!vma_is_mm_backed(vma))
return -EINVAL;
/* Core mm may discard droppable memory at any time. */
- if (new_flags & VM_DROPPABLE)
+ if (vma_flags_test_single_mask(&new_flags, VMA_DROPPABLE))
return -EINVAL;
- new_flags &= ~VM_DONTDUMP;
+ vma_flags_clear(&new_flags, VMA_DONTDUMP_BIT);
break;
case MADV_MERGEABLE:
case MADV_UNMERGEABLE:
diff --git a/mm/mremap.c b/mm/mremap.c
index 0d06d7f37f19..5f4e7d1ce3b7 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -1133,7 +1133,7 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
struct vm_area_struct *vma = vrm->vma;
unsigned long old_addr = vrm->addr;
unsigned long old_len = vrm->old_len;
- vm_flags_t dummy = vma->vm_flags;
+ vma_flags_t dummy = vma->flags;
const bool split_before = vma->vm_start != old_addr;
const bool split_after = vma->vm_end != old_addr + old_len;
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 08/13] mm: convert miscellaneous VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (6 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:30 ` Lorenzo Stoakes (ARM)
2026-11-05 21:43 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 09/13] fs/proc/task_mmu: convert " Lorenzo Stoakes (ARM)
` (4 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:30 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
remaining straightforward VMA flag tests scattered throughout core mm, HMM
(and its test module), DAMON and the OOM reaper.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
include/linux/mm_inline.h | 2 +-
lib/test_hmm.c | 4 ++--
mm/damon/vaddr.c | 2 +-
mm/hmm.c | 6 +++---
mm/internal.h | 2 +-
mm/mempolicy.c | 4 ++--
mm/mmap_lock.c | 4 ++--
mm/msync.c | 4 ++--
mm/oom_kill.c | 4 ++--
mm/pagewalk.c | 2 +-
mm/vma.h | 4 ++--
11 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index ab69b9930893..da04d81a819c 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -657,7 +657,7 @@ static inline pte_marker copy_pte_marker(
static inline bool vma_has_recency(const struct vm_area_struct *vma)
{
- if (vma->vm_flags & (VM_SEQ_READ | VM_RAND_READ))
+ if (vma_test_any(vma, VMA_SEQ_READ_BIT, VMA_RAND_READ_BIT))
return false;
if (vma->vm_file && (vma->vm_file->f_mode & FMODE_NOREUSE))
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index b409c42bfe6f..d7702d99ac9b 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1248,7 +1248,7 @@ static int dmirror_migrate_to_system(struct dmirror *dmirror,
mmap_read_lock(mm);
for (addr = start; addr < end; addr = next) {
vma = vma_lookup(mm, addr);
- if (!vma || !(vma->vm_flags & VM_READ)) {
+ if (!vma || !vma_test(vma, VMA_READ_BIT)) {
ret = -EINVAL;
goto out;
}
@@ -1320,7 +1320,7 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,
mmap_read_lock(mm);
for (addr = start; addr < end; addr = next) {
vma = vma_lookup(mm, addr);
- if (!vma || !(vma->vm_flags & VM_READ)) {
+ if (!vma || !vma_test(vma, VMA_READ_BIT)) {
ret = -EINVAL;
goto out;
}
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b549496ea8e2..9a43f7428142 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -240,7 +240,7 @@ static void damon_va_walk_page_range(struct mm_struct *mm, unsigned long start,
goto lock_mmap;
}
- if (!(vma->vm_flags & VM_PFNMAP)) {
+ if (!vma_test(vma, VMA_PFNMAP_BIT)) {
ops->walk_lock = PGWALK_VMA_RDLOCK_VERIFY;
walk_page_range_vma(vma, start, end, ops, private);
}
diff --git a/mm/hmm.c b/mm/hmm.c
index 2f1e98c6b644..058d0b48399a 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -595,8 +595,8 @@ static int hmm_vma_walk_test(unsigned long start, unsigned long end,
struct hmm_range *range = hmm_vma_walk->range;
struct vm_area_struct *vma = walk->vma;
- if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)) &&
- vma->vm_flags & VM_READ)
+ if (!vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT) &&
+ vma_test(vma, VMA_READ_BIT))
return 0;
/*
@@ -659,7 +659,7 @@ static int hmm_do_fault(struct mm_struct *mm,
return -EFAULT;
if (required_fault & HMM_NEED_WRITE_FAULT) {
- if (!(vma->vm_flags & VM_WRITE))
+ if (!vma_test(vma, VMA_WRITE_BIT))
return -EPERM;
fault_flags |= FAULT_FLAG_WRITE;
}
diff --git a/mm/internal.h b/mm/internal.h
index 8b1263e81054..cbb205f06097 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1249,7 +1249,7 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
static inline bool vma_is_single_threaded_private(struct vm_area_struct *vma)
{
- if (vma->vm_flags & VM_SHARED)
+ if (vma_test(vma, VMA_SHARED_BIT))
return false;
return atomic_read(&vma->vm_mm->mm_users) == 1;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 80c693c6d693..31d42bcad529 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2015,7 +2015,7 @@ SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
bool vma_migratable(struct vm_area_struct *vma)
{
- if (vma->vm_flags & (VM_IO | VM_PFNMAP))
+ if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT))
return false;
/*
@@ -2565,7 +2565,7 @@ struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct
pgoff_t ilx;
struct folio *folio;
- if (vma->vm_flags & VM_DROPPABLE)
+ if (vma_test_single_mask(vma, VMA_DROPPABLE))
gfp |= __GFP_NOWARN;
pol = get_vma_policy(vma, addr, order, &ilx);
diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
index 834bbf86e004..1b0560a4dfcd 100644
--- a/mm/mmap_lock.c
+++ b/mm/mmap_lock.c
@@ -636,7 +636,7 @@ struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm,
* Well, dang. We might still be successful, but only
* if we can extend a vma to do so.
*/
- if (!vma || !(vma->vm_flags & VM_GROWSDOWN)) {
+ if (!vma || !vma_test(vma, VMA_GROWSDOWN_BIT)) {
mmap_read_unlock(mm);
return NULL;
}
@@ -659,7 +659,7 @@ struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm,
goto fail;
if (vma->vm_start <= addr)
goto success;
- if (!(vma->vm_flags & VM_GROWSDOWN))
+ if (!vma_test(vma, VMA_GROWSDOWN_BIT))
goto fail;
}
diff --git a/mm/msync.c b/mm/msync.c
index 90b491a27a14..953efa1738c5 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -81,7 +81,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
}
/* Here vma->vm_start <= start < vma->vm_end. */
if ((flags & MS_INVALIDATE) &&
- (vma->vm_flags & VM_LOCKED)) {
+ vma_test(vma, VMA_LOCKED_BIT)) {
error = -EBUSY;
goto out_unlock;
}
@@ -90,7 +90,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
fend = fstart + (min(end, vma->vm_end) - start) - 1;
start = vma->vm_end;
if ((flags & MS_SYNC) && file &&
- (vma->vm_flags & VM_SHARED)) {
+ vma_test(vma, VMA_SHARED_BIT)) {
get_file(file);
mmap_read_unlock(mm);
error = vfs_fsync_range(file, fstart, fend, 1);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5d48bd862c27..91b11299cb5d 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -524,7 +524,7 @@ static bool __oom_reap_task_mm(struct mm_struct *mm)
* of the address space.
*/
mas_for_each_rev(&mas, vma, 0) {
- if (vma->vm_flags & (VM_HUGETLB|VM_PFNMAP))
+ if (vma_test_any(vma, VMA_HUGETLB_BIT, VMA_PFNMAP_BIT))
continue;
/*
@@ -537,7 +537,7 @@ static bool __oom_reap_task_mm(struct mm_struct *mm)
* we do not want to block exit_mmap by keeping mm ref
* count elevated without a good reason.
*/
- if (vma_is_anonymous(vma) || !(vma->vm_flags & VM_SHARED)) {
+ if (vma_is_anonymous(vma) || !vma_test(vma, VMA_SHARED_BIT)) {
if (zap_vma_for_reaping(vma))
ret = false;
}
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index e6493bbe6919..41e19f544493 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -393,7 +393,7 @@ static int walk_page_test(unsigned long start, unsigned long end,
* define their ->pte_hole() callbacks, so let's delegate them to handle
* vma(VM_PFNMAP).
*/
- if (vma->vm_flags & VM_PFNMAP) {
+ if (vma_test(vma, VMA_PFNMAP_BIT)) {
int err = 1;
if (ops->pte_hole)
err = ops->pte_hole(start, end, -1, walk);
diff --git a/mm/vma.h b/mm/vma.h
index 3fc3b47a954b..201dbfe3d7f8 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -597,9 +597,9 @@ static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma
* private mappings, that's always the case when we have write
* permissions as we properly have to handle COW.
*/
- if (vma->vm_flags & VM_SHARED)
+ if (vma_test(vma, VMA_SHARED_BIT))
return vma_wants_writenotify(vma, vma->vm_page_prot);
- return !!(vma->vm_flags & VM_WRITE);
+ return vma_test(vma, VMA_WRITE_BIT);
}
#ifdef CONFIG_MMU
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 09/13] fs/proc/task_mmu: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (7 preceding siblings ...)
2026-11-05 21:30 ` [PATCH 08/13] mm: convert miscellaneous VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:31 ` Lorenzo Stoakes (ARM)
2026-11-05 21:45 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 10/13] fs/coredump: convert vma_dump_size() " Lorenzo Stoakes (ARM)
` (3 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values where
VMA flags are tested directly in /proc/$pid/[s]maps, pagemap, clear_refs
and PROCMAP_QUERY.
In replacing vm_flags_clear() (which takes the VMA write lock) with
vma_clear_flags() (which does not) in clear_refs_write(), we explicitly
write lock the VMA. The mmap write lock is already held at this point.
The show_vma_header_prefix() and show_smap_vma_flags() output functions and
the thp_vma_allowable_orders() call continue to use legacy flags for the
time being.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
fs/proc/task_mmu.c | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 22361607020d..b6e8ef15e40e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -569,18 +569,18 @@ static struct vm_area_struct *query_matching_vma(struct proc_maps_locking_ctx *l
/* VMA permissions should satisfy query flags */
if (flags & PROCMAP_QUERY_VMA_FLAGS) {
- u32 perm = 0;
+ vma_flags_t perm = EMPTY_VMA_FLAGS;
if (flags & PROCMAP_QUERY_VMA_READABLE)
- perm |= VM_READ;
+ vma_flags_set(&perm, VMA_READ_BIT);
if (flags & PROCMAP_QUERY_VMA_WRITABLE)
- perm |= VM_WRITE;
+ vma_flags_set(&perm, VMA_WRITE_BIT);
if (flags & PROCMAP_QUERY_VMA_EXECUTABLE)
- perm |= VM_EXEC;
+ vma_flags_set(&perm, VMA_EXEC_BIT);
if (flags & PROCMAP_QUERY_VMA_SHARED)
- perm |= VM_MAYSHARE;
+ vma_flags_set(&perm, VMA_MAYSHARE_BIT);
- if ((vma->vm_flags & perm) != perm)
+ if (!vma_test_all_mask(vma, perm))
goto skip_vma;
}
@@ -647,13 +647,13 @@ static int do_procmap_query(struct mm_struct *mm, void __user *uarg)
karg.vma_end = vma->vm_end;
karg.vma_flags = 0;
- if (vma->vm_flags & VM_READ)
+ if (vma_test(vma, VMA_READ_BIT))
karg.vma_flags |= PROCMAP_QUERY_VMA_READABLE;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
karg.vma_flags |= PROCMAP_QUERY_VMA_WRITABLE;
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
karg.vma_flags |= PROCMAP_QUERY_VMA_EXECUTABLE;
- if (vma->vm_flags & VM_MAYSHARE)
+ if (vma_test(vma, VMA_MAYSHARE_BIT))
karg.vma_flags |= PROCMAP_QUERY_VMA_SHARED;
karg.vma_page_size = vma_kernel_pagesize(vma);
@@ -970,7 +970,7 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
{
struct mem_size_stats *mss = walk->private;
struct vm_area_struct *vma = walk->vma;
- bool locked = !!(vma->vm_flags & VM_LOCKED);
+ bool locked = vma_test(vma, VMA_LOCKED_BIT);
struct page *page = NULL;
bool present = false, young = false, dirty = false;
pte_t ptent = ptep_get(pte);
@@ -1017,7 +1017,7 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
{
struct mem_size_stats *mss = walk->private;
struct vm_area_struct *vma = walk->vma;
- bool locked = !!(vma->vm_flags & VM_LOCKED);
+ bool locked = vma_test(vma, VMA_LOCKED_BIT);
struct page *page = NULL;
bool present = false;
struct folio *folio;
@@ -1728,7 +1728,7 @@ static int clear_refs_test_walk(unsigned long start, unsigned long end,
struct clear_refs_private *cp = walk->private;
struct vm_area_struct *vma = walk->vma;
- if (vma->vm_flags & VM_PFNMAP)
+ if (vma_test(vma, VMA_PFNMAP_BIT))
return 1;
/*
@@ -1798,9 +1798,10 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
if (type == CLEAR_REFS_SOFT_DIRTY) {
for_each_vma(vmi, vma) {
- if (!(vma->vm_flags & VM_SOFTDIRTY))
+ if (!vma_test(vma, VMA_SOFTDIRTY_BIT))
continue;
- vm_flags_clear(vma, VM_SOFTDIRTY);
+ vma_start_write(vma);
+ vma_clear_flags(vma, VMA_SOFTDIRTY_BIT);
vma_set_page_prot(vma);
}
@@ -1904,7 +1905,7 @@ static int pagemap_pte_hole(unsigned long start, unsigned long end,
break;
/* Addresses in the VMA. */
- if (vma->vm_flags & VM_SOFTDIRTY)
+ if (vma_test(vma, VMA_SOFTDIRTY_BIT))
pme = make_pme(0, PM_SOFT_DIRTY);
for (; addr < min(end, vma->vm_end); addr += PAGE_SIZE) {
err = add_to_pagemap(&pme, pm);
@@ -1976,7 +1977,7 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
}
out:
- if (vma->vm_flags & VM_SOFTDIRTY)
+ if (vma_test(vma, VMA_SOFTDIRTY_BIT))
flags |= PM_SOFT_DIRTY;
return make_pme(frame, flags);
@@ -1994,7 +1995,7 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr,
struct folio *folio = NULL;
int err = 0;
- if (vma->vm_flags & VM_SOFTDIRTY)
+ if (vma_test(vma, VMA_SOFTDIRTY_BIT))
flags |= PM_SOFT_DIRTY;
if (pmd_none(pmd))
@@ -2116,7 +2117,7 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask,
int err = 0;
pte_t pte;
- if (vma->vm_flags & VM_SOFTDIRTY)
+ if (vma_test(vma, VMA_SOFTDIRTY_BIT))
flags |= PM_SOFT_DIRTY;
ptl = huge_pte_lock(hstate_vma(vma), walk->mm, ptep);
@@ -2625,13 +2626,13 @@ static int pagemap_scan_test_walk(unsigned long start, unsigned long end,
*/
}
- if (vma->vm_flags & VM_PFNMAP)
+ if (vma_test(vma, VMA_PFNMAP_BIT))
return 1;
if (wp_allowed)
vma_category |= PAGE_IS_WPALLOWED;
- if (vma->vm_flags & VM_SOFTDIRTY)
+ if (vma_test(vma, VMA_SOFTDIRTY_BIT))
vma_category |= PAGE_IS_SOFT_DIRTY;
if (!pagemap_scan_is_interesting_vma(vma_category, p))
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 10/13] fs/coredump: convert vma_dump_size() to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (8 preceding siblings ...)
2026-11-05 21:31 ` [PATCH 09/13] fs/proc/task_mmu: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:31 ` Lorenzo Stoakes (ARM)
2026-11-05 21:44 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 11/13] uprobes: convert VMA flag tests " Lorenzo Stoakes (ARM)
` (2 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values when
determining how much of a VMA to dump.
The flags copied into struct core_vma_metadata remain legacy flags as they
are consumed by the binfmt handlers.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
fs/coredump.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index b25ef2ffbdee..6ebc04421b91 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1835,15 +1835,15 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
if (always_dump_vma(vma))
goto whole;
- if (vma->vm_flags & VM_DONTDUMP)
+ if (vma_test(vma, VMA_DONTDUMP_BIT))
return 0;
/* support for DAX */
if (vma_is_dax(vma)) {
- if ((vma->vm_flags & VM_SHARED) &&
+ if (vma_test(vma, VMA_SHARED_BIT) &&
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, DAX_SHARED))
goto whole;
- if (!(vma->vm_flags & VM_SHARED) &&
+ if (!vma_test(vma, VMA_SHARED_BIT) &&
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, DAX_PRIVATE))
goto whole;
return 0;
@@ -1851,21 +1851,21 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
/* Hugetlb memory check */
if (vma_is_hugetlb(vma)) {
- if ((vma->vm_flags & VM_SHARED) &&
+ if (vma_test(vma, VMA_SHARED_BIT) &&
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, HUGETLB_SHARED))
goto whole;
- if (!(vma->vm_flags & VM_SHARED) &&
+ if (!vma_test(vma, VMA_SHARED_BIT) &&
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, HUGETLB_PRIVATE))
goto whole;
return 0;
}
/* Do not dump I/O mapped devices or special mappings */
- if (vma->vm_flags & VM_IO)
+ if (vma_test(vma, VMA_IO_BIT))
return 0;
/* By default, dump shared memory if mapped from an anonymous file. */
- if (vma->vm_flags & VM_SHARED) {
+ if (vma_test(vma, VMA_SHARED_BIT)) {
if (file_inode(vma->vm_file)->i_nlink == 0 ?
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, ANON_SHARED) :
COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, FILE_SHARED))
@@ -1888,7 +1888,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
* dump the first page to aid in determining what was mapped here.
*/
if (COREDUMP_MEMORY_TYPE_INCLUDE(memory_types, ELF_HEADERS) &&
- vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) {
+ vma->vm_pgoff == 0 && vma_test(vma, VMA_READ_BIT)) {
if ((READ_ONCE(file_inode(vma->vm_file)->i_mode) & 0111) != 0)
return PAGE_SIZE;
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 11/13] uprobes: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (9 preceding siblings ...)
2026-11-05 21:31 ` [PATCH 10/13] fs/coredump: convert vma_dump_size() " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:31 ` Lorenzo Stoakes (ARM)
2026-11-05 21:44 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 12/13] perf: " Lorenzo Stoakes (ARM)
2026-11-05 21:31 ` [PATCH 13/13] security: " Lorenzo Stoakes (ARM)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
uprobes VMA validity checks.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
kernel/events/uprobes.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index caf444762a27..853fc952331c 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -134,12 +134,14 @@ static void uprobe_warn(struct task_struct *t, const char *msg)
*/
static bool valid_vma(struct vm_area_struct *vma, bool is_register)
{
- vm_flags_t flags = VM_HUGETLB | VM_MAYEXEC | VM_MAYSHARE;
+ vma_flags_t forbidden = mk_vma_flags(VMA_HUGETLB_BIT,
+ VMA_MAYSHARE_BIT);
if (is_register)
- flags |= VM_WRITE;
+ vma_flags_set(&forbidden, VMA_WRITE_BIT);
- return vma->vm_file && (vma->vm_flags & flags) == VM_MAYEXEC;
+ return vma->vm_file && vma_test(vma, VMA_MAYEXEC_BIT) &&
+ !vma_test_any_mask(vma, forbidden);
}
static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset)
@@ -286,7 +288,7 @@ static bool valid_ref_ctr_vma(struct uprobe *uprobe,
return uprobe->ref_ctr_offset &&
vma->vm_file &&
file_inode(vma->vm_file) == uprobe->inode &&
- (vma->vm_flags & (VM_WRITE|VM_SHARED)) == VM_WRITE &&
+ vma_test(vma, VMA_WRITE_BIT) && !vma_test(vma, VMA_SHARED_BIT) &&
vma->vm_start <= vaddr &&
vma->vm_end > vaddr;
}
@@ -1607,7 +1609,7 @@ int uprobe_mmap(struct vm_area_struct *vma)
return 0;
if (vma->vm_file &&
- (vma->vm_flags & (VM_WRITE|VM_SHARED)) == VM_WRITE &&
+ vma_test(vma, VMA_WRITE_BIT) && !vma_test(vma, VMA_SHARED_BIT) &&
mm_flags_test(MMF_HAS_UPROBES, vma->vm_mm))
delayed_ref_ctr_inc(vma);
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 12/13] perf: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (10 preceding siblings ...)
2026-11-05 21:31 ` [PATCH 11/13] uprobes: convert VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:31 ` Lorenzo Stoakes (ARM)
2026-11-05 21:46 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 13/13] security: " Lorenzo Stoakes (ARM)
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
perf mmap and mmap event logic.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
kernel/events/core.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 457d75ea7142..6bc5dfacfa48 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7224,6 +7224,7 @@ static int map_range(struct perf_buffer *rb, struct vm_area_struct *vma)
unsigned long va = vma->vm_start + PAGE_SIZE * pagenum;
struct page *page = perf_mmap_to_page(rb,
vma_start_pgoff(vma) + pagenum);
+ vma_flags_t vma_flags = vma->flags;
if (page == NULL) {
err = -EINVAL;
@@ -7231,8 +7232,9 @@ static int map_range(struct perf_buffer *rb, struct vm_area_struct *vma)
}
/* Map readonly, perf_mmap_pfn_mkwrite() called on write fault. */
+ vma_flags_clear(&vma_flags, VMA_SHARED_BIT);
err = remap_pfn_range(vma, va, page_to_pfn(page), PAGE_SIZE,
- vm_get_page_prot(vma->vm_flags & ~VM_SHARED));
+ vma_flags_to_page_prot(vma_flags));
if (err)
break;
}
@@ -7350,7 +7352,7 @@ static int perf_mmap_rb(struct vm_area_struct *vma, struct perf_event *event,
if (!perf_mmap_calc_limits(vma, &user_extra, &extra))
return -EPERM;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
rb_flags |= RING_BUFFER_WRITABLE;
rb = rb_alloc(nr_pages,
@@ -7431,7 +7433,7 @@ static int perf_mmap_aux(struct vm_area_struct *vma, struct perf_event *event,
WARN_ON(!rb && event->rb);
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
rb_flags |= RING_BUFFER_WRITABLE;
ret = rb_alloc_aux(rb, event, pgoff_start, nr_pages,
@@ -7466,7 +7468,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
if (event->cpu == -1 && event->attr.inherit)
return -EINVAL;
- if (!(vma->vm_flags & VM_SHARED))
+ if (!vma_test(vma, VMA_SHARED_BIT))
return -EINVAL;
ret = security_perf_event_read(event);
@@ -9829,7 +9831,7 @@ static int perf_event_mmap_match(struct perf_event *event,
{
struct perf_mmap_event *mmap_event = data;
struct vm_area_struct *vma = mmap_event->vma;
- int executable = vma->vm_flags & VM_EXEC;
+ bool executable = vma_test(vma, VMA_EXEC_BIT);
return (!executable && event->attr.mmap_data) ||
(executable && (event->attr.mmap || event->attr.mmap2));
@@ -9862,7 +9864,7 @@ static void perf_event_mmap_output(struct perf_event *event,
if (use_build_id)
misc |= PERF_RECORD_MISC_MMAP_BUILD_ID;
}
- if (!(mmap_event->vma->vm_flags & VM_EXEC))
+ if (!vma_test(mmap_event->vma, VMA_EXEC_BIT))
misc |= PERF_RECORD_MISC_MMAP_DATA;
perf_event_header__init(&mmap_event->event_id.header, &sample,
@@ -9913,19 +9915,19 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
char *buf = NULL;
char *name = NULL;
- if (vma->vm_flags & VM_READ)
+ if (vma_test(vma, VMA_READ_BIT))
prot |= PROT_READ;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
prot |= PROT_WRITE;
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
prot |= PROT_EXEC;
- if (vma->vm_flags & VM_MAYSHARE)
+ if (vma_test(vma, VMA_MAYSHARE_BIT))
flags = MAP_SHARED;
else
flags = MAP_PRIVATE;
- if (vma->vm_flags & VM_LOCKED)
+ if (vma_test(vma, VMA_LOCKED_BIT))
flags |= MAP_LOCKED;
if (vma_is_hugetlb(vma))
flags |= MAP_HUGETLB;
@@ -10091,7 +10093,7 @@ static void perf_addr_filters_adjust(struct vm_area_struct *vma)
* Data tracing isn't supported yet and as such there is no need
* to keep track of anything that isn't related to executable code:
*/
- if (!(vma->vm_flags & VM_EXEC))
+ if (!vma_test(vma, VMA_EXEC_BIT))
return;
rcu_read_lock();
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 13/13] security: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
` (11 preceding siblings ...)
2026-11-05 21:31 ` [PATCH 12/13] perf: " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:31 ` Lorenzo Stoakes (ARM)
2026-11-05 21:46 ` sashiko-bot
12 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-05 21:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Jason Gunthorpe, John Hubbard,
Peter Xu, Matthew Wilcox (Oracle), Jan Kara, Rik van Riel,
Liam R. Howlett, Vlastimil Babka, Harry Yoo, Jann Horn,
Lance Yang, Zi Yan, Matthew Brost, Joshua Hahn, Byungchul Park,
Gregory Price, Ying Huang, Alistair Popple, Baolin Wang,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Usama Arif,
Kiryl Shutsemau, Xu Xin, Chengming Zhou, Madhavan Srinivasan,
Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
Ritesh Harjani (IBM), Shrikanth Hegde, Pedro Falcato, Kairui Song,
Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu,
Baoquan He, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Leon Romanovsky, SJ Park, Rakie Kim, David Rientjes,
Alexander Viro, Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, linux-kernel, linux-fsdevel, linuxppc-dev, kvm, damon,
linux-trace-kernel, linux-perf-users, apparmor,
linux-security-module, linux-integrity, selinux,
Lorenzo Stoakes (ARM)
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
mmap and mprotect LSM hooks of SELinux, AppArmor, IMA and IPE.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
security/apparmor/lsm.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/ipe/hooks.c | 2 +-
security/selinux/hooks.c | 14 +++++++-------
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index c73681d820a0..00099a32b3f6 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -590,7 +590,7 @@ static int apparmor_file_mprotect(struct vm_area_struct *vma,
unsigned long reqprot, unsigned long prot)
{
return common_mmap(OP_FMPROT, vma->vm_file, prot,
- !(vma->vm_flags & VM_SHARED) ? MAP_PRIVATE : 0);
+ !vma_test(vma, VMA_SHARED_BIT) ? MAP_PRIVATE : 0);
}
#ifdef CONFIG_IO_URING
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index fed80da3ee09..92032afe4cd1 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -556,7 +556,7 @@ static int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
/* Is mprotect making an mmap'ed file executable? */
if (!(ima_policy_flag & IMA_APPRAISE) || !vma->vm_file ||
- !(prot & PROT_EXEC) || (vma->vm_flags & VM_EXEC))
+ !(prot & PROT_EXEC) || vma_test(vma, VMA_EXEC_BIT))
return 0;
security_current_getlsmprop_subj(&prop);
diff --git a/security/ipe/hooks.c b/security/ipe/hooks.c
index d878b52ceec8..247b07748b1d 100644
--- a/security/ipe/hooks.c
+++ b/security/ipe/hooks.c
@@ -112,7 +112,7 @@ int ipe_file_mprotect(struct vm_area_struct *vma,
struct ipe_eval_ctx ctx = IPE_EVAL_CTX_INIT;
/* Already Executable */
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
return 0;
if (prot & PROT_EXEC) {
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6168dd5f91c2..1bf78c2a6aba 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4206,16 +4206,16 @@ static int selinux_mmap_backing_file(struct vm_area_struct *vma,
{
unsigned long prot = 0;
- /* translate vma->vm_flags perms into PROT perms */
- if (vma->vm_flags & VM_READ)
+ /* translate VMA flag perms into PROT perms */
+ if (vma_test(vma, VMA_READ_BIT))
prot |= PROT_READ;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
prot |= PROT_WRITE;
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
prot |= PROT_EXEC;
return selinux_mmap_file_common(backing_file, prot,
- vma->vm_flags & VM_SHARED,
+ vma_test(vma, VMA_SHARED_BIT),
true);
}
@@ -4229,13 +4229,13 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
u32 av;
const struct file *file = vma->vm_file;
bool backing_file;
- bool shared = vma->vm_flags & VM_SHARED;
+ bool shared = vma_test(vma, VMA_SHARED_BIT);
/* check if we need to trigger the "backing files are awful" mode */
backing_file = file && (file->f_mode & FMODE_BACKING);
if (default_noexec &&
- (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
+ (prot & PROT_EXEC) && !vma_test(vma, VMA_EXEC_BIT)) {
/*
* We don't use the vma_is_initial_heap() helper as it has
* a history of problems and is currently broken on systems
--
2.56.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 03/13] mm/rmap: convert remaining VMA flag tests to use vma_flags_t
2026-11-05 21:30 ` [PATCH 03/13] mm/rmap: convert remaining VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:37 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:37 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace the remaining uses of the legacy vm_flags_t flags in the rmap logic
> with vma_flags_t values.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t
2026-11-05 21:30 ` [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t Lorenzo Stoakes (ARM)
@ 2026-11-05 21:38 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:38 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values
> throughout the GUP logic, both for the MMU and nommu variants.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 04/13] mm/migrate: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 ` [PATCH 04/13] mm/migrate: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:39 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:39 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
> migration logic.
>
> We retain the READ_ONCE() of vma->vm_flags in remove_migration_pte(), as
> there is no vma_flags_t equivalent, and arch_make_huge_pte() continues to
> take legacy flags for the time being.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=4
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 05/13] mm: convert THP VMA flag tests to use vma_flags_t
2026-11-05 21:30 ` [PATCH 05/13] mm: convert THP " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:40 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:40 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values where
> VMA flags are tested directly in the THP and khugepaged logic.
>
> The thp_vma_allowable_orders() family of functions, hugepage_madvise() and
> khugepaged_enter_vma() continue to take legacy flags for the time being.
>
> Also update BUG_ON()'s to VM_WARN_ON_ONCE() while here.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=5
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 06/13] mm/ksm: convert VMA flag tests to use vma_flags_t
2026-11-05 21:30 ` [PATCH 06/13] mm/ksm: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:40 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:40 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values where
> KSM tests VMA flags directly.
>
> The ksm_madvise() interface continues to take legacy flags for the time
> being.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=6
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 02/13] mm/filemap: convert fault and readahead logic to use vma_flags_t
2026-11-05 21:30 ` [PATCH 02/13] mm/filemap: convert fault and readahead logic " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:41 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:41 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM), Andrew Morton, David Hildenbrand,
Jason Gunthorpe, John Hubbard, Peter Xu, Matthew Wilcox (Oracle),
Jan Kara, Rik van Riel, Liam R. Howlett, Vlastimil Babka,
Harry Yoo, Jann Horn, Lance Yang, Zi Yan, Matthew Brost,
Joshua Hahn, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Usama Arif, Kiryl Shutsemau, Xu Xin, Chengming Zhou,
Madhavan Srinivasan, Nicholas Piggin, Michael Ellerman,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde, Pedro Falcato, Kairui Song, Qi Zheng,
Shakeel Butt, Axel Rasmussen, Yuanchu Xie, Wei Xu, Baoquan He,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Leon Romanovsky,
SJ Park, Rakie Kim, David Rientjes, Alexander Viro,
Christian Brauner, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Masami Hiramatsu, Oleg Nesterov, John Johansen,
Georgia Garcia, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
Stephen Smalley, Ondrej Mosnáček
Cc: linux-mm, kvm, damon, linux-trace-kernel, linux-perf-users,
apparmor, linux-security-module, selinux
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] mm/filemap: use-after-free on vma in do_sync_mmap_readahead()
- [Low] mm/filemap: inner vma declaration shadows outer vma in do_sync_mmap_readahead()
--
commit f5f0f8e634a6a2e2b76ad818de67e83f30cb7dea
Author: Lorenzo Stoakes (ARM) <ljs@kernel.org>
mm/filemap: convert fault and readahead logic to use vma_flags_t
This commit replaces direct checks of vm_flags_t values with vma_flags_t
helpers in the filemap fault and mmap readahead paths.
> diff --git a/mm/filemap.c b/mm/filemap.c
> index b74bc1e5015c6..d8b538bd14043 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -3351,13 +3351,14 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
> struct address_space *mapping = file->f_mapping;
> DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff);
> struct file *fpin = NULL;
> - vm_flags_t vm_flags = vmf->vma->vm_flags;
> + struct vm_area_struct *vma = vmf->vma;
> bool force_thp_readahead = false;
> unsigned int thp_order = 0;
> unsigned short mmap_miss;
[ ... ]
> @@ -3414,7 +3416,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
> * Fetch two folios so we get the chance to actually
> * readahead, unless we've been told not to.
> */
> - if (!(vm_flags & VM_RAND_READ))
> + if (!vma_test(vma, VMA_RAND_READ_BIT))
> ra->size *= 2;
> ra->async_size = folio_nr_pages;
> ra->order = thp_order;
[Severity: High]
Can this trigger a use-after-free on vma?
Previously, do_sync_mmap_readahead() cached vmf->vma->vm_flags by value in a
local variable at entry while the fault lock was held, as introduced by
commit dcfa24ba6899 ("filemap: Cache the value of vm_flags").
In the force_thp_readahead block, maybe_unlock_mmap_for_io() is called before
this check:
if (force_thp_readahead) {
unsigned long folio_nr_pages = 1UL << thp_order;
fpin = maybe_unlock_mmap_for_io(vmf, fpin);
ractl._index &= ~(folio_nr_pages - 1);
ra->size = folio_nr_pages;
/*
* Fetch two folios so we get the chance to actually
* readahead, unless we've been told not to.
*/
if (!vma_test(vma, VMA_RAND_READ_BIT))
ra->size *= 2;
Since maybe_unlock_mmap_for_io() only pins vmf->vma->vm_file and calls
release_fault_lock(vmf) to drop mmap_lock or the per-VMA lock, isn't vma
unprotected against concurrent modification or freeing when vma_test(vma,
VMA_RAND_READ_BIT) dereferences vma->flags?
> @@ -3422,7 +3424,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
> return fpin;
> }
>
> - if (vm_flags & VM_EXEC) {
> + if (vma_test(vma, VMA_EXEC_BIT)) {
> /*
> * Allow arch to request a preferred minimum folio order for
> * executable memory. This can often be beneficial to
[Severity: Low]
Does the newly added outer vma declaration in do_sync_mmap_readahead() cause
the existing inner declaration in this VMA_EXEC_BIT block to shadow it?
if (vma_test(vma, VMA_EXEC_BIT)) {
...
struct vm_area_struct *vma = vmf->vma;
const unsigned long start = vma_start_pgoff(vma);
const unsigned long end = vma_end_pgoff(vma);
Should the inner vma variable be removed now that vma is declared at function
scope?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=2
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 08/13] mm: convert miscellaneous VMA flag tests to use vma_flags_t
2026-11-05 21:30 ` [PATCH 08/13] mm: convert miscellaneous VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:43 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:43 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
> remaining straightforward VMA flag tests scattered throughout core mm, HMM
> (and its test module), DAMON and the OOM reaper.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=8
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() to use vma_flags_t
2026-11-05 21:30 ` [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:43 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:43 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values
> throughout the madvise logic.
>
> In order to do so, update ksm_madvise() and hugepage_madvise() to take a
> vma_flags_t pointer, and update their other callers in mremap and the
> powerpc KVM ultravisor code accordingly.
>
> In the latter case we replace vm_flags_reset() with vma_overwrite_flags().
> The VMA is write locked at this point, so the atomic flags preserved by
> vma_overwrite_flags() cannot differ from those copied, and the behaviour
> is unchanged.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=7
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 10/13] fs/coredump: convert vma_dump_size() to use vma_flags_t
2026-11-05 21:31 ` [PATCH 10/13] fs/coredump: convert vma_dump_size() " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:44 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:44 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values when
> determining how much of a VMA to dump.
>
> The flags copied into struct core_vma_metadata remain legacy flags as they
> are consumed by the binfmt handlers.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=10
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 11/13] uprobes: convert VMA flag tests to use vma_flags_t
2026-11-05 21:31 ` [PATCH 11/13] uprobes: convert VMA flag tests " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:44 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:44 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
> uprobes VMA validity checks.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=11
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 09/13] fs/proc/task_mmu: convert VMA flag tests to use vma_flags_t
2026-11-05 21:31 ` [PATCH 09/13] fs/proc/task_mmu: convert " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:45 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:45 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values where
> VMA flags are tested directly in /proc/$pid/[s]maps, pagemap, clear_refs
> and PROCMAP_QUERY.
>
> In replacing vm_flags_clear() (which takes the VMA write lock) with
> vma_clear_flags() (which does not) in clear_refs_write(), we explicitly
> write lock the VMA. The mmap write lock is already held at this point.
>
> The show_vma_header_prefix() and show_smap_vma_flags() output functions and
> the thp_vma_allowable_orders() call continue to use legacy flags for the
> time being.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 13/13] security: convert VMA flag tests to use vma_flags_t
2026-11-05 21:31 ` [PATCH 13/13] security: " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:46 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:46 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
> mmap and mprotect LSM hooks of SELinux, AppArmor, IMA and IPE.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=13
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 12/13] perf: convert VMA flag tests to use vma_flags_t
2026-11-05 21:31 ` [PATCH 12/13] perf: " Lorenzo Stoakes (ARM)
@ 2026-11-05 21:46 ` sashiko-bot
0 siblings, 0 replies; 27+ messages in thread
From: sashiko-bot @ 2026-11-05 21:46 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: damon, linux-perf-users, linux-security-module, selinux
> Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
> perf mmap and mmap event logic.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=12
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2026-11-05 21:46 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 21:30 [PATCH 00/13] mm: continue vma_flags_t conversion Lorenzo Stoakes (ARM)
2026-11-05 21:30 ` [PATCH 01/13] mm/gup: convert GUP code to use vma_flags_t Lorenzo Stoakes (ARM)
2026-11-05 21:38 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 02/13] mm/filemap: convert fault and readahead logic " Lorenzo Stoakes (ARM)
2026-11-05 21:41 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 03/13] mm/rmap: convert remaining VMA flag tests " Lorenzo Stoakes (ARM)
2026-11-05 21:37 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 04/13] mm/migrate: convert " Lorenzo Stoakes (ARM)
2026-11-05 21:39 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 05/13] mm: convert THP " Lorenzo Stoakes (ARM)
2026-11-05 21:40 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 06/13] mm/ksm: convert " Lorenzo Stoakes (ARM)
2026-11-05 21:40 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 07/13] mm/madvise: convert madvise_vma_behavior() " Lorenzo Stoakes (ARM)
2026-11-05 21:43 ` sashiko-bot
2026-11-05 21:30 ` [PATCH 08/13] mm: convert miscellaneous VMA flag tests " Lorenzo Stoakes (ARM)
2026-11-05 21:43 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 09/13] fs/proc/task_mmu: convert " Lorenzo Stoakes (ARM)
2026-11-05 21:45 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 10/13] fs/coredump: convert vma_dump_size() " Lorenzo Stoakes (ARM)
2026-11-05 21:44 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 11/13] uprobes: convert VMA flag tests " Lorenzo Stoakes (ARM)
2026-11-05 21:44 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 12/13] perf: " Lorenzo Stoakes (ARM)
2026-11-05 21:46 ` sashiko-bot
2026-11-05 21:31 ` [PATCH 13/13] security: " Lorenzo Stoakes (ARM)
2026-11-05 21:46 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox