Hi Paul, On 5/12/21 10:17 PM, Paul E. McKenney wrote: > On Wed, May 12, 2021 at 09:58:18PM +0200, Manfred Spraul wrote: >> [...] >> sma->use_global_lock is evaluated in sem_lock() twice: >> >>>        /* >>>          * Initial check for use_global_lock. Just an optimization, >>>          * no locking, no memory barrier. >>>          */ >>>         if (!sma->use_global_lock) { >> Both sides of the if-clause handle possible data races. >> >> Is >> >>     if (!data_race(sma->use_global_lock)) { >> >> the correct thing to suppress the warning? > Most likely READ_ONCE() rather than data_race(), but please see > the end of this message. Based on the document, I would say data_race() is sufficient: I have replaced the code with "if (jiffies %2)", and it runs fine. Thus I don't see which evil things a compiler could do, ... . [...] Does tools/memory-model/Documentation/access-marking.txt, shown below, > help? > [...] > int foo; > DEFINE_RWLOCK(foo_rwlock); > > void update_foo(int newval) > { > write_lock(&foo_rwlock); > foo = newval; > do_something(newval); > write_unlock(&foo_rwlock); > } > > int read_foo(void) > { > int ret; > > read_lock(&foo_rwlock); > do_something_else(); > ret = foo; > read_unlock(&foo_rwlock); > return ret; > } > > int read_foo_diagnostic(void) > { > return data_race(foo); > } The text didn't help, the example has helped: It was not clear to me if I have to use data_race() both on the read and the write side, or only on one side. Based on this example: plain C may be paired with data_race(), there is no need to mark both sides. Attached is a dummy change to ipc/sem.c, where I have added comments to every access. If data_race() is sufficient, then I think I have understood the rules, and I would recheck ipc/*.c and the netfilter code. --     Manfred