Re: [PATCH 2/2] i387: support lazy restore of FPU state

From: Ingo Molnar
Date: Mon Feb 20 2012 - 02:51:29 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> +DECLARE_PER_CPU(struct task_struct *, fpu_owner_task);

> +static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu)
> +{
> + return new == percpu_read_stable(fpu_owner_task) &&
> + cpu == new->thread.fpu.last_cpu;
> +}

I guess the CPU hotplug case deserves a comment in the code: CPU
hotplug + replug of the same (but meanwhile reset) CPU is safe
because fpu_owner_task[cpu] gets reset to NULL.

Likewise, if we hot-unplug two CPUs and then insert the second
one, it's the same CPU index but not the same FPU state anymore.
There too the CPU hotplug code resetting fpu_owner_task to NULL
makes this optimization safe.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/