Commit c375f15a434db1867cb004bafba92aba739e4e39
Committed by
Linus Torvalds
1 parent
616c05d110
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
x86: move fpu_counter into ARCH specific thread_struct
Only a couple of arches (sh/x86) use fpu_counter in task_struct so it can be moved out into ARCH specific thread_struct, reducing the size of task_struct for other arches. Compile tested i386_defconfig + gcc 4.7.3 Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: Paul Mundt <paul.mundt@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 6 changed files with 19 additions and 10 deletions Side-by-side Diff
arch/x86/include/asm/fpu-internal.h
... | ... | @@ -365,7 +365,7 @@ |
365 | 365 | * Forget coprocessor state.. |
366 | 366 | */ |
367 | 367 | preempt_disable(); |
368 | - tsk->fpu_counter = 0; | |
368 | + tsk->thread.fpu_counter = 0; | |
369 | 369 | __drop_fpu(tsk); |
370 | 370 | clear_used_math(); |
371 | 371 | preempt_enable(); |
... | ... | @@ -424,7 +424,7 @@ |
424 | 424 | * or if the past 5 consecutive context-switches used math. |
425 | 425 | */ |
426 | 426 | fpu.preload = tsk_used_math(new) && (use_eager_fpu() || |
427 | - new->fpu_counter > 5); | |
427 | + new->thread.fpu_counter > 5); | |
428 | 428 | if (__thread_has_fpu(old)) { |
429 | 429 | if (!__save_init_fpu(old)) |
430 | 430 | cpu = ~0; |
431 | 431 | |
432 | 432 | |
... | ... | @@ -433,16 +433,16 @@ |
433 | 433 | |
434 | 434 | /* Don't change CR0.TS if we just switch! */ |
435 | 435 | if (fpu.preload) { |
436 | - new->fpu_counter++; | |
436 | + new->thread.fpu_counter++; | |
437 | 437 | __thread_set_has_fpu(new); |
438 | 438 | prefetch(new->thread.fpu.state); |
439 | 439 | } else if (!use_eager_fpu()) |
440 | 440 | stts(); |
441 | 441 | } else { |
442 | - old->fpu_counter = 0; | |
442 | + old->thread.fpu_counter = 0; | |
443 | 443 | old->thread.fpu.last_cpu = ~0; |
444 | 444 | if (fpu.preload) { |
445 | - new->fpu_counter++; | |
445 | + new->thread.fpu_counter++; | |
446 | 446 | if (!use_eager_fpu() && fpu_lazy_restore(new, cpu)) |
447 | 447 | fpu.preload = 0; |
448 | 448 | else |
arch/x86/include/asm/processor.h
... | ... | @@ -488,6 +488,15 @@ |
488 | 488 | unsigned long iopl; |
489 | 489 | /* Max allowed port in the bitmap, in bytes: */ |
490 | 490 | unsigned io_bitmap_max; |
491 | + /* | |
492 | + * fpu_counter contains the number of consecutive context switches | |
493 | + * that the FPU is used. If this is over a threshold, the lazy fpu | |
494 | + * saving becomes unlazy to save the trap. This is an unsigned char | |
495 | + * so that after 256 times the counter wraps and the behavior turns | |
496 | + * lazy again; this to deal with bursty apps that only use FPU for | |
497 | + * a short time | |
498 | + */ | |
499 | + unsigned char fpu_counter; | |
491 | 500 | }; |
492 | 501 | |
493 | 502 | /* |
arch/x86/kernel/i387.c
arch/x86/kernel/process_32.c
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | childregs->orig_ax = -1; |
154 | 154 | childregs->cs = __KERNEL_CS | get_kernel_rpl(); |
155 | 155 | childregs->flags = X86_EFLAGS_IF | X86_EFLAGS_FIXED; |
156 | - p->fpu_counter = 0; | |
156 | + p->thread.fpu_counter = 0; | |
157 | 157 | p->thread.io_bitmap_ptr = NULL; |
158 | 158 | memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps)); |
159 | 159 | return 0; |
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | p->thread.ip = (unsigned long) ret_from_fork; |
167 | 167 | task_user_gs(p) = get_user_gs(current_pt_regs()); |
168 | 168 | |
169 | - p->fpu_counter = 0; | |
169 | + p->thread.fpu_counter = 0; | |
170 | 170 | p->thread.io_bitmap_ptr = NULL; |
171 | 171 | tsk = current; |
172 | 172 | err = -ENOMEM; |
arch/x86/kernel/process_64.c
... | ... | @@ -163,7 +163,7 @@ |
163 | 163 | p->thread.sp = (unsigned long) childregs; |
164 | 164 | p->thread.usersp = me->thread.usersp; |
165 | 165 | set_tsk_thread_flag(p, TIF_FORK); |
166 | - p->fpu_counter = 0; | |
166 | + p->thread.fpu_counter = 0; | |
167 | 167 | p->thread.io_bitmap_ptr = NULL; |
168 | 168 | |
169 | 169 | savesegment(gs, p->thread.gsindex); |