Skip to contentSkip to conversation

x86: optimize access to __ipipe_tick_regs

PATCH In review Jan Kiszka 2 participants 2 messages Dec 29, 2007 – Dec 30, 2007 x86

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/5 x86: optimize access to __ipipe_tick_regs

By intention, the compiler is not able to fold succeeding accesses to via __raw_get_cpu_var & friends into a single one. As we are in an atomic section in __ipipe_handle_irq, let's help him with a temporary variable, saving some text size in this hotpath.

Jan

---
 arch/x86/kernel/ipipe_32.c |    9 +++++----
 arch/x86/kernel/ipipe_64.c |   13 +++++++------
 2 files changed, 12 insertions(+), 10 deletions(-)
arch/x86/kernel/ipipe_32.c +5 -4
Index: linux-2.6.24-rc6-xeno/arch/x86/kernel/ipipe_32.c
===================================================================
@@ -771,10 +771,11 @@ finalize:
 	 * information. */
 
 	if (irq == __ipipe_tick_irq) {
-		__raw_get_cpu_var(__ipipe_tick_regs).eflags = regs.eflags;
-		__raw_get_cpu_var(__ipipe_tick_regs).eip = regs.eip;
-		__raw_get_cpu_var(__ipipe_tick_regs).xcs = regs.xcs;
-		__raw_get_cpu_var(__ipipe_tick_regs).ebp = regs.ebp;
+		struct pt_regs *tick_regs = &__raw_get_cpu_var(__ipipe_tick_regs);
+		tick_regs->eflags = regs.eflags;
+		tick_regs->xcs = regs.xcs;
+		tick_regs->eip = regs.eip;
+		tick_regs->ebp = regs.ebp;
 	}
 
 	/*
arch/x86/kernel/ipipe_64.c +7 -6
Index: linux-2.6.24-rc6-xeno/arch/x86/kernel/ipipe_64.c
===================================================================
@@ -751,12 +751,13 @@ int __ipipe_handle_irq(struct pt_regs *r
 finalize:
 
 	if (irq == __ipipe_tick_irq) {
-		__raw_get_cpu_var(__ipipe_tick_regs).rip = regs->rip;
-		__raw_get_cpu_var(__ipipe_tick_regs).cs = regs->cs;
-		__raw_get_cpu_var(__ipipe_tick_regs).eflags = regs->eflags;
-		__raw_get_cpu_var(__ipipe_tick_regs).rbp = regs->rbp;
-		__raw_get_cpu_var(__ipipe_tick_regs).rsp = regs->rsp;
-		__raw_get_cpu_var(__ipipe_tick_regs).ss = regs->ss;
+		struct pt_regs *tick_regs = &__raw_get_cpu_var(__ipipe_tick_regs);
+		tick_regs->ss = regs->ss;
+		tick_regs->rsp = regs->rsp;
+		tick_regs->eflags = regs->eflags;
+		tick_regs->cs = regs->cs;
+		tick_regs->rip = regs->rip;
+		tick_regs->rbp = regs->rbp;
 	}
 
 	/*
#1 lore raw
Quoted 5 lines · Jan Kiszka

By intention, the compiler is not able to fold succeeding accesses to via __raw_get_cpu_var & friends into a single one. As we are in an atomic section in __ipipe_handle_irq, let's help him with a temporary variable, saving some text size in this hotpath.

Will merge, thanks.

Signature · 1 line
Philippe.