[PATCH] cpusets - decrustify cpuset mask update code

Previous thread: [PATCH v2] cpuset sched_load_balance flag by Paul Jackson on Saturday, October 6, 2007 - 5:47 am. (4 messages)

Next thread: apparently missing include/linux header files by Robert P. J. Day on Saturday, October 6, 2007 - 5:47 am. (3 messages)
To: Andrew Morton <akpm@...>
Cc: Paul Menage <menage@...>, Paul Jackson <pj@...>, <linux-kernel@...>
Date: Saturday, October 6, 2007 - 5:47 am

From: Paul Jackson <pj@sgi.com>

Decrustify the kernel/cpuset.c 'cpus' and 'mems' updating code.

Other than subtle improvements in the consistency of identifying
white space at the beginning and end of passed in masks, this
doesn't make any visible difference in behaviour. But it's
one or two hundred kernel text bytes smaller, and easier to
understand.

Signed-off-by: Paul Jackson <pj@sgi.com>

---

Andrew - this patch goes after:
cpuset sched_load_balance flag

kernel/cpuset.c | 50 ++++++++++++++++++++------------------------------
1 file changed, 20 insertions(+), 30 deletions(-)

--- 2.6.23-rc8-mm1.orig/kernel/cpuset.c 2007-10-04 10:56:01.745248540 -0700
+++ 2.6.23-rc8-mm1/kernel/cpuset.c 2007-10-04 11:02:32.939745095 -0700
@@ -488,6 +488,14 @@ static int validate_change(const struct
return -EINVAL;
}

+ /* Cpusets with tasks can't have empty cpus_allowed or mems_allowed */
+ if (cgroup_task_count(cur->css.cgroup)) {
+ if (cpus_empty(trial->cpus_allowed) ||
+ nodes_empty(trial->mems_allowed)) {
+ return -ENOSPC;
+ }
+ }
+
return 0;
}

@@ -778,11 +786,13 @@ static int update_cpumask(struct cpuset
trialcs = *cs;

/*
- * We allow a cpuset's cpus_allowed to be empty; if it has attached
- * tasks, we'll catch it later when we validate the change and return
- * -ENOSPC.
+ * An empty cpus_allowed is ok iff there are no tasks in the cpuset.
+ * Since cpulist_parse() fails on an empty mask, we special case
+ * that parsing. The validate_change() call ensures that cpusets
+ * with tasks have cpus.
*/
- if (!buf[0] || (buf[0] == '\n' && !buf[1])) {
+ buf = strstrip(buf);
+ if (!*buf) {
cpus_clear(trialcs.cpus_allowed);
} else {
retval = cpulist_parse(buf, trialcs.cpus_allowed);
@@ -790,10 +800,6 @@ static int update_cpumask(struct cpuset
return retval;
}
cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map);
- /* cpus_allowed cannot be empty for a cpuset...

To: Paul Jackson <pj@...>, Andrew Morton <akpm@...>
Cc: <linux-kernel@...>
Date: Saturday, October 6, 2007 - 5:34 pm

Reviewed-by: Paul Menage <menage@google.com>

Looks fine to me.

Paul
-

Previous thread: [PATCH v2] cpuset sched_load_balance flag by Paul Jackson on Saturday, October 6, 2007 - 5:47 am. (4 messages)

Next thread: apparently missing include/linux header files by Robert P. J. Day on Saturday, October 6, 2007 - 5:47 am. (3 messages)