Skip to content

Commit 5e1246f

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
x86/entry/32: Clean up return from interrupt preemption path
The code flow around the return from interrupt preemption point seems needlessly complicated. There is only one site jumping to resume_kernel, and none (outside of resume_kernel) jumping to restore_all_kernel. Inline resume_kernel in restore_all_kernel and avoid the CONFIG_PREEMPT dependent label. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent c21ac93 commit 5e1246f

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

arch/x86/entry/entry_32.S

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
# define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
6868
#else
6969
# define preempt_stop(clobbers)
70-
# define resume_kernel restore_all_kernel
7170
#endif
7271

7372
.macro TRACE_IRQS_IRET
@@ -755,7 +754,7 @@ ret_from_intr:
755754
andl $SEGMENT_RPL_MASK, %eax
756755
#endif
757756
cmpl $USER_RPL, %eax
758-
jb resume_kernel # not returning to v8086 or userspace
757+
jb restore_all_kernel # not returning to v8086 or userspace
759758

760759
ENTRY(resume_userspace)
761760
DISABLE_INTERRUPTS(CLBR_ANY)
@@ -765,18 +764,6 @@ ENTRY(resume_userspace)
765764
jmp restore_all
766765
END(ret_from_exception)
767766

768-
#ifdef CONFIG_PREEMPT
769-
ENTRY(resume_kernel)
770-
DISABLE_INTERRUPTS(CLBR_ANY)
771-
cmpl $0, PER_CPU_VAR(__preempt_count)
772-
jnz restore_all_kernel
773-
testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off (exception path) ?
774-
jz restore_all_kernel
775-
call preempt_schedule_irq
776-
jmp restore_all_kernel
777-
END(resume_kernel)
778-
#endif
779-
780767
GLOBAL(__begin_SYSENTER_singlestep_region)
781768
/*
782769
* All code from here through __end_SYSENTER_singlestep_region is subject
@@ -1027,6 +1014,15 @@ restore_all:
10271014
INTERRUPT_RETURN
10281015

10291016
restore_all_kernel:
1017+
#ifdef CONFIG_PREEMPT
1018+
DISABLE_INTERRUPTS(CLBR_ANY)
1019+
cmpl $0, PER_CPU_VAR(__preempt_count)
1020+
jnz .Lno_preempt
1021+
testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off (exception path) ?
1022+
jz .Lno_preempt
1023+
call preempt_schedule_irq
1024+
.Lno_preempt:
1025+
#endif
10301026
TRACE_IRQS_IRET
10311027
PARANOID_EXIT_TO_KERNEL_MODE
10321028
BUG_IF_WRONG_CR3

0 commit comments

Comments
 (0)