Blackfin: optimize fixed code handling for the most common case
authorMike Frysinger <vapier@gentoo.org>
Mon, 17 Aug 2009 19:05:07 +0000 (19:05 +0000)
committerMike Frysinger <vapier@gentoo.org>
Thu, 17 Sep 2009 02:10:28 +0000 (22:10 -0400)
The majority of the time we are returning to user space, it is not in the
fixed atomic code region.  So rather than branch to a function where we
check the PC and return, do the check inline and branch only when needed.

Also, tweak some of the fixed code handling based on assumptions we are
aware of but cannot be expressed in C.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
arch/blackfin/kernel/process.c
arch/blackfin/mach-common/entry.S

index 9da36bab7ccb10194a3cde2c40628f4e52aeeccb..f5b286189647ff0f3fcd68ab1abe0d7e79fdc52c 100644 (file)
@@ -282,25 +282,19 @@ void finish_atomic_sections (struct pt_regs *regs)
 {
        int __user *up0 = (int __user *)regs->p0;
 
-       if (regs->pc < ATOMIC_SEQS_START || regs->pc >= ATOMIC_SEQS_END)
-               return;
-
        switch (regs->pc) {
        case ATOMIC_XCHG32 + 2:
                put_user(regs->r1, up0);
-               regs->pc += 2;
+               regs->pc = ATOMIC_XCHG32 + 4;
                break;
 
        case ATOMIC_CAS32 + 2:
        case ATOMIC_CAS32 + 4:
                if (regs->r0 == regs->r1)
+       case ATOMIC_CAS32 + 6:
                        put_user(regs->r2, up0);
                regs->pc = ATOMIC_CAS32 + 8;
                break;
-       case ATOMIC_CAS32 + 6:
-               put_user(regs->r2, up0);
-               regs->pc += 2;
-               break;
 
        case ATOMIC_ADD32 + 2:
                regs->r0 = regs->r1 + regs->r0;
index e7eb16355f74c4f124a28c53acbaf1f1af8a4d5a..a9b15aaf5254487acd9c811c295168bb6df89968 100644 (file)
@@ -1025,6 +1025,12 @@ ENTRY(_schedule_and_signal_from_int)
 #endif
        sti r0;
 
+       /* finish the userspace "atomic" functions for it */
+       r1 = FIXED_CODE_END;
+       r2 = [sp + PT_PC];
+       cc = r1 <= r2;
+       if cc jump .Lresume_userspace (bp);
+
        r0 = sp;
        sp += -12;
        call _finish_atomic_sections;