On Thu, Dec 05, 2024 at 11:26:35AM -0800, Linus Torvalds wrote: > On Thu, 5 Dec 2024 at 10:41, Paul E. McKenney <paulmck@xxxxxxxxxx> wrote: > > > > > To my understanding this is the idiomatic way of spelling out the > > > non-existent in Linux smp_consume_load, for the resize_in_progress > > > flag. > > > > In Linus, "smp_consume_load()" is named rcu_dereference(). > > Linux. One of those days... ;-) > But yes and no. > > It's worth making it really really clear that "rcu_dereference()" is > *not* just a different name for some "smp_consume_load()" operation. > > Why? Because a true smp_consume_load() would work with any random kind > of flags etc. And rcu_dereference() works only because it's a pointer, > and there's an inherent data dependency to what the result points to. > > Paul obviously knows this, but let's make it very clear in this > discussion, because if somebody decided "I want a smp_consume_load(), > and I'll use rcu_dereference() to do that", the end result would > simply not work for arbitrary data, like a flags field or something, > where comparing it against a value will only result in a control > dependency, not an actual data dependency. Fair points! And Linus (and Linux, for that matter) equally obviously already knows this, but please note also that an smp_load_consume() would still order only later dereferences of the thing returned from smp_load_consume(), which means that it pretty much needs to be a pointer. (Yes, in theory, it could be an array index, but in practice compilers know way too much about integer arithmetic for this to be advisable.) Thanx, Paul