Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp614834yba; Wed, 24 Apr 2019 06:56:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlG6IapIiZIzGklk9VuBtfwFIobOY/3TBkkL1nDWmUK9pOj9M2W7wbKkDjcA1e0Q3PctGy X-Received: by 2002:a17:902:bb84:: with SMTP id m4mr31608466pls.302.1556114190993; Wed, 24 Apr 2019 06:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556114190; cv=none; d=google.com; s=arc-20160816; b=H3aP30W3o36c3xRcgp5uQJDmn7ulft9T7wyUEjWWX6luk+s89Xse/qE1ooQ/8jqO81 ylU8aezDvhhB4MIT3VUqyFsj5sRXY+iySaiw04IhxnUB4kLE4EBiJ3nBaDcLZwEu/k/L 3OVehUovpzUxBdgQwKAV594wJxo0ec37RkWOZ5NY1UhV8CulmO684D5ZNXKE9heUZcLC leCCr7qnKEO2yWMRKyAjWJpGE74xeRnaytPStJYOs8tj1NwxSEPV+F6q5C9gq2szP09g vRHwA2rogHFPogANsJ4+0De30gmoVoWFbGqeNCDgdprXvXaFCTVoO9k3T3hE5q60eOKw 2ZZA== 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=7QX33KgC67PDoTzrkrqnfdnUhUCkvPPCxb+Xpw4YLKc=; b=UGes5KoXuSeZ6TYeIJcbFfHK/3XA5o0Qul968HQTa8E0b5wBguotw828aEaE+nZuRm 1dGsmS4rPip+GGWIJFwDHzF/cPiBD/9TmQtLZ95fRbqPgNHI37ORERPBeQAcAkpsIwZ8 Wt91kgDBALZmNYZJEFnAW2KjnsCdOXqFUq5liy1hXQfMvAx1xPGlAol+RgTCZGpc1RlE An1fRzHn+EjgSoplKo42PIgAUIcZ4XPPUjJiCuUSitaOBldWYr3RpMsW5qHKk/d3rASD HuGsBE07otQhk4kTD0tDp4MY5/2iJdkVLqfmEwVi2t/Y2ZjLrl1ewoRuVpMuHgTDK0IR 4Yfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=mzKcNJef; 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 i76si3913406pgd.558.2019.04.24.06.56.14; Wed, 24 Apr 2019 06:56:30 -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=merlin.20170209 header.b=mzKcNJef; 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 S1730195AbfDXM7k (ORCPT + 99 others); Wed, 24 Apr 2019 08:59:40 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34688 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbfDXM7j (ORCPT ); Wed, 24 Apr 2019 08:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=7QX33KgC67PDoTzrkrqnfdnUhUCkvPPCxb+Xpw4YLKc=; b=mzKcNJefoMtUENFS+fT8vBw/b tMBRZ2HSCIhMFX4cFwOKcY8SqdrqPSa3Ll/tBOMLJiRUOPpO/KyDiAZfWGU2x4fVrfcAFPrhnA/zi mAov4DUDwTBKVgTTz502tzocn7w5kJhjhzB7bwqB/Qy+7q8JBGMzWTN6wXIkcRRVqWEqZ/QwDWpgu 6cKhOG4nyHq3LC+KZoZgFLS4NlsduaoGRFuUPW4NTzSSG9I7LS/RUPdac1tS2Aur2GPP+K6CuFiW+ jmtdGln8ys5QPk6Kefb+LZY9kWXNMd5Fh2rWDRppku6Pl0gMTQjux4hfpzQ2E3QXHVe+7VgvOwV2C w/l6k5E/Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJHUZ-0003LE-71; Wed, 24 Apr 2019 12:59:15 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EEA5729BD4885; Wed, 24 Apr 2019 14:59:13 +0200 (CEST) Date: Wed, 24 Apr 2019 14:59:13 +0200 From: Peter Zijlstra To: stern@rowland.harvard.edu, akiyks@gmail.com, andrea.parri@amarulasolutions.com, boqun.feng@gmail.com, dlustig@nvidia.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, npiggin@gmail.com, paulmck@linux.ibm.com, will.deacon@arm.com Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, Huacai Chen , Huang Pei , Paul Burton Subject: Re: [RFC][PATCH 2/5] mips/atomic: Fix loongson_llsc_mb() wreckage Message-ID: <20190424125913.GO12232@hirez.programming.kicks-ass.net> References: <20190424123656.484227701@infradead.org> <20190424124421.636767843@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190424124421.636767843@infradead.org> 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 Wed, Apr 24, 2019 at 02:36:58PM +0200, Peter Zijlstra wrote: > The comment describing the loongson_llsc_mb() reorder case doesn't > make any sense what so ever. Instruction re-ordering is not an SMP > artifact, but rather a CPU local phenomenon. This means that _every_ > LL/SC loop needs this barrier right in front to avoid the CPU from > leaking a memop inside it. > > For the branch speculation case; if futex_atomic_cmpxchg_inatomic() > needs one at the bne branch target, then surely the normal > __cmpxch_asmg() implementation does too. We cannot rely on the > barriers from cmpxchg() because cmpxchg_local() is implemented with > the same macro, and branch prediction and speculation are, too, CPU > local. Also; just doing them all makes for much simpler rules and less mistakes.