]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
arm: optimized current_pt_regs()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 2 Aug 2012 07:49:43 +0000 (11:49 +0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 6 Sep 2012 17:57:23 +0000 (13:57 -0400)
... no need to read current_thread_info()->task only to
feed it to task_thread_page() immediately afterwards.
Moreover, not using current_thread_info() at all ends
up with better assembler - we need a location very close
to the top of kernel stack page and it's actually better
to do or with 0x1fff, followed be subtracting a small
constant than and with ~0x1fff, followed by adding a large
one.  Both & and | would be a couple of insns (mvn lsr/mvn lsl
for |, a pair of bic for &), but the following addition
would cost a pair of add while the subtraction ends up
as a single sub.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/arm/include/asm/thread_info.h

index af7b0bda3355d9af850ae722b2b1f55277ef6e67..82fdd242a26a2928edb4f634643a59899564f4d1 100644 (file)
@@ -97,6 +97,12 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
 }
 
+static inline struct pt_regs *current_pt_regs(void)
+{
+       register unsigned long sp asm ("sp");
+       return (struct pt_regs *)((sp | (THREAD_SIZE - 1)) - 7) - 1;
+}
+
 #define thread_saved_pc(tsk)   \
        ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
 #define thread_saved_sp(tsk)   \