Skip to content

Commit

Permalink
tools/power turbostat: Provide better debug messages for failed capab…
Browse files Browse the repository at this point in the history
…ilities accesses

turbostat reports some capabilities access errors and not others.  Provide
the same debug message for all errors.

[lenb: remove extra quotes]

Cc: David Arcari <[email protected]>
Signed-off-by: Prarit Bhargava <[email protected]>
Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
prarit authored and lenb committed Mar 17, 2023
1 parent 884a1f9 commit 9c08581
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tools/power/x86/turbostat/turbostat.8
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ starts a new interval.
must be run as root.
Alternatively, non-root users can be enabled to run turbostat this way:

# setcap cap_sys_admin,cap_sys_rawio,cap_sys_nice=+ep ./turbostat
# setcap cap_sys_admin,cap_sys_rawio,cap_sys_nice=+ep path/to/turbostat

# chmod +r /dev/cpu/*/msr

Expand Down
12 changes: 6 additions & 6 deletions tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ static int perf_instr_count_open(int cpu_num)
/* counter for cpu_num, including user + kernel and all processes */
fd = perf_event_open(&pea, -1, cpu_num, -1, 0);
if (fd == -1) {
warn("cpu%d: perf instruction counter", cpu_num);
warnx("capget(CAP_PERFMON) failed, try \"# setcap cap_sys_admin=ep %s\"",
progname);
BIC_NOT_PRESENT(BIC_IPC);
}

Expand Down Expand Up @@ -3502,9 +3503,6 @@ void msr_sum_record(void)
/*
* set_my_sched_priority(pri)
* return previous
*
* if non-root, do this:
* # /sbin/setcap cap_sys_rawio,cap_sys_nice=+ep /usr/bin/turbostat
*/
int set_my_sched_priority(int priority)
{
Expand All @@ -3518,7 +3516,8 @@ int set_my_sched_priority(int priority)

retval = setpriority(PRIO_PROCESS, 0, priority);
if (retval)
err(retval, "setpriority(%d)", priority);
errx(retval, "capget(CAP_SYS_NICE) failed,try \"# setcap cap_sys_nice=ep %s\"",
progname);

errno = 0;
retval = getpriority(PRIO_PROCESS, 0);
Expand Down Expand Up @@ -5476,7 +5475,8 @@ void print_dev_latency(void)

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

Expand Down

0 comments on commit 9c08581

Please sign in to comment.