summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJacob Tanenbaum <jtanenba@redhat.com>2015-10-22 11:17:05 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-11-01 20:28:59 -0500
commit20102ac5bee3c7c1ffff43f220e37328b6fffd16 (patch)
tree811e4750b4ae16145cd7b103cdaf1f2a18c21a4f /tools
parent32b88194f71d6ae7768a29f87fbba454728273ee (diff)
cpupower: cpupower monitor reports uninitialized values for offline cpus
[root@hp-dl980g7-02 linux]# cpupower monitor ... 5472| 0| 1|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 10567| 0| 159|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 1661206560|859272560| 150|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 1661206560|943093104| 140|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline because of this cpupower also holds the incorrect value for the number of physical packages in the machine Changed cpupower to initialize the values of an offline cpu's socket and core to -1, warn the user that one or more cpus is/are offline and not print statistics for offline cpus. This fix hides offlined cores where topology cannot be accessed. With a recent kernel patch suggested from Prarit Bhargava it may be possible that soft offlined cores' topology can still be parsed. This patch would then show which cores in which package/socket are offline, when sane toplogoy information is available. Signed-off-by: Jacob Tanenbaum <jtanenba@redhat.com> Signed-off-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/cpupower/utils/helpers/topology.c23
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c9
2 files changed, 23 insertions, 9 deletions
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
index cea398c176e7..9cbb7fd75171 100644
--- a/tools/power/cpupower/utils/helpers/topology.c
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
73 for (cpu = 0; cpu < cpus; cpu++) { 73 for (cpu = 0; cpu < cpus; cpu++) {
74 cpu_top->core_info[cpu].cpu = cpu; 74 cpu_top->core_info[cpu].cpu = cpu;
75 cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu); 75 cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
76 if (!cpu_top->core_info[cpu].is_online)
77 continue;
78 if(sysfs_topology_read_file( 76 if(sysfs_topology_read_file(
79 cpu, 77 cpu,
80 "physical_package_id", 78 "physical_package_id",
81 &(cpu_top->core_info[cpu].pkg)) < 0) 79 &(cpu_top->core_info[cpu].pkg)) < 0) {
82 return -1; 80 cpu_top->core_info[cpu].pkg = -1;
81 cpu_top->core_info[cpu].core = -1;
82 continue;
83 }
83 if(sysfs_topology_read_file( 84 if(sysfs_topology_read_file(
84 cpu, 85 cpu,
85 "core_id", 86 "core_id",
86 &(cpu_top->core_info[cpu].core)) < 0) 87 &(cpu_top->core_info[cpu].core)) < 0) {
87 return -1; 88 cpu_top->core_info[cpu].pkg = -1;
89 cpu_top->core_info[cpu].core = -1;
90 continue;
91 }
88 } 92 }
89 93
90 qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info), 94 qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
@@ -95,12 +99,15 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
95 done by pkg value. */ 99 done by pkg value. */
96 last_pkg = cpu_top->core_info[0].pkg; 100 last_pkg = cpu_top->core_info[0].pkg;
97 for(cpu = 1; cpu < cpus; cpu++) { 101 for(cpu = 1; cpu < cpus; cpu++) {
98 if(cpu_top->core_info[cpu].pkg != last_pkg) { 102 if (cpu_top->core_info[cpu].pkg != last_pkg &&
103 cpu_top->core_info[cpu].pkg != -1) {
104
99 last_pkg = cpu_top->core_info[cpu].pkg; 105 last_pkg = cpu_top->core_info[cpu].pkg;
100 cpu_top->pkgs++; 106 cpu_top->pkgs++;
101 } 107 }
102 } 108 }
103 cpu_top->pkgs++; 109 if (!cpu_top->core_info[0].pkg == -1)
110 cpu_top->pkgs++;
104 111
105 /* Intel's cores count is not consecutively numbered, there may 112 /* Intel's cores count is not consecutively numbered, there may
106 * be a core_id of 3, but none of 2. Assume there always is 0 113 * be a core_id of 3, but none of 2. Assume there always is 0
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index c4bae9203a69..05f953f0f0a0 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -143,6 +143,9 @@ void print_results(int topology_depth, int cpu)
143 /* Be careful CPUs may got resorted for pkg value do not just use cpu */ 143 /* Be careful CPUs may got resorted for pkg value do not just use cpu */
144 if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu)) 144 if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))
145 return; 145 return;
146 if (!cpu_top.core_info[cpu].is_online &&
147 cpu_top.core_info[cpu].pkg == -1)
148 return;
146 149
147 if (topology_depth > 2) 150 if (topology_depth > 2)
148 printf("%4d|", cpu_top.core_info[cpu].pkg); 151 printf("%4d|", cpu_top.core_info[cpu].pkg);
@@ -191,7 +194,8 @@ void print_results(int topology_depth, int cpu)
191 * It's up to the monitor plug-in to check .is_online, this one 194 * It's up to the monitor plug-in to check .is_online, this one
192 * is just for additional info. 195 * is just for additional info.
193 */ 196 */
194 if (!cpu_top.core_info[cpu].is_online) { 197 if (!cpu_top.core_info[cpu].is_online &&
198 cpu_top.core_info[cpu].pkg != -1) {
195 printf(_(" *is offline\n")); 199 printf(_(" *is offline\n"));
196 return; 200 return;
197 } else 201 } else
@@ -388,6 +392,9 @@ int cmd_monitor(int argc, char **argv)
388 return EXIT_FAILURE; 392 return EXIT_FAILURE;
389 } 393 }
390 394
395 if (!cpu_top.core_info[0].is_online)
396 printf("WARNING: at least one cpu is offline\n");
397
391 /* Default is: monitor all CPUs */ 398 /* Default is: monitor all CPUs */
392 if (bitmask_isallclear(cpus_chosen)) 399 if (bitmask_isallclear(cpus_chosen))
393 bitmask_setall(cpus_chosen); 400 bitmask_setall(cpus_chosen);