Merge tag 'x86_mm_for_6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
[linux-block.git] / include / linux / sched / mm.h
index b69fe7e8c0ac8e6e91dd1cc25979ffb27081fc42..af12fcb110057e499e6801c69659bd0f5f2b1485 100644 (file)
@@ -79,6 +79,34 @@ static inline void mmdrop_sched(struct mm_struct *mm)
 }
 #endif
 
+/* Helpers for lazy TLB mm refcounting */
+static inline void mmgrab_lazy_tlb(struct mm_struct *mm)
+{
+       if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT))
+               mmgrab(mm);
+}
+
+static inline void mmdrop_lazy_tlb(struct mm_struct *mm)
+{
+       if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT)) {
+               mmdrop(mm);
+       } else {
+               /*
+                * mmdrop_lazy_tlb must provide a full memory barrier, see the
+                * membarrier comment finish_task_switch which relies on this.
+                */
+               smp_mb();
+       }
+}
+
+static inline void mmdrop_lazy_tlb_sched(struct mm_struct *mm)
+{
+       if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT))
+               mmdrop_sched(mm);
+       else
+               smp_mb(); /* see mmdrop_lazy_tlb() above */
+}
+
 /**
  * mmget() - Pin the address space associated with a &struct mm_struct.
  * @mm: The address space to pin.