Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756732AbbDPCq1 (ORCPT ); Wed, 15 Apr 2015 22:46:27 -0400 Received: from g2t2354.austin.hp.com ([15.217.128.53]:32920 "EHLO g2t2354.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbbDPCqU (ORCPT ); Wed, 15 Apr 2015 22:46:20 -0400 Message-ID: <1429152365.7039.167.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 19:46:05 -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: 1655 Lines: 45 Hi Ingo, 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? Though in the read side for accessing things such as numa_scan_seq, we still want to keep them in order to guarantee that numa_scan_seq is only loaded once right? static void task_numa_placement(struct task_struct *p) { ... seq = ACCESS_ONCE(p->mm->numa_scan_seq); if (p->numa_scan_seq == seq) return; p->numa_scan_seq = seq; ... } -- 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/