Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6857082ybn; Mon, 30 Sep 2019 05:03:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxt54PU5FWda6quXuxcLd4nCKEKs810xeuY7uAnYlt7DcvAHwJQRnEZ4dijDX/yOChMIyPu X-Received: by 2002:a17:906:b259:: with SMTP id ce25mr18050806ejb.229.1569844991970; Mon, 30 Sep 2019 05:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569844991; cv=none; d=google.com; s=arc-20160816; b=DyllYbLi6gnzUAi0tpnhnnAnK0BWczUdM54Jt3Tx2QJVzF8M0CbEkDZgBd9feV1CaV BF+dnAX5LgNKwDMrMnDSx+SsqH8JrayVfEOvt3HhE4I/nXIxWAcJg/LDqa/rXyI+VDv/ SsmBVHDmdBUTZVZ+e0pP94BUrQmHtANmE3LVDV/pVyLmaC2bXcmrkmm5sfr8qveQ4eHp INMueTLSB5ljDcUy6AeRTg1kOyBAiFguc4NrXba16XR7FgA40l2f5rG9FIDyGwOxBb9O iBeU3juO+NzJzHaDz6UZAG+6CHmCLlj4VpaLsBG4EjFjSyZzhqDlvMDF1h8k2SzEyKEo KTfQ== 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; bh=vfk8m9QbBK1FdL+EkeiKXOXWonMZIkbTRy0qgB3cHYI=; b=RYSojD/Yn3XiL1cVGpPYOF55FP4gCq8LLlxd4VIQ+2yLPGZ5gSq/cKZ2oEZoJ+J6jO l/3OjXISDkQy/7b3+pHmftr9xt6XDfCkGvuVjqPDy/1pB/jZWF1hEvWDPySUYt6Psd6E J7P3iz7u5Dec8uQuPwzKqSh13Qgro4nnsc3LAxbeF/gMapFxaDp6eFCTdpy8bmirkam7 BCdZWUfho5Oy7ASa4pSu/5blpQMRc/VsgSmB5pqW7tgDWpHshPm9T7fGYK8DEeX+pdWC IPXC/aBONzI86GMzDkp1DnzbbSzezibRY0kRudwJ/q3OirBYm5U8GOA9ZFIpImHcYY28 X7CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="HjwYwgi/"; 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 y54si7572805edb.217.2019.09.30.05.02.42; Mon, 30 Sep 2019 05:03:11 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="HjwYwgi/"; 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 S1729738AbfI3MCh (ORCPT + 99 others); Mon, 30 Sep 2019 08:02:37 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33704 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbfI3MCh (ORCPT ); Mon, 30 Sep 2019 08:02:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vfk8m9QbBK1FdL+EkeiKXOXWonMZIkbTRy0qgB3cHYI=; b=HjwYwgi/EIYOQ8bR9Z9KaYmT8 Sa0tldH7sSDElZIycK1FpzfRFINKnUKULso6uFJ6YbH4s/cdUrNeLeB8NVNZ1tsEYEPnFqyDbszRn OIaewYlAAr9v4/EefDBfiD10GfWsFq6xZZSESk5Kva+dvbJsHLkegD69D6hE4YJ8jRPfeDSMMxqTx 46CW/xbjODAcJ6ZbS2dfDR5wGTQA1xJcyZWwk9+C4HyzHsSwKQ5pJIduYayXQJhYOxVHQFWLC9scg SAWR2+VssywWFz2l9RKeX4B0PVPBMhEZalpS2bFTWjci+ELJk2xnwcQU0KZqqYlT0C0O9FJpTVqL/ BfbUC87Nw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iEuNr-0001tA-8b; Mon, 30 Sep 2019 12:02:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 685CE3056B6; Mon, 30 Sep 2019 14:01:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3B08D265261AA; Mon, 30 Sep 2019 14:02:29 +0200 (CEST) Date: Mon, 30 Sep 2019 14:02:29 +0200 From: Peter Zijlstra To: Nick Desaulniers Cc: Andrea Parri , David Howells , Linus Torvalds , Will Deacon , "Paul E. McKenney" , Mark Rutland , Linux List Kernel Mailing , linux-fsdevel , jose.marchesi@oracle.com Subject: Re: Do we need to correct barriering in circular-buffers.rst? Message-ID: <20190930120229.GD4581@hirez.programming.kicks-ass.net> References: <28447.1568728295@warthog.procyon.org.uk> <20190917170716.ud457wladfhhjd6h@willie-the-truck> <15228.1568821380@warthog.procyon.org.uk> <5385.1568901546@warthog.procyon.org.uk> <20190923144931.GC2369@hirez.programming.kicks-ass.net> <20190927095107.GA13098@andrea> <20190927124929.GB4643@worktop.programming.kicks-ass.net> <20190930093352.GM4553@hirez.programming.kicks-ass.net> <20190930115440.GC4581@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190930115440.GC4581@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 30, 2019 at 01:54:40PM +0200, Peter Zijlstra wrote: > On Mon, Sep 30, 2019 at 11:33:52AM +0200, Peter Zijlstra wrote: > > Like I said before, something like: "disallowing store hoists over control > > flow depending on a volatile load" would be sufficient I think. > > We need to add 'control flow depending on an inline-asm' to that. We > also very much use that. An example of that would be something like: bool spin_try_lock(struct spinlock *lock) { u32 zero = 0; if (atomic_try_cmpxchg_relaxed(&lock->val, &zero, 1)) { smp_acquire__after_ctrl_dep(); /* aka smp_rmb() */ return true; } return false; } (I think most our actual trylock functions use cmpxchg_acquire(), but the above would be a valid implementation -- and it is the simplest construct using smp_acquire__after_ctrl_dep() I could come up with in a hurry)