summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/exception.S
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-09-15 09:53:04 +0000
committerkib <kib@FreeBSD.org>2011-09-15 09:53:04 +0000
commit747c6e1d12491b777c235cc4aea38bcaac9f2722 (patch)
tree59ec0e24e5811939186235b3d9c2d73de2faadfd /sys/amd64/amd64/exception.S
parent120983786685bae0ccfdf9aedce7cdaf65460803 (diff)
downloadFreeBSD-src-747c6e1d12491b777c235cc4aea38bcaac9f2722.zip
FreeBSD-src-747c6e1d12491b777c235cc4aea38bcaac9f2722.tar.gz
Microoptimize the return path for the fast syscalls on amd64. Arrange
the code to have the fall-through path to follow the likely target. Do not use intermediate register to reload user %rsp. Proposed by: alc Reviewed by: alc, jhb Approved by: re (bz) MFC after: 2 weeks
Diffstat (limited to 'sys/amd64/amd64/exception.S')
-rw-r--r--sys/amd64/amd64/exception.S20
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
index 9f0c69a..89ad638 100644
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -393,14 +393,8 @@ IDTVEC(fast_syscall)
/* Check for and handle AST's on return to userland. */
movq PCPU(CURTHREAD),%rax
testl $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
- je 2f
- sti
- movq %rsp, %rdi
- call ast
- jmp 1b
-
- .align 16
-2: /* Restore preserved registers. */
+ jne 2f
+ /* Restore preserved registers. */
MEXITCOUNT
movq TF_RDI(%rsp),%rdi /* bonus; preserve arg 1 */
movq TF_RSI(%rsp),%rsi /* bonus: preserve arg 2 */
@@ -408,10 +402,16 @@ IDTVEC(fast_syscall)
movq TF_RAX(%rsp),%rax /* return value 1 */
movq TF_RFLAGS(%rsp),%r11 /* original %rflags */
movq TF_RIP(%rsp),%rcx /* original %rip */
- movq TF_RSP(%rsp),%r9 /* user stack pointer */
- movq %r9,%rsp /* original %rsp */
+ movq TF_RSP(%rsp),%rsp /* user stack pointer */
swapgs
sysretq
+
+2: /* AST scheduled. */
+ sti
+ movq %rsp,%rdi
+ call ast
+ jmp 1b
+
3: /* Requested full context restore, use doreti for that. */
MEXITCOUNT
jmp doreti
OpenPOWER on IntegriCloud