[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250210051553.GY1977892@ZenIV>
Date: Mon, 10 Feb 2025 05:15:53 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: NeilBrown <neilb@...e.de>
Cc: Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jeff Layton <jlayton@...nel.org>,
Dave Chinner <david@...morbit.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 02/19] VFS: use global wait-queue table for
d_alloc_parallel()
On Mon, Feb 10, 2025 at 03:58:02PM +1100, NeilBrown wrote:
> 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?
((unsigned long) dentry / L1_CACHE_BYTES) % <table size>
Bits just over the cacheline size should have uniform distribution...
> > 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.
It's not just about the wakeups; any in-lookup dentry should be taken
out of in-lookup hash before it gets dropped.
> > 3) the dance with conditional __wake_up() is worth a helper, IMO.
I mean an inlined helper function.
Powered by blists - more mailing lists