[PATCH v5 2/2] x86/xstate: Make AVX512 status tracking more accurate

From: Noah Goldstein
Date: Wed Oct 27 2021 - 14:21:16 EST


Update the mask for tracking AVX512 usage to not include the opmask
xfeature set.

The purpose of tracking the AVX512 status is to convey information
about possible frequency throttling. Opmask usage does not cause
frequency throttling so it is a completely unnecessary false positive.

Signed-off-by: Noah Goldstein <goldstein.w.n@xxxxxxxxx>
---
arch/x86/include/asm/fpu/types.h | 4 ++++
arch/x86/kernel/fpu/xstate.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
index f5a38a5f3ae1..e9a48f75159e 100644
--- a/arch/x86/include/asm/fpu/types.h
+++ b/arch/x86/include/asm/fpu/types.h
@@ -142,6 +142,10 @@ enum xfeature {
| XFEATURE_MASK_ZMM_Hi256 \
| XFEATURE_MASK_Hi16_ZMM)

+#define XFEATURE_MASK_AVX512_THROTTLE (XFEATURE_MASK_ZMM_Hi256 \
+ | XFEATURE_MASK_Hi16_ZMM)
+
+
#define FIRST_EXTENDED_XFEATURE XFEATURE_YMM

struct reg_128_bit {
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 00b495914be2..e129fae48792 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1254,7 +1254,7 @@ void fpu_update_avx_timestamp(struct fpu *fpu)
* AVX512 state is tracked here because its use is known to slow
* the max clock speed of the core.
*/
- if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512)
+ if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512_THROTTLE)
fpu->avx512_timestamp = jiffies;
}

--
2.25.1