vma_init_lock(vma);
}
+/* Use when VMA is not part of the VMA tree and needs no locking */
+static inline
+void init_vm_flags(struct vm_area_struct *vma, unsigned long flags)
+{
+ WRITE_ONCE(vma->vm_flags, flags);
+}
+
+/* Use when VMA is part of the VMA tree and needs appropriate locking */
+static inline
+void reset_vm_flags(struct vm_area_struct *vma, unsigned long flags)
+{
+ vma_write_lock(vma);
+ init_vm_flags(vma, flags);
+}
+
+static inline
+void set_vm_flags(struct vm_area_struct *vma, unsigned long flags)
+{
+ vma_write_lock(vma);
+ vma->vm_flags |= flags;
+}
+
+static inline
+void clear_vm_flags(struct vm_area_struct *vma, unsigned long flags)
+{
+ vma_write_lock(vma);
+ vma->vm_flags &= ~flags;
+}
+
+static inline
+void mod_vm_flags(struct vm_area_struct *vma,
+ unsigned long set, unsigned long clear)
+{
+ vma_write_lock(vma);
+ vma->vm_flags |= set;
+ vma->vm_flags &= ~clear;
+}
+
static inline void vma_set_anonymous(struct vm_area_struct *vma)
{
vma->vm_ops = NULL;
#endif
};
- unsigned long vm_flags; /* Flags, see mm.h. */
+ /*
+ * Flags, see mm.h.
+ * WARNING! Do not modify directly to keep correct VMA locking.
+ * Use {init|reset|set|clear|mod}_vm_flags() functions instead.
+ */
+ unsigned long vm_flags;
struct anon_vma *anon_vma; /* Serialized by page_table_lock */