Re: [PATCH v3 2/2] x86/xstate: Make AVX512 status tracking more accurate
From: Noah Goldstein
Date: Wed Oct 27 2021 - 13:37:43 EST
On Wed, Oct 27, 2021 at 12:11 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Wed, Oct 27, 2021 at 11:26:15AM -0500, Noah Goldstein wrote:
> > diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
> > index f5a38a5f3ae1..cb10909fa3da 100644
> > --- a/arch/x86/include/asm/fpu/types.h
> > +++ b/arch/x86/include/asm/fpu/types.h
> > @@ -330,11 +330,21 @@ struct fpu {
> > unsigned int last_cpu;
> >
> > /*
> > - * @avx512_timestamp:
> > + * @avx512_ZMM_Hi256_timestamp:
> > *
> > - * Records the timestamp of AVX512 use during last context switch.
> > + * Records the timestamp of AVX512 use in the ZMM_Hi256 xfeature
> > + * set. This include zmm0...zmm15.
> > */
> > - unsigned long avx512_timestamp;
> > + unsigned long avx512_ZMM_Hi256_timestamp;
> > +
> > + /*
> > + * @avx512_Hi16_ZMM_timestamp:
> > + *
> > + * Records the timestamp of AVX512 use in the Hi16_ZMM xfeature
> > + * set. This includes usage of any of the hi16 xmm, ymm, or zmm
> > + * registers.
> > + */
> > + unsigned long avx512_Hi16_ZMM_timestamp;
>
> No, not more of this but less.
>
> That was a bad idea to begin with as exposing this to userspace would
> cause exactly this: but but, I need to track my special use case more
> precisely.
>
> But the feature mask can't give you that precision so it'll be only an
> approximation no matter what you do.
>
> And I'm being told future cores won't have this "problem" so on them
> that file becomes actively misleading.
What I've heard is it's a lot better on Rocket Lake (only extra downclocking
on multicore usage) and TBD for Saphire Rapids.
>
> If you really wanna track performance drop precisely or AVX use or
> whatnot, there's performance counters for that which can give you
> exactly what you wanna know.
>
> So I'll take a simple patch carving out that into a function and which
> removes the opmask and otherwise let that thing die. And on future cores
> which are not affected, that thing will report only 0 anyway.
What about just splitting off a field for 'AVX512_ZMM_Hi256'? That field
seems like it can give meaningful information.
I think mostly like 'AVX512_Hi16_ZMM' will almost always be set because
GLIBC's ifunc uses EVEX implementations for all string/memory functions
on CPUs with avx512.
But if you insist will do.
>
> Thx.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette