Skip to content

Commit 37f68a2

Browse files
spandruvadazhang-rui
authored andcommitted
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 <[email protected]> Tested-by: Zhang Rui <[email protected]>
1 parent f638858 commit 37f68a2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6666,6 +6666,19 @@ void cmdline(int argc, char **argv)
66666666

66676667
int main(int argc, char **argv)
66686668
{
6669+
int fd, ret;
6670+
6671+
fd = open("/sys/fs/cgroup/cgroup.procs", O_WRONLY);
6672+
if (fd < 0)
6673+
goto skip_cgroup_setting;
6674+
6675+
ret = write(fd, "0\n", 2);
6676+
if (ret == -1)
6677+
perror("Can't update cgroup\n");
6678+
6679+
close(fd);
6680+
6681+
skip_cgroup_setting:
66696682
outf = stderr;
66706683
cmdline(argc, argv);
66716684

0 commit comments

Comments
 (0)