From: ebiederm@xmission.com (Eric W. Biederman)
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Kaitao Cheng <pilgrimtao@gmail.com>,
christian@brauner.io, akpm@linux-foundation.org,
gladkov.alexey@gmail.com, guro@fb.com, walken@google.com,
avagin@gmail.com, khlebnikov@yandex-team.ru,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.
Date: Wed, 27 May 2020 11:36:48 -0500 [thread overview]
Message-ID: <87k10x49nj.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20200527152340.GA19985@localhost.localdomain> (Alexey Dobriyan's message of "Wed, 27 May 2020 18:23:40 +0300")
Alexey Dobriyan <adobriyan@gmail.com> writes:
> On Wed, May 27, 2020 at 09:41:53AM -0500, Eric W. Biederman wrote:
>> Kaitao Cheng <pilgrimtao@gmail.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
prev parent reply other threads:[~2020-05-27 16:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 14:11 [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink Kaitao Cheng
2020-05-27 14:41 ` Eric W. Biederman
2020-05-27 15:23 ` Alexey Dobriyan
2020-05-27 16:36 ` Eric W. Biederman [this message]
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=87k10x49nj.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=christian@brauner.io \
--cc=gladkov.alexey@gmail.com \
--cc=guro@fb.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pilgrimtao@gmail.com \
--cc=walken@google.com \
/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