On Sun, Jul 31, 2022 at 1:39 PM Mikulas Patocka <mpatocka@xxxxxxxxxx> wrote: > > Do you think that wait_event also needs a read memory barrier? Not really, no. __wait_event() uses prepare_to_wait(), and it uses set_current_state() very much so that the process state setting is serialized with the test afterwards. And the only race wait_event should worry about is exactly the "go to sleep" vs "make the event true and then wake up" race, so that it doesn't wait forever. There is no guarantee of memory ordering wrt anything else, and I don't think there is any need for such a guarantee. If somebody wants that guarantee, they should probably make the condition for wait_event() to be a "load_acquire()" or similar. Those cases do exist. Linus