From: David Howells <dhowells@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: dhowells@redhat.com, sfrench@samba.org,
linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] cifs: Don't use iov_iter::type directly
Date: Thu, 21 Nov 2019 09:11:11 +0000 [thread overview]
Message-ID: <30992.1574327471@warthog.procyon.org.uk> (raw)
In-Reply-To: <20191121081923.GA19366@infradead.org>
Christoph Hellwig <hch@infradead.org> wrote:
> I'd rather get rid of the accessor and access the fields directly, as
> that is much easier to follow.
The problem is that the type is arranged as a bunch of bits:
ITER_IOVEC = 4,
ITER_KVEC = 8,
ITER_BVEC = 16,
ITER_PIPE = 32,
ITER_DISCARD = 64,
and we end up doing a lot of:
if (type & TYPE1) {
} else if (type & TYPE2) {
} else if (type & TYPE3) {
} else if (type & TYPE4) {
} else {
/* Do ITER_IOVEC */
}
constructs - which isn't necessarily the most efficient for the CPU,
particularly if we get more iterator types. Note that ITER_IOVEC (which I
think is the common case) is usually coming last - and the CPU has to do all
the other checks first since the compiler can't know that it might be able to
take a shortcut (ie. rule out all the other types in one check first).
What I've been exploring is moving to:
ITER_IOVEC = 0
ITER_KVEC = 1,
ITER_BVEC = 2,
ITER_PIPE = 3,
ITER_DISCARD = 4,
and using switch statements - and then leaving it to the compiler to decide
how best to do things. In some ways, it might be nice to let the compiler
decide what constants it might use for this so as to best optimise the use
cases, but there's no way to do that at the moment.
However, all the code that is doing direct accesses using '&' has to change to
make that work - so I've converted it all to using accessors so that I only
have to change the header file, except that the patch to do that crossed with
a cifs patch that added more direct accesses, IIRC.
David
next prev parent reply other threads:[~2019-11-21 9:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 8:13 [PATCH] cifs: Don't use iov_iter::type directly David Howells
2019-11-21 8:19 ` Christoph Hellwig
2019-11-21 9:11 ` David Howells [this message]
2019-11-21 16:07 ` Christoph Hellwig
2019-11-22 16:26 ` Al Viro
2019-12-06 8:35 ` David Howells
2020-01-15 20:53 ` Steve French
2020-01-15 21:19 ` David Howells
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=30992.1574327471@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sfrench@samba.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).