From: Harry Yoo <harry.yoo@oracle.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dave Chinner <david@fromorbit.com>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
"Tobin C. Harding" <tobin@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@suse.cz>, Rik van Riel <riel@surriel.com>,
Andrea Arcangeli <aarcange@redhat.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Michal Hocko <mhocko@kernel.org>,
Byungchul Park <byungchul@sk.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: Re: [DISCUSSION] Revisiting Slab Movable Objects
Date: Wed, 23 Apr 2025 16:20:20 +0900 [thread overview]
Message-ID: <aAiUtCKJOdWjYxDZ@harry> (raw)
In-Reply-To: <20250423014732.GC2023217@ZenIV>
On Wed, Apr 23, 2025 at 02:47:32AM +0100, Al Viro wrote:
> On Tue, Apr 22, 2025 at 07:54:08AM +1000, Dave Chinner wrote:
>
> > I don't have a solution for the dentry cache reference issues - the
> > dentry cache maintains the working set of files, so anything that
> > randomly shoots down unused dentries for compaction is likely to
> > have negative performance implications for dentry cache intensive
> > workloads.
>
> Just to restate the obvious: _relocation_ of dentries is hopeless for
> many, many reasons - starting with "hash of dentry depends upon
> the address of its parent dentry".
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.
> Freeing anything with zero refcount...
> sure, no problem - assuming that you are holding rcu_read_lock(),
> if (READ_ONCE(dentry->d_count) == 0) {
> spin_lock(&dentry->d_lock);
> if (dentry->d_count == 0)
> to_shrink_list(dentry, list);
> spin_unlock(&dentry->d_lock);
> }
> followed by rcu_read_unlock() and shrink_dentry_list(&list) once you
> are done collecting the candidates. If you want to wait for them to
> actually freed, synchronize_rcu() after rcu_read_unlock() (freeing is
> RCU-delayed).
>
> Performance implications are separate story - it really depends upon
> a lot of details. But simple "I want all unused dentries in this
> page kicked out" is doable. And in-use dentries are no-go, no matter
> what.
Thank you for the detailed guidance and confirming that it's doable!
It will be very helpful when implementing this.
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2025-04-23 7:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 13:47 Harry Yoo
2025-04-21 16:33 ` Pedro Falcato
2025-04-22 23:17 ` Harry Yoo
2025-04-23 5:53 ` Christoph Lameter (Ampere)
2025-04-21 21:54 ` Dave Chinner
2025-04-23 1:47 ` Al Viro
2025-04-23 7:20 ` Harry Yoo [this message]
2025-04-23 7:40 ` Al Viro
2025-04-25 11:09 ` Harry Yoo
2025-04-28 15:31 ` Jann Horn
2025-04-30 13:11 ` Harry Yoo
2025-04-30 22:23 ` Jann Horn
2025-05-05 23:29 ` Dave Chinner
2025-04-21 21:59 ` Tobin C. Harding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aAiUtCKJOdWjYxDZ@harry \
--to=harry.yoo@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=byungchul@sk.com \
--cc=cl@linux.com \
--cc=david@fromorbit.com \
--cc=david@redhat.com \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@kernel.org \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=riel@surriel.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=tobin@kernel.org \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox