From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-fscrypt@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] fs: reduce pointers while using file_ra_state_init()
Date: Thu, 29 Jul 2021 11:08:59 -0500 [thread overview]
Message-ID: <20210729160859.sfdypnrti5hxk6fg@fiona> (raw)
In-Reply-To: <YP7uqRrXsbCqTpfx@casper.infradead.org>
On 18:19 26/07, Matthew Wilcox wrote:
> On Mon, Jul 26, 2021 at 11:46:47AM -0500, Goldwyn Rodrigues wrote:
> > Simplification.
> >
> > file_ra_state_init() take struct address_space *, just to use inode
> > pointer by dereferencing from mapping->host.
> >
> > The callers also derive mapping either by file->f_mapping, or
> > even file->f_mapping->host->i_mapping.
> >
> > Change file_ra_state_init() to accept struct inode * to reduce pointer
> > dereferencing, both in the callee and the caller.
> >
> > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> (some adjacent comments)
>
> > diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> > index 4806295116d8..c43bf9915cda 100644
> > --- a/fs/btrfs/free-space-cache.c
> > +++ b/fs/btrfs/free-space-cache.c
> > @@ -351,7 +351,7 @@ static void readahead_cache(struct inode *inode)
> > if (!ra)
> > return;
> >
> > - file_ra_state_init(ra, inode->i_mapping);
> > + file_ra_state_init(ra, inode);
> > last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
> >
> > page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index);
>
> Why does btrfs allocate a file_ra_state using kmalloc instead of
> on the stack?
>
> > +++ b/include/linux/fs.h
> > @@ -3260,7 +3260,7 @@ extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
> >
> >
> > extern void
> > -file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
> > +file_ra_state_init(struct file_ra_state *ra, struct inode *inode);
>
> This should move to pagemap.h (and lose the extern).
> I'd put it near the definition of VM_READAHEAD_PAGES.
>
> > diff --git a/mm/readahead.c b/mm/readahead.c
> > index d589f147f4c2..3541941df5e7 100644
> > --- a/mm/readahead.c
> > +++ b/mm/readahead.c
> > @@ -31,9 +31,9 @@
> > * memset *ra to zero.
> > */
> > void
> > -file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
> > +file_ra_state_init(struct file_ra_state *ra, struct inode *inode)
> > {
> > - ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
> > + ra->ra_pages = inode_to_bdi(inode)->ra_pages;
> > ra->prev_pos = -1;
> > }
> > EXPORT_SYMBOL_GPL(file_ra_state_init);
>
> I'm not entirely sure why this function is out-of-line, tbh.
> Would it make more sense for it to be static inline in a header?
Which one? pagemap.h or fs.h does not know of inode_to_bdi(), should
linux/backing-dev.h be included?
--
Goldwyn
next prev parent reply other threads:[~2021-07-29 16:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 16:46 [PATCH] fs: reduce pointers while using file_ra_state_init() Goldwyn Rodrigues
2021-07-26 17:19 ` Matthew Wilcox
2021-07-29 16:08 ` Goldwyn Rodrigues [this message]
2021-07-26 22:06 ` NeilBrown
2021-07-27 2:05 ` Matthew Wilcox
2021-07-27 2:25 ` NeilBrown
2021-07-27 2:46 ` Goldwyn Rodrigues
2021-07-27 3:49 ` NeilBrown
2021-07-29 4:58 ` NeilBrown
2021-07-29 15:19 ` Goldwyn Rodrigues
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=20210729160859.sfdypnrti5hxk6fg@fiona \
--to=rgoldwyn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.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;
as well as URLs for NNTP newsgroup(s).