Skip to content

Commit 9c08581

Browse files
praritlenb
authored andcommitted
tools/power turbostat: Provide better debug messages for failed capabilities 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]>
1 parent 884a1f9 commit 9c08581

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tools/power/x86/turbostat/turbostat.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ starts a new interval.
340340
must be run as root.
341341
Alternatively, non-root users can be enabled to run turbostat this way:
342342

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

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

tools/power/x86/turbostat/turbostat.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ static int perf_instr_count_open(int cpu_num)
670670
/* counter for cpu_num, including user + kernel and all processes */
671671
fd = perf_event_open(&pea, -1, cpu_num, -1, 0);
672672
if (fd == -1) {
673-
warn("cpu%d: perf instruction counter", cpu_num);
673+
warnx("capget(CAP_PERFMON) failed, try \"# setcap cap_sys_admin=ep %s\"",
674+
progname);
674675
BIC_NOT_PRESENT(BIC_IPC);
675676
}
676677

@@ -3502,9 +3503,6 @@ void msr_sum_record(void)
35023503
/*
35033504
* set_my_sched_priority(pri)
35043505
* return previous
3505-
*
3506-
* if non-root, do this:
3507-
* # /sbin/setcap cap_sys_rawio,cap_sys_nice=+ep /usr/bin/turbostat
35083506
*/
35093507
int set_my_sched_priority(int priority)
35103508
{
@@ -3518,7 +3516,8 @@ int set_my_sched_priority(int priority)
35183516

35193517
retval = setpriority(PRIO_PROCESS, 0, priority);
35203518
if (retval)
3521-
err(retval, "setpriority(%d)", priority);
3519+
errx(retval, "capget(CAP_SYS_NICE) failed,try \"# setcap cap_sys_nice=ep %s\"",
3520+
progname);
35223521

35233522
errno = 0;
35243523
retval = getpriority(PRIO_PROCESS, 0);
@@ -5476,7 +5475,8 @@ void print_dev_latency(void)
54765475

54775476
fd = open(path, O_RDONLY);
54785477
if (fd < 0) {
5479-
warn("fopen %s\n", path);
5478+
warnx("capget(CAP_SYS_ADMIN) failed, try \"# setcap cap_sys_admin=ep %s\"",
5479+
progname);
54805480
return;
54815481
}
54825482

0 commit comments

Comments
 (0)