[RFC/HACK] x86: Fast return to kernel
From: Andy Lutomirski
Date: Fri May 02 2014 - 15:04:28 EST
This speeds up my kernel_pf microbenchmark by about 17%. The cfi
annotations need some work.
Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/