Commit f57ab32a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'pm-tools'

* pm-tools:
  Creating a common structure initialization pattern for struct option
  cpupower: Enable disabled Cstates if they are below max latency
  cpupower: Remove debug message when using cpupower idle-set -D switch
  cpupower: cpupower monitor reports uninitialized values for offline cpus
  tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO
  tools/power turbostat: simplify Bzy_MHz calculation
parents f6f18a26 89ba7d8c
...@@ -134,7 +134,7 @@ void decode_psb(char *p, int numpst) ...@@ -134,7 +134,7 @@ void decode_psb(char *p, int numpst)
} }
static struct option info_opts[] = { static struct option info_opts[] = {
{.name = "numpst", .has_arg=no_argument, .flag=NULL, .val='n'}, {"numpst", no_argument, NULL, 'n'},
}; };
void print_help(void) void print_help(void)
......
...@@ -20,7 +20,9 @@ Disable a specific processor sleep state. ...@@ -20,7 +20,9 @@ Disable a specific processor sleep state.
Enable a specific processor sleep state. Enable a specific processor sleep state.
.TP .TP
\fB\-D\fR \fB\-\-disable-by-latency\fR <LATENCY> \fB\-D\fR \fB\-\-disable-by-latency\fR <LATENCY>
Disable all idle states with a equal or higher latency than <LATENCY> Disable all idle states with a equal or higher latency than <LATENCY>.
Enable all idle states with a latency lower than <LATENCY>.
.TP .TP
\fB\-E\fR \fB\-\-enable-all\fR \fB\-E\fR \fB\-\-enable-all\fR
Enable all idle states if not enabled already. Enable all idle states if not enabled already.
......
...@@ -536,21 +536,21 @@ static int get_latency(unsigned int cpu, unsigned int human) ...@@ -536,21 +536,21 @@ static int get_latency(unsigned int cpu, unsigned int human)
} }
static struct option info_opts[] = { static struct option info_opts[] = {
{ .name = "debug", .has_arg = no_argument, .flag = NULL, .val = 'e'}, {"debug", no_argument, NULL, 'e'},
{ .name = "boost", .has_arg = no_argument, .flag = NULL, .val = 'b'}, {"boost", no_argument, NULL, 'b'},
{ .name = "freq", .has_arg = no_argument, .flag = NULL, .val = 'f'}, {"freq", no_argument, NULL, 'f'},
{ .name = "hwfreq", .has_arg = no_argument, .flag = NULL, .val = 'w'}, {"hwfreq", no_argument, NULL, 'w'},
{ .name = "hwlimits", .has_arg = no_argument, .flag = NULL, .val = 'l'}, {"hwlimits", no_argument, NULL, 'l'},
{ .name = "driver", .has_arg = no_argument, .flag = NULL, .val = 'd'}, {"driver", no_argument, NULL, 'd'},
{ .name = "policy", .has_arg = no_argument, .flag = NULL, .val = 'p'}, {"policy", no_argument, NULL, 'p'},
{ .name = "governors", .has_arg = no_argument, .flag = NULL, .val = 'g'}, {"governors", no_argument, NULL, 'g'},
{ .name = "related-cpus", .has_arg = no_argument, .flag = NULL, .val = 'r'}, {"related-cpus", no_argument, NULL, 'r'},
{ .name = "affected-cpus",.has_arg = no_argument, .flag = NULL, .val = 'a'}, {"affected-cpus", no_argument, NULL, 'a'},
{ .name = "stats", .has_arg = no_argument, .flag = NULL, .val = 's'}, {"stats", no_argument, NULL, 's'},
{ .name = "latency", .has_arg = no_argument, .flag = NULL, .val = 'y'}, {"latency", no_argument, NULL, 'y'},
{ .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'}, {"proc", no_argument, NULL, 'o'},
{ .name = "human", .has_arg = no_argument, .flag = NULL, .val = 'm'}, {"human", no_argument, NULL, 'm'},
{ .name = "no-rounding", .has_arg = no_argument, .flag = NULL, .val = 'n'}, {"no-rounding", no_argument, NULL, 'n'},
{ }, { },
}; };
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
#define NORM_FREQ_LEN 32 #define NORM_FREQ_LEN 32
static struct option set_opts[] = { static struct option set_opts[] = {
{ .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'}, {"min", required_argument, NULL, 'd'},
{ .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'}, {"max", required_argument, NULL, 'u'},
{ .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'}, {"governor", required_argument, NULL, 'g'},
{ .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'}, {"freq", required_argument, NULL, 'f'},
{ .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'}, {"related", no_argument, NULL, 'r'},
{ }, { },
}; };
......
...@@ -126,8 +126,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu) ...@@ -126,8 +126,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
} }
static struct option info_opts[] = { static struct option info_opts[] = {
{ .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'}, {"silent", no_argument, NULL, 's'},
{ .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'}, {"proc", no_argument, NULL, 'o'},
{ }, { },
}; };
......
...@@ -13,14 +13,10 @@ ...@@ -13,14 +13,10 @@
#include "helpers/sysfs.h" #include "helpers/sysfs.h"
static struct option info_opts[] = { static struct option info_opts[] = {
{ .name = "disable", {"disable", required_argument, NULL, 'd'},
.has_arg = required_argument, .flag = NULL, .val = 'd'}, {"enable", required_argument, NULL, 'e'},
{ .name = "enable", {"disable-by-latency", required_argument, NULL, 'D'},
.has_arg = required_argument, .flag = NULL, .val = 'e'}, {"enable-all", no_argument, NULL, 'E'},
{ .name = "disable-by-latency",
.has_arg = required_argument, .flag = NULL, .val = 'D'},
{ .name = "enable-all",
.has_arg = no_argument, .flag = NULL, .val = 'E'},
{ }, { },
}; };
...@@ -148,15 +144,22 @@ int cmd_idle_set(int argc, char **argv) ...@@ -148,15 +144,22 @@ int cmd_idle_set(int argc, char **argv)
(cpu, idlestate); (cpu, idlestate);
state_latency = sysfs_get_idlestate_latency state_latency = sysfs_get_idlestate_latency
(cpu, idlestate); (cpu, idlestate);
printf("CPU: %u - idlestate %u - state_latency: %llu - latency: %llu\n", if (disabled == 1) {
cpu, idlestate, state_latency, latency); if (latency > state_latency){
if (disabled == 1 || latency > state_latency) ret = sysfs_idlestate_disable
(cpu, idlestate, 0);
if (ret == 0)
printf(_("Idlestate %u enabled on CPU %u\n"), idlestate, cpu);
}
continue; continue;
}
if (latency <= state_latency){
ret = sysfs_idlestate_disable ret = sysfs_idlestate_disable
(cpu, idlestate, 1); (cpu, idlestate, 1);
if (ret == 0) if (ret == 0)
printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu); printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu);
} }
}
break; break;
case 'E': case 'E':
for (idlestate = 0; idlestate < idlestates; idlestate++) { for (idlestate = 0; idlestate < idlestates; idlestate++) {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "helpers/sysfs.h" #include "helpers/sysfs.h"
static struct option set_opts[] = { static struct option set_opts[] = {
{ .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, {"perf-bias", optional_argument, NULL, 'b'},
{ }, { },
}; };
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "helpers/bitmask.h" #include "helpers/bitmask.h"
static struct option set_opts[] = { static struct option set_opts[] = {
{ .name = "perf-bias", .has_arg = required_argument, .flag = NULL, .val = 'b'}, {"perf-bias", required_argument, NULL, 'b'},
{ }, { },
}; };
......
...@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top) ...@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
for (cpu = 0; cpu < cpus; cpu++) { for (cpu = 0; cpu < cpus; cpu++) {
cpu_top->core_info[cpu].cpu = cpu; cpu_top->core_info[cpu].cpu = cpu;
cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu); cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
if (!cpu_top->core_info[cpu].is_online)
continue;
if(sysfs_topology_read_file( if(sysfs_topology_read_file(
cpu, cpu,
"physical_package_id", "physical_package_id",
&(cpu_top->core_info[cpu].pkg)) < 0) &(cpu_top->core_info[cpu].pkg)) < 0) {
return -1; cpu_top->core_info[cpu].pkg = -1;
cpu_top->core_info[cpu].core = -1;
continue;
}
if(sysfs_topology_read_file( if(sysfs_topology_read_file(
cpu, cpu,
"core_id", "core_id",
&(cpu_top->core_info[cpu].core)) < 0) &(cpu_top->core_info[cpu].core)) < 0) {
return -1; cpu_top->core_info[cpu].pkg = -1;
cpu_top->core_info[cpu].core = -1;
continue;
}
} }
qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info), qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
...@@ -95,11 +99,14 @@ int get_cpu_topology(struct cpupower_topology *cpu_top) ...@@ -95,11 +99,14 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
done by pkg value. */ done by pkg value. */
last_pkg = cpu_top->core_info[0].pkg; last_pkg = cpu_top->core_info[0].pkg;
for(cpu = 1; cpu < cpus; cpu++) { for(cpu = 1; cpu < cpus; cpu++) {
if(cpu_top->core_info[cpu].pkg != last_pkg) { if (cpu_top->core_info[cpu].pkg != last_pkg &&
cpu_top->core_info[cpu].pkg != -1) {
last_pkg = cpu_top->core_info[cpu].pkg; last_pkg = cpu_top->core_info[cpu].pkg;
cpu_top->pkgs++; cpu_top->pkgs++;
} }
} }
if (!cpu_top->core_info[0].pkg == -1)
cpu_top->pkgs++; cpu_top->pkgs++;
/* Intel's cores count is not consecutively numbered, there may /* Intel's cores count is not consecutively numbered, there may
......
...@@ -143,6 +143,9 @@ void print_results(int topology_depth, int cpu) ...@@ -143,6 +143,9 @@ void print_results(int topology_depth, int cpu)
/* Be careful CPUs may got resorted for pkg value do not just use cpu */ /* Be careful CPUs may got resorted for pkg value do not just use cpu */
if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu)) if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))
return; return;
if (!cpu_top.core_info[cpu].is_online &&
cpu_top.core_info[cpu].pkg == -1)
return;
if (topology_depth > 2) if (topology_depth > 2)
printf("%4d|", cpu_top.core_info[cpu].pkg); printf("%4d|", cpu_top.core_info[cpu].pkg);
...@@ -191,7 +194,8 @@ void print_results(int topology_depth, int cpu) ...@@ -191,7 +194,8 @@ void print_results(int topology_depth, int cpu)
* It's up to the monitor plug-in to check .is_online, this one * It's up to the monitor plug-in to check .is_online, this one
* is just for additional info. * is just for additional info.
*/ */
if (!cpu_top.core_info[cpu].is_online) { if (!cpu_top.core_info[cpu].is_online &&
cpu_top.core_info[cpu].pkg != -1) {
printf(_(" *is offline\n")); printf(_(" *is offline\n"));
return; return;
} else } else
...@@ -388,6 +392,9 @@ int cmd_monitor(int argc, char **argv) ...@@ -388,6 +392,9 @@ int cmd_monitor(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (!cpu_top.core_info[0].is_online)
printf("WARNING: at least one cpu is offline\n");
/* Default is: monitor all CPUs */ /* Default is: monitor all CPUs */
if (bitmask_isallclear(cpus_chosen)) if (bitmask_isallclear(cpus_chosen))
bitmask_setall(cpus_chosen); bitmask_setall(cpus_chosen);
......
...@@ -75,6 +75,7 @@ unsigned int aperf_mperf_multiplier = 1; ...@@ -75,6 +75,7 @@ unsigned int aperf_mperf_multiplier = 1;
int do_smi; int do_smi;
double bclk; double bclk;
double base_hz; double base_hz;
unsigned int has_base_hz;
double tsc_tweak = 1.0; double tsc_tweak = 1.0;
unsigned int show_pkg; unsigned int show_pkg;
unsigned int show_core; unsigned int show_core;
...@@ -96,6 +97,7 @@ unsigned int do_ring_perf_limit_reasons; ...@@ -96,6 +97,7 @@ unsigned int do_ring_perf_limit_reasons;
unsigned int crystal_hz; unsigned int crystal_hz;
unsigned long long tsc_hz; unsigned long long tsc_hz;
int base_cpu; int base_cpu;
double discover_bclk(unsigned int family, unsigned int model);
#define RAPL_PKG (1 << 0) #define RAPL_PKG (1 << 0)
/* 0x610 MSR_PKG_POWER_LIMIT */ /* 0x610 MSR_PKG_POWER_LIMIT */
...@@ -511,9 +513,13 @@ int format_counters(struct thread_data *t, struct core_data *c, ...@@ -511,9 +513,13 @@ int format_counters(struct thread_data *t, struct core_data *c,
} }
/* Bzy_MHz */ /* Bzy_MHz */
if (has_aperf) if (has_aperf) {
if (has_base_hz)
outp += sprintf(outp, "%8.0f", base_hz / units * t->aperf / t->mperf);
else
outp += sprintf(outp, "%8.0f", outp += sprintf(outp, "%8.0f",
1.0 * t->tsc * tsc_tweak / units * t->aperf / t->mperf / interval_float); 1.0 * t->tsc / units * t->aperf / t->mperf / interval_float);
}
/* TSC_MHz */ /* TSC_MHz */
outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float); outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float);
...@@ -1158,12 +1164,6 @@ int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, ...@@ -1158,12 +1164,6 @@ int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV,
static void static void
calculate_tsc_tweak() calculate_tsc_tweak()
{ {
unsigned long long msr;
unsigned int base_ratio;
get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
base_ratio = (msr >> 8) & 0xFF;
base_hz = base_ratio * bclk * 1000000;
tsc_tweak = base_hz / tsc_hz; tsc_tweak = base_hz / tsc_hz;
} }
...@@ -1440,7 +1440,7 @@ dump_config_tdp(void) ...@@ -1440,7 +1440,7 @@ dump_config_tdp(void)
get_msr(base_cpu, MSR_TURBO_ACTIVATION_RATIO, &msr); get_msr(base_cpu, MSR_TURBO_ACTIVATION_RATIO, &msr);
fprintf(stderr, "cpu%d: MSR_TURBO_ACTIVATION_RATIO: 0x%08llx (", base_cpu, msr); fprintf(stderr, "cpu%d: MSR_TURBO_ACTIVATION_RATIO: 0x%08llx (", base_cpu, msr);
fprintf(stderr, "MAX_NON_TURBO_RATIO=%d", (unsigned int)(msr) & 0xEF); fprintf(stderr, "MAX_NON_TURBO_RATIO=%d", (unsigned int)(msr) & 0x7F);
fprintf(stderr, " lock=%d", (unsigned int)(msr >> 31) & 1); fprintf(stderr, " lock=%d", (unsigned int)(msr >> 31) & 1);
fprintf(stderr, ")\n"); fprintf(stderr, ")\n");
} }
...@@ -1821,6 +1821,7 @@ void check_permissions() ...@@ -1821,6 +1821,7 @@ void check_permissions()
int probe_nhm_msrs(unsigned int family, unsigned int model) int probe_nhm_msrs(unsigned int family, unsigned int model)
{ {
unsigned long long msr; unsigned long long msr;
unsigned int base_ratio;
int *pkg_cstate_limits; int *pkg_cstate_limits;
if (!genuine_intel) if (!genuine_intel)
...@@ -1829,6 +1830,8 @@ int probe_nhm_msrs(unsigned int family, unsigned int model) ...@@ -1829,6 +1830,8 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
if (family != 6) if (family != 6)
return 0; return 0;
bclk = discover_bclk(family, model);
switch (model) { switch (model) {
case 0x1A: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */ case 0x1A: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */
case 0x1E: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ case 0x1E: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */
...@@ -1871,9 +1874,13 @@ int probe_nhm_msrs(unsigned int family, unsigned int model) ...@@ -1871,9 +1874,13 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
return 0; return 0;
} }
get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr); get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
pkg_cstate_limit = pkg_cstate_limits[msr & 0xF]; pkg_cstate_limit = pkg_cstate_limits[msr & 0xF];
get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
base_ratio = (msr >> 8) & 0xFF;
base_hz = base_ratio * bclk * 1000000;
has_base_hz = 1;
return 1; return 1;
} }
int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model) int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model)
...@@ -2780,7 +2787,6 @@ void process_cpuid() ...@@ -2780,7 +2787,6 @@ void process_cpuid()
do_skl_residency = has_skl_msrs(family, model); do_skl_residency = has_skl_msrs(family, model);
do_slm_cstates = is_slm(family, model); do_slm_cstates = is_slm(family, model);
do_knl_cstates = is_knl(family, model); do_knl_cstates = is_knl(family, model);
bclk = discover_bclk(family, model);
rapl_probe(family, model); rapl_probe(family, model);
perf_limit_reasons_probe(family, model); perf_limit_reasons_probe(family, model);
......
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