atomic_bitops.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. =============
  2. Atomic bitops
  3. =============
  4. While our bitmap_{}() functions are non-atomic, we have a number of operations
  5. operating on single bits in a bitmap that are atomic.
  6. API
  7. ---
  8. The single bit operations are:
  9. Non-RMW ops:
  10. test_bit()
  11. RMW atomic operations without return value:
  12. {set,clear,change}_bit()
  13. clear_bit_unlock()
  14. RMW atomic operations with return value:
  15. test_and_{set,clear,change}_bit()
  16. test_and_set_bit_lock()
  17. Barriers:
  18. smp_mb__{before,after}_atomic()
  19. All RMW atomic operations have a '__' prefixed variant which is non-atomic.
  20. SEMANTICS
  21. ---------
  22. Non-atomic ops:
  23. In particular __clear_bit_unlock() suffers the same issue as atomic_set(),
  24. which is why the generic version maps to clear_bit_unlock(), see atomic_t.txt.
  25. RMW ops:
  26. The test_and_{}_bit() operations return the original value of the bit.
  27. ORDERING
  28. --------
  29. Like with atomic_t, the rule of thumb is:
  30. - non-RMW operations are unordered;
  31. - RMW operations that have no return value are unordered;
  32. - RMW operations that have a return value are fully ordered.
  33. - RMW operations that are conditional are fully ordered.
  34. Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics,
  35. clear_bit_unlock() which has RELEASE semantics and test_bit_acquire which has
  36. ACQUIRE semantics.
  37. Since a platform only has a single means of achieving atomic operations
  38. the same barriers as for atomic_t are used, see atomic_t.txt.