spinlock.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _ASM_X86_SPINLOCK_H
  2. #define _ASM_X86_SPINLOCK_H
  3. #include <linux/jump_label.h>
  4. #include <linux/atomic.h>
  5. #include <asm/page.h>
  6. #include <asm/processor.h>
  7. #include <linux/compiler.h>
  8. #include <asm/paravirt.h>
  9. #include <asm/bitops.h>
  10. /*
  11. * Your basic SMP spinlocks, allowing only a single CPU anywhere
  12. *
  13. * Simple spin lock operations. There are two variants, one clears IRQ's
  14. * on the local processor, one does not.
  15. *
  16. * These are fair FIFO ticket locks, which support up to 2^16 CPUs.
  17. *
  18. * (the type definitions are in asm/spinlock_types.h)
  19. */
  20. /* How long a lock should spin before we consider blocking */
  21. #define SPIN_THRESHOLD (1 << 15)
  22. extern struct static_key paravirt_ticketlocks_enabled;
  23. static __always_inline bool static_key_false(struct static_key *key);
  24. #include <asm/qspinlock.h>
  25. /*
  26. * Read-write spinlocks, allowing multiple readers
  27. * but only one writer.
  28. *
  29. * NOTE! it is quite common to have readers in interrupts
  30. * but no interrupt writers. For those circumstances we
  31. * can "mix" irq-safe locks - any writer needs to get a
  32. * irq-safe write-lock, but readers can get non-irqsafe
  33. * read-locks.
  34. *
  35. * On x86, we implement read-write locks using the generic qrwlock with
  36. * x86 specific optimization.
  37. */
  38. #include <asm/qrwlock.h>
  39. #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
  40. #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
  41. #define arch_spin_relax(lock) cpu_relax()
  42. #define arch_read_relax(lock) cpu_relax()
  43. #define arch_write_relax(lock) cpu_relax()
  44. #endif /* _ASM_X86_SPINLOCK_H */