Commit ba9c7791 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 0eb392ec de7839ee
...@@ -340,10 +340,12 @@ starts a new interval. ...@@ -340,10 +340,12 @@ starts a new interval.
must be run as root. must be run as root.
Alternatively, non-root users can be enabled to run turbostat this way: 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 # chmod +r /dev/cpu/*/msr
# chmod +r /dev/cpu_dma_latency
.B "turbostat " .B "turbostat "
reads hardware counters, but doesn't write them. reads hardware counters, but doesn't write them.
So it will not interfere with the OS or other programs, including So it will not interfere with the OS or other programs, including
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* turbostat -- show CPU frequency and C-state residency * turbostat -- show CPU frequency and C-state residency
* on modern Intel and AMD processors. * on modern Intel and AMD processors.
* *
* Copyright (c) 2022 Intel Corporation. * Copyright (c) 2023 Intel Corporation.
* Len Brown <len.brown@intel.com> * Len Brown <len.brown@intel.com>
*/ */
...@@ -670,7 +670,7 @@ static int perf_instr_count_open(int cpu_num) ...@@ -670,7 +670,7 @@ static int perf_instr_count_open(int cpu_num)
/* counter for cpu_num, including user + kernel and all processes */ /* counter for cpu_num, including user + kernel and all processes */
fd = perf_event_open(&pea, -1, cpu_num, -1, 0); fd = perf_event_open(&pea, -1, cpu_num, -1, 0);
if (fd == -1) { 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); BIC_NOT_PRESENT(BIC_IPC);
} }
...@@ -2538,7 +2538,7 @@ static void dump_turbo_ratio_limits(int trl_msr_offset, int family, int model) ...@@ -2538,7 +2538,7 @@ static void dump_turbo_ratio_limits(int trl_msr_offset, int family, int model)
get_msr(base_cpu, trl_msr_offset, &msr); get_msr(base_cpu, trl_msr_offset, &msr);
fprintf(outf, "cpu%d: MSR_%sTURBO_RATIO_LIMIT: 0x%08llx\n", fprintf(outf, "cpu%d: MSR_%sTURBO_RATIO_LIMIT: 0x%08llx\n",
base_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY" : "", msr); base_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY_" : "", msr);
if (has_turbo_ratio_group_limits(family, model)) { if (has_turbo_ratio_group_limits(family, model)) {
get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT1, &core_counts); get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT1, &core_counts);
...@@ -3502,9 +3502,6 @@ void msr_sum_record(void) ...@@ -3502,9 +3502,6 @@ void msr_sum_record(void)
/* /*
* set_my_sched_priority(pri) * set_my_sched_priority(pri)
* return previous * 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) int set_my_sched_priority(int priority)
{ {
...@@ -3518,7 +3515,7 @@ int set_my_sched_priority(int priority) ...@@ -3518,7 +3515,7 @@ int set_my_sched_priority(int priority)
retval = setpriority(PRIO_PROCESS, 0, priority); retval = setpriority(PRIO_PROCESS, 0, priority);
if (retval) if (retval)
err(retval, "setpriority(%d)", priority); errx(retval, "capget(CAP_SYS_NICE) failed,try \"# setcap cap_sys_nice=ep %s\"", progname);
errno = 0; errno = 0;
retval = getpriority(PRIO_PROCESS, 0); retval = getpriority(PRIO_PROCESS, 0);
...@@ -4426,7 +4423,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p) ...@@ -4426,7 +4423,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p)
fprintf(outf, "cpu%d: MSR_HWP_STATUS: 0x%08llx " fprintf(outf, "cpu%d: MSR_HWP_STATUS: 0x%08llx "
"(%sGuaranteed_Perf_Change, %sExcursion_Min)\n", "(%sGuaranteed_Perf_Change, %sExcursion_Min)\n",
cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x2) ? "" : "No-"); cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x4) ? "" : "No-");
return 0; return 0;
} }
...@@ -5463,6 +5460,9 @@ unsigned int intel_model_duplicates(unsigned int model) ...@@ -5463,6 +5460,9 @@ unsigned int intel_model_duplicates(unsigned int model)
case INTEL_FAM6_ICELAKE_D: case INTEL_FAM6_ICELAKE_D:
return INTEL_FAM6_ICELAKE_X; return INTEL_FAM6_ICELAKE_X;
case INTEL_FAM6_EMERALDRAPIDS_X:
return INTEL_FAM6_SAPPHIRERAPIDS_X;
} }
return model; return model;
} }
...@@ -5476,13 +5476,13 @@ void print_dev_latency(void) ...@@ -5476,13 +5476,13 @@ void print_dev_latency(void)
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0) { if (fd < 0) {
warn("fopen %s\n", path); warnx("capget(CAP_SYS_ADMIN) failed, try \"# setcap cap_sys_admin=ep %s\"", progname);
return; return;
} }
retval = read(fd, (void *)&value, sizeof(int)); retval = read(fd, (void *)&value, sizeof(int));
if (retval != sizeof(int)) { if (retval != sizeof(int)) {
warn("read %s\n", path); warn("read failed %s", path);
close(fd); close(fd);
return; return;
} }
...@@ -5543,7 +5543,7 @@ void process_cpuid() ...@@ -5543,7 +5543,7 @@ void process_cpuid()
edx_flags = edx; edx_flags = edx;
if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
warnx("get_msr(UCODE)\n"); warnx("get_msr(UCODE)");
/* /*
* check max extended function levels of CPUID. * check max extended function levels of CPUID.
...@@ -6225,7 +6225,7 @@ int get_and_dump_counters(void) ...@@ -6225,7 +6225,7 @@ int get_and_dump_counters(void)
void print_version() void print_version()
{ {
fprintf(outf, "turbostat version 2022.10.04 - Len Brown <lenb@kernel.org>\n"); fprintf(outf, "turbostat version 2023.03.17 - Len Brown <lenb@kernel.org>\n");
} }
#define COMMAND_LINE_SIZE 2048 #define COMMAND_LINE_SIZE 2048
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment