All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andy@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Uros Bizjak <ubizjak@gmail.com>,
	linux-kernel@vger.kernel.org, Kees Cook <kees@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH next] i386: Remove string functions that use 'rep scasb'
Date: Mon, 30 Mar 2026 20:20:14 +0100	[thread overview]
Message-ID: <20260330202014.1eb6fc76@pumpkin> (raw)
In-Reply-To: <CAHp75VfX-PBDSV7yTSZ9a5g3H0De+PPXMnuBkVEuCpMGdxyLuA@mail.gmail.com>

On Mon, 30 Mar 2026 20:21:41 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Mon, Mar 30, 2026 at 7:58 PM Dave Hansen <dave.hansen@intel.com> wrote:
> >
> > On 3/27/26 12:57, david.laight.linux@gmail.com wrote:  
> > > The fixed overhead of all the 'rep xxx' instructions is rather more
> > > that might expect. While 'rep movs' is getting better on more recent
> > > CPU, the same is not true for 'rep scasb'. On my Zen-5 it has a
> > > fixed overhead of 150 clocks and then takes 3 clocks for each byte.
> > > I've not measured any Intel CPU, but the cost might be 'only' 40 +
> > > 2n.  
> >
> > One measurement on a modern 64-bit CPU isn't super convincing to me.
> >  
> > > Remove the asm versions of strcat() strncat() strlen() memchr()
> > > and memscan(), the generic C versions will be faster.
> > >
> > > It is quite likely that all these functions are slower than the generic
> > > code on pretty much all CPU since the 486.  
> >
> > This is rather handwavy for my taste.
> >
> > There seem to be two valid paths here:
> >
> >  1. We continue the "nobody cares about 32-bit" refrain. This removes a
> >     bunch of 32-bit-only code and complexity. If it causes a performance
> >     regression, we do not care much.
> >  2. Someone makes _some_ kind of effort to test this on at least *one*
> >     32-bit-only CPU to see if it does any harm.
> >
> > In other words, I'm not opposed to the patch, but the justification
> > doesn't really work for me as written.  
> 
> I have Intel Quark at hand to test. But I need to know the
> step-by-step instructions on what to do.
> 

I can run my test on a few 'older' systems, but I don't have anything
Intel before Sandy bridge and only an AMD 'Excavator' (or similar).

I do remember (a long time ago) getting my Athlon 700 to run a copy
loop as fast as 'rep movl' - but the setup time was a lot worse.
So I suspect that generation of cpu didn't have a large overhead.
If I've read Agner's tables he gives a 40 clock setup to P-II onwards.

I can give you the source of the test I've been using.

	David

  reply	other threads:[~2026-03-30 19:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27 19:57 [PATCH next] i386: Remove string functions that use 'rep scasb' david.laight.linux
2026-03-30 16:58 ` Dave Hansen
2026-03-30 17:21   ` Andy Shevchenko
2026-03-30 19:20     ` David Laight [this message]
2026-03-30 19:47       ` Dave Hansen
2026-03-31  0:27         ` Maciej W. Rozycki
2026-03-31  6:59           ` 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=20260330202014.1eb6fc76@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.