diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2023-01-24 10:39:53 -0800 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2023-10-24 13:38:09 +0800 |
commit | 37f68a2940558b4f6f8e51b7b1d00f084b4bdde2 (patch) | |
tree | e40f00140952902da7a7c36e8d4dd124f62eb6a6 | |
parent | f638858da0925b29122f05135663013dc240eaf9 (diff) | |
download | lwn-37f68a2940558b4f6f8e51b7b1d00f084b4bdde2.tar.gz lwn-37f68a2940558b4f6f8e51b7b1d00f084b4bdde2.zip |
tools/power/turbostat: Move process to root cgroup
When available CPUs are reduced via cgroup cpuset controller, turbostat
will exit with errors (For example):
get_counters: Could not migrate to CPU 0
turbostat: re-initialized with num_cpus 20
get_counters: Could not migrate to CPU 0
turbostat: re-initialized with num_cpus 20
Move the turbostat to root cgroup, which has every CPU.
Writing the value 0 to a cgroup.procs file causes the writing
process to be moved to the corresponding cgroup.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tested-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 0ef6fba118b1..fea63d9d8e02 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -6666,6 +6666,19 @@ void cmdline(int argc, char **argv) int main(int argc, char **argv) { + int fd, ret; + + fd = open("/sys/fs/cgroup/cgroup.procs", O_WRONLY); + if (fd < 0) + goto skip_cgroup_setting; + + ret = write(fd, "0\n", 2); + if (ret == -1) + perror("Can't update cgroup\n"); + + close(fd); + +skip_cgroup_setting: outf = stderr; cmdline(argc, argv); |