lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87k10x49nj.fsf@x220.int.ebiederm.org>
Date:   Wed, 27 May 2020 11:36:48 -0500
From:   ebiederm@...ssion.com (Eric W. Biederman)
To:     Alexey Dobriyan <adobriyan@...il.com>
Cc:     Kaitao Cheng <pilgrimtao@...il.com>, christian@...uner.io,
        akpm@...ux-foundation.org, gladkov.alexey@...il.com, guro@...com,
        walken@...gle.com, avagin@...il.com, khlebnikov@...dex-team.ru,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.

Alexey Dobriyan <adobriyan@...il.com> writes:

> On Wed, May 27, 2020 at 09:41:53AM -0500, Eric W. Biederman wrote:
>> Kaitao Cheng <pilgrimtao@...il.com> writes:
>> 
>> > we don't need {len = PTR_ERR(pathname)} when IS_ERR(pathname) is false,
>> > it's better to move it into if(IS_ERR(pathname)){}.
>> 
>> Please look at the generated code.
>> 
>> I believe you will find that your change will generate worse assembly.
>
> I think patch is good.
>
> Super duper CPUs which speculate thousands instructions forward won't
> care but more embedded ones do. Or in other words 1 unnecessary instruction
> on common path is more important for slow CPUs than for fast CPUs.

No.  This adds an entire extra basic block, with an extra jump.

A good compiler should not even generate an extra instruction for this
case.  A good compiler will just let len and pathname share the same
register.

So I think this will hurt your slow cpu case two as it winds up just
plain being more assembly code, which stress the size of the slow cpus
caches.



I do admit a good compiler should be able to hoist the assignment above
the branch (as we have today) it gets tricky to tell if hoisting the
assignment is safe.

> This style separates common path from error path more cleanly.

Very arguable.

[snip a completely different case]

Yes larger cases can have different solutions.

Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ