From: Andy Shevchenko <andy@kernel.org>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: Kees Cook <kees@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
Zijun Hu <quic_zijuhu@quicinc.com>,
"Rob Herring (Arm)" <robh@kernel.org>
Subject: Re: [PATCH 1/2] lib/string: Improve strstarts() performance
Date: Mon, 7 Apr 2025 17:39:14 +0300 [thread overview]
Message-ID: <Z_PjksaIc0B2AQhs@smile.fi.intel.com> (raw)
In-Reply-To: <0e603b02-b272-4bcc-8b86-1a3dca9477d7@icloud.com>
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
next prev parent reply other threads:[~2025-04-07 14:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 13:15 [PATCH 0/2] lib/string: Improve performance for both strstarts() and str_has_prefix() Zijun Hu
2025-04-07 13:15 ` [PATCH 1/2] lib/string: Improve strstarts() performance Zijun Hu
2025-04-07 13:51 ` Andy Shevchenko
2025-04-07 14:33 ` Zijun Hu
2025-04-07 14:39 ` Andy Shevchenko [this message]
2025-04-07 14:53 ` Zijun Hu
2025-04-07 16:17 ` Kees Cook
2025-04-08 11:34 ` Zijun Hu
2025-04-08 13:13 ` kernel test robot
2025-04-07 13:15 ` [PATCH 2/2] lib/string: Improve str_has_prefix() performance Zijun Hu
2025-04-07 13:52 ` Andy Shevchenko
2025-04-07 13:49 ` [PATCH 0/2] lib/string: Improve performance for both strstarts() and str_has_prefix() Andy Shevchenko
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=Z_PjksaIc0B2AQhs@smile.fi.intel.com \
--to=andy@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
--cc=robh@kernel.org \
--cc=zijun_hu@icloud.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
all inboxes | Powered by JetHome®