* [folded-merged] mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch removed from -mm tree
@ 2026-08-12 3:22 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-12 3:22 UTC (permalink / raw)
To: mm-commits, ljs, akpm, akpm
The quilt patch titled
Subject: mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix
has been removed from the -mm tree. Its filename was
mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch
This patch was dropped because it was folded into mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping.patch
------------------------------------------------------
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.patch
mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix-fix.patch
tools-testing-selftests-mm-test-anonymous-page-offset-merge-behaviour-fix.patch
mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write-fix.patch
selftests-mm-use-pattern-matching-in-gitignore-fix.patch
alloc_tag-add-ioctl-to-proc-allocinfo-fix.patch
selftests-mm-fix-soft-dirty-kselftest-supported-check-fix.patch
mm-hmmc-hmm_do_fault-suppress-sparse-warning.patch
mm-hmmc-hmm_do_fault-suppress-sparse-warning-fix.patch
lib-kconfigdebug-make-debug_force_weak_per_cpu-depend-on-s390alpha.patch
selftests-cgroup-test_zswap-skip-test_no_kmem_bypass-if-debugfs-is-unavailable-fix.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-12 3:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 3:22 [folded-merged] mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping-fix.patch removed from -mm tree 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.