On Sat, 08 Feb 2025, Al Viro wrote: > 1) what's wrong with using middle bits of dentry as index? What the hell > is that thing about pid for? That does "hell" have to do with it? All we need here is a random number. Preferably a cheap random number. pid is cheap and quite random. The dentry pointer would be even cheaper (no mem access) providing it doesn't cost much to get the randomness out. I considered hash_ptr() but thought that was more code that it was worth. Do you have a formula for selecting the "middle" bits in a way that is expected to still give good randomness? > > 2) part in d_add_ci() might be worth a comment re d_lookup_done() coming > for the original dentry, no matter what. I think the previous code deserved explanation more than the new, but maybe I missed something. In each case, d_wait_lookup() will wait for the given dentry to no longer be d_in_lookup() which means waiting for DCACHE_PAR_LOOKUP to be cleared. The only place which clears DCACHE_PAR_LOOKUP is __d_lookup_unhash_wake(). which always wakes the target. In the previous code it would wake both the non-case-exact dentry and the case-exact dentry waiters but they would go back to sleep if their DCACHE_PAR_LOOKUP hadn't been cleared, so no interesting behaviour. Reusing the wq from one to the other is a sensible simplification, but not something we need any reminder of once it is no longer needed. Would sort of comment would you add? > > 3) the dance with conditional __wake_up() is worth a helper, IMO. > I tried to explain that in the commit message bug I agree it deserves to be in the code too. I have added: /* ->d_wait is only set if some thread is actually waiting. * If we find it is NULL - the common case - then there was no * contention and there are no waiters to be woken. */ and /* Don't set a wait_queue until someone is actually waiting */ before new->d_wait = NULL; in d_alloc_parallel(). Thanks, NeilBrown