From: Eric Biggers <ebiggers@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org,
linux-raid@vger.kernel.org, linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
Taehee Yoo <ap420073@gmail.com>,
netfilter-devel@vger.kernel.org,
Pablo Neira Ayuso <pablo@netfilter.org>,
Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>
Subject: Re: [PATCH 0/6] x86: add missing vzeroupper instructions
Date: Mon, 17 Aug 2026 10:18:34 -0700 [thread overview]
Message-ID: <20260817171834.GA8327@quark> (raw)
In-Reply-To: <20260817115523.7c6c646a@pumpkin>
On Mon, Aug 17, 2026 at 11:55:23AM +0100, David Laight wrote:
> On Mon, 17 Aug 2026 02:15:19 -0700
> Christoph Hellwig <hch@infradead.org> wrote:
>
> > On Sun, Aug 16, 2026 at 10:31:59AM -0700, Eric Biggers wrote:
> > > As for kernel_fpu_begin(), no, it doesn't do vzeroupper.
> > >
> > > I do think that some years down the line, we'll drop the use of SSE in
> > > the kernel entirely. At that point, vzeroupper in kernel_fpu_end()
> > > would make sense.
> >
> > Or add kernel_avx_{begin,end} wrappers that include the vzeroupper
> > in kernel_avx_end. That would be a lot easier to use than the manual
> > vzeroupper in every modern user of in-kernel AVX.
> >
>
> You might want one in the start as well.
> I have a theory that the avx512 logic was added as a completely separate block.
> This meant it could be included in cpu for testing but disabled in any
> released to customers.
> (Or maybe the it is the original avx logic that used latches not in the
> normal register file.)
> A side effect is that different latches are used for the low bits of the
> registers - so when you change to/from avx512 the register contents have to
> be transferred between the blocks - adding latency.
> So if the wrong registers are live for the code you are going to execute
> the data has to be transferred across.
>
> There are also other effects as well.
> I found this link: https://travisdowns.github.io/blog/2020/01/17/avxfreq1.html
> It is a few years old now (2020) but probably still relevant.
> A quick summary is that the first 256 or 512 bit instruction starts a 9us
> window where the cpu runs at 1/4 speed, for 512 bit that is followed by 11us
> where nothing happens at all.
The linked article is about Skylake, which is an older Intel CPU that
has a bad AVX-512 implementation with overly-eager downclocking. Later
Intel CPUs improved the implementation. And of course, AMD just
implemented it properly from the start without the downclocking issues.
Information about AMD Zen 5's AVX-512 implementation can be found here:
https://www.numberworld.org/blogs/2024_8_7_zen5_avx512_teardown/
Most of the AVX-512 optimized code in the kernel already requires
!X86_FEATURE_PREFER_YMM, excluding Skylake as well as Ice Lake.
That being said, if I recall correctly, even with Intel's improved
implementation on Sapphire Rapids and Emerald Rapids, Intel does still
have some start-up latency for accessing ZMM registers. AMD doesn't. I
don't believe vzeroupper helps, unfortunately.
I've considered setting X86_FEATURE_PREFER_YMM on all Intel CPUs, but
then even workloads that would benefit from ZMM registers wouldn't use
them. And I suspect the Intel folks wouldn't agree with that either.
- Eric
prev parent reply other threads:[~2026-08-17 17:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 20:57 [PATCH 0/6] x86: add missing vzeroupper instructions Eric Biggers
2026-08-15 20:57 ` [PATCH 1/6] xor: add missing vzeroupper to AVX code Eric Biggers
2026-08-15 20:57 ` [PATCH 2/6] raid6: add missing vzeroupper to AVX2 code Eric Biggers
2026-08-15 20:57 ` [PATCH 3/6] raid6: add missing vzeroupper to AVX-512 code Eric Biggers
2026-08-15 20:57 ` [PATCH 4/6] crypto: x86/aria - add missing vzeroupper in AVX2 code Eric Biggers
2026-08-15 20:57 ` [PATCH 5/6] crypto: x86/aria - add missing vzeroupper in AVX-512 code Eric Biggers
2026-08-15 20:57 ` [PATCH 6/6] netfilter: nft_set_pipapo_avx2: add missing vzeroupper Eric Biggers
2026-08-16 10:38 ` Stefano Brivio
2026-08-16 17:15 ` Eric Biggers
2026-08-17 11:17 ` Stefano Brivio
2026-08-17 11:17 ` Stefano Brivio
2026-08-16 15:14 ` [PATCH 0/6] x86: add missing vzeroupper instructions David Laight
2026-08-16 17:31 ` Eric Biggers
2026-08-17 9:15 ` Christoph Hellwig
2026-08-17 10:55 ` David Laight
2026-08-17 17:18 ` Eric Biggers [this message]
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=20260817171834.GA8327@quark \
--to=ebiggers@kernel.org \
--cc=ap420073@gmail.com \
--cc=david.laight.linux@gmail.com \
--cc=fw@strlen.de \
--cc=hch@infradead.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--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).