Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp377267imm; Wed, 11 Jul 2018 04:11:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfyohhhsKjIklkYy49QbdhR/bnByopDVVQi+NelXyRdYKMIFCp47IbStEojX0QeQ7lj0ONV X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr26457606pgv.307.1531307509437; Wed, 11 Jul 2018 04:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531307509; cv=none; d=google.com; s=arc-20160816; b=VbNeTLm8NFi7+ZI/2EEufTWodrpfSU3REt6Qio5hqvzN8oHd7gDY/Zmctxna7L2ihn naCPAltXl0/xWGuwxw88Cba19g/Cn+oO+odgm9WKmOrgFK4MaedLQI+A4ptqx7tqG39r 6C4CVaPgO42LnQJvYej+k3qsHQ2wgrxZkK03Utq3TPAT75cacPS0RzIT/rxgxCX4e6MQ mNTjSvCRpAv0fFG2ZB7ZMIuzkhFD/uNj/4/cvITze3sG32GarGRzf67yQFyukvdSJLSc MPJKdHG1g+Lr5ksK3C2SDtxP7ctctLlIRv+qOzI9WG2aNh5Xbx9DKr11brxxQaWnafTU zqKg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=dAuCZZJoWD4NjzZ2cdhm7v1L5BsGI2qcbVsgK7bWiXY=; b=N9xHLlrZvGwvAVId3tGwI3ogVjkd4dUgKx1BiFSlrhzQH5OReiK+6urFo68pzsab1Z y1dgYjoUPMVmUCc9v3dh+9D4xB1yY+UxaLKb+KsmVjyqG6pt7zVTjyfBxr0ulvaqi+lJ 2we9pxv+1ROVDYgXtDCqk+duuk7sOiW79iU6UhjjpHVbYeC7dm/w85uHaRhPM/KmyuML pBfu09QT6v9K+T6aQoVeRI/kl6uoos5uzoLQM6mJs1TqXM7Wz1CetnIwzVHelDU5T8f6 8bjc6MfYBPPCAPHD3CbhxBgzca5dWcnpXSNmiqvmdt3MczeGcCD+a4O0auJLqUdmg88G 3qiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=UQCd5mF4; 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 85-v6si20416489pfm.264.2018.07.11.04.11.34; Wed, 11 Jul 2018 04:11:49 -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=UQCd5mF4; 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 S1732622AbeGKLOF (ORCPT + 99 others); Wed, 11 Jul 2018 07:14:05 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34856 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732606AbeGKLOE (ORCPT ); Wed, 11 Jul 2018 07:14:04 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=dAuCZZJoWD4NjzZ2cdhm7v1L5BsGI2qcbVsgK7bWiXY=; b=UQCd5mF4Xx1PRok2IwVGTe3dVV 8bGmTGE0j530pWZfYxTbApW6dwSWrFT3UtSDFgmlfNpShjR8fnBqflg4ruXv8tuHoS2ZURr7/mtcl I17mz2r+HOaKyzW+x7eFFU6ZtQpYW0raoOdotsB750Dtsi6tYsj+DScM96SRKLZHYslSyjcLQHXLb zy76FP8I+YXRLLbs2cRQfZ1E4Ms8UmMIuYenrcufB20Gw0otYrCtgCX9Crb+3cBaDKDOxaFVKOTon meUxYBU36JjupCoOpbz5XsUm3K2T4ZHycox/kU/Px48b5B2g99pK0ak+jYNDTC4tNEqjXB432tavF teWbhhww==; 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 1fdD0M-0007DG-Ay; Wed, 11 Jul 2018 11:09:54 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EB40320289CB2; Wed, 11 Jul 2018 13:09:52 +0200 (CEST) Date: Wed, 11 Jul 2018 13:09:52 +0200 From: Peter Zijlstra To: Will Deacon Cc: Jiaxun Yang , linux-mips@linux-mips.org, =?utf-8?B?6ZmI5Y2O5omN?= , Paul Burton , Ralf Baechle , James Hogan , Fuxin Zhang , wuzhangjin , stable , Alan Stern , Andrea Parri , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , LKML Subject: Re: [PATCH V2] MIPS: implement smp_cond_load_acquire() for Loongson-3 Message-ID: <20180711110952.GC2476@hirez.programming.kicks-ass.net> References: <1531103198-16764-1-git-send-email-chenhc@lemote.com> <20180710121727.GK2476@hirez.programming.kicks-ass.net> <5471216.FKXZRxKFUI@flygoat-ry> <20180711102106.GG13963@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180711102106.GG13963@arm.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 11, 2018 at 11:21:06AM +0100, Will Deacon wrote: > On Wed, Jul 11, 2018 at 06:05:51PM +0800, Jiaxun Yang wrote: > > On 2018-7-10 Tue at 20:17:27,Peter Zijlstra Wrote: > > > Still, even with the rules above, the best work-around is still the very > > > same cpu_relax() hack. > > > > As you say, SFB makes Loongson not fully SMP-coherent. > > However, modify cpu_relax can solve the current problem, > > but not so straight forward. On the other hand, providing a Loongson-specific > > WRITE_ONCE looks more reasonable, because it the eliminate the "non-cohrency". > > So we can solve the bug from the root. > > Curious, but why is it not straight-forward to hack cpu_relax()? If you try > to hack WRITE_ONCE, you also need to hack atomic_set, atomic64_set and all > the places that should be using WRITE_ONCE but aren't ;~) Right. The problem isn't stores pre-se, normal progress should contain enough stores to flush out 'old' bits in the natural order of things. But the problem is spin-wait loops that inhibit normal progress (and thereby store-buffer flushing). And all spin-wait loops should be having cpu_relax() in them. So cpu_relax() is the natural place to fix this. Adding SYNC to WRITE_ONCE()/atomic* will hurt performance lots and will ultimately not guarantee anything more; and as Will said, keep you chasing dragons where people forgot to use WRITE_ONCE() where they maybe should've.