From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Dave Chinner <david@fromorbit.com>, Hillf Danton <hdanton@sina.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>,
MM <linux-mm@kvack.org>, Matthew Wilcox <willy@infradead.org>,
Mel Gorman <mgorman@techsingularity.net>,
Yu Zhao <yuzhao@google.com>, David Hildenbrand <david@redhat.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] mm/vmscan: add periodic slab shrinker
Date: Tue, 05 Apr 2022 10:22:14 -0700 [thread overview]
Message-ID: <87ilrn5ttl.fsf@stepbren-lnx.us.oracle.com> (raw)
In-Reply-To: <20220404010948.GV1609613@dread.disaster.area>
Dave Chinner <david@fromorbit.com> writes:
[snip]
> If the cache keeps growing, then it's objects are being repeatedly
> referenced and it *should* keep growing. If it's one-off objects
> that are causing the growth of the cache and so objects are being
> reclaimed by the shrinker, then matching the periodic shrink scan to
> the growth rate will substantially reduce the rate of growth of that
> cache.
I can't speak for every slab cache, but I've been coming to the same
conclusion myself regarding the dentry cache. I think that the rate of
stepping through the LRU should be tied to the rate of allocations.
Truly in-use objects shouldn't be harmed by this, as they should get
referenced and rotated to the beginning of the LRU. But the one-offs
which are bloating the cache will be found and removed.
My dentry-related patch here [1] does tie the reclaim to the rate of
allocations. In that patch, I looked for sibling negative dentries to
reclaim, which is just silly in hindsight :)
I've implemented a version of this patch which just takes one step
through the LRU on each d_alloc. It's quite interesting to watch it
work. You can create 5 million negative dentries in directory /A via
stat(), and then create 5 million negative dentries in directory /B. The
total dentry slab size reaches 5 million but never goes past it, since
the old negative dentries from /A aren't really in use, and they get
pruned at the same rate as negative dentries from /B get created. On the
other hand, if you *continue* to stat() on the dentries of /A while you
create negative dentries in /B, then the cache grows to 10 million,
since the /A dentries are actually in use.
Maybe a solution could involve some generic list_lru machinery that can
let you do these sorts of incremental scans? Maybe batching them up so
instead of doing one every allocation, you do them every 100 or 1000?
It would still be up to the individual user to put this to good use in
the object allocation path.
Thanks,
Stephen
[1] https://lore.kernel.org/linux-fsdevel/20220209231406.187668-1-stephen.s.brennan@oracle.com/
next prev parent reply other threads:[~2022-04-05 17:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-02 7:21 Hillf Danton
2022-04-02 17:54 ` Roman Gushchin
2022-04-03 0:56 ` Hillf Danton
2022-04-04 1:09 ` Dave Chinner
2022-04-04 5:14 ` Hillf Danton
2022-04-04 18:32 ` Roman Gushchin
2022-04-04 19:08 ` Roman Gushchin
2022-04-05 5:17 ` Dave Chinner
2022-04-05 16:35 ` Roman Gushchin
2022-04-05 20:58 ` Yang Shi
2022-04-05 21:21 ` Matthew Wilcox
2022-04-06 0:01 ` Dave Chinner
2022-04-06 4:14 ` Hillf Danton
2022-04-21 19:03 ` Kent Overstreet
2022-04-21 23:55 ` Dave Chinner
2022-04-05 21:31 ` Roman Gushchin
2022-04-06 0:11 ` Dave Chinner
2022-04-05 17:22 ` Stephen Brennan [this message]
2022-04-05 21:18 ` Matthew Wilcox
2022-04-05 23:54 ` Dave Chinner
2022-04-06 1:06 ` Stephen Brennan
2022-04-06 3:52 ` Dave Chinner
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=87ilrn5ttl.fsf@stepbren-lnx.us.oracle.com \
--to=stephen.s.brennan@oracle.com \
--cc=david@fromorbit.com \
--cc=david@redhat.com \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=roman.gushchin@linux.dev \
--cc=willy@infradead.org \
--cc=yuzhao@google.com \
/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