lkml.org 
[lkml]   [2019]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2] block: optimise bvec_iter_advance()
Date
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

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-12-01 01:06    [W:0.030 / U:4.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site