* [PATCH] cpusets: fix bug of adding inexistent cpu or mem
@ 2008-05-23 7:47 Lai Jiangshan
2008-05-23 14:20 ` Paul Jackson
0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2008-05-23 7:47 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Kernel Mailing List, menage, pj
Adding inexistent cpu to a cpuset will be omitted quietly.
It should return -EINVAL.
Example: (real_nr_cpus <= 4 < NR_CPUS or cpu#4 was just offline)
# cat cpus
0-1
# /bin/echo 4 > cpus
# /bin/echo $?
0
# cat cpus
#
The same as adding inexistent mem.
This patch will fix this bug.
And when *buf == "", the check is unneeded.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 86ea9e3..039baa4 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -797,8 +797,10 @@ static int update_cpumask(struct cpuset *cs, char *buf)
retval = cpulist_parse(buf, trialcs.cpus_allowed);
if (retval < 0)
return retval;
+
+ if (!cpus_subset(trialcs.cpus_allowed, cpu_online_map))
+ return -EINVAL;
}
- cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map);
retval = validate_change(cs, &trialcs);
if (retval < 0)
return retval;
@@ -932,9 +934,11 @@ static int update_nodemask(struct cpuset *cs, char *buf)
retval = nodelist_parse(buf, trialcs.mems_allowed);
if (retval < 0)
goto done;
+
+ if (!nodes_subset(trialcs.mems_allowed,
+ node_states[N_HIGH_MEMORY]))
+ return -EINVAL;
}
- nodes_and(trialcs.mems_allowed, trialcs.mems_allowed,
- node_states[N_HIGH_MEMORY]);
oldmem = cs->mems_allowed;
if (nodes_equal(oldmem, trialcs.mems_allowed)) {
retval = 0; /* Too easy - nothing to do */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cpusets: fix bug of adding inexistent cpu or mem
2008-05-23 7:47 [PATCH] cpusets: fix bug of adding inexistent cpu or mem Lai Jiangshan
@ 2008-05-23 14:20 ` Paul Jackson
0 siblings, 0 replies; 2+ messages in thread
From: Paul Jackson @ 2008-05-23 14:20 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: akpm, linux-kernel, menage
Lai wrote:
> Adding inexistent cpu to a cpuset will be omitted quietly.
> It should return -EINVAL.
I like this PATCH - thank-you. It was definitely a bug that
trying to add a nonexistent CPU to a cpuset emptied that cpuset
of its current CPUs, returning "success", not an "error".
Acked-by: Paul Jackson <pj@sgi.com>
(By the way, the word "inexistent" is not so commonly used
as is the word "nonexistent", but both words are legitimate,
and mean the same thing.)
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.940.382.4214
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-23 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-23 7:47 [PATCH] cpusets: fix bug of adding inexistent cpu or mem Lai Jiangshan
2008-05-23 14:20 ` Paul Jackson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox