Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158713
b: refs/heads/master
c: 2fcddce
h: refs/heads/master
i:
  158711: 5b204d5
v: v3
  • Loading branch information
Jeremy Fitzhardinge committed Jun 17, 2009
1 parent d803b3f commit 4f0364b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 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: e6e9cac8c3417b43498b243c1f8f11780e157168
refs/heads/master: 2fcddce10f6771cfa0c56fd1e826d50d67d100b7
27 changes: 16 additions & 11 deletions trunk/arch/x86/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,21 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
*next = &next_p->thread;
int cpu = smp_processor_id();
struct tss_struct *tss = &per_cpu(init_tss, cpu);
bool preload_fpu;

/* never put a printk in __switch_to... printk() calls wake_up*() indirectly */

__unlazy_fpu(prev_p);
/*
* 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;

__unlazy_fpu(prev_p);

/* 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 @@ -398,6 +405,11 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT))
__switch_to_xtra(prev_p, next_p, tss);

/* If we're going to preload the fpu context, make sure clts
is run while we're batching the cpu state updates. */
if (preload_fpu)
clts();

/*
* Leave lazy mode, flushing any hypercalls made here.
* This must be done before restoring TLS segments so
Expand All @@ -407,15 +419,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
*/
arch_end_context_switch(next_p);

/* 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()
*/
if (tsk_used_math(next_p) && next_p->fpu_counter > 5)
math_state_restore();
if (preload_fpu)
__math_state_restore();

/*
* Restore %gs if needed (which is common)
Expand Down

0 comments on commit 4f0364b

Please sign in to comment.