From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org, ljs@kernel.org, akpm@linux-foundation.org
Cc: David Hildenbrand <david@kernel.org>
Subject: [to-be-updated] mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t.patch removed from -mm tree
Date: Mon, 09 Nov 2026 09:46:01 -0800 [thread overview]
Message-ID: <20261109174602.01E801F0089F@smtp.kernel.org> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 15218 bytes --]
The quilt patch titled
Subject: mm/madvise: convert madvise_vma_behavior() to use vma_flags_t
has been removed from the -mm tree. Its filename was
mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: mm/madvise: convert madvise_vma_behavior() to use vma_flags_t
Date: Thu, 05 Nov 2026 21:30:58 +0000
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.
Link: https://lore.kernel.org/20261105-late-2026-vma-flags-v1-7-0d3cd15ab75f@kernel.org
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Xu Xin <xu.xin@linux.dev>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <chleroy@kernel.org>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Kairui Song <kasong@tencent.com>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: SJ Park <sj@kernel.org>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: John Johansen <john.johansen@canonical.com>
Cc: Georgia Garcia <georgia.garcia@canonical.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: James Morris <jmorris@namei.org>
Cc: Serge E. Hallyn <serge@hallyn.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: Eric Snowberg <eric.snowberg@oracle.com>
Cc: Fan Wu <wufan@kernel.org>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: Ondrej Mosnáček <omosnacek@gmail.com>
---
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(-)
--- a/arch/powerpc/kvm/book3s_hv_uvmem.c~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/arch/powerpc/kvm/book3s_hv_uvmem.c
@@ -393,7 +393,7 @@ static int kvmppc_memslot_page_merge(str
{
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(str
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);
--- a/include/linux/huge_mm.h~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/include/linux/huge_mm.h
@@ -507,7 +507,7 @@ change_huge_pud(struct mmu_gather *tlb,
__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);
@@ -709,7 +709,7 @@ static inline bool unmap_huge_pmd_locked
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;
}
--- a/include/linux/ksm.h~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/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(con
#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;
}
--- a/mm/khugepaged.c~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/mm/khugepaged.c
@@ -363,16 +363,16 @@ static unsigned int collapse_max_ptes_sw
}
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
--- a/mm/ksm.c~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/mm/ksm.c
@@ -781,7 +781,8 @@ static struct vm_area_struct *find_merge
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;
}
@@ -3023,7 +3024,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;
@@ -3041,11 +3042,11 @@ int ksm_madvise(struct vm_area_struct *v
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)) {
@@ -3054,7 +3055,7 @@ int ksm_madvise(struct vm_area_struct *v
return err;
}
- *vm_flags &= ~VM_MERGEABLE;
+ vma_flags_clear(vma_flags, VMA_MERGEABLE_BIT);
break;
}
--- a/mm/madvise.c~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/mm/madvise.c
@@ -148,11 +148,10 @@ static int replace_anon_vma_name(struct
* 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(stru
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 madvi
* 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();
@@ -890,12 +890,12 @@ bool madvise_dontneed_free_valid_vma(str
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)
@@ -1030,7 +1030,7 @@ static long madvise_remove(struct madvis
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;
@@ -1342,7 +1342,7 @@ static bool can_madvise_modify(struct ma
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;
@@ -1366,7 +1366,7 @@ static int madvise_vma_behavior(struct m
{
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;
@@ -1397,44 +1397,47 @@ static int madvise_vma_behavior(struct m
/* 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:
--- a/mm/mremap.c~mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t
+++ a/mm/mremap.c
@@ -1118,7 +1118,7 @@ static unsigned long prep_move_vma(struc
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;
_
Patches currently in -mm which might be from ljs@kernel.org are
mm-vma-read-anon_vma-carefully-in-validate_mm.patch
mm-convert-miscellaneous-vma-flag-tests-to-use-vma_flags_t.patch
fs-proc-task_mmu-convert-vma-flag-tests-to-use-vma_flags_t.patch
fs-coredump-convert-vma_dump_size-to-use-vma_flags_t.patch
uprobes-convert-vma-flag-tests-to-use-vma_flags_t.patch
perf-convert-vma-flag-tests-to-use-vma_flags_t.patch
security-convert-vma-flag-tests-to-use-vma_flags_t.patch
reply other threads:[~2026-11-09 17:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109174602.01E801F0089F@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=ljs@kernel.org \
--cc=mm-commits@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.