Skip to content

Commit 0fe4ff8

Browse files
goldsteinnsuryasaimadhu
authored andcommitted
x86/fpu: Correct AVX512 state tracking
Add a separate, local mask for tracking AVX512 usage which does not include the opmask xfeature set. Opmask registers usage does not cause frequency throttling so it is a completely unnecessary false positive. While at it, carve it out into a separate function to keep that abomination extracted out. [ bp: Rediff and cleanup ontop of 5.16-rc1. ] Signed-off-by: Noah Goldstein <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fa55b7d commit 0fe4ff8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

arch/x86/kernel/fpu/core.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ bool irq_fpu_usable(void)
9898
}
9999
EXPORT_SYMBOL(irq_fpu_usable);
100100

101+
/*
102+
* Track AVX512 state use because it is known to slow the max clock
103+
* speed of the core.
104+
*/
105+
static void update_avx_timestamp(struct fpu *fpu)
106+
{
107+
108+
#define AVX512_TRACKING_MASK (XFEATURE_MASK_ZMM_Hi256 | XFEATURE_MASK_Hi16_ZMM)
109+
110+
if (fpu->fpstate->regs.xsave.header.xfeatures & AVX512_TRACKING_MASK)
111+
fpu->avx512_timestamp = jiffies;
112+
}
113+
101114
/*
102115
* Save the FPU register state in fpu->fpstate->regs. The register state is
103116
* preserved.
@@ -116,13 +129,7 @@ void save_fpregs_to_fpstate(struct fpu *fpu)
116129
{
117130
if (likely(use_xsave())) {
118131
os_xsave(fpu->fpstate);
119-
120-
/*
121-
* AVX512 state is tracked here because its use is
122-
* known to slow the max clock speed of the core.
123-
*/
124-
if (fpu->fpstate->regs.xsave.header.xfeatures & XFEATURE_MASK_AVX512)
125-
fpu->avx512_timestamp = jiffies;
132+
update_avx_timestamp(fpu);
126133
return;
127134
}
128135

0 commit comments

Comments
 (0)