From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbaA3XI2 (ORCPT ); Thu, 30 Jan 2014 18:08:28 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:60512 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753330AbaA3XI1 (ORCPT ); Thu, 30 Jan 2014 18:08:27 -0500 Date: Thu, 30 Jan 2014 15:08:12 -0800 From: Nishanth Aravamudan To: David Rientjes Cc: Eric Dumazet , Christoph Lameter , Eric Dumazet , LKML , Anton Blanchard , Andrew Morton , Tejun Heo , Oleg Nesterov , Jan Kara , Thomas Gleixner , Tetsuo Handa , linux-mm@kvack.org, Wanpeng Li , Joonsoo Kim , Ben Herrenschmidt Subject: [PATCH] kthread: ensure locality of task_struct allocations Message-ID: <20140130230812.GA874@linux.vnet.ibm.com> References: <20140128183808.GB9315@linux.vnet.ibm.com> <1391062491.28432.68.camel@edumazet-glaptop2.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux 3.11.0-15-generic (x86_64) User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14013023-9332-0000-0000-000002F1DB8D Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.01.2014 [14:47:05 -0800], David Rientjes wrote: > On Wed, 29 Jan 2014, Eric Dumazet wrote: > > > > Eric, did you try this when writing 207205a2ba26 ("kthread: NUMA aware > > > kthread_create_on_node()") or was it always numa_node_id() from the > > > beginning? > > > > Hmm, I think I did not try this, its absolutely possible NUMA_NO_NODE > > was better here. > > > > Nishanth, could you change your patch to just return NUMA_NO_NODE for the > non-kthreadd case? Something like the following? In the presence of memoryless nodes, numa_node_id() will return the current CPU's NUMA node, but that may not be where we expect to allocate from memory from. Instead, we should rely on the fallback code in the memory allocator itself, by using NUMA_NO_NODE. Also, when calling kthread_create_on_node(), use the nearest node with memory to the cpu in question, rather than the node it is running on. Signed-off-by: Nishanth Aravamudan Cc: Anton Blanchard Cc: Christoph Lameter Cc: Andrew Morton Cc: Tejun Heo Cc: Oleg Nesterov Cc: Jan Kara Cc: David Rientjes Cc: Thomas Gleixner Cc: Tetsuo Handa Cc: linux-kernel@vger.kernel.org Cc: Wanpeng Li Cc: Joonsoo Kim Cc: Ben Herrenschmidt --- Note that I haven't yet tested this change on the system that reproduce the original problem yet. diff --git a/kernel/kthread.c b/kernel/kthread.c index b5ae3ee..9a130ec 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -217,7 +217,7 @@ int tsk_fork_get_node(struct task_struct *tsk) if (tsk == kthreadd_task) return tsk->pref_node_fork; #endif - return numa_node_id(); + return NUMA_NO_NODE; } static void create_kthread(struct kthread_create_info *create) @@ -369,7 +369,7 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data), { struct task_struct *p; - p = kthread_create_on_node(threadfn, data, cpu_to_node(cpu), namefmt, + p = kthread_create_on_node(threadfn, data, cpu_to_mem(cpu), namefmt, cpu); if (IS_ERR(p)) return p;