Re: [PATCH 1/1] headers/deps: x86/fpu: Make task_struct::thread constant size

From: Oleg Nesterov
Date: Tue Mar 26 2024 - 13:51:20 EST


On 03/20, Ingo Molnar wrote:
>
> --- a/arch/x86/kernel/fpu/init.c
> +++ b/arch/x86/kernel/fpu/init.c
> @@ -38,7 +38,7 @@ static void fpu__init_cpu_generic(void)
> /* Flush out any pending x87 state: */
> #ifdef CONFIG_MATH_EMULATION
> if (!boot_cpu_has(X86_FEATURE_FPU))
> - fpstate_init_soft(&current->thread.fpu.fpstate->regs.soft);
> + fpstate_init_soft(current->thread.fpu->fpstate->regs.soft);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Typo? it should be

&current->thread.fpu->fpstate->regs.soft

> +static struct fpu x86_init_fpu __read_mostly;
> +
> static void __init fpu__init_system_early_generic(void)
> {
> + {
> + int this_cpu = smp_processor_id();
> +
> + fpstate_reset(&x86_init_fpu);
> + current->thread.fpu = &x86_init_fpu;
> + per_cpu(fpu_fpregs_owner_ctx, this_cpu) = &x86_init_fpu;
> + x86_init_fpu.last_cpu = this_cpu;
> + }

Can't x86_init_fpu be declared inside the block above?

> void __init fpu__init_system(void)
> {
> - fpstate_reset(&current->thread.fpu);
> fpu__init_system_early_generic();
> + fpstate_reset(current->thread.fpu);

It seems that fpstate_reset(current->thread.fpu) is not needed after the
change in fpu__init_system_early_generic() above.

Oleg.