Re: [PATCH 2.6.17-rc1-mm1 2/9] AutoPage Migration - V0.2 - add auto_migrate_enable sysctl

Lee Schermerhorn
2006-04-07T20:36:25Z

AutoPage Migration - V0.2 - 2/9 add auto_migrate_enable sysctl

V0.2: moved controls to mm/migrate.c
renamed "sched_migrate_memory" to "auto_migrate_enable"

This patch adds the infrastructure for "migration controls" under
/sys/kernel/migration. It also adds a single such control--
auto_migrate_enable--to enable/disable automatic, scheduler driven
task memory migration. May also be initialized from boot command
line option.

Default is disabled!

Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>

Index: linux-2.6.16-mm1/mm/migrate.c
===================================================================
--- linux-2.6.16-mm1.orig/mm/migrate.c 2006-03-23 16:49:16.000000000 -0500
+++ linux-2.6.16-mm1/mm/migrate.c 2006-03-23 16:49:40.000000000 -0500
@@ -25,8 +25,7 @@
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/swapops.h>
-
-#include "internal.h"
+#include <linux/sysfs.h>

#include "internal.h"

@@ -36,6 +35,76 @@
#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))

/*
+ * System Controls for [auto] migration
+ */
+#define MIGRATION_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+ __ATTR(_name, 0644, _name##_show, _name##_store)
+
+/*
+ * auto_migrate_enable: boot option and sysctl to enable/disable
+ * memory migration on inter-node task migration due to scheduler
+ * load balancing or change in cpu affinity.
+ */
+int auto_migrate_enable = 0;
+
+static int __init set_auto_migrate_enable(char *str)
+{
+ get_option(&str, &auto_migrate_enable);
+ return 1;
+}
+
+__setup("auto_migrate_enable", set_auto_migrate_enable);
+
+static ssize_t auto_migrate_enable_show(struct subsystem *subsys, char *page)
+{
+ return sprintf(page, "auto_migrate_enable %s\n",
+ auto_migrate_enable ? "on" : "off");
+}
+static ssize_t auto_migrate_enable_store(struct subsystem *subsys,
+ const char *page, size_t count)
+{
+ unsigned long n = simple_strtoul(page, NULL, 10);
+ if (n)
+ auto_migrate_enable = 1;
+ else
+ auto_migrate_enable = 0;
+ return count;
+}
+MIGRATION_ATTR_RW(auto_migrate_enable);
+
+decl_subsys(migration, NULL, NULL);
+EXPORT_SYMBOL(migration_subsys);
+
+static struct attribute *migration_attrs[] = {
+ &auto_migrate_enable_attr.attr,
+ NULL
+};
+
+static struct attribute_group migration_attr_group = {
+ .attrs = migration_attrs,
+};
+
+static int __init migration_control_init(void)
+{
+ int error;
+
+ /*
+ * child of kernel subsys
+ */
+ kset_set_kset_s(&migration_subsys, kernel_subsys);
+ error = subsystem_register(&migration_subsys);
+ if (!error)
+ error = sysfs_create_group(&migration_subsys.kset.kobj,
+ &migration_attr_group);
+ return error;
+}
+subsys_initcall(migration_control_init);
+/*
+ * end Migration System Controls
+ */
+
+/*
* Isolate one page from the LRU lists. If successful put it onto
* the indicated list with elevated page count.
*
Index: linux-2.6.16-mm1/include/linux/auto-migrate.h
===================================================================
--- linux-2.6.16-mm1.orig/include/linux/auto-migrate.h 2006-03-23 16:49:34.000000000 -0500
+++ linux-2.6.16-mm1/include/linux/auto-migrate.h 2006-03-23 16:49:40.000000000 -0500
@@ -13,6 +13,8 @@

extern void auto_migrate_task_memory(void);

+extern int auto_migrate_enable;
+
#else /* !CONFIG_MIGRATION */

#endif /* CONFIG_MIGRATION */