[PATCH] sched: Fix build problems when CONFIG_NUMA=y and CONFIG_SMP=n

Luck, Tony
2012-06-20T20:59:47Z

It is possible to have a single cpu system with both local
and remote memory.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---

Broken in linux-next for the past couple of days. Perhaps
we need some more stubs though - sched_fork() seems to need
#ifdef CONFIG_SMP around every other line ... not pretty.

Another approach would be to outlaw such strange configurations
and make sure that CONFIG_SMP is set whenever CONFIG_NUMA is set.
We had such a discussion a long time ago, and at that time
decided to keep supporting it. But with multi-core cpus now
the norm - perhaps it is time to change our minds.

kernel/sched/core.c | 2 ++
kernel/sched/numa.c | 16 ++++++++++++++++
kernel/sched/sched.h | 2 +-
3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 46460ac..f261599 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1799,7 +1799,9 @@ void sched_fork(struct task_struct *p)
#endif
put_cpu();

+#ifdef CONFIG_SMP
select_task_node(p, p->mm, SD_BALANCE_FORK);
+#endif
}

/*
diff --git a/kernel/sched/numa.c b/kernel/sched/numa.c
index 002f71c..4ff3b7c 100644
--- a/kernel/sched/numa.c
+++ b/kernel/sched/numa.c
@@ -18,6 +18,21 @@
#include "sched.h"

+#ifndef CONFIG_SMP
+void mm_init_numa(struct mm_struct *mm)
+{
+}
+void exit_numa(struct mm_struct *mm)
+{
+}
+void account_numa_dequeue(struct task_struct *p)
+{
+}
+__init void init_sched_numa(void)
+{
+}
+#else
+
static const int numa_balance_interval = 2 * HZ; /* 2 seconds */

struct numa_ops {
@@ -853,3 +868,4 @@ static __init int numa_init(void)
return 0;
}
early_initcall(numa_init);
+#endif
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 4134d37..9bf5ba8 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -473,7 +473,7 @@ struct rq {

static inline struct list_head *offnode_tasks(struct rq *rq)
{
-#ifdef CONFIG_NUMA
+#if defined(CONFIG_NUMA) && defined(CONFIG_SMP)
return &rq->offnode_tasks;
#else
return NULL;
--
1.7.10.2.552.gaa3bb87