linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/traps: get rid of unnecessary preempt_disable/preempt_enable_no_resched
@ 2016-11-28  7:50 Alexander Kuleshov
  2017-02-04 16:19 ` [tip:x86/cleanups] x86/traps: Get " tip-bot for Alexander Kuleshov
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kuleshov @ 2016-11-28  7:50 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H . Peter Anvin, x86, Andy Lutomirski,
	Borislav Petkov, Tony Luck, Jianyu Zhan, Paul Gortmaker,
	linux-kernel, Alexander Kuleshov

Exception handlers which may run on IST stack calls ist_enter() at the
start of execution and ist_exit() in the end. The ist_enter() disables
preemption unconditionally and ist_exit() enables it.

Besides this, such exception handlers do additional unnecessary calls
of preempt_disable() and preempt_enable_no_resched() after/before
ist_enter()/ist_exit(). Let's get rid from them.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 arch/x86/kernel/traps.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index bd4e3d4..5fbff64 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -563,11 +563,9 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
 	 * as we may switch to the interrupt stack.
 	 */
 	debug_stack_usage_inc();
-	preempt_disable();
 	cond_local_irq_enable(regs);
 	do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL);
 	cond_local_irq_disable(regs);
-	preempt_enable_no_resched();
 	debug_stack_usage_dec();
 exit:
 	ist_exit(regs);
@@ -742,14 +740,12 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
 	debug_stack_usage_inc();
 
 	/* It's safe to allow irq's after DR6 has been saved */
-	preempt_disable();
 	cond_local_irq_enable(regs);
 
 	if (v8086_mode(regs)) {
 		handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
 					X86_TRAP_DB);
 		cond_local_irq_disable(regs);
-		preempt_enable_no_resched();
 		debug_stack_usage_dec();
 		goto exit;
 	}
@@ -769,7 +765,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
 	if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp)
 		send_sigtrap(tsk, regs, error_code, si_code);
 	cond_local_irq_disable(regs);
-	preempt_enable_no_resched();
 	debug_stack_usage_dec();
 
 exit:
-- 
2.8.0.rc3.1353.gea9bdc0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:x86/cleanups] x86/traps: Get rid of unnecessary preempt_disable/preempt_enable_no_resched
  2016-11-28  7:50 [PATCH] x86/traps: get rid of unnecessary preempt_disable/preempt_enable_no_resched Alexander Kuleshov
@ 2017-02-04 16:19 ` tip-bot for Alexander Kuleshov
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Alexander Kuleshov @ 2017-02-04 16:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, nasa4836, tglx, linux-kernel, luto, tony.luck,
	kuleshovmail, paul.gortmaker, hpa, bp

Commit-ID:  07d495dae20717b00881798ef812f7aa53ca0eb3
Gitweb:     http://git.kernel.org/tip/07d495dae20717b00881798ef812f7aa53ca0eb3
Author:     Alexander Kuleshov <kuleshovmail@gmail.com>
AuthorDate: Mon, 28 Nov 2016 13:50:57 +0600
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 4 Feb 2017 09:36:59 +0100

x86/traps: Get rid of unnecessary preempt_disable/preempt_enable_no_resched

Exception handlers which may run on IST stack call ist_enter() at the start
of execution and ist_exit() in the end. ist_enter() disables preemption
unconditionally and ist_exit() enables it.

So the extra preempt_disable/enable() pairs nested inside the
ist_enter/exit() regions are pointless and can be removed.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Jianyu Zhan <nasa4836@gmail.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/20161128075057.7724-1-kuleshovmail@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/traps.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index bf0c6d0..1dc86ee 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -563,11 +563,9 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
 	 * as we may switch to the interrupt stack.
 	 */
 	debug_stack_usage_inc();
-	preempt_disable();
 	cond_local_irq_enable(regs);
 	do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL);
 	cond_local_irq_disable(regs);
-	preempt_enable_no_resched();
 	debug_stack_usage_dec();
 exit:
 	ist_exit(regs);
@@ -742,14 +740,12 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
 	debug_stack_usage_inc();
 
 	/* It's safe to allow irq's after DR6 has been saved */
-	preempt_disable();
 	cond_local_irq_enable(regs);
 
 	if (v8086_mode(regs)) {
 		handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
 					X86_TRAP_DB);
 		cond_local_irq_disable(regs);
-		preempt_enable_no_resched();
 		debug_stack_usage_dec();
 		goto exit;
 	}
@@ -769,7 +765,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
 	if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp)
 		send_sigtrap(tsk, regs, error_code, si_code);
 	cond_local_irq_disable(regs);
-	preempt_enable_no_resched();
 	debug_stack_usage_dec();
 
 exit:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-04 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-28  7:50 [PATCH] x86/traps: get rid of unnecessary preempt_disable/preempt_enable_no_resched Alexander Kuleshov
2017-02-04 16:19 ` [tip:x86/cleanups] x86/traps: Get " tip-bot for Alexander Kuleshov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).