[PATCH 11/20] mm/vma: introduce [vma_flags,legacy]_to_[legacy,vma_flags]() helpers
Lorenzo Stoakes (Oracle)
ljs at kernel.org
Fri Mar 13 06:16:09 AEDT 2026
While we are still converting VMA flags from vma_flags_t to vm_flags_t,
introduce helpers to convert between the two to allow for iterative
development without having to 'change the world' in a single commit'.
Also update VMA flags tests to reflect the change.
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs at kernel.org>
---
include/linux/mm_types.h | 26 ++++++++++++++++++++++++++
tools/testing/vma/include/dup.h | 26 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index ea76821c01e3..63a25f97cd1c 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1069,6 +1069,32 @@ static __always_inline void vma_flags_clear_all(vma_flags_t *flags)
bitmap_zero(flags->__vma_flags, NUM_VMA_FLAG_BITS);
}
+/*
+ * Helper function which converts a vma_flags_t value to a legacy vm_flags_t
+ * value. This is only valid if the input flags value can be expressed in a
+ * system word.
+ *
+ * Will be removed once the conversion to VMA flags is complete.
+ */
+static __always_inline vm_flags_t vma_flags_to_legacy(vma_flags_t flags)
+{
+ return (vm_flags_t)flags.__vma_flags[0];
+}
+
+/*
+ * Helper function which converts a legacy vm_flags_t value to a vma_flags_t
+ * value.
+ *
+ * Will be removed once the conversion to VMA flags is complete.
+ */
+static __always_inline vma_flags_t legacy_to_vma_flags(vm_flags_t flags)
+{
+ vma_flags_t ret;
+
+ ret.__vma_flags[0] = (unsigned long)flags;
+ return ret;
+}
+
/*
* Copy value to the first system word of VMA flags, non-atomically.
*
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index fa2df96f9dee..c27fcfb50d8d 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -800,6 +800,32 @@ static __always_inline void vma_flags_clear_all(vma_flags_t *flags)
bitmap_zero(ACCESS_PRIVATE(flags, __vma_flags), NUM_VMA_FLAG_BITS);
}
+/*
+ * Helper function which converts a vma_flags_t value to a legacy vm_flags_t
+ * value. This is only valid if the input flags value can be expressed in a
+ * system word.
+ *
+ * Will be removed once the conversion to VMA flags is complete.
+ */
+static __always_inline vm_flags_t vma_flags_to_legacy(vma_flags_t flags)
+{
+ return (vm_flags_t)flags.__vma_flags[0];
+}
+
+/*
+ * Helper function which converts a legacy vm_flags_t value to a vma_flags_t
+ * value.
+ *
+ * Will be removed once the conversion to VMA flags is complete.
+ */
+static __always_inline vma_flags_t legacy_to_vma_flags(vm_flags_t flags)
+{
+ vma_flags_t ret;
+
+ ret.__vma_flags[0] = (unsigned long)flags;
+ return ret;
+}
+
static __always_inline void vma_flags_set_flag(vma_flags_t *flags,
vma_flag_t bit)
{
--
2.53.0
More information about the Linuxppc-dev
mailing list