mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>,
	torvalds@linux-foundation.org, mingo@redhat.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86: prevent gcc from emitting rep movsq/stosq for inlined ops
Date: Fri, 6 Jun 2025 10:19:04 +0200	[thread overview]
Message-ID: <20250606081904.GK30486@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAFULd4Z4SJZErfV1AG_a-+SDd=gnXa88=suRAFN3RHB5M+=bFw@mail.gmail.com>

On Fri, Jun 06, 2025 at 09:27:07AM +0200, Uros Bizjak wrote:

> Now, to use function call instead of "rep movsb", you can
> use -mstringop-strategy=libcall instead of some objtool substitution
> (-O2 -mno-sse -mstringop-strategy=libcall):
> 
> foo:
>        subq    $8, %rsp
>        movl    $160, %edx
>        leaq    16(%rsp), %rsi
>        call    memcpy
>        addq    $8, %rsp
>        ret
> 
> Which IMO is what you are looking for.

Well, no, because I can't replace the 'call memcpy' with "cs;cs;cs;rep
movsb" on good machines.

We want the "rep movsb" / "rep stosb" interface so we can actually use
those instructions when they're good, but then fall back to an
out-of-line function (with the same calling convention as the
instruction) when they're not so very good.



  reply	other threads:[~2025-06-06  8:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 16:47 Mateusz Guzik
2025-06-05 18:32 ` Linus Torvalds
2025-06-05 19:00 ` Peter Zijlstra
2025-06-06  6:13   ` Uros Bizjak
2025-06-06  6:27     ` Uros Bizjak
2025-06-06  7:20       ` Peter Zijlstra
2025-06-09 21:09         ` David Laight
2025-06-15 16:41           ` Uros Bizjak
2025-06-06  7:27   ` Uros Bizjak
2025-06-06  8:19     ` Peter Zijlstra [this message]
2025-06-08 20:51     ` David Laight
2025-06-09  6:04       ` Uros Bizjak
2025-06-09 16:38         ` Linus Torvalds
2025-06-09 19:25           ` Linus Torvalds
2025-06-09 19:04         ` David Laight
2025-06-06 15:36   ` Mateusz Guzik
2025-06-06 17:59     ` Linus Torvalds
2025-06-09 21:19 ` David Laight

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=20250606081904.GK30486@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjguzik@gmail.com \
    --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 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®