diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2008-03-10 18:28:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-19 13:19:55 -0400 |
commit | aa283f49276e7d840a40fb01eee6de97eaa7e012 (patch) | |
tree | b17b134b174666e482b1a8ad486436a3d5cdb83e /arch/x86/kernel/traps_32.c | |
parent | 61c4628b538608c1a85211ed8438136adfeb9a95 (diff) |
x86, fpu: lazy allocation of FPU area - v5
Only allocate the FPU area when the application actually uses FPU, i.e., in the
first lazy FPU trap. This could save memory for non-fpu using apps.
for example: on my system after boot, there are around 300 processes, with
only 17 using FPU.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/traps_32.c')
-rw-r--r-- | arch/x86/kernel/traps_32.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 8d136a73ce8e..471e694d6713 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c | |||
@@ -1148,9 +1148,22 @@ asmlinkage void math_state_restore(void) | |||
1148 | struct thread_info *thread = current_thread_info(); | 1148 | struct thread_info *thread = current_thread_info(); |
1149 | struct task_struct *tsk = thread->task; | 1149 | struct task_struct *tsk = thread->task; |
1150 | 1150 | ||
1151 | if (!tsk_used_math(tsk)) { | ||
1152 | local_irq_enable(); | ||
1153 | /* | ||
1154 | * does a slab alloc which can sleep | ||
1155 | */ | ||
1156 | if (init_fpu(tsk)) { | ||
1157 | /* | ||
1158 | * ran out of memory! | ||
1159 | */ | ||
1160 | do_group_exit(SIGKILL); | ||
1161 | return; | ||
1162 | } | ||
1163 | local_irq_disable(); | ||
1164 | } | ||
1165 | |||
1151 | clts(); /* Allow maths ops (or we recurse) */ | 1166 | clts(); /* Allow maths ops (or we recurse) */ |
1152 | if (!tsk_used_math(tsk)) | ||
1153 | init_fpu(tsk); | ||
1154 | restore_fpu(tsk); | 1167 | restore_fpu(tsk); |
1155 | thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */ | 1168 | thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */ |
1156 | tsk->fpu_counter++; | 1169 | tsk->fpu_counter++; |