* David Howells <dhowells@xxxxxxxxxx> wrote: > Andrew Morton <akpm@xxxxxxxx> wrote: > > > How can we get away without a barrier? > > Is this what you're thinking of: > > struct dentry * d_find_alias(struct inode *inode) > { > struct dentry *de = NULL; > > smp_rmb(); > if (!list_empty(&inode->i_dentry)) { > spin_lock(&dcache_lock); no barrier is needed i think. This code just picks an alias, with no guarantee of any ordering wrt. add/removal ops from the alias list. In other words, d_find_alias() depends on external serialization - when used standalone it is fundamentally nondeterministic anyway. it is true that the list_empty() might observe an intermediate state of the list [e.g. backlink not modified yet but forward link modified - or the other way around], but that's not a problem: it either returns true or false, both of which are correct results when the modification is underway in parallel on another CPU. When d_find_alias() returns non-NULL it will only do it by taking dcache_lock, so the correct use of the list is always guaranteed. [ a barrier would have no useful effect here anyway - it only guarantees instruction ordering locally, and has no deterministic effect on the order of memory values being written from another CPU. A barrier makes sense when ordering of writes to two different memory values is deterministic - e.g. a flag and a resource pointer. But in the case of list_empty(), the order of modifications to the two pointers in the list is not guaranteed. ] Ingo