Commit 5be7a479 authored by Paul Menage's avatar Paul Menage Committed by Linus Torvalds

Fix cpuset sched_relax_domain_level control file

Due to a merge conflict, the sched_relax_domain_level control file was marked
as being handled by cpuset_read/write_u64, but the code to handle it was
actually in cpuset_common_file_read/write.

Since the value being written/read is in fact a signed integer, it should be
treated as such; this patch adds cpuset_read/write_s64 functions, and uses
them to handle the sched_relax_domain_level file.

With this patch, the sched_relax_domain_level can be read and written, and the
correct contents seen/updated.
Signed-off-by: default avatarPaul Menage <menage@google.com>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Paul Jackson <pj@sgi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4ea33e2d
...@@ -1031,11 +1031,9 @@ int current_cpuset_is_being_rebound(void) ...@@ -1031,11 +1031,9 @@ int current_cpuset_is_being_rebound(void)
return task_cs(current) == cpuset_being_rebound; return task_cs(current) == cpuset_being_rebound;
} }
static int update_relax_domain_level(struct cpuset *cs, char *buf) static int update_relax_domain_level(struct cpuset *cs, s64 val)
{ {
int val = simple_strtol(buf, NULL, 10); if ((int)val < 0)
if (val < 0)
val = -1; val = -1;
if (val != cs->relax_domain_level) { if (val != cs->relax_domain_level) {
...@@ -1280,9 +1278,6 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont, ...@@ -1280,9 +1278,6 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont,
case FILE_MEMLIST: case FILE_MEMLIST:
retval = update_nodemask(cs, buffer); retval = update_nodemask(cs, buffer);
break; break;
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
retval = update_relax_domain_level(cs, buffer);
break;
default: default:
retval = -EINVAL; retval = -EINVAL;
goto out2; goto out2;
...@@ -1348,6 +1343,30 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val) ...@@ -1348,6 +1343,30 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
return retval; return retval;
} }
static int cpuset_write_s64(struct cgroup *cgrp, struct cftype *cft, s64 val)
{
int retval = 0;
struct cpuset *cs = cgroup_cs(cgrp);
cpuset_filetype_t type = cft->private;
cgroup_lock();
if (cgroup_is_removed(cgrp)) {
cgroup_unlock();
return -ENODEV;
}
switch (type) {
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
retval = update_relax_domain_level(cs, val);
break;
default:
retval = -EINVAL;
break;
}
cgroup_unlock();
return retval;
}
/* /*
* These ascii lists should be read in a single call, by using a user * These ascii lists should be read in a single call, by using a user
* buffer large enough to hold the entire map. If read in smaller * buffer large enough to hold the entire map. If read in smaller
...@@ -1406,9 +1425,6 @@ static ssize_t cpuset_common_file_read(struct cgroup *cont, ...@@ -1406,9 +1425,6 @@ static ssize_t cpuset_common_file_read(struct cgroup *cont,
case FILE_MEMLIST: case FILE_MEMLIST:
s += cpuset_sprintf_memlist(s, cs); s += cpuset_sprintf_memlist(s, cs);
break; break;
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
s += sprintf(s, "%d", cs->relax_domain_level);
break;
default: default:
retval = -EINVAL; retval = -EINVAL;
goto out; goto out;
...@@ -1449,6 +1465,18 @@ static u64 cpuset_read_u64(struct cgroup *cont, struct cftype *cft) ...@@ -1449,6 +1465,18 @@ static u64 cpuset_read_u64(struct cgroup *cont, struct cftype *cft)
} }
} }
static s64 cpuset_read_s64(struct cgroup *cont, struct cftype *cft)
{
struct cpuset *cs = cgroup_cs(cont);
cpuset_filetype_t type = cft->private;
switch (type) {
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
return cs->relax_domain_level;
default:
BUG();
}
}
/* /*
* for the common functions, 'private' gives the type of file * for the common functions, 'private' gives the type of file
...@@ -1499,8 +1527,8 @@ static struct cftype files[] = { ...@@ -1499,8 +1527,8 @@ static struct cftype files[] = {
{ {
.name = "sched_relax_domain_level", .name = "sched_relax_domain_level",
.read_u64 = cpuset_read_u64, .read_s64 = cpuset_read_s64,
.write_u64 = cpuset_write_u64, .write_s64 = cpuset_write_s64,
.private = FILE_SCHED_RELAX_DOMAIN_LEVEL, .private = FILE_SCHED_RELAX_DOMAIN_LEVEL,
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment