aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2007-05-08 03:31:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:14 -0400
commit6f7f02e78a75a09195d963e0392b195bc2d55c5c (patch)
treea0ead177a4faaafdfa400ff9de3c992603e42f4d
parent0c28f287aa57e065116731c1e44bedcbc14fd53f (diff)
cpusets: allow empty {cpus,mems}_allowed to be set for unpopulated cpuset
You currently cannot remove all cpus or mems from cpus_allowed or mems_allowed of a cpuset. We now allow both if there are no attached tasks. Acked-by: Paul Jackson <pj@sgi.com> Cc: Christoph Lameter <clameter@engr.sgi.com> Signed-off-by: Paul Menage <menage@google.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/cpuset.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index e6d002fc7392..88b416dfbc72 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -821,11 +821,22 @@ static int update_cpumask(struct cpuset *cs, char *buf)
821 return -EACCES; 821 return -EACCES;
822 822
823 trialcs = *cs; 823 trialcs = *cs;
824 retval = cpulist_parse(buf, trialcs.cpus_allowed); 824
825 if (retval < 0) 825 /*
826 return retval; 826 * We allow a cpuset's cpus_allowed to be empty; if it has attached
827 * tasks, we'll catch it later when we validate the change and return
828 * -ENOSPC.
829 */
830 if (!buf[0] || (buf[0] == '\n' && !buf[1])) {
831 cpus_clear(trialcs.cpus_allowed);
832 } else {
833 retval = cpulist_parse(buf, trialcs.cpus_allowed);
834 if (retval < 0)
835 return retval;
836 }
827 cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map); 837 cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map);
828 if (cpus_empty(trialcs.cpus_allowed)) 838 /* cpus_allowed cannot be empty for a cpuset with attached tasks. */
839 if (atomic_read(&cs->count) && cpus_empty(trialcs.cpus_allowed))
829 return -ENOSPC; 840 return -ENOSPC;
830 retval = validate_change(cs, &trialcs); 841 retval = validate_change(cs, &trialcs);
831 if (retval < 0) 842 if (retval < 0)
@@ -918,16 +929,27 @@ static int update_nodemask(struct cpuset *cs, char *buf)
918 return -EACCES; 929 return -EACCES;
919 930
920 trialcs = *cs; 931 trialcs = *cs;
921 retval = nodelist_parse(buf, trialcs.mems_allowed); 932
922 if (retval < 0) 933 /*
923 goto done; 934 * We allow a cpuset's mems_allowed to be empty; if it has attached
935 * tasks, we'll catch it later when we validate the change and return
936 * -ENOSPC.
937 */
938 if (!buf[0] || (buf[0] == '\n' && !buf[1])) {
939 nodes_clear(trialcs.mems_allowed);
940 } else {
941 retval = nodelist_parse(buf, trialcs.mems_allowed);
942 if (retval < 0)
943 goto done;
944 }
924 nodes_and(trialcs.mems_allowed, trialcs.mems_allowed, node_online_map); 945 nodes_and(trialcs.mems_allowed, trialcs.mems_allowed, node_online_map);
925 oldmem = cs->mems_allowed; 946 oldmem = cs->mems_allowed;
926 if (nodes_equal(oldmem, trialcs.mems_allowed)) { 947 if (nodes_equal(oldmem, trialcs.mems_allowed)) {
927 retval = 0; /* Too easy - nothing to do */ 948 retval = 0; /* Too easy - nothing to do */
928 goto done; 949 goto done;
929 } 950 }
930 if (nodes_empty(trialcs.mems_allowed)) { 951 /* mems_allowed cannot be empty for a cpuset with attached tasks. */
952 if (atomic_read(&cs->count) && nodes_empty(trialcs.mems_allowed)) {
931 retval = -ENOSPC; 953 retval = -ENOSPC;
932 goto done; 954 goto done;
933 } 955 }