Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1968406imm; Thu, 12 Jul 2018 10:46:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeEGsc9jpmrV5ZHN+2aQe7qCOMvuhvpdk3aXQSiWULMVMfy+tErPzt9XDiIQcVhAd+BP0TD X-Received: by 2002:a17:902:321:: with SMTP id 30-v6mr3167160pld.122.1531417583516; Thu, 12 Jul 2018 10:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531417583; cv=none; d=google.com; s=arc-20160816; b=WZ9MBpqtyHJghL6SNtcGCkDwxHHWFeMT0M9YT4S/H1yYOXZavi/3sjPokUASZP9D7z GfeTgIQxvhE0kq+XZEMkMZhxhqdqfleMKCJHK1tIBs4VZtu8t4VdIv8jNiCFLty/cMNJ VSwGJZ+7W+NEwZNaHSdWcAvVvz7K0L2HFG/4GVllUdgBRJVdAjE91j6VXBwsWsoREUWN DYZ94qA+L2G0kZ3s9rofYmz6FILVA6ymjj1mGsD0ITJIJqjA4s884GdRAWSMFLqBwawA 1m9R8syhL5Dc+yzG4KBkL5o+Tgwz5GIpMtew5aVLp5vb//Bq/NsTcjT9yoQ5bHe+1Snv Cl2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=EjVcH7YLw8ZdGHtJ/psVQSXscAxtrdV2QAzG4MbyvqQ=; b=xaWiWI3tZiy5vYspP1Y0tVrG7XAzDr/t1QzuYU1z35hejoosTtkb37FcMjDgNFtyOk Ra+IdM3vmd35U9i80p/RWyxVfM/gBfM3ObwwNSXgAMS+Uy9LJEiZJPk3NjCpHcT+cbZv eI8Iv7DAvFjuowwlGmqln0CDSaxaBzuXp1SI/lTAlSn6vDGcJo05bI7yCKVeGI/kEQKr 03LxmRH7oCa9Oa9kX1a7e7DxHWMzfEYu6z7J1Y4Jp6w+GW/jC55kDPhsvT/hLHkDiw5r Dd3jAeRGYjtwsjHHdiFI3VclipJqH9U/AbrAgAWKsPTkmg692rRJCW9JlWSMjnUzAT3t X0Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Qzi5g/jo"; 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 i10-v6si24906494pfe.119.2018.07.12.10.46.08; Thu, 12 Jul 2018 10:46:23 -0700 (PDT) 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=@amarulasolutions.com header.s=google header.b="Qzi5g/jo"; 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 S1726710AbeGLR4K (ORCPT + 99 others); Thu, 12 Jul 2018 13:56:10 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52346 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbeGLR4K (ORCPT ); Thu, 12 Jul 2018 13:56:10 -0400 Received: by mail-wm0-f66.google.com with SMTP id o11-v6so493060wmh.2 for ; Thu, 12 Jul 2018 10:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EjVcH7YLw8ZdGHtJ/psVQSXscAxtrdV2QAzG4MbyvqQ=; b=Qzi5g/jol+J6qUk4SPrLAn3LjJ3eYUo8FmDgf95sdN/FrdqfZVkmBKPDNYZfLZQFUe iVTwPDAY+sklYArH5OA4erxRiYL8XSzV182bfzuPPiSjDHioRlPkpnULemnuR/BwJsoa VvUePaqy5V6L8I4OCCJLmd1r0ovfdxp+6YKqw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EjVcH7YLw8ZdGHtJ/psVQSXscAxtrdV2QAzG4MbyvqQ=; b=ZmcI3CBv5vfnhy2DL28TZSWouybSWRwiSbCZJoReEP5cpxncf8GuftaK25CyYn34ke WCiNQ0/Fml9ZBbKeYpc+EBWmWHYFqqORm7TJf8ByrdyYt0DW5RZ8m7hB+ciKm+Htzrld nxxJFDwpQukipeJH2fJ74lx0apHk5k4TCmPfV0grITTlTxHfAhDr3J9K5bBHVtiTqBeB 89o2pABjVB54Px8GH2G9+gl9sLy1+fhzvoXwFzPz+h2ne4c8TP8lF7uiGElQNGIlrsnD T5bvoI+JsBJm/LocaJLBUzR4A1h3QyNebf46S5OHATn+gPNWlGLaKxcXtuBJFUP6WHrq v0nA== X-Gm-Message-State: AOUpUlGZWE0A1ex2OmUi5aeJO6AXCDGLHNMcfHtGUcYtXByxAdD+y+xI WI5Yuyd1HF/eQN8YcgtLaYh8Lg== X-Received: by 2002:a1c:dc89:: with SMTP id t131-v6mr2084955wmg.50.1531417533953; Thu, 12 Jul 2018 10:45:33 -0700 (PDT) Received: from andrea ([94.230.152.15]) by smtp.gmail.com with ESMTPSA id w21-v6sm5846052wmw.29.2018.07.12.10.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 10:45:33 -0700 (PDT) Date: Thu, 12 Jul 2018 19:45:27 +0200 From: Andrea Parri To: Peter Zijlstra Cc: Will Deacon , Alan Stern , "Paul E. McKenney" , LKMM Maintainers -- Akira Yokosawa , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Kernel development list , Linus Torvalds Subject: Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Message-ID: <20180712174527.GA3533@andrea> References: <20180710093821.GA5414@andrea> <20180711094310.GA13963@arm.com> <20180711123421.GA9673@andrea> <20180712074040.GA4920@worktop.programming.kicks-ass.net> <20180712115249.GA6201@andrea> <20180712134821.GT2494@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180712134821.GT2494@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Anyway, back to the problem of being able to use the memory model to > describe locks. This is I think a useful property. > > My earlier reasoning was that: > > - smp_store_release() + smp_load_acquire() := RCpc > > - we use smp_store_release() as unlock() > > Therefore, if we want unlock+lock to imply at least TSO (ideally > smp_mb()) we need lock to make up for whatever unlock lacks. > > Hence my proposal to strenghten rmw-acquire, because that is the basic > primitive used to implement lock. > > But as you (and Will) point out, we don't so much care about rmw-acquire > semantics as much as that we care about unlock+lock behaviour. Another > way to look at this is to define: > > smp-store-release + rmw-acquire := TSO (ideally smp_mb) > > But then we also have to look at: > > rmw-release + smp-load-acquire > rmw-release + rmw-acquire > > for completeness sake, and I would suggest they result in (at least) the > same (TSO) ordering as the one we really care about. Indeed (unless I'm not seeing something... ;-). > > One alternative is to no longer use smp_store_release() for unlock(), > and say define atomic_set_release() to be in the rmw-release class > instead of being a simple smp_store_release(). > > Another, and I like this proposal least, is to introduce a new barrier > to make this all work. An smp_tso__after_unlock_lock()? (In a certain sense, the solution adopted by RCU aligns to this approach: live with powerpc's RCpc and introduce smp_mb__after_unlock_lock().) Or did you have something else in mind? But I wouldn't hasten to introduce such a barrier, given that: (1) this would be a "do { } while (0)" for all the supported arch. _if_ we sticked to the current implementations, and (2) even if these implementations changed or some new arch. required a non-trivial definition, we still would have to find a "pure/TSO" case ;-). Andrea