[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjDiDOcz2GHC88rV8gySCMZZko8PFW-ywJDkeY5n+je9Q@mail.gmail.com>
Date: Tue, 17 Sep 2019 13:45:20 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Borislav Petkov <bp@...en8.de>, x86-ml <x86@...nel.org>,
Andy Lutomirski <luto@...nel.org>,
lkml <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] Improve memset
On Tue, Sep 17, 2019 at 1:10 PM Josh Poimboeuf <jpoimboe@...hat.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
Powered by blists - more mailing lists