x86/asm/entry/64: Simplify looping around preempt_schedule_irq()
authorDenys Vlasenko <[email protected]>
Tue, 31 Mar 2015 17:00:07 +0000 (19:00 +0200)
committerIngo Molnar <[email protected]>
Wed, 1 Apr 2015 11:17:39 +0000 (13:17 +0200)
At the 'exit_intr' label we test whether interrupt/exception was in
kernel. If it did, we jump to the preemption check. If preemption
does happen (IOW if we call preempt_schedule_irq()), we go back to
'exit_intr'.

But it's pointless, we already know that the test succeeded last
time, preemption doesn't change the fact that interrupt/exception
was in the kernel.

We can go back directly to checking PER_CPU_VAR(__preempt_count) instead.

This makes the 'exit_intr' label unused, drop it.

Signed-off-by: Denys Vlasenko <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Will Drewry <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/kernel/entry_64.S

index 9f8d01f1f1b2fae67ff9e14d118052e46a1bd169..bad285d84a9fc65f8edb4d36fbfe9f43a02600a5 100644 (file)
@@ -654,7 +654,6 @@ ret_from_intr:
        CFI_DEF_CFA_REGISTER    rsp
        CFI_ADJUST_CFA_OFFSET   RBP
 
-exit_intr:
        testl $3,CS(%rsp)
        je retint_kernel
        /* Interrupt came from user space */
@@ -741,12 +740,12 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
        /* Interrupts are off */
        /* Check if we need preemption */
-       cmpl    $0,PER_CPU_VAR(__preempt_count)
-       jnz     1f
        bt      $9,EFLAGS(%rsp) /* interrupts were off? */
        jnc     1f
+0:     cmpl    $0,PER_CPU_VAR(__preempt_count)
+       jnz     1f
        call    preempt_schedule_irq
-       jmp     exit_intr
+       jmp     0b
 1:
 #endif
        /*