Linux NUMA userland tools development
 help / color / mirror / Atom feed
From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: linux-numa@vger.kernel.org
Cc: akpm@linux-foundation.org, Mel Gorman <mel@csn.ul.ie>,
	cl@linux-foundation.org, Nick Piggin <npiggin@kernel.dk>,
	Hugh Dickins <hughd@google.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	andi@firstfloor.org, David Rientjes <rientjes@google.com>,
	Avi Kivity <avi@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>
Subject: [PATCH/RFC 2/11] numa - Automatic-migration - per cpuset automigration control
Date: Thu, 11 Nov 2010 15:01:20 -0500	[thread overview]
Message-ID: <20101111200120.12641.89365.sendpatchset@zaphod.localdomain> (raw)
In-Reply-To: <20101111200103.12641.80303.sendpatchset@zaphod.localdomain>

AutoPage Migration - add auto_migration enable per cpuset control

This patch implements a per cpuset "auto_migration" control.
Default is disabled.

Earlier versions of this patch used a task flag for this purpose
to avoid extra cache misses in the fault path and such.  There
are currently no task flags available, so this version uses
a flag in another variable in another cache line :(.

Because AUTO_MIGRATE requires CPUSETS, unconditionally select
same in mm/Kconfig.

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

 include/linux/cpuset.h |   16 ++++++++++++++++
 include/linux/sched.h  |   18 ++++++++++++++++++
 kernel/cpuset.c        |   31 ++++++++++++++++++++++++++++++-
 mm/Kconfig             |    1 +
 4 files changed, 65 insertions(+), 1 deletion(-)

Index: linux-2.6.36-mmotm-101103-1217/include/linux/sched.h
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/include/linux/sched.h
+++ linux-2.6.36-mmotm-101103-1217/include/linux/sched.h
@@ -1458,6 +1458,7 @@ struct task_struct {
 	short shared_huge_policy_enabled:1;
 	short shared_file_policy_enabled:1;
 	short migrate_on_fault_enabled:1;
+	short auto_migrate_enabled:1;
 #endif
 	atomic_t fs_excl;	/* holding fs exclusive resources */
 	struct rcu_head rcu;
@@ -1926,6 +1927,23 @@ static inline int migrate_on_fault_enabl
 }
 #endif
 
+#ifdef CONFIG_AUTO_MIGRATION
+static inline void set_auto_migrate_enabled(struct task_struct *tsk,
+							int val)
+{
+	tsk->auto_migrate_enabled = !!val;
+}
+static inline int auto_migrate_enabled(struct task_struct *tsk)
+{
+	return tsk->auto_migrate_enabled;
+}
+#else
+static inline void set_auto_migrate_enabled(struct task_struct *tsk,
+							int val)
+{
+}
+#endif
+
 #ifdef CONFIG_HOTPLUG_CPU
 extern void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p);
 extern void idle_task_exit(void);
Index: linux-2.6.36-mmotm-101103-1217/kernel/cpuset.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/kernel/cpuset.c
+++ linux-2.6.36-mmotm-101103-1217/kernel/cpuset.c
@@ -135,6 +135,7 @@ typedef enum {
 	CS_SHARED_HUGE_POLICY,
  	CS_SHARED_FILE_POLICY,
 	CS_MIGRATE_ON_FAULT,
+	CS_AUTO_MIGRATE,
 } cpuset_flagbits_t;
 
 /* convenient tests for these bits */
@@ -188,6 +189,11 @@ static inline int is_migrate_on_fault(co
 	return test_bit(CS_MIGRATE_ON_FAULT,  &cs->flags);
 }
 
+static inline int is_auto_migrate(const struct cpuset *cs)
+{
+	return test_bit(CS_AUTO_MIGRATE,  &cs->flags);
+}
+
 static struct cpuset top_cpuset = {
 	.flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)),
 };
@@ -352,6 +358,10 @@ static void cpuset_update_task_cpuset_fl
 		set_migrate_on_fault_enabled(tsk, 1);
 	else
 		set_migrate_on_fault_enabled(tsk, 0);
+	if (is_auto_migrate(cs))
+		set_auto_migrate_enabled(tsk, 1);
+	else
+		set_auto_migrate_enabled(tsk, 0);
 
 }
 
@@ -1294,7 +1304,8 @@ static int update_flag(cpuset_flagbits_t
 			|| (is_spread_page(cs) != is_spread_page(trialcs))
 			|| (is_shared_huge_policy(cs) != is_shared_huge_policy(trialcs))
 			|| (is_shared_file_policy(cs) != is_shared_file_policy(trialcs))
-			|| (is_migrate_on_fault(cs) != is_migrate_on_fault(trialcs)));
+			|| (is_migrate_on_fault(cs) != is_migrate_on_fault(trialcs))
+			|| (is_auto_migrate(cs) != is_auto_migrate(trialcs)));
 
 	mutex_lock(&callback_mutex);
 	cs->flags = trialcs->flags;
@@ -1533,6 +1544,7 @@ typedef enum {
 	FILE_SHARED_HUGE_POLICY,
 	FILE_SHARED_FILE_POLICY,
 	FILE_MIGRATE_ON_FAULT,
+	FILE_AUTO_MIGRATE,
 } cpuset_filetype_t;
 
 static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
@@ -1580,6 +1592,9 @@ static int cpuset_write_u64(struct cgrou
 		break;
 	case FILE_MIGRATE_ON_FAULT:
 		retval = update_flag(CS_MIGRATE_ON_FAULT, cs, val);
+  		break;
+	case FILE_AUTO_MIGRATE:
+		retval = update_flag(CS_AUTO_MIGRATE, cs, val);
 		break;
 	default:
 		retval = -EINVAL;
@@ -1751,6 +1766,8 @@ static u64 cpuset_read_u64(struct cgroup
 		return is_shared_file_policy(cs);
 	case FILE_MIGRATE_ON_FAULT:
 		return is_migrate_on_fault(cs);
+	case FILE_AUTO_MIGRATE:
+		return is_auto_migrate(cs);
 	default:
 		BUG();
 	}
@@ -1889,6 +1906,13 @@ static struct cftype cft_migrate_on_faul
 	.private = FILE_MIGRATE_ON_FAULT,
 };
 
+static struct cftype cft_auto_migration = {
+	.name = "auto_migration",
+	.read_u64 = cpuset_read_u64,
+	.write_u64 = cpuset_write_u64,
+	.private = FILE_AUTO_MIGRATE,
+};
+
 static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)
 {
 	int err;
@@ -1909,6 +1933,9 @@ static int cpuset_populate(struct cgroup
 						&cft_migrate_on_fault);
 	if (err < 0)
 		return err;
+	err = add_auto_migration_file(cont, ss, &cft_auto_migration);
+	if (err < 0)
+		return err;
 	/* memory_pressure_enabled is in root cpuset only */
 	if (!cont->parent)
 		err = cgroup_add_file(cont, ss,
@@ -1989,6 +2016,8 @@ static struct cgroup_subsys_state *cpuse
 		set_bit(CS_SHARED_FILE_POLICY, &cs->flags);
 	if (is_migrate_on_fault(parent))
 		set_bit(CS_MIGRATE_ON_FAULT, &cs->flags);
+	if (is_auto_migrate(parent))
+		set_bit(CS_AUTO_MIGRATE, &cs->flags);
 	set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
 	cpumask_clear(cs->cpus_allowed);
 	nodes_clear(cs->mems_allowed);
Index: linux-2.6.36-mmotm-101103-1217/mm/Kconfig
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/Kconfig
+++ linux-2.6.36-mmotm-101103-1217/mm/Kconfig
@@ -214,6 +214,7 @@ config MIGRATE_ON_FAULT
 config AUTO_MIGRATION
 	bool "Auto-migrate task memory"
 	depends on MIGRATION
+	select CPUSETS
 	help
 	  Allows tasks' private memory to follow that task itself across
 	  inter-node migrations.
Index: linux-2.6.36-mmotm-101103-1217/include/linux/cpuset.h
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/include/linux/cpuset.h
+++ linux-2.6.36-mmotm-101103-1217/include/linux/cpuset.h
@@ -164,6 +164,22 @@ static inline int add_migrate_on_fault_f
 }
 #endif
 
+#ifdef CONFIG_AUTO_MIGRATION
+static inline int add_auto_migration_file(struct cgroup *cg,
+						struct cgroup_subsys *ss,
+						struct cftype *cft)
+{
+	return cgroup_add_file(cg, ss, cft);
+}
+#else
+static inline int add_auto_migration_file(struct cgroup *cg,
+						struct cgroup_subsys *ss,
+						struct cftype *cft)
+{
+	return 0;
+}
+#endif
+
 extern void __init cpuset_init_shared_huge_policy(int dflt);
 extern void __init cpuset_init_shared_file_policy(int dflt);
 

  parent reply	other threads:[~2010-11-11 20:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 20:01 [PATCH/RFC 0/11] numa - Automatic-migration Lee Schermerhorn
2010-11-11 20:01 ` [PATCH/RFC 1/11] numa - Automatic-migration - preparation, cleanup Lee Schermerhorn
2010-11-11 20:01 ` Lee Schermerhorn [this message]
2010-11-11 20:01 ` [PATCH/RFC 3/11] numa - Automatic-migration - check notify migrate pending Lee Schermerhorn
2010-11-11 20:01 ` [PATCH/RFC 4/11] numa - Automatic-migration - ia64 " Lee Schermerhorn
2010-11-11 20:01 ` [PATCH/RFC 5/11] numa - Automatic-migration - x86_64 " Lee Schermerhorn
2010-11-11 20:01 ` [PATCH/RFC 6/11] numa - Automatic-migration - hook to scheduler inter-node migration Lee Schermerhorn
2010-11-11 20:01 ` [PATCH/RFC 7/11] numa - Automatic-migration - add internode migration delay Lee Schermerhorn
2010-11-11 20:02 ` [PATCH/RFC 8/11] numa - Automatic-migration - per cpuset max mapcount control Lee Schermerhorn
2010-11-11 20:02 ` [PATCH/RFC 9/11] numa - Automatic-migration - hook to migrate on fault Lee Schermerhorn
2010-11-11 20:02 ` [PATCH/RFC 10/11] numa - Automatic-migration - per proc automigrate kick control Lee Schermerhorn
2010-11-11 20:02 ` [PATCH/RFC 11/11] numa - Automatic-migration - add statistics Lee Schermerhorn
2010-11-14  6:42 ` [PATCH/RFC 0/11] numa - Automatic-migration KOSAKI Motohiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101111200120.12641.89365.sendpatchset@zaphod.localdomain \
    --to=lee.schermerhorn@hp.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-numa@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=npiggin@kernel.dk \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox