Re: [PATCH 3/3, v4] x86/fpu: Remove init_task FPU state dependencies, add debugging warning for PF_KTHREAD tasks

From: Ingo Molnar
Date: Fri Jun 07 2024 - 06:57:01 EST



* Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> On 06/06, Ingo Molnar wrote:
> >
> > I changed the debug check to test for PF_KTHREAD, and to return NULL:
> >
> > +#ifdef CONFIG_X86_DEBUG_FPU
> > +struct fpu *x86_task_fpu(struct task_struct *task)
> > +{
> > + if (WARN_ON_ONCE(task->flags & PF_KTHREAD))
> > + return NULL;
> > +
> > + return (void *)task + sizeof(*task);
> > +}
> > +#endif
>
> How many users enable CONFIG_X86_DEBUG_FPU?

Ubuntu does:

kepler:~/tip> grep X86_DEBUG_FPU /boot/config-6.*
/boot/config-6.8.0-35-generic:CONFIG_X86_DEBUG_FPU=y

Fedora doesn't:

kepler:~/s/tmp> grep X86_DEBUG_FPU ./lib/modules/6.9.0-64.fc41.x86_64/config
# CONFIG_X86_DEBUG_FPU is not set

So it's a bit of a hit and miss, but at least one major distribution does,
which is all that we need really.

> [...] Perhaps it makes sense to check PF_KTHREAD unconditionally for the
> start, them add if (IS_ENABLED(X86_DEBUG_FPU)). But I won't insist.

I think Ubuntu ought to add enough debug coverage - and this check isn't
exactly cheap, given how it replaces a simple build time structure offset
with a full-blown function call ...

> For the record, I think we can later change this code to check
>
> task->flags & (PF_KTHREAD | PF_USER_WORKER)
>
> but I guess this needs some (simple) changes in the ptrace/coredump
> paths.

Sounds useful, would you be interested in cooking up a series on top of
tip:master (or tip:WIP.x86/fpu), if you are interested and have the time?

I'll send out one last iteration of this series today, otherwise the
changes seem close to final for an upstream merge via the tip:x86/fpu tree.

Thanks,

Ingo