From: Jan Kara <jack@suse.cz>
To: Matthew Wilcox <willy@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] iomap: Add iomap_iter API
Date: Wed, 22 Apr 2020 17:19:18 +0200 [thread overview]
Message-ID: <20200422151918.GA20756@quack2.suse.cz> (raw)
In-Reply-To: <20200401184245.GI21484@bombadil.infradead.org>
On Wed 01-04-20 11:42:45, Matthew Wilcox wrote:
> On Wed, Apr 01, 2020 at 08:42:48AM -0700, Christoph Hellwig wrote:
> > > +loff_t iomap_iter(struct iomap_iter *iter, loff_t written)
> > > +{
> > > + const struct iomap_ops *ops = iter->ops;
> > > + struct iomap *iomap = &iter->iomap;
> > > + struct iomap *srcmap = &iter->srcmap;
> >
> > I think it makes sense to only have members in the iter structure
> > that this function modifies. That is, just pass inode, ops and flags
> > as explicit parameters.
>
> One of the annoying things we do when looking at the disassembly is
> spend a lot of instructions shuffling arguments around. Passing as many
> arguments as possible in a struct minimises that.
Somewhat late to the game but ... from the conversions of "explicit
arguments to struct of arguments" I've seen (e.g. in xarray) compilers seem
to generate somewhat slower code when arguments are passed in structs. From
the profiling I did it just seems that when arguments are passed directly,
they are in registers which is generally the fastest access you can get.
When you pass arguments in structs, compilers just fetch the value from
stack which is slower even if its cached. And when the argument is not used
frequently or there's something else cache heavy going on, you may have to
go to L2 or L3 which is when you feel the pain... E.g. I've observed some
of the xarray functions which were "logically" identical to their
radix-tree counterparts generate non-negligible amount of cache misses when
reading their arguments from the passed struct.
I don't think iomap is as CPU sensitive as xarray (generally there's much
heavier work that happens in the filesystem) so I'd just strive for code
simplicity here. But I wanted to mention this so that it's clear that
pushing arguments to structs isn't free either.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-04-22 15:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 15:25 [RFC 0/2] Begin switching iomap from apply to iter Matthew Wilcox
2020-04-01 15:25 ` [PATCH 1/2] iomap: Add iomap_iter API Matthew Wilcox
2020-04-01 15:42 ` Christoph Hellwig
2020-04-01 18:42 ` Matthew Wilcox
2020-04-22 15:19 ` Jan Kara [this message]
2020-04-01 19:20 ` Matthew Wilcox
2020-04-02 7:48 ` Christoph Hellwig
2020-04-01 15:25 ` [PATCH 2/2] iomap: Convert page_mkwrite to iter API Matthew Wilcox
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=20200422151918.GA20756@quack2.suse.cz \
--to=jack@suse.cz \
--cc=hch@infradead.org \
--cc=linux-xfs@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).