From owner-svn-src-head@freebsd.org Mon Oct 7 12:53:28 2019 Return-Path: Delivered-To: svn-src-head@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 3534D12E995; Mon, 7 Oct 2019 12:53:28 +0000 (UTC) (envelope-from avg@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 46n0lX0cNrz3yWs; Mon, 7 Oct 2019 12:53:28 +0000 (UTC) (envelope-from avg@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 EC2F9EE81; Mon, 7 Oct 2019 12:53:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x97CrRDx015961; Mon, 7 Oct 2019 12:53:27 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x97CrRcF015960; Mon, 7 Oct 2019 12:53:27 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910071253.x97CrRcF015960@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 7 Oct 2019 12:53:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353270 - head/sys/cddl/contrib/opensolaris/common/atomic/i386 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/cddl/contrib/opensolaris/common/atomic/i386 X-SVN-Commit-Revision: 353270 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 07 Oct 2019 12:53:28 -0000 Author: avg Date: Mon Oct 7 12:53:27 2019 New Revision: 353270 URL: https://svnweb.freebsd.org/changeset/base/353270 Log: fix up r353168, add atomic_swap_64 to i386 version of opensolaris_atomic.S The compatibility code for the atomic operations in ZFS code is a bit messy. In some cases the native definitions are directly made available, in some cases there are emulated operations in opensolaris_atomic.c and in yet other cases there are atomic operations implemented in assembly that were obtained from OpenSolaris / illumos. This commit adds atomic_swap_64 for use with i386 userland. The code is copied from illumos. I am not sure why FreeBSD does not provide that operation natively. Maybe because we try (or pretend) to support processors that did not have the necessary instructions. While here I also added atomic_load_64 for the same reasons. This is original code based on iilumos atomic_swap_64 and FreeBSD atomic_load_acq_64_i586. Pointyhat to: avg MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Modified: head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Mon Oct 7 12:51:36 2019 (r353269) +++ head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Mon Oct 7 12:53:27 2019 (r353270) @@ -126,6 +126,34 @@ ret SET_SIZE(atomic_cas_64) + ENTRY(atomic_swap_64) + pushl %esi + pushl %ebx + movl 12(%esp), %esi + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl (%esi), %eax + movl 4(%esi), %edx // %edx:%eax = old value +1: + lock + cmpxchg8b (%esi) + jne 1b + popl %ebx + popl %esi + ret + SET_SIZE(atomic_swap_64) + + ENTRY(atomic_load_64) + pushl %esi + movl 8(%esp), %esi + movl %ebx, %eax // make old and new values equal, so that + movl %ecx, %edx // destination is never changed + lock + cmpxchg8b (%esi) + popl %esi + ret + SET_SIZE(atomic_load_64) + ENTRY(membar_producer) lock xorl $0, (%esp)