Received: by 10.223.185.116 with SMTP id b49csp3913994wrg; Mon, 26 Feb 2018 08:08:10 -0800 (PST) X-Google-Smtp-Source: AH8x2264Bi57r8zpIlzLtaNS0Leb0yaGWr/caqLwRSkZwfuhS+82b7KOcDnufMW3Cy+bcLcI0VT9 X-Received: by 10.98.204.69 with SMTP id a66mr11065462pfg.33.1519661290058; Mon, 26 Feb 2018 08:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519661290; cv=none; d=google.com; s=arc-20160816; b=RGX2Bnuju8QSpLAncmZHRtVUdWdSHnbsoCqaLnDN9Un14NCvhCkcsCalPdRn+XWR2B oa9WZqmLkloiMqzkGy7Nijykk4lTXslOOo95jRDyEnQI3F8C+MIU0GOf72I4tyjSbxVM zPOAcddGCopgDNUdKS+Psjw14VN9cK0O3Sn2OnMEi97kN1wz5fhBrC7TZs6kdYpJG2pN sQeZKKu9AiF9CO3WyTRPHUOaEzJqvUWzl4JBi3Y2ak2ZYMrCLLEopYqgr802Dx6KMh8e 1RJkxxNUdHGSTtJduVcWEIMWv988Ds/G6APFr/ipcu4eCPJdMhMnFHM7cInB8Dut/NKz 8IAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=enNgluIHZrOuL8loN9i9Q59WUNbc7yhNQEYSKxGPCqw=; b=ZGKS4rcd7kU9f+2VrmZJp/GQt0KPvjoBMWIyQokogLsOv91vWKbuZGFO2G4EK8ESnN x+NHYqOCVGZHPHr8lpQSxubibE+i2EJlsbedSOoz18rAFX+hdzigidaauIIIPHvDvLpw w7BTwYVYLABqRBQ/RyETFP85VYcUz9aoF16fRyD8J88MXyCPIa6z+D1ssdly3QXSDcKt CujhELj+JlherEbFuXCqmpSQNxoMlTF26FfWO7opokfEKVEa3GeiscqLYvWo7q8+yW/x BHKa7+ohk4U/Gs7/A5GWb5XJK4a+3mszMy42TVKnKx+2tDZ1L1bh+Ha+I5NavDGhlPUH pj3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CaRHOOp5; 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 b14-v6si3483224pll.178.2018.02.26.08.07.54; Mon, 26 Feb 2018 08:08:10 -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=fail header.i=@gmail.com header.s=20161025 header.b=CaRHOOp5; 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 S1751903AbeBZQHC (ORCPT + 99 others); Mon, 26 Feb 2018 11:07:02 -0500 Received: from mail-io0-f178.google.com ([209.85.223.178]:38043 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbeBZQHB (ORCPT ); Mon, 26 Feb 2018 11:07:01 -0500 Received: by mail-io0-f178.google.com with SMTP id g21so17749091ioj.5 for ; Mon, 26 Feb 2018 08:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=enNgluIHZrOuL8loN9i9Q59WUNbc7yhNQEYSKxGPCqw=; b=CaRHOOp5GjiuP90Wjz7zrHsAAe5uNcZxgKtDIVsd4ulL+YWH8L/UCR+sNvWozICqM2 GcipUN3ld6pVQXpmxqrD/x86CsdoRPl/4MJ1gn9RFt/5uM+j9nOgwMdd6SqxJF0tV1ti EbzuU1bgzFKpkFn+0wfEA5s4T/APq/RVvYMmWkxNKhXgfFiSe8CPP0jlIUfuoO4pijxE 4ClWACbdx2oJC0lPavKy0B4nGmELxK2s0ay7Cbi/7Tr4dHtIn6TFYXC18hh92aU2HoPl sBvKhEnfDWuNkmIbqeGmwXPE1bCWDKj4Lpf1wJoNt2UeKeV8haG4X90QLPaJJ8klf9l3 x0cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=enNgluIHZrOuL8loN9i9Q59WUNbc7yhNQEYSKxGPCqw=; b=C94rJgbUZX43GeY3oFN0AY4vjol0jfT8+iUQboB/xKPfjCrj50IMFA6GyPbUP8qfLW fxv1SYj0Z72wjkoB1/reM3WE2ijW4uBc9HXaNfuhoXu8gkbUpzVjsCy2LztCAmTnm5ua LGgBukUXiSsK1H8dZ1RuD7lEgbLKA6immB9sR0r7gc3nzqOhKTWvPmZI/T2NKKYVX9/H fRibSyvwpsgbhmuuRyB/S9UZDXwRbIkJVDgdRdVGHzElA7mHMkbJwAYQlNN8iow1DRbe oGAXIHRXAMNqftou/gTxS3wy+23BOx8WPREtSwTacSg8jh6oxPd64jHtw+W+W4kYpNSj E0wA== X-Gm-Message-State: APf1xPD2mdB9HvFZMlML96EpAGZOsDnIMo9VdhP2rXLnuSfd9QIVxbWc Chy5ngLGI8HpJvLVhKX5JRS8Hw3QdzMVctTDsiA= X-Received: by 10.107.9.138 with SMTP id 10mr12159495ioj.257.1519661220423; Mon, 26 Feb 2018 08:07:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.135.221 with HTTP; Mon, 26 Feb 2018 08:06:59 -0800 (PST) In-Reply-To: <20180226142107.uid5vtv5r7zbso33@yquem.inria.fr> References: <1519301990-11766-1-git-send-email-parri.andrea@gmail.com> <20180222134004.GN25181@hirez.programming.kicks-ass.net> <20180222141249.GA14033@andrea> <82beae6a-2589-6136-b563-3946d7c4fc60@nvidia.com> <20180222181317.GI2855@linux.vnet.ibm.com> <20180222182717.GS25181@hirez.programming.kicks-ass.net> <563431d0-4fb5-9efd-c393-83cc5197e934@nvidia.com> <20180226142107.uid5vtv5r7zbso33@yquem.inria.fr> From: Linus Torvalds Date: Mon, 26 Feb 2018 08:06:59 -0800 X-Google-Sender-Auth: cMCb4WadqRBhWl4I8ZHV2u08Hls Message-ID: Subject: Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock() To: Luc Maranget Cc: Daniel Lustig , Peter Zijlstra , "Paul E. McKenney" , Andrea Parri , Linux Kernel Mailing List , Palmer Dabbelt , Albert Ou , Alan Stern , Will Deacon , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Akira Yokosawa , Ingo Molnar , linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget wrote: > > That is, locks are not implemented from more basic primitive but are specified. > The specification can be described as behaving that way: > - A lock behaves as a read-modify-write. the read behaving as a read-acquire This is wrong, or perhaps just misleading. The *whole* r-m-w acts as an acquire. Not just the read part. The write is very much part of it. Maybe that's what you meant, but it read to me as "just the read part of the rmw behaves as a read-acquire". Because it is very important that the _write_ part of the rmw is also ordered wrt everything that is inside the spinlock. So doing a spinlock as (a) read-locked-acquire modify (c) write-conditional would be wrong, because the accesses inside the spinlock are ordered not just wrt the read-acquire, they have to be ordered wrt the write too. So it is closer to say that it's the _write_ of the r-m-w sequence that has the acquire semantics, not the read. > - A unlock behaves as a store release. Yes. Linus