Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1550255yba; Thu, 25 Apr 2019 01:31:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg0mhs1BwhycEYpOPtmIi9aS6Av8K/otLCVSdcvCXRqmKp3xmLyp+3OGGv0A2rhH/M6D64 X-Received: by 2002:aa7:800e:: with SMTP id j14mr38049775pfi.157.1556181066018; Thu, 25 Apr 2019 01:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556181066; cv=none; d=google.com; s=arc-20160816; b=LSR9VZHZGxsBb+VEL8O0CZ6NLqGh/EIZVq/usOrsH7q0lev1KsFFEpWqpSFm1+s3bW 6A33T4XDDpjjualLqxU8PcjjWEkmxX/pVDpztvr03wJRM/JBpTDk+S+AXLZ6fXw98J3C puej+4jDxbUoALk88x4EQ9HwRtqaWQXkoN4dBoDlpGOtbK7hMgiP7vK0KG3gEIdRD0Hc VUjG4nF/IZYSxvVGgFV8QkwL+NRnEnQoCXIxtPlBU/IrxfRautS3U6NnzfgmYuNL1Spz K0cihJ6lxnBkSch/UAC/SD6D2/WUsuZmO54+vJyFlahjvDecvuXJG+0YhX64EqDd0DCe ddfg== 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=7SBdbneTIvlthhDhg6TpFypFUS7+gOMvyzOHEIcI3nc=; b=bqGp9de5vRbYMtqJv1eKmVMrcbaeSxh3aOEq9xjhQgqBe1vFRTxlaSpwbzTzIqYvyy 0g+NBYv3QNDxIjx7chJIQw1uI+YiQWy3+XnfzS2nhqlUSSmD+IBpVA5HsJ+ZqFFtMQp4 IphqJhs5sHdNfgwKNXVRh+zmlPtfwZaG7hhtGkiLOJgNy54sFBR2nmgMF594AcjSE4N6 +5oXRM+Y4i2/8NlW0uxeIpIMG2HLeXyAhNwB5ntOZCdgPlbgHUE/eHLteeNoMFMewjXZ QEGRlzBKiaftvBoVd154xKenGWj3DmA2gnBAZkmJA1JhaU4o818ozD2A99eiE9zFZJZw ZxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=3kRAaV2g; 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 j187si22400184pfc.181.2019.04.25.01.30.50; Thu, 25 Apr 2019 01:31:06 -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=3kRAaV2g; 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 S1729930AbfDYG7t (ORCPT + 99 others); Thu, 25 Apr 2019 02:59:49 -0400 Received: from merlin.infradead.org ([205.233.59.134]:47258 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbfDYG7t (ORCPT ); Thu, 25 Apr 2019 02:59:49 -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=7SBdbneTIvlthhDhg6TpFypFUS7+gOMvyzOHEIcI3nc=; b=3kRAaV2gxYu2GzuzIzRUU/xjJ mbLxblsafMZZXtjyP64G0UJ8HEE8ASi7/DFavQceu3cX3Mg8ck+jY1HOjPfo0lttqkDI8T8KGgCh7 oZ8gC5fE6D1iQFye1WrxtGajJeC69R09VBJgQQ5yzWpX/hIGpY9l547N8+Ltoc//WA9mVQGeu4BNN B5v/19vS/MICl/jBC3RQmTUIzj2uCb2QZqJHFfaN+Qz+tj+UXJHm+pQGQTmyhAN45SEvP6PHqDQ+9 FWbbhQUyVNeXLXrluUd8ubuA/d99ikN5PFaN8gb96+7NRwHIXst7WlUWD4LNJ7xADlY1vCdwpwA4B dFPZiTcRA==; 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 1hJYLu-0008Qg-2d; Thu, 25 Apr 2019 06:59:26 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5407B20D0A201; Thu, 25 Apr 2019 08:59:23 +0200 (CEST) Date: Thu, 25 Apr 2019 08:59:23 +0200 From: Peter Zijlstra To: Paul Burton Cc: "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" , "linux-kernel@vger.kernel.org" , "torvalds@linux-foundation.org" Subject: Re: [RFC][PATCH 1/5] mips/atomic: Fix cmpxchg64 barriers Message-ID: <20190425065923.GT11158@hirez.programming.kicks-ass.net> References: <20190424123656.484227701@infradead.org> <20190424124421.579563933@infradead.org> <20190424210019.knq4nijg3xoqxzhg@pburton-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190424210019.knq4nijg3xoqxzhg@pburton-laptop> 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 09:00:25PM +0000, Paul Burton wrote: > Hi Peter, > > On Wed, Apr 24, 2019 at 02:36:57PM +0200, Peter Zijlstra wrote: > > There were no memory barriers on cmpxchg64() _at_all_. Fix this. > > This does looks problematic, but it's worth noting that this code path > is only applicable to 32b kernels running on 64b CPUs which is pretty > rare. The commit message as-is suggests to me that all configurations > are broken, which isn't the case (at least, not in this respect :) ). OK, I hadn't gone through the ifdef selection process. I just encountered this cmpxchg implementation and noted a significant lack of barriers. > > > > Cc: Paul Burton > > Signed-off-by: Peter Zijlstra (Intel) > > --- > > arch/mips/include/asm/cmpxchg.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > --- a/arch/mips/include/asm/cmpxchg.h > > +++ b/arch/mips/include/asm/cmpxchg.h > > @@ -290,9 +290,11 @@ static inline unsigned long __cmpxchg64( > > * will cause a build error unless cpu_has_64bits is a \ > > * compile-time constant 1. \ > > */ \ > > - if (cpu_has_64bits && kernel_uses_llsc) \ > > + if (cpu_has_64bits && kernel_uses_llsc) { \ > > + smp_mb__before_llsc(); \ > > __res = __cmpxchg64((ptr), __old, __new); \ > > - else \ > > + smp_llsc_mb(); \ > > + } else \ > > __res = __cmpxchg64_unsupported(); \ > > It would be good to also add braces around the else block, and I believe > checkpatch should be complaining about that ("braces {} should be used > on all arms of this statement"). You're right, I'll fix up.