Re: [PATCH v6 1/3] x86/fpu: track AVX-512 usage of tasks

From: Thomas Gleixner
Date: Tue Dec 18 2018 - 09:15:20 EST


On Tue, 18 Dec 2018, Aubrey Li wrote:
> diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
> index a38bf5a1e37a..8778ac172255 100644
> --- a/arch/x86/include/asm/fpu/internal.h
> +++ b/arch/x86/include/asm/fpu/internal.h
> @@ -411,6 +411,13 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
> {
> if (likely(use_xsave())) {
> copy_xregs_to_kernel(&fpu->state.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_64;

Even if unlikely this is incorrect when running a 32 bit kernel because
there jiffies_64 cannot be atomically loaded vs. a concurrent update. See
the comment in include/linux/jiffies.h right above the jiffies_64
declaration.

Thanks,

tglx