per_cpu(fpu_fpregs_owner_ctx, cpu) = NULL;
}
-/*
- * Used to indicate that the FPU state in memory is newer than the FPU
- * state in registers, and the FPU state should be reloaded next time the
- * task is run. Only safe on the current task, or non-running tasks.
- */
-static inline void task_disable_lazy_fpu_restore(struct task_struct *tsk)
-{
- tsk->thread.fpu.last_cpu = ~0;
-}
-
static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu)
{
return &new->thread.fpu == this_cpu_read_stable(fpu_fpregs_owner_ctx) &&
if (old_fpu->has_fpu) {
if (!fpu_save_init(&old->thread.fpu))
- task_disable_lazy_fpu_restore(old);
+ old->thread.fpu.last_cpu = -1;
else
old->thread.fpu.last_cpu = cpu;
stts();
} else {
old->thread.fpu.counter = 0;
- task_disable_lazy_fpu_restore(old);
+ old->thread.fpu.last_cpu = -1;
if (fpu.preload) {
new->thread.fpu.counter++;
if (fpu_lazy_restore(new, cpu))
};
struct fpu {
+ /*
+ * Records the last CPU on which this context was loaded into
+ * FPU registers. (In the lazy-switching case we might be
+ * able to reuse FPU registers across multiple context switches
+ * this way, if no intermediate task used the FPU.)
+ *
+ * A value of -1 is used to indicate that the FPU state in context
+ * memory is newer than the FPU state in registers, and that the
+ * FPU state should be reloaded next time the task is run.
+ */
unsigned int last_cpu;
+
unsigned int has_fpu;
union thread_xstate *state;
/*
dst->thread.fpu.counter = 0;
dst->thread.fpu.has_fpu = 0;
dst->thread.fpu.state = NULL;
-
- task_disable_lazy_fpu_restore(dst);
+ dst->thread.fpu.last_cpu = -1;
if (src_fpu->fpstate_active) {
int err = fpstate_alloc(dst_fpu);
return -EINVAL;
if (child_fpu->fpstate_active) {
- task_disable_lazy_fpu_restore(child);
+ child->thread.fpu.last_cpu = -1;
return 0;
}