Commit ce512b84 authored by Thomas Renninger's avatar Thomas Renninger Committed by Rafael J. Wysocki

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: default avatarThomas Renninger <trenn@suse.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e51207f0
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <getopt.h> #include <getopt.h>
#include "cpufreq.h" #include "cpufreq.h"
#include "helpers/sysfs.h"
#include "helpers/helpers.h" #include "helpers/helpers.h"
#include "helpers/bitmask.h" #include "helpers/bitmask.h"
...@@ -647,11 +648,14 @@ int cmd_freq_info(int argc, char **argv) ...@@ -647,11 +648,14 @@ int cmd_freq_info(int argc, char **argv)
if (!bitmask_isbitset(cpus_chosen, cpu)) if (!bitmask_isbitset(cpus_chosen, cpu))
continue; continue;
if (cpufreq_cpu_exists(cpu)) {
printf(_("couldn't analyze CPU %d as it doesn't seem to be present\n"), cpu); printf(_("analyzing CPU %d:\n"), cpu);
if (sysfs_is_cpu_online(cpu) != 1) {
printf(_(" *is offline\n"));
printf("\n");
continue; continue;
} }
printf(_("analyzing CPU %d:\n"), cpu);
switch (output_param) { switch (output_param) {
case 'b': case 'b':
...@@ -693,6 +697,7 @@ int cmd_freq_info(int argc, char **argv) ...@@ -693,6 +697,7 @@ int cmd_freq_info(int argc, char **argv)
} }
if (ret) if (ret)
return ret; return ret;
printf("\n");
} }
return ret; return ret;
} }
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <getopt.h> #include <getopt.h>
#include <cpufreq.h>
#include "helpers/helpers.h" #include "helpers/helpers.h"
#include "helpers/sysfs.h" #include "helpers/sysfs.h"
...@@ -25,8 +24,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) ...@@ -25,8 +24,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
unsigned int idlestates, idlestate; unsigned int idlestates, idlestate;
char *tmp; char *tmp;
printf(_ ("Analyzing CPU %d:\n"), cpu);
idlestates = sysfs_get_idlestate_count(cpu); idlestates = sysfs_get_idlestate_count(cpu);
if (idlestates == 0) { if (idlestates == 0) {
printf(_("CPU %u: No idle states\n"), cpu); printf(_("CPU %u: No idle states\n"), cpu);
...@@ -71,7 +68,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) ...@@ -71,7 +68,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
printf(_("Duration: %llu\n"), printf(_("Duration: %llu\n"),
sysfs_get_idlestate_time(cpu, idlestate)); sysfs_get_idlestate_time(cpu, idlestate));
} }
printf("\n");
} }
static void cpuidle_general_output(void) static void cpuidle_general_output(void)
...@@ -189,9 +185,16 @@ int cmd_idle_info(int argc, char **argv) ...@@ -189,9 +185,16 @@ int cmd_idle_info(int argc, char **argv)
for (cpu = bitmask_first(cpus_chosen); for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) { cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) || if (!bitmask_isbitset(cpus_chosen, cpu))
cpufreq_cpu_exists(cpu)) continue;
printf(_("analyzing CPU %d:\n"), cpu);
if (sysfs_is_cpu_online(cpu) != 1) {
printf(_(" *is offline\n"));
printf("\n");
continue; continue;
}
switch (output_param) { switch (output_param) {
...@@ -203,6 +206,7 @@ int cmd_idle_info(int argc, char **argv) ...@@ -203,6 +206,7 @@ int cmd_idle_info(int argc, char **argv)
cpuidle_cpu_output(cpu, verbose); cpuidle_cpu_output(cpu, verbose);
break; break;
} }
printf("\n");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <string.h> #include <string.h>
#include <getopt.h> #include <getopt.h>
#include <cpufreq.h>
#include "helpers/helpers.h" #include "helpers/helpers.h"
#include "helpers/sysfs.h" #include "helpers/sysfs.h"
...@@ -83,12 +82,16 @@ int cmd_info(int argc, char **argv) ...@@ -83,12 +82,16 @@ int cmd_info(int argc, char **argv)
for (cpu = bitmask_first(cpus_chosen); for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) { cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) || if (!bitmask_isbitset(cpus_chosen, cpu))
cpufreq_cpu_exists(cpu))
continue; continue;
printf(_("analyzing CPU %d:\n"), cpu); printf(_("analyzing CPU %d:\n"), cpu);
if (sysfs_is_cpu_online(cpu) != 1){
printf(_(" *is offline\n"));
continue;
}
if (params.perf_bias) { if (params.perf_bias) {
ret = msr_intel_get_perf_bias(cpu); ret = msr_intel_get_perf_bias(cpu);
if (ret < 0) { if (ret < 0) {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <string.h> #include <string.h>
#include <getopt.h> #include <getopt.h>
#include <cpufreq.h>
#include "helpers/helpers.h" #include "helpers/helpers.h"
#include "helpers/sysfs.h" #include "helpers/sysfs.h"
#include "helpers/bitmask.h" #include "helpers/bitmask.h"
...@@ -78,10 +77,15 @@ int cmd_set(int argc, char **argv) ...@@ -78,10 +77,15 @@ int cmd_set(int argc, char **argv)
for (cpu = bitmask_first(cpus_chosen); for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) { cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) || if (!bitmask_isbitset(cpus_chosen, cpu))
cpufreq_cpu_exists(cpu))
continue; continue;
if (sysfs_is_cpu_online(cpu) != 1){
fprintf(stderr, _("Cannot set values on CPU %d:"), cpu);
fprintf(stderr, _(" *is offline\n"));
continue;
}
if (params.perf_bias) { if (params.perf_bias) {
ret = msr_intel_set_perf_bias(cpu, perf_bias); ret = msr_intel_set_perf_bias(cpu, perf_bias);
if (ret) { if (ret) {
......
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