[PATCH 16/20] mm/vma: introduce vma_clear_flags[_mask]()
Lorenzo Stoakes (Oracle)
ljs at kernel.org
Fri Mar 13 06:16:14 AEDT 2026
Introduce a helper function and helper macro to easily clear a VMA's flags
using the new vma_flags_t vma->flags field:
* vma_clear_flags_mask() - Clears all of the flags in a specified mask in
the VMA's flags field.
* vma_clear_flags() - Clears all of the specified individual VMA flag bits
in a VMA's flags field.
Also update the VMA tests to reflect the change.
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs at kernel.org>
---
include/linux/mm.h | 16 ++++++++++++++++
tools/testing/vma/include/dup.h | 9 +++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4b574d941ea3..bec1b43efa50 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1324,6 +1324,22 @@ static __always_inline void vma_set_flags_mask(struct vm_area_struct *vma,
#define vma_set_flags(vma, ...) \
vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__))
+/* Helper to clear all VMA flags in a VMA. */
+static __always_inline void vma_clear_flags_mask(struct vm_area_struct *vma,
+ vma_flags_t flags)
+{
+ vma_flags_clear_mask(&vma->flags, flags);
+}
+
+/*
+ * Helper macro for clearing VMA flags, e.g.:
+ *
+ * vma_clear_flags(vma, VMA_IO_BIT, VMA_PFNMAP_BIT, VMA_DONTEXPAND_BIT,
+ * VMA_DONTDUMP_BIT);
+ */
+#define vma_clear_flags(vma, ...) \
+ vma_clear_flags_mask(vma, mk_vma_flags(__VA_ARGS__))
+
/*
* Test whether a specific VMA flag is set in a VMA descriptor, e.g.:
*
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index 70cabacdb9cc..81bd34c62c75 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -1039,6 +1039,15 @@ static __always_inline void vma_set_flags_mask(struct vm_area_struct *vma,
#define vma_set_flags(vma, ...) \
vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__))
+static __always_inline void vma_clear_flags_mask(struct vm_area_struct *vma,
+ vma_flags_t flags)
+{
+ vma_flags_clear_mask(&vma->flags, flags);
+}
+
+#define vma_clear_flags(vmag, ...) \
+ vma_clear_flags_mask(vmag, mk_vma_flags(__VA_ARGS__))
+
static __always_inline bool vma_desc_test(const struct vm_area_desc *desc,
vma_flag_t bit)
{
--
2.53.0
More information about the Linuxppc-dev
mailing list