From: Dave Chinner <david@fromorbit.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Andreas Dilger <adilger@dilger.ca>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Matthew Wilcox <willy@infradead.org>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>,
Ian Kent <raven@themaw.net>
Subject: Re: bad things when too many negative dentries in a directory
Date: Thu, 17 Apr 2025 07:41:21 +1000 [thread overview]
Message-ID: <aAAkAZQqlw_DcDQH@dread.disaster.area> (raw)
In-Reply-To: <CAJfpegtchAYvz8vLzrAkVy5WmV-Zc1PLbXUuwzxpiBCPOhK5Rg@mail.gmail.com>
On Wed, Apr 16, 2025 at 05:18:17PM +0200, Miklos Szeredi wrote:
> On Tue, 15 Apr 2025 at 19:22, Andreas Dilger <adilger@dilger.ca> wrote:
>
> > If the negative dentry count exceeds the actual entry count, it would
> > be more efficient to just cache all of the positive dentries and mark
> > the directory with a "full dentry list" flag that indicates all of the
> > names are already present in dcache and any miss is authoritative.
> > In essence that gives an "infinite" negative lookup cache instead of
> > explicitly storing all of the possible negative entries.
>
> This sounds nice in theory, but there are quite a number of things to sort out:
>
> - The "full dir read" needs to be done in the background to avoid
> large latencies, right?
>
> - Instantiate inodes during this, or have some dentry flag indicating
> that it's to be done later?
>
> - When does the whole directory get reclaimed?
>
> - What about revalidation in netfs? How often should a "full dir
> read" get triggered?
>
> I feel that it's just too complex.
>
> What's wrong with just trying to get rid of the bad effects of
> negative dentries, instead of getting rid of the dentries themselves ?
>
> Lack of memory pressure should mean that nobody else needs that
> memory, so it should make no difference if it's used up in negative
> dentries instead of being free memory. Maybe I'm missing something
> fundamental?
There is no issue with the existence of huge numbers of negative
dentries. The issue is the overhead and latency of reclaiming
hundreds of millions of tiny objects to release the memory is
prohibitive. Dentry reclaim is generally pretty slow, especially if
it is being done by a single background thread like kswapd.
FWIW, I think there is a simpler version of this "per-directory
dentry count" heuristic that might work well enough to bound the
upper maximum: apply the same hueristic to the entire dentry cache.
I'm pretty sure this has been proposed in the past, but we should
probably revisit it anyway because this problem hasn't gone away.
i.e. if the number of negative dentries exceeds the number of
positive dentries and the total number of dentries exceeds a certain
amount of memory, kick a background thread to reap some negative
dentries from the LRU. e.g. every 30s check if dentries exceed 10%
of memory and negative dentries exceed positive. If so, reap the
oldest 10% of negative dentries.
That will still allow a system with free memory to build up a -lot-
of negative dentries, but also largely bound the amount of free
memory that can be consumed by negative dentries to around 5% of
total memory.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2025-04-16 21:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 9:40 bad things when too many negative dentries in a directory Miklos Szeredi
2025-04-11 14:47 ` Christian Brauner
2025-04-11 15:40 ` Miklos Szeredi
2025-04-11 16:01 ` Matthew Wilcox
2025-04-14 14:07 ` James Bottomley
2025-04-14 14:30 ` Matthew Wilcox
2025-04-14 15:40 ` James Bottomley
2025-04-14 16:14 ` Matthew Wilcox
2025-04-14 17:58 ` James Bottomley
2025-04-15 17:22 ` Andreas Dilger
2025-04-16 15:18 ` Miklos Szeredi
2025-04-16 15:37 ` Matthew Wilcox
2025-04-16 21:41 ` Dave Chinner [this message]
2025-04-16 15:26 ` James Bottomley
2025-04-22 6:57 ` Andreas Dilger
2025-04-14 6:28 ` Ian Kent
2025-04-14 7:17 ` Miklos Szeredi
2025-04-12 1:48 ` Ian Kent
2025-04-12 1:56 ` Ian Kent
2025-04-12 6:31 ` Ian Kent
2025-04-11 21:02 ` Mateusz Guzik
2025-04-20 4:49 ` Al Viro
2025-05-08 15:45 ` Miklos Szeredi
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=aAAkAZQqlw_DcDQH@dread.disaster.area \
--to=david@fromorbit.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=adilger@dilger.ca \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.