* + mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch added to mm-unstable branch
@ 2026-08-10 22:10 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-10 22:10 UTC (permalink / raw)
To: mm-commits, ljs, akpm, akpm
The patch titled
Subject: mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix
has been added to the -mm mm-unstable branch. Its filename is
mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix
Date: Mon Aug 10 03:07:02 PM PDT 2026
add comments, per Lorenzo
Link: https://lore.kernel.org/ann-vS6MYT9kuXqu@lucifer
Cc: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/mm.h | 57 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
--- a/include/linux/mm.h~mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix
+++ a/include/linux/mm.h
@@ -2271,17 +2271,74 @@ void unpin_user_pages(struct page **page
void unpin_user_folio(struct folio *folio, unsigned long npages);
void unpin_folios(struct folio **folios, unsigned long nfolios);
+/**
+ * vma_flags_is_cow_mapping() - Do these VMA flags imply a CoW mapping?
+ * @flags: The VMA flags to check.
+ *
+ * Mappings which could be CoW'd (subject to Copy-On-Write faults) are
+ * described as CoW mappings.
+ *
+ * All mappings backed by anonymous folios (all anonymous mappings and most
+ * MAP_PRIVATE-file backed ranges) are CoW mappings.
+ *
+ * All other mappings (including all writable MAP_SHARED mappings) are
+ * non-CoW.
+ *
+ * The criteria are !VMA_SHARED_BIT, VMA_MAYWRITE_BIT.
+ *
+ * VMA_MAYWRITE_BIT is checked instead of VMA_WRITE_BIT to account for both
+ * future mprotect() calls which can render a read-only mapping writable, and
+ * GUP with FOLL_FORCE (e.g. ptrace) which can CoW a read-only mapping.
+ *
+ * - No anonymous mapping can ever clear VMA_MAYWRITE_BIT.
+ *
+ * - Writes to anonymous mappings do not immediately result in CoW faults but
+ * may do so after the process is forked or if a read is followed by a
+ * write.
+ *
+ * - Writes to MAP_PRIVATE file-backed mappings result in CoW faults and may
+ * do so again after fork.
+ *
+ * - MAP_SHARED mappings of a file opened read-only are transformed into
+ * VMA_MAYSHARE_BIT, !VMA_SHARED_BIT, !VMA_MAYWRITE_BIT mappings, so remain
+ * non-CoW.
+ *
+ * - Drivers may clear VMA_MAYWRITE_BIT but do so at mmap() time and cannot
+ * mark themselves anonymous. Having cleared this flag it is not valid for
+ * them to leave the VMA_WRITE_BIT flag set.
+ *
+ * As a consequence, the anonymous reverse mapping only tracks CoW mappings.
+ *
+ * Returns: true if the flags indicate a CoW mapping, otherwise false.
+ */
static inline bool vma_flags_is_cow_mapping(const vma_flags_t *flags)
{
return vma_flags_test(flags, VMA_MAYWRITE_BIT) &&
!vma_flags_test(flags, VMA_SHARED_BIT);
}
+/**
+ * vma_is_cow_mapping() - Is this VMA a CoW mapping?
+ * @desc: The VMA to check.
+ *
+ * See vma_flags_is_cow_mapping() for details.
+ *
+ * Returns: true if the VMA is a CoW mapping, otherwise false.
+ */
static inline bool vma_is_cow_mapping(const struct vm_area_struct *vma)
{
return vma_flags_is_cow_mapping(&vma->flags);
}
+/**
+ * vma_desc_is_cow_mapping() - Is this VMA descriptor a CoW mapping?
+ * @desc: The VMA descriptor to check.
+ *
+ * See vma_flags_is_cow_mapping() for details.
+ *
+ * Returns: true if the VMA descriptor describes a CoW mapping, otherwise
+ * false.
+ */
static inline bool vma_desc_is_cow_mapping(struct vm_area_desc *desc)
{
return vma_flags_is_cow_mapping(&desc->vma_flags);
_
Patches currently in -mm which might be from akpm@linux-foundation.org are
mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch
mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write-fix.patch
selftests-mm-use-pattern-matching-in-gitignore-fix.patch
selftests-mm-fix-soft-dirty-kselftest-supported-check-fix.patch
alloc_tag-add-ioctl-to-proc-allocinfo-fix.patch
mm-hmmc-hmm_do_fault-suppress-sparse-warning.patch
drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-10 22:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 22:10 + mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch added to mm-unstable branch Andrew Morton
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.