From patchwork Fri May 27 10:06:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9138089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF38760759 for ; Fri, 27 May 2016 10:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C205E28093 for ; Fri, 27 May 2016 10:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6E3028137; Fri, 27 May 2016 10:40:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 160E528093 for ; Fri, 27 May 2016 10:40:22 +0000 (UTC) Received: from localhost ([::1]:45131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FBl-0000yq-Mb for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 06:40:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Efr-0002iR-0C for qemu-devel@nongnu.org; Fri, 27 May 2016 06:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6Efo-0007RC-Rp for qemu-devel@nongnu.org; Fri, 27 May 2016 06:07:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57735) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Efo-0007R4-Mc for qemu-devel@nongnu.org; Fri, 27 May 2016 06:07:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6241381F03 for ; Fri, 27 May 2016 10:07:20 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4RA6isd030403 for ; Fri, 27 May 2016 06:07:19 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 12:06:33 +0200 Message-Id: <1464343604-517-21-git-send-email-pbonzini@redhat.com> In-Reply-To: <1464343604-517-1-git-send-email-pbonzini@redhat.com> References: <1464343604-517-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 27 May 2016 10:07:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/31] docs/atomics: update comparison with Linux X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Over time, some differences between QEMU and Linux atomics are getting smoothed. In particular, Linux grew atomic_fetch_or (and in general the differences regarding RMW operations were not described accurately) and smp_load_acquire/smp_store_release. Also, set_mb was renamed to smp_store_mb(). Include these changes in the documentation. Signed-off-by: Paolo Bonzini --- docs/atomics.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/atomics.txt b/docs/atomics.txt index 67a27ad..c95950b 100644 --- a/docs/atomics.txt +++ b/docs/atomics.txt @@ -340,17 +340,27 @@ and memory barriers, and the equivalents in QEMU: properly aligned. No barriers are implied by atomic_read/set in either Linux or QEMU. -- most atomic read-modify-write operations in Linux return void; - in QEMU, all of them return the old value of the variable. +- atomic read-modify-write operations in Linux are of three kinds: + + atomic_OP returns void + atomic_OP_return returns new value of the variable + atomic_fetch_OP returns the old value of the variable + atomic_cmpxchg returns the old value of the variable + + In QEMU, the second kind does not exist. Currently Linux has + atomic_fetch_or only. QEMU provides and, or, inc, dec, add, sub. - different atomic read-modify-write operations in Linux imply a different set of memory barriers; in QEMU, all of them enforce sequential consistency, which means they imply full memory barriers before and after the operation. -- Linux does not have an equivalent of atomic_mb_read() and - atomic_mb_set(). In particular, note that set_mb() is a little - weaker than atomic_mb_set(). +- Linux does not have an equivalent of atomic_mb_set(). In particular, + note that smp_store_mb() is a little weaker than atomic_mb_set(). + atomic_mb_read() compiles to the same instructions as Linux's + smp_load_acquire(), but this should be treated as an implementation + detail. If required, QEMU might later add atomic_load_acquire() and + atomic_store_release() macros. SOURCES