Skip to content

Commit ba9c779

Browse files
committed
Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat fweaks and fixes from Len Brown: "Leprechaun sized fixes and tweaks touching only turbostat. 'Keeping happy users happy since 2010'" * 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: tools/power turbostat: version 2023.03.17 tools/power turbostat: fix decoding of HWP_STATUS tools/power turbostat: Introduce support for EMR tools/power turbostat: remove stray newlines from warn/warnx strings tools/power turbostat: Fix /dev/cpu_dma_latency warnings tools/power turbostat: Provide better debug messages for failed capabilities accesses tools/power turbostat: update dump of SECONDARY_TURBO_RATIO_LIMIT
2 parents 0eb392e + de7839e commit ba9c779

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

tools/power/x86/turbostat/turbostat.8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,12 @@ 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

347+
# chmod +r /dev/cpu_dma_latency
348+
347349
.B "turbostat "
348350
reads hardware counters, but doesn't write them.
349351
So it will not interfere with the OS or other programs, including

tools/power/x86/turbostat/turbostat.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* turbostat -- show CPU frequency and C-state residency
44
* on modern Intel and AMD processors.
55
*
6-
* Copyright (c) 2022 Intel Corporation.
6+
* Copyright (c) 2023 Intel Corporation.
77
* Len Brown <len.brown@intel.com>
88
*/
99

@@ -670,7 +670,7 @@ 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\"", progname);
674674
BIC_NOT_PRESENT(BIC_IPC);
675675
}
676676

@@ -2538,7 +2538,7 @@ static void dump_turbo_ratio_limits(int trl_msr_offset, int family, int model)
25382538

25392539
get_msr(base_cpu, trl_msr_offset, &msr);
25402540
fprintf(outf, "cpu%d: MSR_%sTURBO_RATIO_LIMIT: 0x%08llx\n",
2541-
base_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY" : "", msr);
2541+
base_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY_" : "", msr);
25422542

25432543
if (has_turbo_ratio_group_limits(family, model)) {
25442544
get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT1, &core_counts);
@@ -3502,9 +3502,6 @@ void msr_sum_record(void)
35023502
/*
35033503
* set_my_sched_priority(pri)
35043504
* return previous
3505-
*
3506-
* if non-root, do this:
3507-
* # /sbin/setcap cap_sys_rawio,cap_sys_nice=+ep /usr/bin/turbostat
35083505
*/
35093506
int set_my_sched_priority(int priority)
35103507
{
@@ -3518,7 +3515,7 @@ int set_my_sched_priority(int priority)
35183515

35193516
retval = setpriority(PRIO_PROCESS, 0, priority);
35203517
if (retval)
3521-
err(retval, "setpriority(%d)", priority);
3518+
errx(retval, "capget(CAP_SYS_NICE) failed,try \"# setcap cap_sys_nice=ep %s\"", progname);
35223519

35233520
errno = 0;
35243521
retval = getpriority(PRIO_PROCESS, 0);
@@ -4426,7 +4423,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p)
44264423

44274424
fprintf(outf, "cpu%d: MSR_HWP_STATUS: 0x%08llx "
44284425
"(%sGuaranteed_Perf_Change, %sExcursion_Min)\n",
4429-
cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x2) ? "" : "No-");
4426+
cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x4) ? "" : "No-");
44304427

44314428
return 0;
44324429
}
@@ -5463,6 +5460,9 @@ unsigned int intel_model_duplicates(unsigned int model)
54635460

54645461
case INTEL_FAM6_ICELAKE_D:
54655462
return INTEL_FAM6_ICELAKE_X;
5463+
5464+
case INTEL_FAM6_EMERALDRAPIDS_X:
5465+
return INTEL_FAM6_SAPPHIRERAPIDS_X;
54665466
}
54675467
return model;
54685468
}
@@ -5476,13 +5476,13 @@ void print_dev_latency(void)
54765476

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

54835483
retval = read(fd, (void *)&value, sizeof(int));
54845484
if (retval != sizeof(int)) {
5485-
warn("read %s\n", path);
5485+
warn("read failed %s", path);
54865486
close(fd);
54875487
return;
54885488
}
@@ -5543,7 +5543,7 @@ void process_cpuid()
55435543
edx_flags = edx;
55445544

55455545
if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
5546-
warnx("get_msr(UCODE)\n");
5546+
warnx("get_msr(UCODE)");
55475547

55485548
/*
55495549
* check max extended function levels of CPUID.
@@ -6225,7 +6225,7 @@ int get_and_dump_counters(void)
62256225

62266226
void print_version()
62276227
{
6228-
fprintf(outf, "turbostat version 2022.10.04 - Len Brown <lenb@kernel.org>\n");
6228+
fprintf(outf, "turbostat version 2023.03.17 - Len Brown <lenb@kernel.org>\n");
62296229
}
62306230

62316231
#define COMMAND_LINE_SIZE 2048

0 commit comments

Comments
 (0)