Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756573AbbDOStc (ORCPT ); Wed, 15 Apr 2015 14:49:32 -0400 Received: from g9t5009.houston.hp.com ([15.240.92.67]:41628 "EHLO g9t5009.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755050AbbDOStX (ORCPT ); Wed, 15 Apr 2015 14:49:23 -0400 Message-ID: <1429123749.7039.107.camel@j-VirtualBox> Subject: Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler From: Jason Low To: Ingo Molnar Cc: Steven Rostedt , Peter Zijlstra , Mel Gorman , Rik van Riel , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Andrew Morton , Oleg Nesterov , Mike Galbraith , Frederic Weisbecker , Mel Gorman , Preeti U Murthy , hideaki.kimura@hp.com, Aswin Chandramouleeswaran , Scott J Norton , jason.low2@hp.com Date: Wed, 15 Apr 2015 11:49:09 -0700 In-Reply-To: <20150415074601.GC13449@gmail.com> References: <1429052986-9420-1-git-send-email-jason.low2@hp.com> <1429052986-9420-2-git-send-email-jason.low2@hp.com> <20150414195906.3adc89d9@gandalf.local.home> <1429063953.7039.88.camel@j-VirtualBox> <20150414224059.061ec5bf@grimm.local.home> <20150415074601.GC13449@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1540 Lines: 33 On Wed, 2015-04-15 at 09:46 +0200, Ingo Molnar wrote: > * Steven Rostedt wrote: > > You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, > > and just a: > > > > p->mm->numa_scan_seq = READ_ONCE(p->numa_scan_seq) + 1; > > > > Can be done. But I'm still trying to wrap my head around why this is > > needed here. Comments would have been really helpful. We should make > > all READ_ONCE() WRITE_ONCE and obsolete ACCESS_ONCE() have mandatory > > comments just like we do with memory barriers. > > So the original ACCESS_ONCE() barriers were misguided to begin with: I > think they tried to handle races with the scheduler balancing softirq > and tried to avoid having to use atomics for the sequence counter > (which would be overkill), but things like ACCESS_ONCE(x)++ never > guaranteed atomicity (or even coherency) of the update. > > But since in reality this is only statistical sampling code, all these > compiler barriers can be removed I think. Peter, Mel, Rik, do you > agree? So I'll keep the READ_ONCE nested inside WRITE_ONCE for the purpose of this patch since this patch is a conversion from ACCESS_ONCE, but yes, if the original purpose of ACCESS_ONCE was to do an atomic increment, then the ACCESS_ONCE doesn't help with that. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/