Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexey Dobriyan <adobriyan@xxxxxxxxx> writes:

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



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux