From: Linus Torvalds <torvalds@linux-foundation.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>, x86-ml <x86@kernel.org>,
Andy Lutomirski <luto@kernel.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Improve memset
Date: Tue, 17 Sep 2019 13:45:20 -0700 [thread overview]
Message-ID: <CAHk-=wjDiDOcz2GHC88rV8gySCMZZko8PFW-ywJDkeY5n+je9Q@mail.gmail.com> (raw)
In-Reply-To: <20190917201021.evoxxj7vkcb45rpg@treble>
On Tue, Sep 17, 2019 at 1:10 PM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> Could it instead do this?
>
> ALTERNATIVE_2("call memset_orig",
> "call memset_rep", X86_FEATURE_REP_GOOD,
> "rep; stosb", X86_FEATURE_ERMS)
>
> Then the "reverse alternatives" feature wouldn't be needed anyway.
That sounds better, but I'm a bit nervous about the whole thing
because who knows when the alternatives code itself internally uses
memset() and then we have a nasty little chicken-and-egg problem.
Also, for it to make sense to inline rep stosb, I think we also need
to just make the calling conventions for the alternative calls be that
they _don't_ clobber other registers than the usual rep ones
(cx/di/si). Otherwise one big code generation advantage of inlining
the thing just goes away.
On the whole I get the feeling that this is all painful complexity and
we shouldn't do it. At least not without some hard performance numbers
for some huge improvement, which I don't think we've seen.
Because I find the thing fascinating conceptually, but am not at all
convinced I want to deal with the pain in practice ;)
Linus
next prev parent reply other threads:[~2019-09-17 20:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 7:22 [RFC] Improve memset Borislav Petkov
2019-09-13 7:35 ` Ingo Molnar
2019-09-13 7:50 ` Borislav Petkov
2019-09-13 8:51 ` Rasmus Villemoes
2019-09-13 9:00 ` Linus Torvalds
2019-09-13 9:18 ` Rasmus Villemoes
2019-09-13 10:42 ` Borislav Petkov
2019-09-13 16:36 ` Borislav Petkov
2019-09-16 9:18 ` Rasmus Villemoes
2019-09-16 17:25 ` Linus Torvalds
2019-09-16 17:40 ` Andy Lutomirski
2019-09-16 21:29 ` Linus Torvalds
2019-09-16 23:13 ` Andy Lutomirski
2019-09-16 23:26 ` Linus Torvalds
2019-09-17 8:15 ` Borislav Petkov
2019-09-17 10:55 ` David Laight
2019-09-17 20:10 ` Josh Poimboeuf
2019-09-17 20:45 ` Linus Torvalds [this message]
2019-09-19 12:55 ` Borislav Petkov
2019-09-19 12:49 ` Borislav Petkov
2019-09-14 9:29 Alexey Dobriyan
2019-09-14 11:39 ` Borislav Petkov
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='CAHk-=wjDiDOcz2GHC88rV8gySCMZZko8PFW-ywJDkeY5n+je9Q@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=bp@alien8.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).