linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Shyam Prasad N <nspmangalore@gmail.com>
Cc: lsf-pc@lists.linux-foundation.org,
	 linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-mm@kvack.org, brauner@kernel.org,
	 Matthew Wilcox <willy@infradead.org>,
	David Howells <dhowells@redhat.com>,
	 Jeff Layton <jlayton@redhat.com>,
	Steve French <smfrench@gmail.com>,
	trondmy@kernel.org,  Shyam Prasad N <sprasad@microsoft.com>
Subject: Re: [Lsf-pc] [LSF/MM/BPF TOPIC] Predictive readahead of dentries
Date: Tue, 14 Jan 2025 13:39:28 +0100	[thread overview]
Message-ID: <6wcmvyeuelngltuiohumo6pffwptgbgofqba453pdi45ahydkn@ern4qy4i2zoa> (raw)
In-Reply-To: <CANT5p=rxLH-D9qSoOWgjYeD87uahmZJMwXp8uNKW66mbv8hmDg@mail.gmail.com>

Hello!

On Tue 14-01-25 09:08:38, Shyam Prasad N wrote:
> The Linux kernel does buffered reads and writes using the page cache
> layer, where the filesystem reads and writes are offloaded to the
> VM/MM layer. The VM layer does a predictive readahead of data by
> optionally asking the filesystem to read more data asynchronously than
> what was requested.
> 
> The VFS layer maintains a dentry cache which gets populated during
> access of dentries (either during readdir/getdents or during lookup).
> This dentries within a directory actually forms the address space for
> the directory, which is read sequentially during getdents. For network
> filesystems, the dentries are also looked up during revalidate.
> 
> During sequential getdents, it makes sense to perform a readahead
> similar to file reads. Even for revalidations and dentry lookups,
> there can be some heuristics that can be maintained to know if the
> lookups within the directory are sequential in nature. With this, the
> dentry cache can be pre-populated for a directory, even before the
> dentries are accessed, thereby boosting the performance. This could
> give even more benefits for network filesystems by avoiding costly
> round trips to the server.
> 
> NFS client already does a simplistic form of this readahead by
> maintaining an address space for the directory inode and storing the
> dentry records returned by the server in this space. However, this
> dentry access mechanism is so generic that I feel that this can be a
> part of the VFS/VM layer, similar to buffered reads of a file. Also,
> VFS layer is better equipped to store heuristics about dentry access
> patterns.

Interesting idea. Note that individual filesystems actually do directory
readahead on their own. They just don't readahead 'struct dentry' but
rather issue readahead for metadata blocks to get into cache which is what
takes most time. Readahead makes the most sense for readdir() (or
getdents() as you call it) calls where the filesystem driver has all the
information it needs (unlike VFS) for performing efficient readahead. So
here I'm not sure there's much need for a change.

I'm not against some form of readahead for ->lookup calls but we'd have to
very carefully design the heuristics for detecting some kind of pattern of
->lookup calls so that we know which entry is going to be the next one
looked up and evaluate whether it is actually an overall win or not. So
for this the discussion would need a more concrete proposal to be useful I
think.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


  reply	other threads:[~2025-01-14 12:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  3:38 Shyam Prasad N
2025-01-14 12:39 ` Jan Kara [this message]
2025-01-15  9:52   ` [Lsf-pc] " Shyam Prasad N
2025-01-14 13:24 ` Amir Goldstein
2025-01-14 14:12   ` Benjamin Coddington
2025-01-14 15:01     ` Paulo Alcantara
2025-01-15 14:30       ` Shyam Prasad N
2025-01-15 14:47         ` Paulo Alcantara
2025-01-15 11:27   ` Shyam Prasad N
2025-01-15 14:21     ` Amir Goldstein
2025-01-20 21:26   ` Benjamin Coddington
2025-01-14 15:59 ` James Bottomley
2025-01-16  4:50 ` Al Viro
2025-01-16  5:31 ` Christoph Hellwig

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=6wcmvyeuelngltuiohumo6pffwptgbgofqba453pdi45ahydkn@ern4qy4i2zoa \
    --to=jack@suse.cz \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lsf-pc@lists.linux-foundation.org \
    --cc=nspmangalore@gmail.com \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=trondmy@kernel.org \
    --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