mutex.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Mutexes: blocking mutual exclusion locks
  3. *
  4. * started by Ingo Molnar:
  5. *
  6. * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
  7. *
  8. * This file contains mutex debugging related internal prototypes, for the
  9. * !CONFIG_DEBUG_MUTEXES case. Most of them are NOPs:
  10. */
  11. #define spin_lock_mutex(lock, flags) \
  12. do { spin_lock(lock); (void)(flags); } while (0)
  13. #define spin_unlock_mutex(lock, flags) \
  14. do { spin_unlock(lock); (void)(flags); } while (0)
  15. #define mutex_remove_waiter(lock, waiter, task) \
  16. __list_del((waiter)->list.prev, (waiter)->list.next)
  17. #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
  18. /*
  19. * The mutex owner can get read and written to locklessly.
  20. * We should use WRITE_ONCE when writing the owner value to
  21. * avoid store tearing, otherwise, a thread could potentially
  22. * read a partially written and incomplete owner value.
  23. */
  24. static inline void mutex_set_owner(struct mutex *lock)
  25. {
  26. WRITE_ONCE(lock->owner, current);
  27. }
  28. static inline void mutex_clear_owner(struct mutex *lock)
  29. {
  30. WRITE_ONCE(lock->owner, NULL);
  31. }
  32. #else
  33. static inline void mutex_set_owner(struct mutex *lock)
  34. {
  35. }
  36. static inline void mutex_clear_owner(struct mutex *lock)
  37. {
  38. }
  39. #endif
  40. #define debug_mutex_wake_waiter(lock, waiter) do { } while (0)
  41. #define debug_mutex_free_waiter(waiter) do { } while (0)
  42. #define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0)
  43. #define debug_mutex_unlock(lock) do { } while (0)
  44. #define debug_mutex_init(lock, name, key) do { } while (0)
  45. static inline void
  46. debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter)
  47. {
  48. }