From owner-svn-src-head@FreeBSD.ORG Thu Sep 15 09:53:04 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0B9A106564A; Thu, 15 Sep 2011 09:53:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B06CC8FC18; Thu, 15 Sep 2011 09:53:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8F9r4lk066724; Thu, 15 Sep 2011 09:53:04 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8F9r4Ab066722; Thu, 15 Sep 2011 09:53:04 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201109150953.p8F9r4Ab066722@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 15 Sep 2011 09:53:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225575 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2011 09:53:04 -0000 Author: kib Date: Thu Sep 15 09:53:04 2011 New Revision: 225575 URL: http://svn.freebsd.org/changeset/base/225575 Log: 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 Modified: head/sys/amd64/amd64/exception.S Modified: head/sys/amd64/amd64/exception.S ============================================================================== --- head/sys/amd64/amd64/exception.S Thu Sep 15 09:22:49 2011 (r225574) +++ head/sys/amd64/amd64/exception.S Thu Sep 15 09:53:04 2011 (r225575) @@ -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