From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755009AbcBBWak (ORCPT ); Tue, 2 Feb 2016 17:30:40 -0500 Received: from e18.ny.us.ibm.com ([129.33.205.208]:37745 "EHLO e18.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071AbcBBWaj (ORCPT ); Tue, 2 Feb 2016 17:30:39 -0500 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 2 Feb 2016 14:30:34 -0800 From: "Paul E. McKenney" To: Linus Torvalds Cc: Boqun Feng , Will Deacon , Peter Zijlstra , "Maciej W. Rozycki" , David Daney , =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= , Ralf Baechle , Linux Kernel Mailing List Subject: Re: [RFC][PATCH] mips: Fix arch_spin_unlock() Message-ID: <20160202223034.GM6719@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20160129095958.GA4541@arm.com> <20160129102253.GG4503@linux.vnet.ibm.com> <20160201135621.GD6828@arm.com> <20160202035458.GF6719@linux.vnet.ibm.com> <20160202051904.GC1239@fixme-laptop.cn.ibm.com> <20160202064433.GG6719@linux.vnet.ibm.com> <20160202120252.GI6719@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16020222-0045-0000-0000-00000338A3F1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 02, 2016 at 09:56:14AM -0800, Linus Torvalds wrote: > On Tue, Feb 2, 2016 at 4:02 AM, Paul E. McKenney > wrote: > > > > The sorts of things I am really worried about are abominations like this > > (and far worse): > > That one doesn't have any causal chain that I can see, so I agree that > it's an abomination, but it also doesn't act as an argument. > > > r1 == 1 && r2 == 1 && c == 2 && r3 == 0 ??? > > What do you see as the problem here? The above can happen in a > strictly ordered situation: thread2 runs first (c == 2, r3 = 0), then > thread3 runs (d = 1, a = 1) then thread0 runs (r1 = 1) and then > thread1 starts running but the store to c doesn't complete (now r2 = > 1). Apologies, I should have added that the condition does not get evaluated until all the dust settles. At that point both stores to c would have completed, so that c == 1. > So there's no reason for your case to not happen, but the real issue > is that there is no causal relationship that your example describes, > so it's not even interesting. Because of the write-to-write relationship between thread1() and thread2(), yes. And I am very glad that you find this one uninteresting, because including it would make things -really- complicated. > Causality breaking is what really screws with peoples minds. The > reason transitivity is important (and why smp_read_barrier_depends() > is so annoying) is because causal breaks make peoples minds twist in > bad ways. Agreed, which means it is very important that the various flavors of release-acquire chains be transitive. In addition, smp_mb() is transitive, as are synchronize_rcu() and friends. > Sadly, memory orderings are very seldom described as honoring > causality, and instead people have the crazy litmus tests. Indeed, a memory model defined solely by litmus tests would qualify as an exotic form of torture. What we do instead is use sets of litmus tests as test cases for the prototype memory model under consideration. It is all too easy to create a set of rules that look good and sound good, but which mess something up. The litmus tests help catch these sorts of errors. Thanx, Paul