- To: linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx
- Subject: [PATCH 17/39] autonuma: alloc/free/init sched_autonuma
- From: Andrea Arcangeli <aarcange@xxxxxxxxxx>
- Date: Mon, 26 Mar 2012 19:46:04 +0200
- Cc: Hillf Danton <dhillf@xxxxxxxxx>, Dan Smith <danms@xxxxxxxxxx>, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxx>, Paul Turner <pjt@xxxxxxxxxx>, Suresh Siddha <suresh.b.siddha@xxxxxxxxx>, Mike Galbraith <efault@xxxxxx>, "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx>, Lai Jiangshan <laijs@xxxxxxxxxxxxxx>, Bharata B Rao <bharata.rao@xxxxxxxxx>, Lee Schermerhorn <Lee.Schermerhorn@xxxxxx>, Rik van Riel <riel@xxxxxxxxxx>, Johannes Weiner <hannes@xxxxxxxxxxx>
- Delivered-to: linux-mm-outgoing@xxxxxxxxx
- Delivered-to: int-list-linux-mm@xxxxxxxxx
- Delivered-to: linux-mm@xxxxxxxxx
- In-reply-to: <1332783986-24195-1-git-send-email-aarcange@redhat.com>
This is where the dynamically allocated sched_autonuma structure is
being handled.
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 not 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 <aarcange@xxxxxxxxxx>
---
kernel/fork.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index ba3b339..938098b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -168,6 +168,7 @@ static void account_kernel_stack(struct thread_info *ti, int account)
void free_task(struct task_struct *tsk)
{
account_kernel_stack(tsk->stack, -1);
+ free_sched_autonuma(tsk);
free_thread_info(tsk->stack);
rt_mutex_debug_task_free(tsk);
ftrace_graph_exit_task(tsk);
@@ -227,6 +228,8 @@ void __init fork_init(unsigned long mempages)
/* do the arch specific task caches init */
arch_task_cache_init();
+ sched_autonuma_init();
+
/*
* The default maximum number of threads is set to a safe
* value: the thread structures can take up at most half
@@ -259,23 +262,23 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
struct thread_info *ti;
unsigned long *stackend;
int node = tsk_fork_get_node(orig);
- int err;
prepare_to_copy(orig);
tsk = alloc_task_struct_node(node);
- if (!tsk)
+ if (unlikely(!tsk))
return NULL;
ti = alloc_thread_info_node(tsk, node);
- if (!ti) {
- free_task_struct(tsk);
- return NULL;
- }
+ if (unlikely(!ti))
+ goto out_task_struct;
- err = arch_dup_task_struct(tsk, orig);
- if (err)
- goto out;
+ if (unlikely(arch_dup_task_struct(tsk, orig)))
+ goto out_thread_info;
+
+ if (unlikely(alloc_sched_autonuma(tsk, orig, node)))
+ /* free_thread_info() undoes arch_dup_task_struct() too */
+ goto out_thread_info;
tsk->stack = ti;
@@ -303,8 +306,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
return tsk;
-out:
+out_thread_info:
free_thread_info(ti);
+out_task_struct:
free_task_struct(tsk);
return NULL;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>
[Site Home]
[Linux ARM Kernel]
[Linux ARM]
[Linux Omap]
[Fedora ARM]
[IETF Annouce]
[Security]
[Bugtraq]
[Linux]
[Linux OMAP]
[Linux MIPS]
[ECOS]
[Tools]
[DDR & Rambus]
[Asterisk Internet PBX]
[Linux API]
[Monitors]