Skip to content

Commit d80a4ac

Browse files
Abhishek Goelshuahkh
authored andcommitted
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 <[email protected]> Acked-by: Thomas Renninger <[email protected]> Reviewed-by: Shuah Khan <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 7e5705c commit d80a4ac

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tools/power/cpupower/utils/cpupower-info.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <errno.h>
1111
#include <string.h>
1212
#include <getopt.h>
13+
#include <sys/utsname.h>
1314

1415
#include "helpers/helpers.h"
1516
#include "helpers/sysfs.h"
@@ -30,6 +31,7 @@ int cmd_info(int argc, char **argv)
3031
extern char *optarg;
3132
extern int optind, opterr, optopt;
3233
unsigned int cpu;
34+
struct utsname uts;
3335

3436
union {
3537
struct {
@@ -39,6 +41,13 @@ int cmd_info(int argc, char **argv)
3941
} params = {};
4042
int ret = 0;
4143

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+
}
50+
4251
setlocale(LC_ALL, "");
4352
textdomain(PACKAGE);
4453

tools/power/cpupower/utils/cpupower-set.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <errno.h>
1111
#include <string.h>
1212
#include <getopt.h>
13+
#include <sys/utsname.h>
1314

1415
#include "helpers/helpers.h"
1516
#include "helpers/sysfs.h"
@@ -31,6 +32,7 @@ int cmd_set(int argc, char **argv)
3132
extern char *optarg;
3233
extern int optind, opterr, optopt;
3334
unsigned int cpu;
35+
struct utsname uts;
3436

3537
union {
3638
struct {
@@ -41,6 +43,13 @@ int cmd_set(int argc, char **argv)
4143
int perf_bias = 0;
4244
int ret = 0;
4345

46+
ret = uname(&uts);
47+
if (!ret && (!strcmp(uts.machine, "ppc64le") ||
48+
!strcmp(uts.machine, "ppc64"))) {
49+
fprintf(stderr, _("Subcommand not supported on POWER.\n"));
50+
return ret;
51+
}
52+
4453
setlocale(LC_ALL, "");
4554
textdomain(PACKAGE);
4655

0 commit comments

Comments
 (0)