Received: by 10.223.185.111 with SMTP id b44csp841331wrg; Fri, 9 Mar 2018 15:00:01 -0800 (PST) X-Google-Smtp-Source: AG47ELuYIK8MiUXw+UNZBd0To1JMtg+rLXdxIokR2msAO8xL2CCkJLbeJl/nTaBtOK7w0kNPT0UB X-Received: by 2002:a17:902:7c84:: with SMTP id y4-v6mr103167pll.305.1520636401805; Fri, 09 Mar 2018 15:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520636401; cv=none; d=google.com; s=arc-20160816; b=I14vTaddy2suGyfHlHsu8wEPMPvOAywJFFttucvo6dKzlczrrQZFjRJVyaiU3P9PK3 /mU5vmdLXzrfczhmVwsPtrtHOe1nt3XJ9JEEvHxtiEMCLycAkSmZUq4nuat96sbUsHq8 f78x3RuSkM1KHzoJAVWulxgBYUKAAcm5mc4n/O4QOS+yVHbw3lUtwqTcXgzGaNYPbea0 L/6t1E40ZP4QW4H/Gi7VRusKAblUtjA3KEYste5+7+/6rMuF00BwUvMCIdsIatwgSI3Y K/g1i7qxDVsS+C7yxjPxGCWBkKHOwpBFXTIYht7KyPWtYuBnVZ/en2JzgwciOJIwlgaQ ZRUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=eGK9/y5JItvmWfXJjcxzfOB1aZgtgYGNEETZRBz59bA=; b=HWuKkArv+WOt3bQKWNzbmHKwGHay8cOgI6q2a7PGi/m0tCcRYGoLWK3CEP2lpzD+hj c9akQsajfdIcVGFl63smwWFXCmGZj4IJ9D2RQXvAu1Im+us5Sk+O/fauKjrJqjKLK7St 2blvH3AEGEZ6pftYf9txA9kCS5r2fhs8L0A4wYB7+rvIqs0vskk1PEgt1B+wbOUyrsF3 HutqukKMUJlhIDh3dkg2MsByvZVRxG+Z3uKnGPS3DjTW5sAY45SagX3pxgFFdQWUlA3z HJpw2ZAtW0eBB3uHDRyG2TVJet0DViV/7pSccL+0aHSj7A8cm2xxEu8LT727DYU+o7V6 4ZzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ejAdBJRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x81si228538pgx.159.2018.03.09.14.59.47; Fri, 09 Mar 2018 15:00:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ejAdBJRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932692AbeCIW6C (ORCPT + 99 others); Fri, 9 Mar 2018 17:58:02 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:37568 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932186AbeCIW6B (ORCPT ); Fri, 9 Mar 2018 17:58:01 -0500 Received: by mail-pf0-f193.google.com with SMTP id h11so1871993pfn.4 for ; Fri, 09 Mar 2018 14:58:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=eGK9/y5JItvmWfXJjcxzfOB1aZgtgYGNEETZRBz59bA=; b=ejAdBJRNAUA+avbUelt62MOVOke45R26CG4BxxatCPOBJAY0NgPfQgZAPusF36/rB/ KNIsdfzcn824d/1MUaDAQi7xiGpv/4wDHzCIOGmvp98XKvuukh0qQONa1ZSCXdSNDZKa Ksa8s5iWbEwJbC0srkcj4sonZXotbWO8oVB2wcK1uGifTnbrYH4sGzHAU1BRA3Akwhuc /hUjVbrHX2GTG6PsmmTO7MXRuaD59tqWe0bJQM6XEZUJ3B05fmHrCNP/JM2T9P6CUw5i BIG01hxZmb8Gwc5Ddlg0LRkuKADglDBHX9BBVJPHWl6R71KeZDHL7jO+m8ydxxafA0LA 6/fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=eGK9/y5JItvmWfXJjcxzfOB1aZgtgYGNEETZRBz59bA=; b=RR9LMDdLO/brO4vP+IuxP3JRaDARNsAeZNaTCKp3LN0Oql8aZ7erm5AIuzeXzpFhRb Pc4amcBH5BYaQnzitA3XCTdq8utu4c5d/k5Ap5b8IueBH0xkbI2Ly28oDle9Vzf96VTn jntFS7igCQxCKuSQ4O5Igx0W2OUZcyuDZaE0qFcywXSFIOE+SWiGSu9y1dYCpAeFsrg+ Qqj6AwpYSrL9GUPwxCb1WMGoRMq6IpZVRuafxALryUpEq2RI+0KmY09hXyYLHKJoOnt2 XZLdmkSoZkyJCYioBvoEMvEivXAVRbEQgji7nuWJ/SXWSNIzZ9f0N4UZnrQ1YBOsL4Ww Dtrw== X-Gm-Message-State: AElRT7GlMMs4irsLyoJmr1BlPngCUM7T5/xozySkcR59Q7cEWgvKFywb ur4NcFFSB3ZMuvVvu4qkOgS0Bw== X-Received: by 10.98.182.26 with SMTP id j26mr98522pff.223.1520636280332; Fri, 09 Mar 2018 14:58:00 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id 76sm4698600pfp.53.2018.03.09.14.57.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 14:57:59 -0800 (PST) Date: Fri, 09 Mar 2018 14:57:59 -0800 (PST) X-Google-Original-Date: Fri, 09 Mar 2018 14:57:57 PST (-0800) Subject: Re: [PATCH v2 2/2] riscv/atomic: Strengthen implementations with fences In-Reply-To: <20180309213008.GA3154@andrea> CC: albert@sifive.com, Daniel Lustig , stern@rowland.harvard.edu, Will Deacon , peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, paulmck@linux.vnet.ibm.com, akiyks@gmail.com, mingo@kernel.org, Linus Torvalds , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: parri.andrea@gmail.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 09 Mar 2018 13:30:08 PST (-0800), parri.andrea@gmail.com wrote: > On Fri, Mar 09, 2018 at 10:54:27AM -0800, Palmer Dabbelt wrote: >> On Fri, 09 Mar 2018 10:36:44 PST (-0800), parri.andrea@gmail.com wrote: > > [...] > > >> >This belongs to the "few style fixes" (in the specific, 80-chars lines) >> >mentioned in the cover letter; I could not resist ;-), but I'll remove >> >them in v3 if you like so. >> >> No problem, just next time it's a bit easier to not mix the really complicated >> stuff (memory model changes) with the really simple stuff (whitespace changes). > > Got it. > > >> >This proposal relies on the generic definition, >> > >> > include/linux/atomic.h , >> > >> >and on the >> > >> > __atomic_op_acquire() >> > __atomic_op_release() >> > >> >above to build the acquire/release atomics (except for the xchg,cmpxchg, >> >where the ACQUIRE_BARRIER is inserted conditionally/on success). >> >> I thought we wanted to use the AQ and RL bits for AMOs, just not for LR/SC >> sequences. IIRC the AMOs are safe with the current memory model, but I might >> just have some version mismatches in my head. > > AMO.aqrl are "safe" w.r.t. the LKMM (as they provide "full-ordering"); OTOH, > AMO.aq and AMO.rl present weaknesses that LKMM (and some kernel developers) > do not "expect". I was probing this issue in: > > https://marc.info/?l=linux-kernel&m=151930201102853&w=2 > > (c.f., e.g., test "RISCV-unlock-lock-read-ordering" from that post). > > Quoting from the commit message of my patch 1/2: > > "Referring to the "unlock-lock-read-ordering" test reported below, > Daniel wrote: > > I think an RCpc interpretation of .aq and .rl would in fact > allow the two normal loads in P1 to be reordered [...] > > [...] > > Likewise even if the unlock()/lock() is between two stores. > A control dependency might originate from the load part of > the amoswap.w.aq, but there still would have to be something > to ensure that this load part in fact performs after the store > part of the amoswap.w.rl performs globally, and that's not > automatic under RCpc. > > Simulation of the RISC-V memory consistency model confirmed this > expectation." > > I have just (re)checked these observations against the latest specification, > and my results _confirmed_ these verdicts. Thanks, I must have just gotten confused about a draft spec or something. I'm pulling these on top or your other memory model related patch. I've renamed the branch "next-mm" to be a bit more descriptiove. Thanks!