linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] block: optimise bvec_iter_advance()
Date: Sun, 1 Dec 2019 03:04:36 +0300	[thread overview]
Message-ID: <74c78d40-8b0c-2e87-d882-8396411a7be5@gmail.com> (raw)
In-Reply-To: <20191130220458.GA297712@rani.riverdale.lan>


[-- Attachment #1.1: Type: text/plain, Size: 1410 bytes --]

On 01/12/2019 01:05, Arvind Sankar wrote:
> On Sat, Nov 30, 2019 at 11:23:52PM +0300, Pavel Begunkov wrote:
>> bvec_iter_advance() is quite popular, but compilers fail to do proper
>> alias analysis and optimise it good enough. The assembly is checked
>> for gcc 9.2, x86-64.
>>
>> - remove @iter->bi_size from min(...), as it's always less than @bytes.
>> Modify at the beginning and forget about it.
>>
>> - the compiler isn't able to collapse memory dependencies and remove
>> writes in the loop. Help it by explicitly using local vars.
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> ---
>>
>> v2: simplify code (Arvind Sankar)
>>
> 
> Thanks :)
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
> 
> Btw, I discovered that gcc 9.2 doesn't optimize away the second
> comparison in something like

That's unfortunate. IDK, whether it could be easily done in gcc,
but maybe relay it to compiler guys?

> 
> 	m = min(a,b);
> 	return m>a;
> 
> So the WARN_ONCE bit doesn't get optimized away even in cases like
> bio_for_each_bvec where it's guaranteed at compile-time to not trigger.
> 

That's more like a starting point. The idea is to revise and
tune/rewrite iteration helpers including *for_each_bvec(). I assume,
all those are really poorly optimisable (especially with
-fno-strict-aliasing). So, noted to consider

-- 
Pavel Begunkov


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-12-01  0:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1575144884.git.asml.silence@gmail.com>
2019-11-30 20:23 ` [PATCH v2] block: optimise bvec_iter_advance() Pavel Begunkov
2019-11-30 22:05   ` Arvind Sankar
2019-12-01  0:04     ` Pavel Begunkov [this message]
2019-12-03 14:37   ` Jens Axboe

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=74c78d40-8b0c-2e87-d882-8396411a7be5@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nivedita@alum.mit.edu \
    /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).