From owner-svn-src-all@freebsd.org Wed Aug 28 19:40:57 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8A31E49F5; Wed, 28 Aug 2019 19:40:57 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Jbh94T9Lz4bqK; Wed, 28 Aug 2019 19:40:57 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7B4F4C559; Wed, 28 Aug 2019 19:40:57 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SJevXp041849; Wed, 28 Aug 2019 19:40:57 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SJevd4041816; Wed, 28 Aug 2019 19:40:57 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201908281940.x7SJevd4041816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 28 Aug 2019 19:40:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351577 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 351577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 19:40:57 -0000 Author: mjg Date: Wed Aug 28 19:40:57 2019 New Revision: 351577 URL: https://svnweb.freebsd.org/changeset/base/351577 Log: amd64: clean up cpu_switch.S - LK macro (conditional on SMP for the lock prefix) is unused - SETLK unnecessarily performs xchg. obtained value is never used and the implicit lock prefix adds avoidable cost. Barrier provided by it does not appear to be of any use. - the lock waited for is almost never blocked, yet the loop starts with a pause. Move it out of the common case. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19563 Modified: head/sys/amd64/amd64/cpu_switch.S Modified: head/sys/amd64/amd64/cpu_switch.S ============================================================================== --- head/sys/amd64/amd64/cpu_switch.S Wed Aug 28 19:28:27 2019 (r351576) +++ head/sys/amd64/amd64/cpu_switch.S Wed Aug 28 19:40:57 2019 (r351577) @@ -45,18 +45,6 @@ .text -#ifdef SMP -#define LK lock ; -#else -#define LK -#endif - -#if defined(SCHED_ULE) && defined(SMP) -#define SETLK xchgq -#else -#define SETLK movq -#endif - /* * cpu_throw() * @@ -150,17 +138,15 @@ ctx_switch_xsave: movq %rdx,%r15 movq %rsi,%rdi callq pmap_activate_sw - SETLK %r15,TD_LOCK(%r13) /* Release the old thread */ + movq %r15,TD_LOCK(%r13) /* Release the old thread */ sw1: movq TD_PCB(%r12),%r8 #if defined(SCHED_ULE) && defined(SMP) - /* Wait for the new thread to become unblocked */ movq $blocked_lock, %rdx -1: movq TD_LOCK(%r12),%rcx cmpq %rcx, %rdx - pause - je 1b + je sw1wait +sw1cont: #endif /* * At this point, we've switched address spaces and are ready @@ -496,3 +482,14 @@ ENTRY(resumectx) xorl %eax,%eax ret END(resumectx) + +/* Wait for the new thread to become unblocked */ +#if defined(SCHED_ULE) && defined(SMP) +sw1wait: +1: + pause + movq TD_LOCK(%r12),%rcx + cmpq %rcx, %rdx + je 1b + jmp sw1cont +#endif