barrier.h 620 B

123456789101112131415161718192021222324252627
  1. #ifndef _ASM_X86_BARRIER_H_
  2. #define _ASM_X86_BARRIER_H_
  3. /*
  4. * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com>
  5. *
  6. * This work is licensed under the terms of the GNU LGPL, version 2.
  7. */
  8. #define mb() asm volatile("mfence":::"memory")
  9. #define rmb() asm volatile("lfence":::"memory")
  10. #define wmb() asm volatile("sfence":::"memory")
  11. #define smp_rmb() barrier()
  12. #define smp_wmb() barrier()
  13. /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
  14. static inline void rep_nop(void)
  15. {
  16. asm volatile("rep; nop" ::: "memory");
  17. }
  18. static inline void cpu_relax(void)
  19. {
  20. rep_nop();
  21. }
  22. #endif