Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/asm/entry/64: Simplify looping around preempt_schedule_irq()

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 <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1427821211-25099-5-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Denys Vlasenko and committed by
Ingo Molnar
36acef25 32a04077

+3 -4
+3 -4
arch/x86/kernel/entry_64.S
··· 654 654 CFI_DEF_CFA_REGISTER rsp 655 655 CFI_ADJUST_CFA_OFFSET RBP 656 656 657 - exit_intr: 658 657 testl $3,CS(%rsp) 659 658 je retint_kernel 660 659 /* Interrupt came from user space */ ··· 740 741 #ifdef CONFIG_PREEMPT 741 742 /* Interrupts are off */ 742 743 /* Check if we need preemption */ 743 - cmpl $0,PER_CPU_VAR(__preempt_count) 744 - jnz 1f 745 744 bt $9,EFLAGS(%rsp) /* interrupts were off? */ 746 745 jnc 1f 746 + 0: cmpl $0,PER_CPU_VAR(__preempt_count) 747 + jnz 1f 747 748 call preempt_schedule_irq 748 - jmp exit_intr 749 + jmp 0b 749 750 1: 750 751 #endif 751 752 /*