path: root/arch/x86/include/asm
diff options
authorAubrey Li <>2019-01-18 02:38:20 +0800
committerIngo Molnar <>2019-02-11 14:28:56 +0100
commit2f7726f955572e587d5f50fbe9b2deed5334bd90 (patch)
treec6d08f8f4087340abd848b505ae76548423568d2 /arch/x86/include/asm
parentdc14b5fe7d0a1e37e9388964614676e4166b2953 (diff)
x86/fpu: Track AVX-512 usage of tasks
User space tools which do automated task placement need information about AVX-512 usage of tasks, because AVX-512 usage could cause core turbo frequency drop and impact the running task on the sibling CPU. The XSAVE hardware structure has bits that indicate when valid state is present in registers unique to AVX-512 use. Use these bits to indicate when AVX-512 has been in use and add per-task AVX-512 state timestamp tracking to context switch. Well-written AVX-512 applications are expected to clear the AVX-512 state when not actively using AVX-512 registers, so the tracking mechanism is imprecise and can theoretically miss AVX-512 usage during context switch. But it has been measured to be precise enough to be useful under real-world workloads like tensorflow and linpack. If higher precision is required, suggest user space tools to use the PMU-based mechanisms in combination. Signed-off-by: Aubrey Li <> Reviewed-by: Thomas Gleixner <> Cc: Andy Lutomirski <> Cc: Arjan van de Ven <> Cc: Borislav Petkov <> Cc: Dave Hansen <> Cc: Dave Hansen <> Cc: Fenghua Yu <> Cc: H. Peter Anvin <> Cc: Linus Torvalds <> Cc: Oleg Nesterov <> Cc: Peter Zijlstra <> Cc: Tim Chen <> Cc: Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'arch/x86/include/asm')
2 files changed, 14 insertions, 0 deletions
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index 5d536e3dcc6d..fb04a3ded7dd 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -376,6 +376,13 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
if (likely(use_xsave())) {
+ /*
+ * 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)
+ fpu->avx512_timestamp = jiffies;
return 1;
diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
index 202c53918ecf..2e32e178e064 100644
--- a/arch/x86/include/asm/fpu/types.h
+++ b/arch/x86/include/asm/fpu/types.h
@@ -303,6 +303,13 @@ struct fpu {
unsigned char initialized;
+ * @avx512_timestamp:
+ *
+ * Records the timestamp of AVX512 use during last context switch.
+ */
+ unsigned long avx512_timestamp;
+ /*
* @state:
* In-memory copy of all FPU registers that we save/restore