Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158715
b: refs/heads/master
c: 17950c5
h: refs/heads/master
i:
  158713: 4f0364b
  158711: 5b204d5
v: v3
  • Loading branch information
Jeremy Fitzhardinge committed Jun 17, 2009
1 parent 2ba4d5f commit f92a725
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 16d9dbf0c2bd167fdd942b83592d59696c7b73bd
refs/heads/master: 17950c5b243f99cbabef173415ee988c52104d7e
27 changes: 18 additions & 9 deletions trunk/arch/x86/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,17 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
int cpu = smp_processor_id();
struct tss_struct *tss = &per_cpu(init_tss, cpu);
unsigned fsindex, gsindex;
bool preload_fpu;

/*
* If the task has used fpu the last 5 timeslices, just do a full
* restore of the math state immediately to avoid the trap; the
* chances of needing FPU soon are obviously high now
*/
preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;

/* we're going to use this soon, after a few expensive things */
if (next_p->fpu_counter > 5)
if (preload_fpu)
prefetch(next->xstate);

/*
Expand Down Expand Up @@ -422,6 +430,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
/* Must be after DS reload */
unlazy_fpu(prev_p);

/* Make sure cpu is ready for new context */
if (preload_fpu)
clts();

/*
* Leave lazy mode, flushing any hypercalls made here.
* This must be done before restoring TLS segments so
Expand Down Expand Up @@ -480,15 +492,12 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
__switch_to_xtra(prev_p, next_p, tss);

/* If the task has used fpu the last 5 timeslices, just do a full
* restore of the math state immediately to avoid the trap; the
* chances of needing FPU soon are obviously high now
*
* tsk_used_math() checks prevent calling math_state_restore(),
* which can sleep in the case of !tsk_used_math()
/*
* Preload the FPU context, now that we've determined that the
* task is likely to be using it.
*/
if (tsk_used_math(next_p) && next_p->fpu_counter > 5)
math_state_restore();
if (preload_fpu)
__math_state_restore();
return prev_p;
}

Expand Down

0 comments on commit f92a725

Please sign in to comment.