Re: x86/fpu: Inaccurate AVX-512 Usage Tracking via arch_status

From: Dave Hansen

Date: Mon Oct 27 2025 - 10:33:34 EST


On 10/27/25 00:50, chuang wrote:
> On AVX-512 capable systems, the implementation appears to record the
> current timestamp into 'task->thread.fpu.avx512_timestamp' upon any
> task switch, irrespective of whether the task has actually executed an
> AVX-512 instruction.

The timestamp update ultimately has _zero_ to do with executing
AVX-512 instructions. It's all about the state in the ZMM registers, not
AVX-512 instructions.

Those registers are inherited at fork and I don't see avx512_timestamp
being zeroed anywhere. So I suspect what you are seeing is that some
_parent_ used AVX512, and its children are getting stuck with
avx512_timestamp.

You could probably confirm this by dumping ->avx512_timestamp in
fpu_clone().

Or, try the attached patch and see if it makes things work more like
you'd expect.diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 1f71cc135e9a..2a8c159de5e2 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -648,6 +648,8 @@ int fpu_clone(struct task_struct *dst, u64 clone_flags, bool minimal,
/* The new task's FPU state cannot be valid in the hardware. */
dst_fpu->last_cpu = -1;

+ dst_fpu->avx512_timestamp = 0;
+
fpstate_reset(dst_fpu);

if (!cpu_feature_enabled(X86_FEATURE_FPU))