From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932856AbdIYA1D (ORCPT ); Sun, 24 Sep 2017 20:27:03 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59742 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932660AbdIYA1B (ORCPT ); Sun, 24 Sep 2017 20:27:01 -0400 Date: Sun, 24 Sep 2017 17:26:53 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Steven Rostedt , Linux Kernel Mailing List , Ingo Molnar , Andrew Morton , stable Subject: Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers Reply-To: paulmck@linux.vnet.ibm.com References: <20170923205621.811805556@goodmis.org> <20170923205804.098759069@goodmis.org> <20170925000303.GJ3521@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-GCONF: 00 x-cbid: 17092500-0044-0000-0000-00000394B708 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007786; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000231; SDB=6.00921895; UDB=6.00463312; IPR=6.00702037; BA=6.00005602; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017261; XFM=3.00000015; UTC=2017-09-25 00:26:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092500-0045-0000-0000-000007C3BD82 Message-Id: <20170925002653.GL3521@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-24_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709250004 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 24, 2017 at 05:12:13PM -0700, Linus Torvalds wrote: > On Sun, Sep 24, 2017 at 5:03 PM, Paul E. McKenney > wrote: > > > > Mostly just paranoia on my part. I would be happy to remove it if > > you prefer. Or you or Steve can do so if that is more convenient. > > I really don't think it's warranted. The values are *stable*. There's > no subtle lack of locking, or some optimistic access to a value that > can change. > > The compiler can generate code to read the value fifteen billion > times, and it will always get the same value. > > Yes, maybe in between the different accesses, an NMI will happen, and > the value will be incremented, but then as the NMI exits, it will > decrement again, so the code that got interrupted will not actually > see the change. > > So the READ_ONCE() isn't "paranoia". It's just confusing. > > > And yes, consistency would dictate that the uses in rcu_nmi_enter() > > and rcu_nmi_exit() should be _ONCE(), particularly the stores to > > ->dynticks_nmi_nesting. > > NO. > > That would be just more of that confusion. > > That value is STABLE. It's stable even within an NMI handler. The NMI > code can read it, modify it, write it back, do a little dance, all > without having to care. There's no "_ONCE()" about it - not for the > readers, not for the writers, not for _anybody_. > > So adding even more READ/WRITE_ONCE() accesses wouldn't be > "consistent", it would just be insanity. > > Now, if an NMI happens and the value would be different on entry than > it is on exit, that would be something else. Then it really wouldn't > be stable wrt random users. But that would also be a major bug in the > NMI handler, as far as I can tell. > > So the reason I'm objecting to that READ_ONCE() is that it isn't > "paranoia", it's "voodoo programming". And we don't do voodoo > programming. I already agreed that the READ_ONCE() can be removed. But without the WRITE_ONCE(), the compiler could theoretically tear the store. Now we might be asserting that our compilers don't do that, and that if they ever do, we will file a bug or whatever. So are we asserting that our compilers won't ever do store tearing? Thanx, Paul