Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Paul 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: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Paul Menage and committed by
Linus Torvalds
5be7a479 4ea33e2d

+40 -12
+40 -12
kernel/cpuset.c
··· 1031 1031 return task_cs(current) == cpuset_being_rebound; 1032 1032 } 1033 1033 1034 - static int update_relax_domain_level(struct cpuset *cs, char *buf) 1034 + static int update_relax_domain_level(struct cpuset *cs, s64 val) 1035 1035 { 1036 - int val = simple_strtol(buf, NULL, 10); 1037 - 1038 - if (val < 0) 1036 + if ((int)val < 0) 1039 1037 val = -1; 1040 1038 1041 1039 if (val != cs->relax_domain_level) { ··· 1278 1280 case FILE_MEMLIST: 1279 1281 retval = update_nodemask(cs, buffer); 1280 1282 break; 1281 - case FILE_SCHED_RELAX_DOMAIN_LEVEL: 1282 - retval = update_relax_domain_level(cs, buffer); 1283 - break; 1284 1283 default: 1285 1284 retval = -EINVAL; 1286 1285 goto out2; ··· 1334 1339 case FILE_SPREAD_SLAB: 1335 1340 retval = update_flag(CS_SPREAD_SLAB, cs, val); 1336 1341 cs->mems_generation = cpuset_mems_generation++; 1342 + break; 1343 + default: 1344 + retval = -EINVAL; 1345 + break; 1346 + } 1347 + cgroup_unlock(); 1348 + return retval; 1349 + } 1350 + 1351 + static int cpuset_write_s64(struct cgroup *cgrp, struct cftype *cft, s64 val) 1352 + { 1353 + int retval = 0; 1354 + struct cpuset *cs = cgroup_cs(cgrp); 1355 + cpuset_filetype_t type = cft->private; 1356 + 1357 + cgroup_lock(); 1358 + 1359 + if (cgroup_is_removed(cgrp)) { 1360 + cgroup_unlock(); 1361 + return -ENODEV; 1362 + } 1363 + switch (type) { 1364 + case FILE_SCHED_RELAX_DOMAIN_LEVEL: 1365 + retval = update_relax_domain_level(cs, val); 1337 1366 break; 1338 1367 default: 1339 1368 retval = -EINVAL; ··· 1425 1406 case FILE_MEMLIST: 1426 1407 s += cpuset_sprintf_memlist(s, cs); 1427 1408 break; 1428 - case FILE_SCHED_RELAX_DOMAIN_LEVEL: 1429 - s += sprintf(s, "%d", cs->relax_domain_level); 1430 - break; 1431 1409 default: 1432 1410 retval = -EINVAL; 1433 1411 goto out; ··· 1460 1444 return is_spread_page(cs); 1461 1445 case FILE_SPREAD_SLAB: 1462 1446 return is_spread_slab(cs); 1447 + default: 1448 + BUG(); 1449 + } 1450 + } 1451 + 1452 + static s64 cpuset_read_s64(struct cgroup *cont, struct cftype *cft) 1453 + { 1454 + struct cpuset *cs = cgroup_cs(cont); 1455 + cpuset_filetype_t type = cft->private; 1456 + switch (type) { 1457 + case FILE_SCHED_RELAX_DOMAIN_LEVEL: 1458 + return cs->relax_domain_level; 1463 1459 default: 1464 1460 BUG(); 1465 1461 } ··· 1527 1499 1528 1500 { 1529 1501 .name = "sched_relax_domain_level", 1530 - .read_u64 = cpuset_read_u64, 1531 - .write_u64 = cpuset_write_u64, 1502 + .read_s64 = cpuset_read_s64, 1503 + .write_s64 = cpuset_write_s64, 1532 1504 .private = FILE_SCHED_RELAX_DOMAIN_LEVEL, 1533 1505 }, 1534 1506