Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753300AbbEHNXS (ORCPT ); Fri, 8 May 2015 09:23:18 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48133 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751363AbbEHNXO (ORCPT ); Fri, 8 May 2015 09:23:14 -0400 Date: Fri, 8 May 2015 06:22:19 -0700 From: tip-bot for Jason Low Message-ID: Cc: bp@alien8.de, umgwanakikbuti@gmail.com, hpa@zytor.com, torvalds@linux-foundation.org, peterz@infradead.org, rostedt@goodmis.org, paulmck@linux.vnet.ibm.com, waiman.long@hp.com, jason.low2@hp.com, preeti@linux.vnet.ibm.com, akpm@linux-foundation.org, aswin@hp.com, oleg@redhat.com, tglx@linutronix.de, mgorman@suse.de, linux-kernel@vger.kernel.org, dave@stgolabs.net, scott.norton@hp.com, mingo@kernel.org, riel@redhat.com, fweisbec@gmail.com Reply-To: dave@stgolabs.net, scott.norton@hp.com, riel@redhat.com, fweisbec@gmail.com, mingo@kernel.org, preeti@linux.vnet.ibm.com, aswin@hp.com, akpm@linux-foundation.org, oleg@redhat.com, mgorman@suse.de, linux-kernel@vger.kernel.org, tglx@linutronix.de, rostedt@goodmis.org, paulmck@linux.vnet.ibm.com, peterz@infradead.org, jason.low2@hp.com, waiman.long@hp.com, bp@alien8.de, umgwanakikbuti@gmail.com, torvalds@linux-foundation.org, hpa@zytor.com In-Reply-To: <1430440094.2475.61.camel@j-VirtualBox> References: <1430440094.2475.61.camel@j-VirtualBox> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/numa: Document usages of mm->numa_scan_seq Git-Commit-ID: 7e5a2c1729f1612618ed236249a15bf15f309325 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3072 Lines: 76 Commit-ID: 7e5a2c1729f1612618ed236249a15bf15f309325 Gitweb: http://git.kernel.org/tip/7e5a2c1729f1612618ed236249a15bf15f309325 Author: Jason Low AuthorDate: Thu, 30 Apr 2015 17:28:14 -0700 Committer: Ingo Molnar CommitDate: Fri, 8 May 2015 12:13:13 +0200 sched/numa: Document usages of mm->numa_scan_seq The p->mm->numa_scan_seq is accessed using READ_ONCE/WRITE_ONCE and modified without exclusive access. It is not clear why it is accessed this way. This patch provides some documentation on that. Suggested-by: Ingo Molnar Signed-off-by: Jason Low Signed-off-by: Peter Zijlstra (Intel) Acked-by: Thomas Gleixner Acked-by: Rik van Riel Cc: Andrew Morton Cc: Aswin Chandramouleeswaran Cc: Borislav Petkov Cc: Davidlohr Bueso Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Mel Gorman Cc: Mike Galbraith Cc: Oleg Nesterov Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Preeti U Murthy Cc: Scott J Norton Cc: Steven Rostedt Cc: Waiman Long Link: http://lkml.kernel.org/r/1430440094.2475.61.camel@j-VirtualBox Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d6915a0..f18ddb7 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 field 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,14 @@ 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 + * and the update is not guaranteed to be atomic. That's not + * much of an issue though, since this is just used for + * statistical sampling. Use READ_ONCE/WRITE_ONCE, which are not + * expensive, to avoid any form of compiler optimizations: + */ WRITE_ONCE(p->mm->numa_scan_seq, READ_ONCE(p->mm->numa_scan_seq) + 1); p->mm->numa_scan_offset = 0; } -- 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/