Re: [PATCH] 9p/client: fix data race on req->status

From: Dominique Martinet
Date: Mon Dec 05 2022 - 17:28:24 EST


Christian Schoenebeck wrote on Mon, Dec 05, 2022 at 04:19:01PM +0100:
> I must have missed the prior discussion, but looking at the suggested

Good point, I'll add a link to the report as well...
It's this thread:
https://lkml.kernel.org/r/CA+G9fYsK5WUxs6p9NaE4e3p7ew_+s0SdW0+FnBgiLWdYYOvoMg@xxxxxxxxxxxxxx

> solution: if there is no lock, then adding READ_ONCE() and WRITE_ONCE() would
> not fix cross-CPU issues, as those would not have a memory barrier in that
> case.
>
> Shouldn't that therefore rather be at least smp_load_acquire() and
> smp_store_release() at such places instead?

The barrier is here -- I think we're just protecting against compiler
reordering or if on some arch the store isn't actually atomic.

This code path actually was broken before I added the barrier a while
ago (2b6e72ed747f68a03), as I was observing some rare but very real
errors on a big server so I'm fairly confident that for at least x86_64
the generated code isn't too bad, but if KCSAN helps catching stuff I
won't complain.

--
Dominique