Merge branch 'pm-tools'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 11 Nov 2015 23:22:56 +0000 (00:22 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 11 Nov 2015 23:22:56 +0000 (00:22 +0100)
* 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

tools/power/cpupower/debug/i386/dump_psb.c
tools/power/cpupower/man/cpupower-idle-set.1
tools/power/cpupower/utils/cpufreq-info.c
tools/power/cpupower/utils/cpufreq-set.c
tools/power/cpupower/utils/cpuidle-info.c
tools/power/cpupower/utils/cpuidle-set.c
tools/power/cpupower/utils/cpupower-info.c
tools/power/cpupower/utils/cpupower-set.c
tools/power/cpupower/utils/helpers/topology.c
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
tools/power/x86/turbostat/turbostat.c

index 8d6a47514253822bb0673968707bc4ecc6a7749e..2c768cf70128cb2d8bbd6a151b6ec51414dafc65 100644 (file)
@@ -134,7 +134,7 @@ next_one:
 }
 
 static struct option info_opts[] = {
-       {.name = "numpst",      .has_arg=no_argument,   .flag=NULL, .val='n'},
+     {"numpst", no_argument, NULL, 'n'},
 };
 
 void print_help(void)
index 3e6799d7a79f1d951f1d6e95f65f337663c8f286..580c4e3ea92ad5425cb0b0c458c2d3fbfa23983c 100644 (file)
@@ -20,7 +20,9 @@ Disable a specific processor sleep state.
 Enable a specific processor sleep state.
 .TP
 \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
 \fB\-E\fR \fB\-\-enable-all\fR
 Enable all idle states if not enabled already.
index b4b90a97662cda4abe72c82419c815888231235b..0e676433024109bef6d9a87e08709c40be37b2df 100644 (file)
@@ -536,21 +536,21 @@ static int get_latency(unsigned int cpu, unsigned int human)
 }
 
 static struct option info_opts[] = {
-       { .name = "debug",      .has_arg = no_argument,         .flag = NULL,   .val = 'e'},
-       { .name = "boost",      .has_arg = no_argument,         .flag = NULL,   .val = 'b'},
-       { .name = "freq",       .has_arg = no_argument,         .flag = NULL,   .val = 'f'},
-       { .name = "hwfreq",     .has_arg = no_argument,         .flag = NULL,   .val = 'w'},
-       { .name = "hwlimits",   .has_arg = no_argument,         .flag = NULL,   .val = 'l'},
-       { .name = "driver",     .has_arg = no_argument,         .flag = NULL,   .val = 'd'},
-       { .name = "policy",     .has_arg = no_argument,         .flag = NULL,   .val = 'p'},
-       { .name = "governors",  .has_arg = no_argument,         .flag = NULL,   .val = 'g'},
-       { .name = "related-cpus", .has_arg = no_argument,       .flag = NULL,   .val = 'r'},
-       { .name = "affected-cpus",.has_arg = no_argument,       .flag = NULL,   .val = 'a'},
-       { .name = "stats",      .has_arg = no_argument,         .flag = NULL,   .val = 's'},
-       { .name = "latency",    .has_arg = no_argument,         .flag = NULL,   .val = 'y'},
-       { .name = "proc",       .has_arg = no_argument,         .flag = NULL,   .val = 'o'},
-       { .name = "human",      .has_arg = no_argument,         .flag = NULL,   .val = 'm'},
-       { .name = "no-rounding", .has_arg = no_argument,        .flag = NULL,   .val = 'n'},
+       {"debug",        no_argument,            NULL,   'e'},
+       {"boost",        no_argument,            NULL,   'b'},
+       {"freq",         no_argument,            NULL,   'f'},
+       {"hwfreq",       no_argument,            NULL,   'w'},
+       {"hwlimits",     no_argument,            NULL,   'l'},
+       {"driver",       no_argument,            NULL,   'd'},
+       {"policy",       no_argument,            NULL,   'p'},
+       {"governors",    no_argument,            NULL,   'g'},
+       {"related-cpus",  no_argument,   NULL,   'r'},
+       {"affected-cpus", no_argument,   NULL,   'a'},
+       {"stats",        no_argument,            NULL,   's'},
+       {"latency",      no_argument,            NULL,   'y'},
+       {"proc",         no_argument,            NULL,   'o'},
+       {"human",        no_argument,            NULL,   'm'},
+       {"no-rounding", no_argument,     NULL,   'n'},
        { },
 };
 
index 4e213576381eab03c64444b6acee614e9c84f874..0fbd1a22c0a984c0ceac2f832ca791058c0d1524 100644 (file)
 #define NORM_FREQ_LEN 32
 
 static struct option set_opts[] = {
-       { .name = "min",        .has_arg = required_argument,   .flag = NULL,   .val = 'd'},
-       { .name = "max",        .has_arg = required_argument,   .flag = NULL,   .val = 'u'},
-       { .name = "governor",   .has_arg = required_argument,   .flag = NULL,   .val = 'g'},
-       { .name = "freq",       .has_arg = required_argument,   .flag = NULL,   .val = 'f'},
-       { .name = "related",    .has_arg = no_argument,         .flag = NULL,   .val='r'},
+       {"min",         required_argument,      NULL, 'd'},
+       {"max",         required_argument,      NULL, 'u'},
+       {"governor",    required_argument,      NULL, 'g'},
+       {"freq",        required_argument,      NULL, 'f'},
+       {"related",     no_argument,            NULL, 'r'},
        { },
 };
 
index 75e66de7e7a7fc9934ec005667c6857cff42ff04..750c1d82c3f7b7f16a3eea71df3c9d6e7a4ceb7d 100644 (file)
@@ -126,8 +126,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
 }
 
 static struct option info_opts[] = {
-       { .name = "silent",     .has_arg = no_argument, .flag = NULL,   .val = 's'},
-       { .name = "proc",       .has_arg = no_argument, .flag = NULL,   .val = 'o'},
+       {"silent", no_argument, NULL, 's'},
+       {"proc", no_argument, NULL, 'o'},
        { },
 };
 
index d45d8d775c021482ab7a4d113351c7f6abd9a9ac..d6b6ae44b8c247ffdb6378d8dcd3cb36f0265142 100644 (file)
 #include "helpers/sysfs.h"
 
 static struct option info_opts[] = {
-       { .name = "disable",
-         .has_arg = required_argument, .flag = NULL,   .val = 'd'},
-       { .name = "enable",
-         .has_arg = required_argument, .flag = NULL,   .val = 'e'},
-       { .name = "disable-by-latency",
-         .has_arg = required_argument, .flag = NULL,   .val = 'D'},
-       { .name = "enable-all",
-         .has_arg = no_argument,       .flag = NULL,   .val = 'E'},
-       { },
+     {"disable",       required_argument,              NULL, 'd'},
+     {"enable",                required_argument,              NULL, 'e'},
+     {"disable-by-latency", required_argument,         NULL, 'D'},
+     {"enable-all",    no_argument,                    NULL, 'E'},
+     { },
 };
 
 
@@ -148,14 +144,21 @@ int cmd_idle_set(int argc, char **argv)
                                        (cpu, idlestate);
                                state_latency = sysfs_get_idlestate_latency
                                        (cpu, idlestate);
-                               printf("CPU: %u - idlestate %u - state_latency: %llu - latency: %llu\n",
-                                      cpu, idlestate, state_latency, latency);
-                               if (disabled == 1 || latency > state_latency)
+                               if (disabled == 1) {
+                                       if (latency > state_latency){
+                                               ret = sysfs_idlestate_disable
+                                                       (cpu, idlestate, 0);
+                                               if (ret == 0)
+               printf(_("Idlestate %u enabled on CPU %u\n"),  idlestate, cpu);
+                                       }
                                        continue;
-                               ret = sysfs_idlestate_disable
-                                       (cpu, idlestate, 1);
-                               if (ret == 0)
+                               }
+                               if (latency <= state_latency){
+                                       ret = sysfs_idlestate_disable
+                                               (cpu, idlestate, 1);
+                                       if (ret == 0)
                printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu);
+                               }
                        }
                        break;
                case 'E':
index 136d979e958634b83a3f2cd007a7d192036ee152..10299f2e9d2a6917f0601dd07eedb0ff03c6bc92 100644 (file)
@@ -17,8 +17,8 @@
 #include "helpers/sysfs.h"
 
 static struct option set_opts[] = {
-       { .name = "perf-bias",  .has_arg = optional_argument,   .flag = NULL,   .val = 'b'},
-       { },
+     {"perf-bias", optional_argument, NULL, 'b'},
+     { },
 };
 
 static void print_wrong_arg_exit(void)
index 573c75f8e3f5da78afdfd4b2e22dff9cde18d01e..3e6f374f8dd73ddc1fd1b6d3b30f175fcc7f9e4b 100644 (file)
@@ -18,7 +18,7 @@
 #include "helpers/bitmask.h"
 
 static struct option set_opts[] = {
-       { .name = "perf-bias",  .has_arg = required_argument,   .flag = NULL,   .val = 'b'},
+       {"perf-bias", required_argument, NULL, 'b'},
        { },
 };
 
index cea398c176e7f29057a24463f296300f8ce5f23f..9cbb7fd7517122c423d316efb5e736a52c799d3a 100644 (file)
@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
        for (cpu = 0; cpu < cpus; cpu++) {
                cpu_top->core_info[cpu].cpu = 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(
                        cpu,
                        "physical_package_id",
-                       &(cpu_top->core_info[cpu].pkg)) < 0)
-                       return -1;
+                       &(cpu_top->core_info[cpu].pkg)) < 0) {
+                       cpu_top->core_info[cpu].pkg = -1;
+                       cpu_top->core_info[cpu].core = -1;
+                       continue;
+               }
                if(sysfs_topology_read_file(
                        cpu,
                        "core_id",
-                       &(cpu_top->core_info[cpu].core)) < 0)
-                       return -1;
+                       &(cpu_top->core_info[cpu].core)) < 0) {
+                       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),
@@ -95,12 +99,15 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
           done by pkg value. */
        last_pkg = cpu_top->core_info[0].pkg;
        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;
                        cpu_top->pkgs++;
                }
        }
-       cpu_top->pkgs++;
+       if (!cpu_top->core_info[0].pkg == -1)
+               cpu_top->pkgs++;
 
        /* Intel's cores count is not consecutively numbered, there may
         * be a core_id of 3, but none of 2. Assume there always is 0
index c4bae9203a692f2065ee9ec4f8d747c0912d8a94..05f953f0f0a0cf2b3d479ce6a6dcbc9c0d9a8c28 100644 (file)
@@ -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 */
        if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))
                return;
+       if (!cpu_top.core_info[cpu].is_online &&
+           cpu_top.core_info[cpu].pkg == -1)
+               return;
 
        if (topology_depth > 2)
                printf("%4d|", cpu_top.core_info[cpu].pkg);
@@ -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
         * 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"));
                return;
        } else
@@ -388,6 +392,9 @@ int cmd_monitor(int argc, char **argv)
                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 */
        if (bitmask_isallclear(cpus_chosen))
                bitmask_setall(cpus_chosen);
index bde0ef1a63df4876d5149c85f4083eb92561dbb4..d8e4b20b6d54cc14c25482279a2a652fe483a2f3 100644 (file)
@@ -75,6 +75,7 @@ unsigned int aperf_mperf_multiplier = 1;
 int do_smi;
 double bclk;
 double base_hz;
+unsigned int has_base_hz;
 double tsc_tweak = 1.0;
 unsigned int show_pkg;
 unsigned int show_core;
@@ -96,6 +97,7 @@ unsigned int do_ring_perf_limit_reasons;
 unsigned int crystal_hz;
 unsigned long long tsc_hz;
 int base_cpu;
+double discover_bclk(unsigned int family, unsigned int model);
 
 #define RAPL_PKG               (1 << 0)
                                        /* 0x610 MSR_PKG_POWER_LIMIT */
@@ -511,9 +513,13 @@ int format_counters(struct thread_data *t, struct core_data *c,
        }
 
        /* Bzy_MHz */
-       if (has_aperf)
-               outp += sprintf(outp, "%8.0f",
-                       1.0 * t->tsc * tsc_tweak / units * t->aperf / t->mperf / interval_float);
+       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",
+                               1.0 * t->tsc / units * t->aperf / t->mperf / interval_float);
+       }
 
        /* TSC_MHz */
        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,
 static void
 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;
 }
 
@@ -1440,7 +1440,7 @@ dump_config_tdp(void)
        
        get_msr(base_cpu, MSR_TURBO_ACTIVATION_RATIO, &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, ")\n");
 }
@@ -1821,6 +1821,7 @@ void check_permissions()
 int probe_nhm_msrs(unsigned int family, unsigned int model)
 {
        unsigned long long msr;
+       unsigned int base_ratio;
        int *pkg_cstate_limits;
 
        if (!genuine_intel)
@@ -1829,6 +1830,8 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
        if (family != 6)
                return 0;
 
+       bclk = discover_bclk(family, model);
+
        switch (model) {
        case 0x1A:      /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */
        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)
                return 0;
        }
        get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
-
        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;
 }
 int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model)
@@ -2780,7 +2787,6 @@ void process_cpuid()
        do_skl_residency = has_skl_msrs(family, model);
        do_slm_cstates = is_slm(family, model);
        do_knl_cstates  = is_knl(family, model);
-       bclk = discover_bclk(family, model);
 
        rapl_probe(family, model);
        perf_limit_reasons_probe(family, model);