Move ARCH specific fpu_counter out of task_struct
Subsystems (4)
cover Move ARCH specific fpu_counter out of task_struct
Hi,
This is a resend of the patches I sent last week which failed to draw any attention.
This basically came up when ARC SMP 3.11 failed to build due to a ST insn dealing with task_struct.thread going out of range.
When staring at code I spotted @fpu_counter in task_struct which only SH/x86 happen to use, and can be easily moved out into corresponding ARCH specific thread_struct. This saves 4 bytes per task_struct instantiated, for all the other 18 arches.
One of the resistance to the patch(es) could be that task_struct fields were at some point arranged to reduce the number of line misses. However there is lot of variance there due to so many #ifdefs, variable size of cpumask (>32 cores..) etc, so that argument alone might not be sufficient vs. saving 4 bytes per instance.
Comments please !
Thx,
-Vineet
Vineet Gupta (3):
sh: Move fpu_counter into ARCH specific thread_struct
x86: Move fpu_counter into ARCH specific thread_struct
sched: Remove ARCH specific fpu_counter from task_struct
arch/sh/include/asm/fpu.h | 2 +- arch/sh/include/asm/processor_32.h | 10 ++++++++++ arch/sh/include/asm/processor_64.h | 10 ++++++++++ arch/sh/kernel/cpu/fpu.c | 2 +- arch/sh/kernel/process_32.c | 6 +++--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- include/linux/sched.h | 9 --------- 12 files changed, 44 insertions(+), 24 deletions(-)
Signature · 1 line
1.8.1.2
RFC PATCH 1/3 sh: 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 sh defconfig + sh4-linux-gcc (4.6.3)
--- arch/sh/include/asm/fpu.h | 2 +- arch/sh/include/asm/processor_32.h | 10 ++++++++++ arch/sh/include/asm/processor_64.h | 10 ++++++++++ arch/sh/kernel/cpu/fpu.c | 2 +- arch/sh/kernel/process_32.c | 6 +++--- 5 files changed, 25 insertions(+), 5 deletions(-)
arch/sh/include/asm/fpu.h +1 -1
@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)save_fpu (tsk);release_fpu (regs); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ; }static inline void unlazy_fpu (struct task_struct *tsk,struct pt_regs *regs)
arch/sh/include/asm/processor_32.h +10 -0
@@ -111,6 +111,16 @@ struct thread_struct {/* Extended processor state */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_THREAD { \
arch/sh/include/asm/processor_64.h +10 -0
@@ -126,6 +126,16 @@ struct thread_struct {/* floating point info */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_MMAP \
arch/sh/kernel/cpu/fpu.c +1 -1
@@ -44,7 +44,7 @@ void __fpu_state_restore(void)restore_fpu (tsk);task_thread_info (tsk)->status |=TS_USEDFPU ; - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }void fpu_state_restore (struct pt_regs *regs)
arch/sh/kernel/process_32.c +3 -3
@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,#endif ti->addr_limit =KERNEL_DS ; ti->status &= ~TS_USEDFPU ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ;return 0 ; } *childregs = *current_pt_regs ();
@@ -189,7 +189,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)unlazy_fpu (prev,task_pt_regs (prev));/* we're going to use this soon, after a few expensive things */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )prefetch (next_t->xstate);#ifdef CONFIG_MMU
@@ -207,7 +207,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)* restore of the math state immediately to avoid the trap; the * chances of needing FPU soon are obviously high now */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )__fpu_state_restore ();return prev;
Signature · 1 line
1.8.1.2
Peter Zijlstra
maintainerRe: [RFC PATCH REBASED 1/3] sh: Move fpu_counter into ARCH specific thread_struct
Quoted 6 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested sh defconfig + sh4-linux-gcc (4.6.3)
Quoted 14 lines
Signed-off-by Vineet Gupta <[email protected]>Cc Paul Mundt <[email protected]>Cc Michel Lespinasse <[email protected]>Cc Kuninori Morimoto <[email protected]>Cc Al Viro <[email protected]>Cc Andrew Morton <[email protected]>Cc Jesper Nilsson <[email protected]>Cc Chris Metcalf <[email protected]>Cc "David S. Miller" <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>
Your mailer didn't actually pick up any of those and I'm sure Paul Mundt would love to see patches to his arch land in his Inbox.. Added him to CC.
Quoted 110 lines
--- arch/sh/include/asm/fpu.h | 2 +- arch/sh/include/asm/processor_32.h | 10 ++++++++++ arch/sh/include/asm/processor_64.h | 10 ++++++++++ arch/sh/kernel/cpu/fpu.c | 2 +- arch/sh/kernel/process_32.c | 6 +++--- 5 files changed, 25 insertions(+), 5 deletions(-)arch/sh/include/asm/fpu.h +1
-1@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)save_fpu (tsk);release_fpu (regs); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ; }static inline void unlazy_fpu (struct task_struct *tsk,struct pt_regs *regs)arch/sh/include/asm/processor_32.h +10
-0@@ -111,6 +111,16 @@ struct thread_struct {/* Extended processor state */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_THREAD { \arch/sh/include/asm/processor_64.h +10
-0@@ -126,6 +126,16 @@ struct thread_struct {/* floating point info */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_MMAP \arch/sh/kernel/cpu/fpu.c +1
-1@@ -44,7 +44,7 @@ void __fpu_state_restore(void)restore_fpu (tsk);task_thread_info (tsk)->status |=TS_USEDFPU ; - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }void fpu_state_restore (struct pt_regs *regs)arch/sh/kernel/process_32.c +3
-3@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,#endif ti->addr_limit =KERNEL_DS ; ti->status &= ~TS_USEDFPU ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ;return 0 ; } *childregs = *current_pt_regs ();@@ -189,7 +189,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)unlazy_fpu (prev,task_pt_regs (prev));/* we're going to use this soon, after a few expensive things */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )prefetch (next_t->xstate);#ifdef CONFIG_MMU @@ -207,7 +207,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)* restore of the math state immediately to avoid the trap; the * chances of needing FPU soon are obviously high now */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )__fpu_state_restore ();return prev;Signature · 1 line
1.8.1.2
Re: [RFC PATCH REBASED 1/3] sh: Move fpu_counter into ARCH specific thread_struct
On 09/17/2013 01:30 PM, Peter Zijlstra wrote:
On Tue, Sep 17, 2013 at 11:47:17AM +0530, Vineet Gupta wrote:
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 sh defconfig + sh4-linux-gcc (4.6.3)
Your mailer didn't actually pick up any of those and I'm sure Paul Mundt would love to see patches to his arch land in his Inbox.. Added him to CC.
Thx.
For some reason the email to Paul bounced last time as well
--------------->8----------------------- [email protected]<mailto:[email protected]>>: host mail.linux-sh.org[111.68.239.195] said: 550 5.7.1
<[email protected]><mailto:[email protected]>... Relaying denied. Proper authentication required. (in reply to RCPT TO command)
--------------->8-----------------------
Did you get that too after sending this CCed email to him.
And that in turns causes some weirdness with git send-email ignoring all the CCs in individual patches - weird !
-Vineet
Peter Zijlstra
maintainerRe: [RFC PATCH REBASED 1/3] sh: Move fpu_counter into ARCH specific thread_struct
Quoted 9 lines · Vineet Gupta
For some reason the email to Paul bounced last time as well
--------------->8----------------------- [email protected]<mailto:[email protected]>>: host mail.linux-sh.org[111.68.239.195] said: 550 5.7.1
<[email protected]><mailto:[email protected]>... Relaying denied. Proper authentication required. (in reply to RCPT TO command)
--------------->8-----------------------Did you get that too after sending this CCed email to him.
Yep.. :/
Re: [RFC PATCH REBASED 1/3] sh: Move fpu_counter into ARCH specific thread_struct
In reply to Vineet GuptaHi Paul/SH folks.
Would appreciate your ACK/NAK on this.
Thx,
-Vineet
Quoted 128 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested sh defconfig + sh4-linux-gcc (4.6.3)
Signed-off-by Vineet Gupta <[email protected]>Cc Paul Mundt <[email protected]>Cc Michel Lespinasse <[email protected]>Cc Kuninori Morimoto <[email protected]>Cc Al Viro <[email protected]>Cc Andrew Morton <[email protected]>Cc Jesper Nilsson <[email protected]>Cc Chris Metcalf <[email protected]>Cc "David S. Miller" <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>--- arch/sh/include/asm/fpu.h | 2 +- arch/sh/include/asm/processor_32.h | 10 ++++++++++ arch/sh/include/asm/processor_64.h | 10 ++++++++++ arch/sh/kernel/cpu/fpu.c | 2 +- arch/sh/kernel/process_32.c | 6 +++--- 5 files changed, 25 insertions(+), 5 deletions(-)arch/sh/include/asm/fpu.h +1
-1@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)save_fpu (tsk);release_fpu (regs); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ; }static inline void unlazy_fpu (struct task_struct *tsk,struct pt_regs *regs)arch/sh/include/asm/processor_32.h +10
-0@@ -111,6 +111,16 @@ struct thread_struct {/* Extended processor state */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_THREAD { \arch/sh/include/asm/processor_64.h +10
-0@@ -126,6 +126,16 @@ struct thread_struct {/* floating point info */ union thread_xstate *xstate; + +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };#define INIT_MMAP \arch/sh/kernel/cpu/fpu.c +1
-1@@ -44,7 +44,7 @@ void __fpu_state_restore(void)restore_fpu (tsk);task_thread_info (tsk)->status |=TS_USEDFPU ; - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }void fpu_state_restore (struct pt_regs *regs)arch/sh/kernel/process_32.c +3
-3@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,#endif ti->addr_limit =KERNEL_DS ; ti->status &= ~TS_USEDFPU ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ;return 0 ; } *childregs = *current_pt_regs ();@@ -189,7 +189,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)unlazy_fpu (prev,task_pt_regs (prev));/* we're going to use this soon, after a few expensive things */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )prefetch (next_t->xstate);#ifdef CONFIG_MMU @@ -207,7 +207,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)* restore of the math state immediately to avoid the trap; the * chances of needing FPU soon are obviously high now */ -if (next->fpu_counter >5 ) +if (next->thread.fpu_counter >5 )__fpu_state_restore ();return prev;
RFC PATCH 2/3 x86: Move fpu_counter into ARCH specific thread_struct
In reply to Vineet GuptaOnly 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
--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)
arch/x86/include/asm/fpu-internal.h +5 -5
@@ -365,7 +365,7 @@ static inline void drop_fpu(struct task_struct *tsk)* Forget coprocessor state.. */ preempt_disable (); - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;__drop_fpu (tsk);clear_used_math ();preempt_enable ();
@@ -424,7 +424,7 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta* or if the past 5 consecutive context-switches used math. */ fpu.preload =tsk_used_math (new) && (use_eager_fpu () || - new->fpu_counter >5 ); + new->thread.fpu_counter >5 );if (__thread_has_fpu (old)) {if (!__save_init_fpu (old)) cpu = ~0 ;
@@ -433,16 +433,16 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta/* Don't change CR0.TS if we just switch! */ if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;__thread_set_has_fpu (new);prefetch (new->thread.fpu.state); }else if (!use_eager_fpu ())stts (); }else { - old->fpu_counter =0 ; + old->thread.fpu_counter =0 ; old->thread.fpu.last_cpu = ~0 ;if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;if (!use_eager_fpu () &&fpu_lazy_restore (new, cpu)) fpu.preload =0 ;else
arch/x86/include/asm/processor.h +9 -0
@@ -488,6 +488,15 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };/*
arch/x86/kernel/i387.c +1 -1
@@ -100,7 +100,7 @@ void unlazy_fpu(struct task_struct *tsk)__save_init_fpu (tsk);__thread_fpu_end (tsk); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;preempt_enable (); }EXPORT_SYMBOL (unlazy_fpu);
arch/x86/kernel/process_32.c +2 -2
@@ -153,7 +153,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->orig_ax =-1 ; childregs->cs = __KERNEL_CS |get_kernel_rpl (); childregs->flags =X86_EFLAGS_IF |X86_EFLAGS_FIXED ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));return 0 ;
@@ -166,7 +166,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.ip = (unsigned long ) ret_from_fork;task_user_gs (p) =get_user_gs (current_pt_regs ()); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ; tsk = current; err = -ENOMEM ;
arch/x86/kernel/process_64.c +1 -1
@@ -163,7 +163,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.sp = (unsigned long ) childregs; p->thread.usersp = me->thread.usersp;set_tsk_thread_flag (p,TIF_FORK ); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;savesegment (gs, p->thread.gsindex);
arch/x86/kernel/traps.c +1 -1
@@ -653,7 +653,7 @@ void math_state_restore(void)return ; } - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }EXPORT_SYMBOL_GPL (math_state_restore);
Signature · 1 line
1.8.1.2
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
[+cc: x86 folks] as the mailer skipped the CC list.
Quoted 157 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)arch/x86/include/asm/fpu-internal.h +5
-5@@ -365,7 +365,7 @@ static inline void drop_fpu(struct task_struct *tsk)* Forget coprocessor state.. */ preempt_disable (); - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;__drop_fpu (tsk);clear_used_math ();preempt_enable ();@@ -424,7 +424,7 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta* or if the past 5 consecutive context-switches used math. */ fpu.preload =tsk_used_math (new) && (use_eager_fpu () || - new->fpu_counter >5 ); + new->thread.fpu_counter >5 );if (__thread_has_fpu (old)) {if (!__save_init_fpu (old)) cpu = ~0 ;@@ -433,16 +433,16 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta/* Don't change CR0.TS if we just switch! */ if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;__thread_set_has_fpu (new);prefetch (new->thread.fpu.state); }else if (!use_eager_fpu ())stts (); }else { - old->fpu_counter =0 ; + old->thread.fpu_counter =0 ; old->thread.fpu.last_cpu = ~0 ;if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;if (!use_eager_fpu () &&fpu_lazy_restore (new, cpu)) fpu.preload =0 ;else arch/x86/include/asm/processor.h +9
-0@@ -488,6 +488,15 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };/* arch/x86/kernel/i387.c +1
-1@@ -100,7 +100,7 @@ void unlazy_fpu(struct task_struct *tsk)__save_init_fpu (tsk);__thread_fpu_end (tsk); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;preempt_enable (); }EXPORT_SYMBOL (unlazy_fpu);arch/x86/kernel/process_32.c +2
-2@@ -153,7 +153,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->orig_ax =-1 ; childregs->cs = __KERNEL_CS |get_kernel_rpl (); childregs->flags =X86_EFLAGS_IF |X86_EFLAGS_FIXED ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));return 0 ;@@ -166,7 +166,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.ip = (unsigned long ) ret_from_fork;task_user_gs (p) =get_user_gs (current_pt_regs ()); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ; tsk = current; err = -ENOMEM ;arch/x86/kernel/process_64.c +1
-1@@ -163,7 +163,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.sp = (unsigned long ) childregs; p->thread.usersp = me->thread.usersp;set_tsk_thread_flag (p,TIF_FORK ); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;savesegment (gs, p->thread.gsindex);arch/x86/kernel/traps.c +1
-1@@ -653,7 +653,7 @@ void math_state_restore(void)return ; } - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }EXPORT_SYMBOL_GPL (math_state_restore);
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
Quoted 154 lines · Vineet Gupta
[+cc: x86 folks] as the mailer skipped the CC list.
Quoted 151 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)arch/x86/include/asm/fpu-internal.h +5
-5@@ -365,7 +365,7 @@ static inline void drop_fpu(struct task_struct *tsk)* Forget coprocessor state.. */ preempt_disable (); - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;__drop_fpu (tsk);clear_used_math ();preempt_enable ();@@ -424,7 +424,7 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta* or if the past 5 consecutive context-switches used math. */ fpu.preload =tsk_used_math (new) && (use_eager_fpu () || - new->fpu_counter >5 ); + new->thread.fpu_counter >5 );if (__thread_has_fpu (old)) {if (!__save_init_fpu (old)) cpu = ~0 ;@@ -433,16 +433,16 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta/* Don't change CR0.TS if we just switch! */ if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;__thread_set_has_fpu (new);prefetch (new->thread.fpu.state); }else if (!use_eager_fpu ())stts (); }else { - old->fpu_counter =0 ; + old->thread.fpu_counter =0 ; old->thread.fpu.last_cpu = ~0 ;if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;if (!use_eager_fpu () &&fpu_lazy_restore (new, cpu)) fpu.preload =0 ;else arch/x86/include/asm/processor.h +9
-0@@ -488,6 +488,15 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };/* arch/x86/kernel/i387.c +1
-1@@ -100,7 +100,7 @@ void unlazy_fpu(struct task_struct *tsk)__save_init_fpu (tsk);__thread_fpu_end (tsk); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;preempt_enable (); }EXPORT_SYMBOL (unlazy_fpu);arch/x86/kernel/process_32.c +2
-2@@ -153,7 +153,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->orig_ax =-1 ; childregs->cs = __KERNEL_CS |get_kernel_rpl (); childregs->flags =X86_EFLAGS_IF |X86_EFLAGS_FIXED ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));return 0 ;@@ -166,7 +166,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.ip = (unsigned long ) ret_from_fork;task_user_gs (p) =get_user_gs (current_pt_regs ()); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ; tsk = current; err = -ENOMEM ;arch/x86/kernel/process_64.c +1
-1@@ -163,7 +163,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.sp = (unsigned long ) childregs; p->thread.usersp = me->thread.usersp;set_tsk_thread_flag (p,TIF_FORK ); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;savesegment (gs, p->thread.gsindex);arch/x86/kernel/traps.c +0
-0@@ -653,7 +653,7 @@ void math_state_restore(void)return ; }
Quoted 7 lines
arch/x86/kernel/traps.c void math_state_restore(void) · line 659
Quoted 6 lines
arch/x86/kernel/traps.c +1
-1- tsk->fpu_counter++; + tsk->thread.fpu_counter++; }EXPORT_SYMBOL_GPL (math_state_restore);
Comments please ! Can I get ACK/NAK on this while waiting for SH folks to respond on a similar change. It seems a straightforward mechanical change !
-Vineet
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
In reply to Vineet GuptaQuoted 1 line · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it
Wouldn't it make sense to also have the arch/sh changes here in this same commit then, rather than breaking their build?
Paul.
--
Quoted 156 lines
can be moved out into ARCH specific
thread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)arch/x86/include/asm/fpu-internal.h +5
-5@@ -365,7 +365,7 @@ static inline void drop_fpu(struct task_struct *tsk)* Forget coprocessor state.. */ preempt_disable (); - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;__drop_fpu (tsk);clear_used_math ();preempt_enable ();@@ -424,7 +424,7 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta* or if the past 5 consecutive context-switches used math. */ fpu.preload =tsk_used_math (new) && (use_eager_fpu () || - new->fpu_counter >5 ); + new->thread.fpu_counter >5 );if (__thread_has_fpu (old)) {if (!__save_init_fpu (old)) cpu = ~0 ;@@ -433,16 +433,16 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta/* Don't change CR0.TS if we just switch! */ if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;__thread_set_has_fpu (new);prefetch (new->thread.fpu.state); }else if (!use_eager_fpu ())stts (); }else { - old->fpu_counter =0 ; + old->thread.fpu_counter =0 ; old->thread.fpu.last_cpu = ~0 ;if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;if (!use_eager_fpu () &&fpu_lazy_restore (new, cpu)) fpu.preload =0 ;else arch/x86/include/asm/processor.h +9
-0@@ -488,6 +488,15 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };/* arch/x86/kernel/i387.c +1
-1@@ -100,7 +100,7 @@ void unlazy_fpu(struct task_struct *tsk)__save_init_fpu (tsk);__thread_fpu_end (tsk); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;preempt_enable (); }EXPORT_SYMBOL (unlazy_fpu);arch/x86/kernel/process_32.c +2
-2@@ -153,7 +153,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->orig_ax =-1 ; childregs->cs = __KERNEL_CS |get_kernel_rpl (); childregs->flags =X86_EFLAGS_IF |X86_EFLAGS_FIXED ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));return 0 ;@@ -166,7 +166,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.ip = (unsigned long ) ret_from_fork;task_user_gs (p) =get_user_gs (current_pt_regs ()); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ; tsk = current; err = -ENOMEM ;arch/x86/kernel/process_64.c +1
-1@@ -163,7 +163,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.sp = (unsigned long ) childregs; p->thread.usersp = me->thread.usersp;set_tsk_thread_flag (p,TIF_FORK ); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;savesegment (gs, p->thread.gsindex);arch/x86/kernel/traps.c +1
-1@@ -653,7 +653,7 @@ void math_state_restore(void)return ; } - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }EXPORT_SYMBOL_GPL (math_state_restore);
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
Quoted 5 lines · Paul Gortmaker
Quoted 1 line · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso itWouldn't it make sense to also have the
arch/shchanges here in this same commit then, rather than breaking their build?
Ah, nevermind; I didn't immediately notice that the removal from task_struct wasn't done in this patch, since I only was Cc'd on 2/3.
Thanks,
P.
--
Quoted 160 lines
Paul.
--Quoted 156 lines
can be moved out into ARCH specific
thread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)arch/x86/include/asm/fpu-internal.h +5
-5@@ -365,7 +365,7 @@ static inline void drop_fpu(struct task_struct *tsk)* Forget coprocessor state.. */ preempt_disable (); - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;__drop_fpu (tsk);clear_used_math ();preempt_enable ();@@ -424,7 +424,7 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta* or if the past 5 consecutive context-switches used math. */ fpu.preload =tsk_used_math (new) && (use_eager_fpu () || - new->fpu_counter >5 ); + new->thread.fpu_counter >5 );if (__thread_has_fpu (old)) {if (!__save_init_fpu (old)) cpu = ~0 ;@@ -433,16 +433,16 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta/* Don't change CR0.TS if we just switch! */ if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;__thread_set_has_fpu (new);prefetch (new->thread.fpu.state); }else if (!use_eager_fpu ())stts (); }else { - old->fpu_counter =0 ; + old->thread.fpu_counter =0 ; old->thread.fpu.last_cpu = ~0 ;if (fpu.preload) { - new->fpu_counter++; + new->thread.fpu_counter++;if (!use_eager_fpu () &&fpu_lazy_restore (new, cpu)) fpu.preload =0 ;else arch/x86/include/asm/processor.h +9
-0@@ -488,6 +488,15 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter; };/* arch/x86/kernel/i387.c +1
-1@@ -100,7 +100,7 @@ void unlazy_fpu(struct task_struct *tsk)__save_init_fpu (tsk);__thread_fpu_end (tsk); }else - tsk->fpu_counter =0 ; + tsk->thread.fpu_counter =0 ;preempt_enable (); }EXPORT_SYMBOL (unlazy_fpu);arch/x86/kernel/process_32.c +2
-2@@ -153,7 +153,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->orig_ax =-1 ; childregs->cs = __KERNEL_CS |get_kernel_rpl (); childregs->flags =X86_EFLAGS_IF |X86_EFLAGS_FIXED ; - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));return 0 ;@@ -166,7 +166,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.ip = (unsigned long ) ret_from_fork;task_user_gs (p) =get_user_gs (current_pt_regs ()); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ; tsk = current; err = -ENOMEM ;arch/x86/kernel/process_64.c +1
-1@@ -163,7 +163,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.sp = (unsigned long ) childregs; p->thread.usersp = me->thread.usersp;set_tsk_thread_flag (p,TIF_FORK ); - p->fpu_counter =0 ; + p->thread.fpu_counter =0 ; p->thread.io_bitmap_ptr =NULL ;savesegment (gs, p->thread.gsindex);arch/x86/kernel/traps.c +1
-1@@ -653,7 +653,7 @@ void math_state_restore(void)return ; } - tsk->fpu_counter++; + tsk->thread.fpu_counter++; }EXPORT_SYMBOL_GPL (math_state_restore);
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
In reply to Vineet GuptaQuoted 24 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>
Quoted 8 lines
--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)
Thanks,
Ingo
Re: [RFC PATCH REBASED 2/3] x86: Move fpu_counter into ARCH specific thread_struct
Hi Ingo,
Quoted 36 lines · Ingo Molnar
Quoted 24 lines · Vineet Gupta
Only a couple of arches (sh/x86) use
fpu_counterintask_structso it can be moved out into ARCH specificthread_struct, reducing the size oftask_structfor other arches.Compile tested
i386_defconfig+ gcc 4.7.3Signed-off-by Vineet Gupta <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Suresh Siddha <[email protected]>Cc Borislav Petkov <[email protected]>Cc Vincent Palatin <[email protected]>Cc Len Brown <[email protected]>Cc Al Viro <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Pekka Riikonen <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Jones <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "Paul E. McKenney" <[email protected]>Quoted 8 lines
--- arch/x86/include/asm/fpu-internal.h | 10 +++++----- arch/x86/include/asm/processor.h | 9 +++++++++ arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/process_32.c | 4 ++-- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/traps.c | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-)
Quoted 6 lines
Acked-by Ingo Molnar <[email protected]>Thanks,
Ingo
We are still at girdlock here because linux-sh mailing list seems be /dev/null, while email to Paul Mundt kept bouncing.
I tried to contact someone in SuperH community, via the superH Linux portal - and got this.
-------------->8--------------
Vineet
Unfortunately Paul Mundt is no longer work for Renesas and SuperH Linux. Maybe he intentionally shutdown his e-mail server. So this is not a simple server problem. Very sorry for your inconvenience. -------------->8--------------
So do you think it would appropriate to take this patch series anyways. For last several months none of the cross-arch sweeping patches have had any ACK's from them plus this is a straight forward mechanical change.
-Vineet
RFC PATCH 3/3 sched: Remove ARCH specific fpu_counter from task_struct
In reply to Vineet Guptafpu_counter in task_struct was used only by sh/x86.
Both of these now carry it in ARCH specific thread_struct, hence this can now be removed from generic task_struct, shrinking it slightly for other arches.
--- include/linux/sched.h | 9 --------- 1 file changed, 9 deletions(-)
include/linux/sched.h +0 -9
@@ -1046,15 +1046,6 @@ struct task_struct {struct hlist_head preempt_notifiers;#endif -/* -* fpu_counter contains the number of consecutive context switches -* that the FPU is used. If this is over a threshold, the lazy fpu -* saving becomes unlazy to save the trap. This is an unsigned char -* so that after 256 times the counter wraps and the behavior turns -* lazy again; this to deal with bursty apps that only use FPU for -* a short time -*/ -unsigned char fpu_counter;#ifdef CONFIG_BLK_DEV_IO_TRACE unsigned int btrace_seq;#endif
Signature · 1 line
1.8.1.2