On Wed, Apr 23, 2025 at 04:20:20PM +0900, Harry Yoo wrote: > If we can't migrate or reclaim dentries with a nonzero refcount, > can we at least prevent slab pages from containing a mix of dentries > with zero and nonzero refcounts? > > An idea: "Migrate a dentry (and inode?) _before_ it becomes unrelocatable" > This is somewhat similar to "Migrate a page out of the movable area before > pinning it" in MM. > > For example, suppose we have two slab caches for dentry: > dentry_cache_unref and dentry_cache_ref. > > When a dentry with a zero refcount is about to have its refcount > incremented, the VFS allocates a new object from dentry_cache_ref, copies > the dentry into it, frees the original dentry back to > dentry_cache_unref, and returns the newly allocated object. > > Similarly when a dentry with a nonzero refcount drops to zero, > it is migrated to dentry_cache_unref. This should be handled on the VFS > side rather than by the slab allocator. > > This approach could, at least, help reduce fragmentation. No. This is utterly insane - you'd need to insert RCU delay on each of those transitions and that is not to mention the frequency with which those will happen on a lot of loads (any kind of builds included). Not a chance.