numa: add a sysctl for numa_balancing
authorAndi Kleen <ak@linux.intel.com>
Thu, 23 Jan 2014 23:53:13 +0000 (15:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jan 2014 00:36:51 +0000 (16:36 -0800)
Add a working sysctl to enable/disable automatic numa memory balancing
at runtime.

This allows us to track down performance problems with this feature and
is generally a good idea.

This was possible earlier through debugfs, but only with special
debugging options set.  Also fix the boot message.

[akpm@linux-foundation.org: s/sched_numa_balancing/sysctl_numa_balancing/]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sched/sysctl.h
kernel/sched/core.c
kernel/sysctl.c
mm/mempolicy.c

index 31e0193cb0c5b06c505742c3ec21e41a902ea6ed..b13cf430764f76cc4053f1c935e1e417a32188a1 100644 (file)
@@ -99,4 +99,8 @@ extern int sched_rt_handler(struct ctl_table *table, int write,
                void __user *buffer, size_t *lenp,
                loff_t *ppos);
 
+extern int sysctl_numa_balancing(struct ctl_table *table, int write,
+                                void __user *buffer, size_t *lenp,
+                                loff_t *ppos);
+
 #endif /* _SCHED_SYSCTL_H */
index 4d6964e49711c3ae5cb337be9a8738ca308ca258..7fea865a810da70b72a8ae247bda8064f5b58193 100644 (file)
@@ -1770,7 +1770,29 @@ void set_numabalancing_state(bool enabled)
        numabalancing_enabled = enabled;
 }
 #endif /* CONFIG_SCHED_DEBUG */
-#endif /* CONFIG_NUMA_BALANCING */
+
+#ifdef CONFIG_PROC_SYSCTL
+int sysctl_numa_balancing(struct ctl_table *table, int write,
+                        void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       struct ctl_table t;
+       int err;
+       int state = numabalancing_enabled;
+
+       if (write && !capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       t = *table;
+       t.data = &state;
+       err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
+       if (err < 0)
+               return err;
+       if (write)
+               set_numabalancing_state(state);
+       return err;
+}
+#endif
+#endif
 
 /*
  * fork()/clone()-time setup:
index 332cefcdb04b4a004b280aebdd4d7de61a036dea..693eac39c2028d36a45a82d6160510b8fd105ed0 100644 (file)
@@ -389,6 +389,15 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },
+       {
+               .procname       = "numa_balancing",
+               .data           = NULL, /* filled in by handler */
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = sysctl_numa_balancing,
+               .extra1         = &zero,
+               .extra2         = &one,
+       },
 #endif /* CONFIG_NUMA_BALANCING */
 #endif /* CONFIG_SCHED_DEBUG */
        {
index 0cd2c4d4e2703f88f56b957b6f442a531fbd2e1f..947293e765338c77757e1ea2d753da0643307fee 100644 (file)
@@ -2668,7 +2668,7 @@ static void __init check_numabalancing_enable(void)
 
        if (nr_node_ids > 1 && !numabalancing_override) {
                printk(KERN_INFO "Enabling automatic NUMA balancing. "
-                       "Configure with numa_balancing= or sysctl");
+                       "Configure with numa_balancing= or the kernel.numa_balancing sysctl");
                set_numabalancing_state(numabalancing_default);
        }
 }