[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_PjksaIc0B2AQhs@smile.fi.intel.com>
Date: Mon, 7 Apr 2025 17:39:14 +0300
From: Andy Shevchenko <andy@...nel.org>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: Kees Cook <kees@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>,
"Rob Herring (Arm)" <robh@...nel.org>
Subject: Re: [PATCH 1/2] lib/string: Improve strstarts() performance
On Mon, Apr 07, 2025 at 10:33:34PM +0800, Zijun Hu wrote:
> On 2025/4/7 21:51, Andy Shevchenko wrote:
> > First of all, this function is supposed to be run against constant string literals.
>
> for strstarts(s, "prefix"), strlen("prefix") should *NOT* be compile
> time constant. it is a loop and unavoidable to have strlen("prefix")
> iterations.
What do you mean by that? Compiler uses __builtin_strlen() and it *IS*
a compile-time constant. Just check it.
> > Second, this commit message has zero proofs to tell if there is actual performance
> > downgrage even in the case when prefix is not a constant string literal.
>
> for either constant string or non constant string. this patch
> eliminating a loop which have strlen()iterations. i feel it is obvious
> it can improve performance.
No, it's not.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists