Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7016933ybi; Thu, 13 Jun 2019 08:12:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1JgO7eKDJ+KuBc8szGgRBMnbt7i7XPVy6n4RLZ6VYSqtoHU+0CJvcYF0Lz48iFNHlaAEO X-Received: by 2002:a17:90a:730b:: with SMTP id m11mr6082489pjk.89.1560438747744; Thu, 13 Jun 2019 08:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560438747; cv=none; d=google.com; s=arc-20160816; b=cklKAKlN8vGrSn00s56gsp8xvdjiCiQjLVBxJ/U7Erhcj9nnZkd2rzLUudtYlqtlr3 pftVQlN2xr2GerENVt0oSJqcnPZBe22i43TNSqy0akh+0MYqcOr/kDpM0XabWz34xM7h G5v21toCwqGyC6XB+zZOtVZnQTGYjAoRGjCd3YrwlgAJG9U0CyaT+3D3DUYHbQAX+QNU 5aKI6nnunF6GScNk6k+wyIdnIqih41GfXXDQBYvJAH7I8HR+2I7wcq+Y+7rHhRRa+HTB FhH1isPpd4/XLTF5BPZ7iv5NHoVQri+VB51d4UW+q0DVvq1qFG1BCiX4ulzDsLJSsV2t h3dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:cc:to:from:date:user-agent :message-id:dkim-signature; bh=l04+nuc8FItMhrlUdke+dDyeO4FcnJ4DLhxtL7h4uWw=; b=MIUrpSHmxD3kVBnlHX88L6OJ1bi+12odgn9211HBDLuwoHmJPqTKmV8/IYN9+U+IIN woKMcc5sTzhSlqL23NQ/SLNhnLZH8ym37lft41YFMfTTDhMsjJfqEjt0v1vCh2kkOonf Vvv/YkjBps88iiZdA4vHcqNRHrf8qa24UHk2unWsg8mkT6s3D/N+zycg5yiJOtse8Dl2 v/yFbc7TPZa1gGi1BZ1mMenfjxIgC+MEawiL/wMmZY0YQMYd+boCxpfOrg5u8cLCse4Q UkqDWjW+DvKkr2uUUivfPUoARGUK7G8OTMi74zzyWTo9bGkFH4uL5E839nzpgbmjvm0V tbdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Dyedfdz8; 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 r3si3411819plb.14.2019.06.13.08.12.12; Thu, 13 Jun 2019 08:12:27 -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=Dyedfdz8; 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 S1733112AbfFMPKp (ORCPT + 99 others); Thu, 13 Jun 2019 11:10:45 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49582 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732306AbfFMNvW (ORCPT ); Thu, 13 Jun 2019 09:51:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Subject:Cc:To:From:Date:Message-Id: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=l04+nuc8FItMhrlUdke+dDyeO4FcnJ4DLhxtL7h4uWw=; b=Dyedfdz8cqa1qtwMp4kxTOjis yz6nEYshl3JJmNB6VXPpJNo560qsMGykCHEhUrEl7UPK5q7gjLymIqN7dbMKW/6p6oiEZXDRetq9L BppDMIVPaY/ATTg4tP2vaIFm1d/pSCPSwX9JpZO5Fvzth8PbuQomyeC6xv+yn7yARxVU7LTnaWwqZ WcCeaOQlpgze1p3Qi/vrSeYF9FfL8gE/U/l8jsxtuGp+MK1aOdqaGcZzvQJgOmYzOPpdqjvVisGny iGzfeLgu2nOeGsTY6xQ0oCN0JJGNn8sr1MrsG918wFRehWQjHgCSMHkOksRUXU8G0ZAzVd9OKhsBj nYMSOBLPw==; 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.92 #3 (Red Hat Linux)) id 1hbQ7z-0004Bn-KB; Thu, 13 Jun 2019 13:50:55 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id EE15520316592; Thu, 13 Jun 2019 15:50:53 +0200 (CEST) Message-Id: <20190613134317.734881240@infradead.org> User-Agent: quilt/0.65 Date: Thu, 13 Jun 2019 15:43:17 +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, peterz@infradead.org, will.deacon@arm.com, paul.burton@mips.com Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org Subject: [PATCH v2 0/4] atomic: Fixes to smp_mb__{before,after}_atomic() and mips. Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This all started when Andrea Parri found a 'surprising' behaviour for x86: http://lkml.kernel.org/r/20190418125412.GA10817@andrea Basically we fail for: *x = 1; atomic_inc(u); smp_mb__after_atomic(); r0 = *y; Because, while the atomic_inc() implies memory order, it (surprisingly) does not provide a compiler barrier. This then allows the compiler to re-order like so: atomic_inc(u); *x = 1; smp_mb__after_atomic(); r0 = *y; Which the CPU is then allowed to re-order (under TSO rules) like: atomic_inc(u); r0 = *y; *x = 1; And this very much was not intended. This had me audit all the (strong) architectures that had weak smp_mb__{before,after}_atomic: ia64, mips, sparc, s390, x86, xtensa. Of those, only x86 and mips were affected. Looking at MIPS to solve this, led to the other MIPS patches. All these patches have been through 0day for quite a while. Paul, how do you want to route the MIPS bits?