diff options
author | Thomas Renninger <trenn@suse.com> | 2015-12-01 11:14:15 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-02 20:30:30 -0500 |
commit | ce512b84045459f4a6c119a109c950c6bc4a6f3a (patch) | |
tree | 7dc8c24c52f5b870ce1a6c1a4b09adfdaa0e7d98 /tools | |
parent | e51207f0030474958e59bbc7e002f169bdb05c50 (diff) |
cpupower: Do not analyse offlined cpus
Use sysfs_is_cpu_online(cpu) instead of cpufreq_cpu_exists(cpu) to detect offlined cpus.
Re-arrange printfs slightly to have a consistent output even if you have multiple CPUs
as output and even if offlined cores are in between.
Signed-off-by: Thomas Renninger <trenn@suse.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/cpupower/utils/cpufreq-info.c | 11 | ||||
-rw-r--r-- | tools/power/cpupower/utils/cpuidle-info.c | 16 | ||||
-rw-r--r-- | tools/power/cpupower/utils/cpupower-info.c | 9 | ||||
-rw-r--r-- | tools/power/cpupower/utils/cpupower-set.c | 10 |
4 files changed, 31 insertions, 15 deletions
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 0e6764330241..522b357f4110 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <getopt.h> | 14 | #include <getopt.h> |
15 | 15 | ||
16 | #include "cpufreq.h" | 16 | #include "cpufreq.h" |
17 | #include "helpers/sysfs.h" | ||
17 | #include "helpers/helpers.h" | 18 | #include "helpers/helpers.h" |
18 | #include "helpers/bitmask.h" | 19 | #include "helpers/bitmask.h" |
19 | 20 | ||
@@ -647,11 +648,14 @@ int cmd_freq_info(int argc, char **argv) | |||
647 | 648 | ||
648 | if (!bitmask_isbitset(cpus_chosen, cpu)) | 649 | if (!bitmask_isbitset(cpus_chosen, cpu)) |
649 | continue; | 650 | continue; |
650 | if (cpufreq_cpu_exists(cpu)) { | 651 | |
651 | printf(_("couldn't analyze CPU %d as it doesn't seem to be present\n"), cpu); | 652 | printf(_("analyzing CPU %d:\n"), cpu); |
653 | |||
654 | if (sysfs_is_cpu_online(cpu) != 1) { | ||
655 | printf(_(" *is offline\n")); | ||
656 | printf("\n"); | ||
652 | continue; | 657 | continue; |
653 | } | 658 | } |
654 | printf(_("analyzing CPU %d:\n"), cpu); | ||
655 | 659 | ||
656 | switch (output_param) { | 660 | switch (output_param) { |
657 | case 'b': | 661 | case 'b': |
@@ -693,6 +697,7 @@ int cmd_freq_info(int argc, char **argv) | |||
693 | } | 697 | } |
694 | if (ret) | 698 | if (ret) |
695 | return ret; | 699 | return ret; |
700 | printf("\n"); | ||
696 | } | 701 | } |
697 | return ret; | 702 | return ret; |
698 | } | 703 | } |
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c index 750c1d82c3f7..8bf8ab5ffa25 100644 --- a/tools/power/cpupower/utils/cpuidle-info.c +++ b/tools/power/cpupower/utils/cpuidle-info.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | #include <string.h> | 13 | #include <string.h> |
14 | #include <getopt.h> | 14 | #include <getopt.h> |
15 | #include <cpufreq.h> | ||
16 | 15 | ||
17 | #include "helpers/helpers.h" | 16 | #include "helpers/helpers.h" |
18 | #include "helpers/sysfs.h" | 17 | #include "helpers/sysfs.h" |
@@ -25,8 +24,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) | |||
25 | unsigned int idlestates, idlestate; | 24 | unsigned int idlestates, idlestate; |
26 | char *tmp; | 25 | char *tmp; |
27 | 26 | ||
28 | printf(_ ("Analyzing CPU %d:\n"), cpu); | ||
29 | |||
30 | idlestates = sysfs_get_idlestate_count(cpu); | 27 | idlestates = sysfs_get_idlestate_count(cpu); |
31 | if (idlestates == 0) { | 28 | if (idlestates == 0) { |
32 | printf(_("CPU %u: No idle states\n"), cpu); | 29 | printf(_("CPU %u: No idle states\n"), cpu); |
@@ -71,7 +68,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) | |||
71 | printf(_("Duration: %llu\n"), | 68 | printf(_("Duration: %llu\n"), |
72 | sysfs_get_idlestate_time(cpu, idlestate)); | 69 | sysfs_get_idlestate_time(cpu, idlestate)); |
73 | } | 70 | } |
74 | printf("\n"); | ||
75 | } | 71 | } |
76 | 72 | ||
77 | static void cpuidle_general_output(void) | 73 | static void cpuidle_general_output(void) |
@@ -189,10 +185,17 @@ int cmd_idle_info(int argc, char **argv) | |||
189 | for (cpu = bitmask_first(cpus_chosen); | 185 | for (cpu = bitmask_first(cpus_chosen); |
190 | cpu <= bitmask_last(cpus_chosen); cpu++) { | 186 | cpu <= bitmask_last(cpus_chosen); cpu++) { |
191 | 187 | ||
192 | if (!bitmask_isbitset(cpus_chosen, cpu) || | 188 | if (!bitmask_isbitset(cpus_chosen, cpu)) |
193 | cpufreq_cpu_exists(cpu)) | ||
194 | continue; | 189 | continue; |
195 | 190 | ||
191 | printf(_("analyzing CPU %d:\n"), cpu); | ||
192 | |||
193 | if (sysfs_is_cpu_online(cpu) != 1) { | ||
194 | printf(_(" *is offline\n")); | ||
195 | printf("\n"); | ||
196 | continue; | ||
197 | } | ||
198 | |||
196 | switch (output_param) { | 199 | switch (output_param) { |
197 | 200 | ||
198 | case 'o': | 201 | case 'o': |
@@ -203,6 +206,7 @@ int cmd_idle_info(int argc, char **argv) | |||
203 | cpuidle_cpu_output(cpu, verbose); | 206 | cpuidle_cpu_output(cpu, verbose); |
204 | break; | 207 | break; |
205 | } | 208 | } |
209 | printf("\n"); | ||
206 | } | 210 | } |
207 | return EXIT_SUCCESS; | 211 | return EXIT_SUCCESS; |
208 | } | 212 | } |
diff --git a/tools/power/cpupower/utils/cpupower-info.c b/tools/power/cpupower/utils/cpupower-info.c index 10299f2e9d2a..c7caa8eaa6d0 100644 --- a/tools/power/cpupower/utils/cpupower-info.c +++ b/tools/power/cpupower/utils/cpupower-info.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <getopt.h> | 13 | #include <getopt.h> |
14 | 14 | ||
15 | #include <cpufreq.h> | ||
16 | #include "helpers/helpers.h" | 15 | #include "helpers/helpers.h" |
17 | #include "helpers/sysfs.h" | 16 | #include "helpers/sysfs.h" |
18 | 17 | ||
@@ -83,12 +82,16 @@ int cmd_info(int argc, char **argv) | |||
83 | for (cpu = bitmask_first(cpus_chosen); | 82 | for (cpu = bitmask_first(cpus_chosen); |
84 | cpu <= bitmask_last(cpus_chosen); cpu++) { | 83 | cpu <= bitmask_last(cpus_chosen); cpu++) { |
85 | 84 | ||
86 | if (!bitmask_isbitset(cpus_chosen, cpu) || | 85 | if (!bitmask_isbitset(cpus_chosen, cpu)) |
87 | cpufreq_cpu_exists(cpu)) | ||
88 | continue; | 86 | continue; |
89 | 87 | ||
90 | printf(_("analyzing CPU %d:\n"), cpu); | 88 | printf(_("analyzing CPU %d:\n"), cpu); |
91 | 89 | ||
90 | if (sysfs_is_cpu_online(cpu) != 1){ | ||
91 | printf(_(" *is offline\n")); | ||
92 | continue; | ||
93 | } | ||
94 | |||
92 | if (params.perf_bias) { | 95 | if (params.perf_bias) { |
93 | ret = msr_intel_get_perf_bias(cpu); | 96 | ret = msr_intel_get_perf_bias(cpu); |
94 | if (ret < 0) { | 97 | if (ret < 0) { |
diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index 3e6f374f8dd7..532f46b9a335 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <getopt.h> | 13 | #include <getopt.h> |
14 | 14 | ||
15 | #include <cpufreq.h> | ||
16 | #include "helpers/helpers.h" | 15 | #include "helpers/helpers.h" |
17 | #include "helpers/sysfs.h" | 16 | #include "helpers/sysfs.h" |
18 | #include "helpers/bitmask.h" | 17 | #include "helpers/bitmask.h" |
@@ -78,10 +77,15 @@ int cmd_set(int argc, char **argv) | |||
78 | for (cpu = bitmask_first(cpus_chosen); | 77 | for (cpu = bitmask_first(cpus_chosen); |
79 | cpu <= bitmask_last(cpus_chosen); cpu++) { | 78 | cpu <= bitmask_last(cpus_chosen); cpu++) { |
80 | 79 | ||
81 | if (!bitmask_isbitset(cpus_chosen, cpu) || | 80 | if (!bitmask_isbitset(cpus_chosen, cpu)) |
82 | cpufreq_cpu_exists(cpu)) | ||
83 | continue; | 81 | continue; |
84 | 82 | ||
83 | if (sysfs_is_cpu_online(cpu) != 1){ | ||
84 | fprintf(stderr, _("Cannot set values on CPU %d:"), cpu); | ||
85 | fprintf(stderr, _(" *is offline\n")); | ||
86 | continue; | ||
87 | } | ||
88 | |||
85 | if (params.perf_bias) { | 89 | if (params.perf_bias) { |
86 | ret = msr_intel_set_perf_bias(cpu, perf_bias); | 90 | ret = msr_intel_set_perf_bias(cpu, perf_bias); |
87 | if (ret) { | 91 | if (ret) { |