[lkml]   [2020]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.
Alexey Dobriyan <> writes:

> On Wed, May 27, 2020 at 09:41:53AM -0500, Eric W. Biederman wrote:
>> Kaitao Cheng <> 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

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

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.


 \ /
  Last update: 2020-05-27 18:40    [W:0.057 / U:9.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site