From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx121.postini.com [74.125.245.121]) by kanga.kvack.org (Postfix) with SMTP id AE47D6B00BE for ; Wed, 3 Oct 2012 19:51:55 -0400 (EDT) From: Andrea Arcangeli Subject: [PATCH 15/33] autonuma: alloc/free/init task_autonuma Date: Thu, 4 Oct 2012 01:50:57 +0200 Message-Id: <1349308275-2174-16-git-send-email-aarcange@redhat.com> In-Reply-To: <1349308275-2174-1-git-send-email-aarcange@redhat.com> References: <1349308275-2174-1-git-send-email-aarcange@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Linus Torvalds , Andrew Morton , Peter Zijlstra , Ingo Molnar , Mel Gorman , Hugh Dickins , Rik van Riel , Johannes Weiner , Hillf Danton , Andrew Jones , Dan Smith , Thomas Gleixner , Paul Turner , Christoph Lameter , Suresh Siddha , Mike Galbraith , "Paul E. McKenney" , Lai Jiangshan , Bharata B Rao , Lee Schermerhorn , Srivatsa Vaddagiri , Alex Shi , Mauricio Faria de Oliveira , Konrad Rzeszutek Wilk , Don Morris , Benjamin Herrenschmidt This is where the dynamically allocated task_autonuma structure is being handled. This is the structure holding the per-thread NUMA statistics generated by the NUMA hinting page faults. This per-thread NUMA statistical information is needed by sched_autonuma_balance to make optimal NUMA balancing decisions. It also contains the task_selected_nid which hints the stock CPU scheduler on the best NUMA node to schedule this thread on (as decided by sched_autonuma_balance). The reason for keeping this outside of the task_struct besides not using too much kernel stack, is to only allocate it on NUMA hardware. So the non NUMA hardware only pays the memory of a pointer in the kernel stack (which remains NULL at all times in that case). If the kernel is compiled with CONFIG_AUTONUMA=n, not even the pointer is allocated on the kernel stack of course. Signed-off-by: Andrea Arcangeli --- kernel/fork.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 14d68d3..1d8a7e8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -209,6 +209,7 @@ void free_task(struct task_struct *tsk) { account_kernel_stack(tsk->stack, -1); arch_release_thread_info(tsk->stack); + free_task_autonuma(tsk); free_thread_info(tsk->stack); rt_mutex_debug_task_free(tsk); ftrace_graph_exit_task(tsk); @@ -264,6 +265,9 @@ void __init fork_init(unsigned long mempages) /* do the arch specific task caches init */ arch_task_cache_init(); + /* prepare task_autonuma for alloc_task_autonuma/free_task_autonuma */ + task_autonuma_init(); + /* * The default maximum number of threads is set to a safe * value: the thread structures can take up at most half @@ -310,6 +314,10 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) if (err) goto free_ti; + if (unlikely(alloc_task_autonuma(tsk, orig, node))) + /* free_thread_info() undoes arch_dup_task_struct() too */ + goto free_ti; + tsk->stack = ti; setup_thread_stack(tsk, orig); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org