Skip to contentSkip to conversation

+ sh-move-fpu_counter-into-arch-specific-thread_struct.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Oct 10, 2013 SuperH

lore
Share & tools
lore
#0 lore raw

Subject: + sh-move-fpu_counter-into-arch-specific-thread_struct.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Thu, 10 Oct 2013 14:40:12 -0700

The patch titled
Subject: sh: move fpu_counter into ARCH specific thread_struct
has been added to the -mm tree. Its filename is
sh-move-fpu_counter-into-arch-specific-thread_struct.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/sh-move-fpu_counter-into-arch-specific-thread_struct.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/sh-move-fpu_counter-into-arch-specific-thread_struct.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Vineet Gupta <[email protected]>
Subject: 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 renamed from arch/sh/include/asm/fpu.h~sh-move-fpu_counter-into-arch-specific-thread_struct +1 -1
diff -puN arch/sh/include/asm/fpu.h~sh-move-fpu_counter-into-arch-specific-thread_struct arch/sh/include/asm/fpu.h
@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct t
 		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 renamed from arch/sh/include/asm/processor_32.h~sh-move-fpu_counter-into-arch-specific-thread_struct +10 -0
diff -puN arch/sh/include/asm/processor_32.h~sh-move-fpu_counter-into-arch-specific-thread_struct arch/sh/include/asm/processor_32.h
@@ -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 renamed from arch/sh/include/asm/processor_64.h~sh-move-fpu_counter-into-arch-specific-thread_struct +10 -0
diff -puN arch/sh/include/asm/processor_64.h~sh-move-fpu_counter-into-arch-specific-thread_struct arch/sh/include/asm/processor_64.h
@@ -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 renamed from arch/sh/kernel/cpu/fpu.c~sh-move-fpu_counter-into-arch-specific-thread_struct +1 -1
diff -puN arch/sh/kernel/cpu/fpu.c~sh-move-fpu_counter-into-arch-specific-thread_struct arch/sh/kernel/cpu/fpu.c
@@ -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 renamed from arch/sh/kernel/process_32.c~sh-move-fpu_counter-into-arch-specific-thread_struct +3 -3
diff -puN arch/sh/kernel/process_32.c~sh-move-fpu_counter-into-arch-specific-thread_struct arch/sh/kernel/process_32.c
@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flag
 #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, st
 	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, st
 	 * 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;

_

Patches currently in -mm which might be from [email protected] are

sh-move-fpu_counter-into-arch-specific-thread_struct.patch x86-move-fpu_counter-into-arch-specific-thread_struct.patch sched-remove-arch-specific-fpu_counter-from-task_struct.patch