Re: [PATCH 6/9] x86/fpu: Make sure x86_task_fpu() doesn't get called for PF_KTHREAD tasks during exit
From: Oleg Nesterov
Date: Mon Jun 10 2024 - 06:03:34 EST
The whole series looks good to me, and afaics 7/9 allows more
cleanups / improvements.
But let me ask a stupid question about fpu__drop(), I know nothing
about fpu asm.
fpu__drop() does
/* Ignore delayed exceptions from user space */
asm volatile("1: fwait\n"
and this comment predates the git history. Could someone explain
why exactly the exiting user-space thread needs fwait ?
And if it is needed, suppose that a kernel thread exits right
after kernel_fpu_end(), can this lead to the delayed exception?
And otoh, perhaps fpu__drop() can set TIF_NEED_FPU_LOAD to avoid
switch_fpu_prepare()->save_fpregs_to_fpstate() on its path to the
final schedule?
On 06/08, Ingo Molnar wrote:
>
> void fpu__drop(struct task_struct *tsk)
> {
> - struct fpu *fpu = x86_task_fpu(tsk);
> + struct fpu *fpu;
> +
> + /* PF_KTHREAD tasks do not use the FPU context area: */
> + if (tsk->flags & PF_KTHREAD)
> + return;
I think it can already do
if (tsk->flags & (PF_KTHREAD | PF_USER_WORKER))
return;
This matches other similar checks. But I won't insist, and I
think all these checks need some cleanups anyway.
Oleg.