Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932256AbbDQITz (ORCPT ); Fri, 17 Apr 2015 04:19:55 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:36296 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932222AbbDQITq (ORCPT ); Fri, 17 Apr 2015 04:19:46 -0400 Date: Fri, 17 Apr 2015 10:19:41 +0200 From: Ingo Molnar To: Jason Low Cc: Peter Zijlstra , Steven Rostedt , Rik van Riel , Linus Torvalds , 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 Subject: Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler Message-ID: <20150417081941.GA11663@gmail.com> References: <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> <20150416165224.GD12676@worktop.ger.corp.intel.com> <20150416180227.GB17401@gmail.com> <20150416181535.GA23123@twins.programming.kicks-ass.net> <20150416182426.GA17852@gmail.com> <1429241148.7039.187.camel@j-VirtualBox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1429241148.7039.187.camel@j-VirtualBox> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1804 Lines: 52 * Jason Low wrote: > On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote: > > Would it make sense to add a few comments to the seq field definition > > site(s), about how it's supposed to be accessed - or to the > > READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering? > > How about this: > > --- > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 5a44371..63fa87f 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -1794,6 +1794,11 @@ static void task_numa_placement(struct task_struct *p) > u64 runtime, period; > spinlock_t *group_lock = NULL; > > + /* > + * The p->mm->numa_scan_seq gets updated without > + * exclusive access. Use READ_ONCE() here to ensure > + * that the field is read in a single access. > + */ > seq = READ_ONCE(p->mm->numa_scan_seq); > if (p->numa_scan_seq == seq) > return; > @@ -2107,6 +2112,13 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags) > > static void reset_ptenuma_scan(struct task_struct *p) > { > + /* > + * We only did a read acquisition of the mmap sem, so > + * p->mm->numa_scan_seq is written to without exclusive access. > + * That's not much of an issue though, since this is just used > + * for statistical sampling. Use WRITE_ONCE and READ_ONCE, which > + * are not expensive, to avoid load/store tearing. > + */ > WRITE_ONCE(p->mm->numa_scan_seq, READ_ONCE(p->mm->numa_scan_seq) + 1); > p->mm->numa_scan_offset = 0; > } Perfect! It just needs a changelog and a SOB. Thanks, Ingo -- 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/