aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2013-10-07 06:29:26 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-09 08:47:57 -0400
commit5e1576ed0e54d419286a8096133029062b6ad456 (patch)
tree2394e5c0ed3783e36f23961c0330276cde820e03 /kernel/sched/core.c
parent0f19c17929c952c6f0966d93ab05558e7bf814cc (diff)
sched/numa: Stay on the same node if CLONE_VM
A newly spawned thread inside a process should stay on the same NUMA node as its parent. This prevents processes from being "torn" across multiple NUMA nodes every time they spawn a new thread. Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Mel Gorman <mgorman@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1381141781-10992-49-git-send-email-mgorman@suse.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 51092d5cc64c..3e2c893df173 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1696,7 +1696,7 @@ int wake_up_state(struct task_struct *p, unsigned int state)
1696 * 1696 *
1697 * __sched_fork() is basic setup used by init_idle() too: 1697 * __sched_fork() is basic setup used by init_idle() too:
1698 */ 1698 */
1699static void __sched_fork(struct task_struct *p) 1699static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
1700{ 1700{
1701 p->on_rq = 0; 1701 p->on_rq = 0;
1702 1702
@@ -1725,11 +1725,15 @@ static void __sched_fork(struct task_struct *p)
1725 p->mm->numa_scan_seq = 0; 1725 p->mm->numa_scan_seq = 0;
1726 } 1726 }
1727 1727
1728 if (clone_flags & CLONE_VM)
1729 p->numa_preferred_nid = current->numa_preferred_nid;
1730 else
1731 p->numa_preferred_nid = -1;
1732
1728 p->node_stamp = 0ULL; 1733 p->node_stamp = 0ULL;
1729 p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0; 1734 p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0;
1730 p->numa_migrate_seq = 1; 1735 p->numa_migrate_seq = 1;
1731 p->numa_scan_period = sysctl_numa_balancing_scan_delay; 1736 p->numa_scan_period = sysctl_numa_balancing_scan_delay;
1732 p->numa_preferred_nid = -1;
1733 p->numa_work.next = &p->numa_work; 1737 p->numa_work.next = &p->numa_work;
1734 p->numa_faults = NULL; 1738 p->numa_faults = NULL;
1735 p->numa_faults_buffer = NULL; 1739 p->numa_faults_buffer = NULL;
@@ -1761,12 +1765,12 @@ void set_numabalancing_state(bool enabled)
1761/* 1765/*
1762 * fork()/clone()-time setup: 1766 * fork()/clone()-time setup:
1763 */ 1767 */
1764void sched_fork(struct task_struct *p) 1768void sched_fork(unsigned long clone_flags, struct task_struct *p)
1765{ 1769{
1766 unsigned long flags; 1770 unsigned long flags;
1767 int cpu = get_cpu(); 1771 int cpu = get_cpu();
1768 1772
1769 __sched_fork(p); 1773 __sched_fork(clone_flags, p);
1770 /* 1774 /*
1771 * We mark the process as running here. This guarantees that 1775 * We mark the process as running here. This guarantees that
1772 * nobody will actually run it, and a signal or other external 1776 * nobody will actually run it, and a signal or other external
@@ -4287,7 +4291,7 @@ void init_idle(struct task_struct *idle, int cpu)
4287 4291
4288 raw_spin_lock_irqsave(&rq->lock, flags); 4292 raw_spin_lock_irqsave(&rq->lock, flags);
4289 4293
4290 __sched_fork(idle); 4294 __sched_fork(0, idle);
4291 idle->state = TASK_RUNNING; 4295 idle->state = TASK_RUNNING;
4292 idle->se.exec_start = sched_clock(); 4296 idle->se.exec_start = sched_clock();
4293 4297