Skip to contentSkip to conversation

sched/numa: Provide sysctl knob to disable numa scheduling and turn it off by default

tip:sched/numa tip-bot for Peter Zijlstra 1 participant 1 message May 18, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Commit-ID:  bcdf5162b92dfc0999b0e0ecf25d778733cc4c4d
Gitweb:     http://git.kernel.org/tip/bcdf5162b92dfc0999b0e0ecf25d778733cc4c4d
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Thu, 17 May 2012 15:07:31 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 18 May 2012 09:48:59 +0200

sched/numa: Provide sysctl knob to disable numa scheduling and turn it off by default

Provide a knob to make all this numa scheduling go-away.

Also provide a Kconfig entry to set the default for this new knob.

---
 include/linux/sched.h |   13 +++++++
 init/Kconfig          |   18 ++++++++++
 kernel/sched/numa.c   |   89 +++++++++++++++++++++++++++++++++++++++---------
 kernel/sysctl.c       |   11 ++++++
 4 files changed, 114 insertions(+), 17 deletions(-)
include/linux/sched.h +13 -0
index 024a5f9..4879103 100644
@@ -90,6 +90,7 @@ struct sched_param {
 #include <linux/latencytop.h>
 #include <linux/cred.h>
 #include <linux/llist.h>
+#include <linux/jump_label.h>
 
 #include <asm/processor.h>
 
@@ -1584,9 +1585,14 @@ struct task_struct {
 /* Future-safe accessor for struct task_struct's cpus_allowed. */
 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
 
+extern struct static_key sched_numa_disabled;
+
 static inline int tsk_home_node(struct task_struct *p)
 {
 #ifdef CONFIG_NUMA
+	if (static_key_false(&sched_numa_disabled))
+		return -1;
+
 	return p->node;
 #else
 	return -1;
@@ -2058,6 +2064,13 @@ static inline void sched_autogroup_exit(struct signal_struct *sig) { }
 extern unsigned int sysctl_sched_cfs_bandwidth_slice;
 #endif
 
+#ifdef CONFIG_NUMA
+extern int sysctl_sched_numa;
+int sched_numa_handler(struct ctl_table *table, int write,
+		void __user *buffer, size_t *lenp,
+		loff_t *ppos);
+#endif
+
 #ifdef CONFIG_RT_MUTEXES
 extern int rt_mutex_getprio(struct task_struct *p);
 extern void rt_mutex_setprio(struct task_struct *p, int prio);
init/Kconfig +18 -0
index e4e84f2..2f6bfc1 100644
@@ -865,6 +865,24 @@ config SCHED_AUTOGROUP
 	  desktop applications.  Task group autogeneration is currently based
 	  upon task session.
 
+config SCHED_NUMA_DEFAULT
+	bool "Enable NUMA scheduling by default"
+	depends on NUMA
+	default n
+	help
+	  This option selects the default enablement of a scheduler feature
+	  that gives each process a home-node and allocates all its memory
+	  from there and tries to schedule all the process tasks on that node
+	  (or as near to it) while trying to maintain fairness.
+
+	  Without this feature memory is allocated on whatever node a task
+	  happens to run on and the scheduler is free to migrate tasks around
+	  at will -- which can result in significant cross-node memory
+	  traffic.
+
+	  Regardless of this setting it can always be changed at runtime
+	  by changing /proc/sys/kernel/sched_numa.
+
 config MM_OWNER
 	def_bool NUMA
 
kernel/sched/numa.c +72 -17

134 lines not on this page · raw message

kernel/sysctl.c +11 -0
index 4ab1187..40ecba2 100644
@@ -373,6 +373,17 @@ static struct ctl_table kern_table[] = {
 		.extra1		= &one,
 	},
 #endif
+#ifdef CONFIG_NUMA
+	{
+		.procname	= "sched_numa",
+		.data		= &sysctl_sched_numa,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= sched_numa_handler,
+		.extra1		= &zero,
+		.extra2		= &one,
+	},
+#endif
 #ifdef CONFIG_PROVE_LOCKING
 	{
 		.procname	= "prove_locking",