membarrier.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ========================
  3. membarrier() System Call
  4. ========================
  5. MEMBARRIER_CMD_{PRIVATE,GLOBAL}_EXPEDITED - Architecture requirements
  6. =====================================================================
  7. Memory barriers before updating rq->curr
  8. ----------------------------------------
  9. The commands MEMBARRIER_CMD_PRIVATE_EXPEDITED and MEMBARRIER_CMD_GLOBAL_EXPEDITED
  10. require each architecture to have a full memory barrier after coming from
  11. user-space, before updating rq->curr. This barrier is implied by the sequence
  12. rq_lock(); smp_mb__after_spinlock() in __schedule(). The barrier matches a full
  13. barrier in the proximity of the membarrier system call exit, cf.
  14. membarrier_{private,global}_expedited().
  15. Memory barriers after updating rq->curr
  16. ---------------------------------------
  17. The commands MEMBARRIER_CMD_PRIVATE_EXPEDITED and MEMBARRIER_CMD_GLOBAL_EXPEDITED
  18. require each architecture to have a full memory barrier after updating rq->curr,
  19. before returning to user-space. The schemes providing this barrier on the various
  20. architectures are as follows.
  21. - alpha, arc, arm, hexagon, mips rely on the full barrier implied by
  22. spin_unlock() in finish_lock_switch().
  23. - arm64 relies on the full barrier implied by switch_to().
  24. - powerpc, riscv, s390, sparc, x86 rely on the full barrier implied by
  25. switch_mm(), if mm is not NULL; they rely on the full barrier implied
  26. by mmdrop(), otherwise. On powerpc and riscv, switch_mm() relies on
  27. membarrier_arch_switch_mm().
  28. The barrier matches a full barrier in the proximity of the membarrier system call
  29. entry, cf. membarrier_{private,global}_expedited().