Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpupower : Handle set and info subcommands correctly

Cpupower tool has set and info options which are being used only by
x86 machines. This patch removes support for these two subcommands
from cpupower utility for POWER. Thus, these two subcommands will now be
available only for intel.
This removes the ambiguous error message while using set option in case
of using non-intel systems.

Without this patch on a POWER system:

root@ubuntu:~# cpupower info
System does not support Intel's performance bias setting

root@ubuntu:~# cpupower set -b 10
Error setting perf-bias value on CPU

With this patch on a POWER box:

root@ubuntu:~# cpupower info
Subcommand not supported on POWER

Same result for set subcommand.
This patch does not affect results on a intel box.

Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Abhishek Goel and committed by
Shuah Khan
d80a4ac2 7e5705c6

+18
+9
tools/power/cpupower/utils/cpupower-info.c
··· 10 10 #include <errno.h> 11 11 #include <string.h> 12 12 #include <getopt.h> 13 + #include <sys/utsname.h> 13 14 14 15 #include "helpers/helpers.h" 15 16 #include "helpers/sysfs.h" ··· 31 30 extern char *optarg; 32 31 extern int optind, opterr, optopt; 33 32 unsigned int cpu; 33 + struct utsname uts; 34 34 35 35 union { 36 36 struct { ··· 40 38 int params; 41 39 } params = {}; 42 40 int ret = 0; 41 + 42 + ret = uname(&uts); 43 + if (!ret && (!strcmp(uts.machine, "ppc64le") || 44 + !strcmp(uts.machine, "ppc64"))) { 45 + fprintf(stderr, _("Subcommand not supported on POWER.\n")); 46 + return ret; 47 + } 43 48 44 49 setlocale(LC_ALL, ""); 45 50 textdomain(PACKAGE);
+9
tools/power/cpupower/utils/cpupower-set.c
··· 10 10 #include <errno.h> 11 11 #include <string.h> 12 12 #include <getopt.h> 13 + #include <sys/utsname.h> 13 14 14 15 #include "helpers/helpers.h" 15 16 #include "helpers/sysfs.h" ··· 32 31 extern char *optarg; 33 32 extern int optind, opterr, optopt; 34 33 unsigned int cpu; 34 + struct utsname uts; 35 35 36 36 union { 37 37 struct { ··· 42 40 } params; 43 41 int perf_bias = 0; 44 42 int ret = 0; 43 + 44 + ret = uname(&uts); 45 + if (!ret && (!strcmp(uts.machine, "ppc64le") || 46 + !strcmp(uts.machine, "ppc64"))) { 47 + fprintf(stderr, _("Subcommand not supported on POWER.\n")); 48 + return ret; 49 + } 45 50 46 51 setlocale(LC_ALL, ""); 47 52 textdomain(PACKAGE);