Skip to content

Commit

Permalink
tools/power turbostat: Fix warning upon failed /dev/cpu_dma_latency read
Browse files Browse the repository at this point in the history
Previously a failed read of /dev/cpu_dma_latency erroneously complained
turbostat: capget(CAP_SYS_ADMIN) failed, try "# setcap cap_sys_admin=ep ./turbostat

This went unnoticed because this file is typically visible to root,
and turbostat was typically run as root.

Going forward, when a non-root user can run turbostat...
Complain about failed read access to this file only if --debug is used.

Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Len Brown committed Apr 2, 2024
1 parent 538d505 commit b6fe938
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -5545,7 +5545,8 @@ void print_dev_latency(void)

fd = open(path, O_RDONLY);
if (fd < 0) {
warnx("capget(CAP_SYS_ADMIN) failed, try \"# setcap cap_sys_admin=ep %s\"", progname);
if (debug)
warnx("Read %s failed", path);
return;
}

Expand Down

0 comments on commit b6fe938

Please sign in to comment.