Re: [PATCH 3/9] x86/fpu: Make task_struct::thread constant size

From: Oleg Nesterov
Date: Tue Jun 11 2024 - 08:44:08 EST


I don't think this can explain the problem reported by Nathan, but.

On 06/08, Ingo Molnar wrote:
>
> +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;

OK,

> + per_cpu(fpu_fpregs_owner_ctx, this_cpu) = &x86_init_fpu;
> + x86_init_fpu.last_cpu = this_cpu;

Why? I think it should do

x86_init_fpu.last_cpu = -1;
set_thread_flag(TIF_NEED_FPU_LOAD);

And the next patch should kill x86_init_fpu altogether, but keep
TIF_NEED_FPU_LOAD. It should be never cleared if PF_KTHREAD.

Oleg.