Re: [GIT PULL] s390 updates for 5.15-rc6

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

 



On Sat, Oct 16, 2021 at 09:22:12AM -0700, Linus Torvalds wrote:
> On Sat, Oct 16, 2021 at 2:26 AM Vasily Gorbik <gor@xxxxxxxxxxxxx> wrote:
> >
> > - Fix broken strrchr implementation.
> 
> I pulled this, but had to look at this commit just because it struck me as odd.
> 
> Is the generic strrchr() implementation so bad for s390 that it shows
> up? It looks like the s390 implementation wants to avoid checking
> separately against the final NUL character and basically uses the
> optimized strlen function to do so, but when strrchr has to walk the
> string _anyway_ this all looks a bit odd.

The difference is that it walks the string from the end to the start,
taking into account that searching for the end of the string can be
considered fast.

> Not a big deal. I just get the feeling that s390 (and probably other
> architectures) might be a bit too eager to make their own helper
> string functions for reasons that may be historical ("we didn't have
> generic string functions at all long ago") or misguided ("we'll do an
> architecture-optimized version even for things that don't matter").

This function exists for historical reasons, and in this case it is
probably more the "optimized version for things that don't matter".

The only caller which sort of gets called more frequently seems to be
kbasename().

Some numbers, running 1.000.000 strrchr on an 80 byte string:

 s390  generic   search for
 57us     55us   first character in string
 15us     55us   last character in string
 44us     55us   character in middle of string

So yes, we could probably just drop our own implementation, given that
it hardly matters in real life.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux