lkml.org 
[lkml]   [2014]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC/HACK] x86: Fast return to kernel
Date
This speeds up my kernel_pf microbenchmark by about 17%.  The cfi
annotations need some work.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---

My test case is here:

https://gitorious.org/linux-test-utils/linux-clock-tests/source/kernel_pf.c

This could have some other interesting benefits. For example, pages faults
that happen during an NMI might not re-enable NMIs.

arch/x86/kernel/entry_64.S | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1e96c36..922a057 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1033,9 +1033,24 @@ retint_swapgs: /* return to user-space */
retint_restore_args: /* return to kernel space */
DISABLE_INTERRUPTS(CLBR_ANY)
/*
- * The iretq could re-enable interrupts:
+ * The popfq could re-enable interrupts:
*/
TRACE_IRQS_IRETQ
+
+ /* Fast return to kernel. */
+ movq RSP-ARGOFFSET(%rsp), %rsi
+ subq $16, %rsi
+ movq EFLAGS-ARGOFFSET(%rsp), %rdi
+ movq %rdi, (%rsi)
+ movq RIP-ARGOFFSET(%rsp), %rdi
+ movq %rdi, 8(%rsi)
+ movq %rsi, RIP-ARGOFFSET(%rsp)
+ RESTORE_ARGS 1,8,1
+ popq %rsp
+ popfq
+ /* Interrupts are still off because of the one-insn grace period. */
+ retq
+
restore_args:
RESTORE_ARGS 1,8,1

--
1.9.0


\
 
 \ /
  Last update: 2014-05-02 22:01    [W:0.459 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site