0001 =============
0002 Atomic bitops
0003 =============
0004
0005 While our bitmap_{}() functions are non-atomic, we have a number of operations
0006 operating on single bits in a bitmap that are atomic.
0007
0008
0009 API
0010 ---
0011
0012 The single bit operations are:
0013
0014 Non-RMW ops:
0015
0016 test_bit()
0017
0018 RMW atomic operations without return value:
0019
0020 {set,clear,change}_bit()
0021 clear_bit_unlock()
0022
0023 RMW atomic operations with return value:
0024
0025 test_and_{set,clear,change}_bit()
0026 test_and_set_bit_lock()
0027
0028 Barriers:
0029
0030 smp_mb__{before,after}_atomic()
0031
0032
0033 All RMW atomic operations have a '__' prefixed variant which is non-atomic.
0034
0035
0036 SEMANTICS
0037 ---------
0038
0039 Non-atomic ops:
0040
0041 In particular __clear_bit_unlock() suffers the same issue as atomic_set(),
0042 which is why the generic version maps to clear_bit_unlock(), see atomic_t.txt.
0043
0044
0045 RMW ops:
0046
0047 The test_and_{}_bit() operations return the original value of the bit.
0048
0049
0050 ORDERING
0051 --------
0052
0053 Like with atomic_t, the rule of thumb is:
0054
0055 - non-RMW operations are unordered;
0056
0057 - RMW operations that have no return value are unordered;
0058
0059 - RMW operations that have a return value are fully ordered.
0060
0061 - RMW operations that are conditional are fully ordered.
0062
0063 Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics,
0064 clear_bit_unlock() which has RELEASE semantics and test_bit_acquire which has
0065 ACQUIRE semantics.
0066
0067 Since a platform only has a single means of achieving atomic operations
0068 the same barriers as for atomic_t are used, see atomic_t.txt.
0069