summaryrefslogtreecommitdiff
path: root/tools/power/cpupower/utils/cpupower.c
diff options
context:
space:
mode:
authorBrahadambal Srinivasan <latha@linux.vnet.ibm.com>2020-10-23 20:55:27 +0530
committerShuah Khan <skhan@linuxfoundation.org>2020-10-26 13:36:24 -0600
commit748f0d70087c56226bf1df1f91a00b7ab4c8f883 (patch)
tree8b9c94c478ebd88016e402cadb505a14fa9ca77d /tools/power/cpupower/utils/cpupower.c
parent3650b228f83adda7e5ee532e2b90429c03f7b9ec (diff)
downloadlwn-748f0d70087c56226bf1df1f91a00b7ab4c8f883.tar.gz
lwn-748f0d70087c56226bf1df1f91a00b7ab4c8f883.zip
cpupower: Provide online and offline CPU information
When a user tries to modify cpuidle or cpufreq properties on offline CPUs, the tool returns success (exit status 0) but also does not provide any warning message regarding offline cpus that may have been specified but left unchanged. In case of all or a few CPUs being offline, it can be difficult to keep track of which CPUs didn't get the new frequency or idle state set. Silent failures are difficult to keep track of when there are a huge number of CPUs on which the action is performed. This patch adds helper functions to find both online and offline CPUs and print them out accordingly. We use these helper functions in cpuidle-set and cpufreq-set to print an additional message if the user attempts to modify offline cpus. Reported-by: Pavithra R. Prakash <pavrampu@in.ibm.com> Signed-off-by: Brahadambal Srinivasan <latha@linux.vnet.ibm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/power/cpupower/utils/cpupower.c')
-rw-r--r--tools/power/cpupower/utils/cpupower.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
index 8e3d08042825..8ac3304a9957 100644
--- a/tools/power/cpupower/utils/cpupower.c
+++ b/tools/power/cpupower/utils/cpupower.c
@@ -34,6 +34,8 @@ int run_as_root;
int base_cpu;
/* Affected cpus chosen by -c/--cpu param */
struct bitmask *cpus_chosen;
+struct bitmask *online_cpus;
+struct bitmask *offline_cpus;
#ifdef DEBUG
int be_verbose;
@@ -178,6 +180,8 @@ int main(int argc, const char *argv[])
char pathname[32];
cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
+ online_cpus = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
+ offline_cpus = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
argc--;
argv += 1;
@@ -230,6 +234,10 @@ int main(int argc, const char *argv[])
ret = p->main(argc, argv);
if (cpus_chosen)
bitmask_free(cpus_chosen);
+ if (online_cpus)
+ bitmask_free(online_cpus);
+ if (offline_cpus)
+ bitmask_free(offline_cpus);
return ret;
}
print_help();