From patchwork Wed May 25 12:26:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9135249 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 98C0A6075C for ; Wed, 25 May 2016 12:30:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BD4D282D4 for ; Wed, 25 May 2016 12:30:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80C81282DC; Wed, 25 May 2016 12:30:16 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 2A025282D4 for ; Wed, 25 May 2016 12:30:16 +0000 (UTC) Received: from localhost ([::1]:59543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Xx1-00006J-8H for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 08:30:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Xt8-0005t1-DL for qemu-devel@nongnu.org; Wed, 25 May 2016 08:26:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Xt3-0008PU-9e for qemu-devel@nongnu.org; Wed, 25 May 2016 08:26:13 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Xt3-0008PO-36 for qemu-devel@nongnu.org; Wed, 25 May 2016 08:26:09 -0400 Received: by mail-wm0-x244.google.com with SMTP id f75so14901856wmf.2 for ; Wed, 25 May 2016 05:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=nbFC1RT1kqZC7APHz1UNLPOqozbtOVPo82sr/xyEAls=; b=FV9x+ajG2YA1YRejRD6UxZ5UTW6TBZWee9R7X5NgfIyWVlNdgGLKYBjaOm47InKrwJ oQXmwSeQo62rB1F7qYzaoRfyViCjxc/eEwkWLQZu+fxaiXwvNuNmhZlakR/XlQBckiCz 6IovhikePMvHDE24P5SrwbIr6a+2G6NKScItaxU5MM/ZeVnmIhUNNg4Ae9WnmAUsMEfK 9JM/ndhxnuLhMXmbhgRpUjNzgBJUvCUo7VA2HO23pU2zycVviOl0V9EQWGv4JDB9uOzP Qbhj2nGVNoWbVtqyRCJZwhZIefwDfMkJx+WPUxcJor4sIdoGTCh/DWUaGOmr1p5vUtPD nHqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=nbFC1RT1kqZC7APHz1UNLPOqozbtOVPo82sr/xyEAls=; b=lXmKASK/yJPybh1kMB3aXaSy9UV9+QdopULHf75TFdeurIsUGpLg4VJy2+SMfwiCO/ cQCroT5szcPpwvUJ+mREHE42iheokMEpOaUHqm08uy5m05JfFv2ItUdusI4WhoOx2wf8 Srj7+PAXmNglpGUxFYW9m1dD3/KweNzKqVGK6e1fxbXtGb0qmP5bXZkYL/7DjqifHb6/ Z+fcjK77z8dKZAEOc9AWkM1lXDuiEIoFNdKcpyiHSWLrmD6MRYPzXVgjmnoWlIsgU5Dk XwgIf5iXRGvgVZmOAWyW0FtzKbOWRR6m+WgPKijIxlVsKr2+wIiYIfWIYkdT3A8uY8x7 lrNA== X-Gm-Message-State: ALyK8tK0SIQdS65Z3rMWCmCcOHBo2usCp2IyYFDqXp/rbymRwFJJxcCvZ7WEV2dMK+wfrg== X-Received: by 10.28.5.140 with SMTP id 134mr3384800wmf.80.1464179168415; Wed, 25 May 2016 05:26:08 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id y1sm6596304wjg.10.2016.05.25.05.26.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 05:26:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 14:26:06 +0200 Message-Id: <1464179166-24137-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH] 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: , Cc: mttcg@greensocs.com, cota@braap.org 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..3f8b770 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 all of inc, dec, and, sub, and, or. - 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