On Tue, Aug 06, 2024 at 10:41:59AM +0200, Christian Brauner wrote: > > Would rcu_assign_pointer of pointers + smp_store_release of max_fds on expand > > (all under ->files_lock, etc.) paired with > > smp_load_acquire of max_fds + rcu_dereference of ->fd on file lookup side > > be enough, or do we need an explicit smp_wmb/smp_rmb in there? > > Afair, smp_load_acquire() would be a barrier for both later loads and > stores and smp_store_release() would be a barrier for both earlier loads > and stores. > > Iiuc, here we only care about ordering stores to ->fd and max_fds on the > write side and about ordering loads of max_fds and ->fd on the reader > side. The reader doesn't actually write anything. > > In other words, we want to make ->fd visible before max_fds on the write > side and we want to load max_fds after ->fd. > > So I think smp_wmb() and smp_rmb() would be sufficient. I also find it > clearer in this case. It's not the question of sufficiency; it's whether anything cheaper can be had.