[ 184.344960] BUG: KCSAN: data-race in sem_lock / sem_unlock.part.00000000000001371 <sem_unlock.part.0>:
[ 184.360437]
[ 184.375443] write to 0xffff8881022fd6c0 of 4 bytes by task 1128 on cpu 0:
[ 184.391192] sem_unlock.part.0+0xfa/0x118
[ 184.406693] do_semtimedop+0x690/0xab30000000000001bbc <sem_lock>:
[ 184.422032] __x64_sys_semop+0x3e/0x43
[ 184.437180] do_syscall_64+0x9e/0xb5
[ 184.452125] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 184.467269]
[ 184.482215] read to 0xffff8881022fd6c0 of 4 bytes by task 1129 on cpu 2:
[ 184.497750] sem_lock+0x59/0xe0
[ 184.513121] do_semtimedop+0x4f6/0xab3
[ 184.528427] __x64_sys_semop+0x3e/0x43
[ 184.543540] do_syscall_64+0x9e/0xb5
[ 184.558473] entry_SYSCALL_64_after_hwframe+0x44/0xae
/*Both sides of the if-clause handle possible data races.
* Initial check for use_global_lock. Just an optimization,
* no locking, no memory barrier.
*/
if (!sma->use_global_lock) {
/*Here I would need advise: The code only checks for zero / non-zero.
* It appears that no complex operation is around.
* Acquire the per-semaphore lock.
*/
spin_lock(&sem->lock);
/* see SEM_BARRIER_1 for purpose/pairing */
if (!smp_load_acquire(&sma->use_global_lock)) {
if (sma->use_global_lock == 1) {
/* See SEM_BARRIER_1 for purpose/pairing */
smp_store_release(&sma->use_global_lock, 0);
} else {
sma->use_global_lock--;
}