to update AVX512 state > + */ > +static inline void update_avx512_state(struct fpu *fpu) > +{ > + /* > + * AVX512 state is tracked here because its use is known to slow > + * the max clock speed of the core. > + * > + * However, AVX512-using tasks are expected to clear this state when > + * not actively using these registers. Thus, this tracking mechanism > + * can miss. To ensure that false-negatives do not immediately show > + * up, decay the usage count over time. > + */ > + if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512) > + fpu->avx512_usage = AVX512_STATE_DECAY_COUNT; > + else if (fpu->avx512_usage) > + fpu->avx512_usage--; > +} > + > /* > * This function is called only during boot time when x86 caps are not set > * up and alternative can not be used yet. > @@ -411,6 +432,7 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu) > { > if (likely(use_xsave())) { > copy_xregs_to_kernel(&fpu->state.xsave); > + update_avx512_state(fpu); > return 1; > }
Is there a reason we shouldn't do: if (!cpu_feature_enabled(X86_FEATURE_AVX512F)) update_avx512_state(fpu); ?