Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 43008
b: refs/heads/master
c: acc2076
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Ebbert authored and Andi Kleen committed Dec 7, 2006
1 parent 23e9d19 commit 837412f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 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: be44d2aabce2d62f72d5751d1871b6212bf7a1c7
refs/heads/master: acc207616a91a413a50fdd8847a747c4a7324167
12 changes: 12 additions & 0 deletions trunk/arch/i386/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas

__unlazy_fpu(prev_p);


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

/*
* Reload esp0.
*/
Expand Down Expand Up @@ -697,6 +702,13 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas

disable_tsc(prev_p, 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
*/
if (next_p->fpu_counter > 5)
math_state_restore();

return prev_p;
}

Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/i386/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ fastcall unsigned long patch_espfix_desc(unsigned long uesp,
* Must be called with kernel preemption disabled (in this case,
* local interrupts are disabled at the call-site in entry.S).
*/
asmlinkage void math_state_restore(struct pt_regs regs)
asmlinkage void math_state_restore(void)
{
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = thread->task;
Expand All @@ -1128,6 +1128,7 @@ asmlinkage void math_state_restore(struct pt_regs regs)
init_fpu(tsk);
restore_fpu(tsk);
thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
tsk->fpu_counter++;
}

#ifndef CONFIG_MATH_EMULATION
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/asm-i386/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ static inline void __save_init_fpu( struct task_struct *tsk )

#define __unlazy_fpu( tsk ) do { \
if (task_thread_info(tsk)->status & TS_USEDFPU) \
save_init_fpu( tsk ); \
save_init_fpu( tsk ); \
else \
tsk->fpu_counter = 0; \
} while (0)

#define __clear_fpu( tsk ) \
Expand Down Expand Up @@ -118,6 +120,7 @@ static inline void save_init_fpu( struct task_struct *tsk )
extern unsigned short get_fpu_cwd( struct task_struct *tsk );
extern unsigned short get_fpu_swd( struct task_struct *tsk );
extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
extern asmlinkage void math_state_restore(void);

/*
* Signal frame handlers...
Expand Down

0 comments on commit 837412f

Please sign in to comment.