Skip to contentSkip to conversation

cpupower : Handle set and info subcommands for powerpc

PATCH shuah 3 participants 6 messages Sep 11, 2019 – Sep 12, 2019 1 message not in the archive

lore
Share & tools
lore

shuah

author
#1 lore raw
In reply to a message not in the archive
Quoted 4 lines · Abhishek Goel

Cpupower tool has set and info options which are not being used by POWER machines. For powerpc, we will return directly for these two subcommands. This removes the ambiguous error message while using set option in case of power systems.

What is the error message you see? Please include it in the commit log.

Quoted 12 lines
---
  tools/power/cpupower/utils/cpupower-info.c | 5 +++++
  tools/power/cpupower/utils/cpupower-set.c  | 5 +++++
  2 files changed, 10 insertions(+)
tools/power/cpupower/utils/cpupower-info.c +0 -0
index 4c9d342b70ff..674b707a76af 100644

tools/power/cpupower/utils/cpupower-info.c int cmd_info(int argc, char **argv) · line 46

Quoted 8 lines
tools/power/cpupower/utils/cpupower-info.c +5 -0
@@ -39,6 +39,11 @@ int cmd_info(int argc, char **argv)
  	} params = {};
  	int ret = 0;
 
+	#ifdef __powerpc__
+	printf(_("Cannot read info as system does not support performance bias setting\n"));
+	return 0;
+	#endif
+

I am not in favor of bailing out this early with this ifdef switch. I would rather see this checked somehow(?) when the ambiguous error happens.

Quoted 8 lines
tools/power/cpupower/utils/cpupower-info.c +0 -0
  	setlocale(LC_ALL, "");
  	textdomain(PACKAGE);
 
tools/power/cpupower/utils/cpupower-set.c +0 -0
index 3cd95c6cb974..c95b29278780 100644

tools/power/cpupower/utils/cpupower-set.c int cmd_set(int argc, char **argv) · line 48

Quoted 8 lines
tools/power/cpupower/utils/cpupower-set.c +5 -0
@@ -41,6 +41,11 @@ int cmd_set(int argc, char **argv)
  	int perf_bias = 0;
  	int ret = 0;
 
+	#ifdef __powerpc__
+	printf(_("System does not support performance bias setting\n"));
+	return 0;
+	#endif
+

Same here.

tools/power/cpupower/utils/cpupower-set.c int cmd_set(int argc, char **argv) · line 51

Quoted 4 lines
tools/power/cpupower/utils/cpupower-set.c +0 -0
  	setlocale(LC_ALL, "");
  	textdomain(PACKAGE);
 

thanks,
-- Shuah

#2 lore raw

Hi Shuah,

Thanks for the review. Few comments below.

Quoted 8 lines · shuah
Quoted 4 lines · Abhishek Goel

Cpupower tool has set and info options which are not being used by POWER machines. For powerpc, we will return directly for these two subcommands. This removes the ambiguous error message while using set option in case of power systems.

What is the error message you see? Please include it in the commit log.

Sure. Will include it in next version.

Quoted 7 lines
Quoted 7 lines

---
  tools/power/cpupower/utils/cpupower-info.c | 5 +++++ tools/power/cpupower/utils/cpupower-set.c  | 5 +++++

  2 files changed, 10 insertions(+)
Quoted 14 lines
Quoted 7 lines
tools/power/cpupower/utils/cpupower-info.c +0 -0
index 4c9d342b70ff..674b707a76af 100644
@@ -39,6 +39,11 @@ int cmd_info(int argc, char **argv)
       } params = {};
       int ret = 0;
Quoted 6 lines

  +    #ifdef __powerpc__
+    printf(_("Cannot read info as system does not support performance bias setting\n"));
+    return 0;
+    #endif
+

We see something like this for "cpupower info" ---> "System does not support Intel's performance bias setting"

Quoted 3 lines

I am not in favor of bailing out this early with this ifdef switch. I would rather see this checked somehow(?) when the ambiguous error happens.

Since these two options are not being used by any other architecture except x86, I suggest these options should not even be shown for other architecture. So we can do something like this in cpupower.c :

static struct cmd_struct commands[] = {
         .............
+#if defined (__x86_64__) || defined (__i386__)
        { "set",        cmd_set,        1    },
        { "info",        cmd_info,        0    },
+#endif
        ..............

Is this Okay?

Quoted 18 lines
Quoted 10 lines

      setlocale(LC_ALL, "");
      textdomain(PACKAGE);
  diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index 3cd95c6cb974..c95b29278780 100644

tools/power/cpupower/utils/cpupower-set.c +0 -0
@@ -41,6 +41,11 @@ int cmd_set(int argc, char **argv)
       int perf_bias = 0;
       int ret = 0;
Quoted 5 lines

  +    #ifdef __powerpc__
+    printf(_("System does not support performance bias setting\n")); +    return 0;
+    #endif
+

Same here.

For "cpupower set -b 10", we get something like :
"Error setting perf-bias value on CPU"

Quoted 6 lines
Quoted 3 lines

      setlocale(LC_ALL, "");
      textdomain(PACKAGE);

thanks,
-- Shuah

Thanks,
-- Abhishek

#5 lore raw
In reply to a message not in the archive

Hi Abishek,

Quoted 17 lines · CEST Abhishek Goel

Cpupower tool has set and info options which are not being used by POWER machines. For powerpc, we will return directly for these two subcommands. This removes the ambiguous error message while using set option in case of power systems.

---
 tools/power/cpupower/utils/cpupower-info.c | 5 +++++
 tools/power/cpupower/utils/cpupower-set.c  | 5 +++++
 2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/tools/power/cpupower/utils/cpupower-info.c index 4c9d342b70ff..674b707a76af 100644

tools/power/cpupower/utils/cpupower-info.c int cmd_info(int argc, char **argv) · line 46

Quoted 8 lines
tools/power/cpupower/utils/cpupower-info.c +4 -0
@@ -39,6 +39,11 @@ int cmd_info(int argc, char **argv)
 	} params = {};
 	int ret = 0;
 
+	#ifdef __powerpc__
+	printf(_("Cannot read info as system does not support performance bias
 setting\n")); +	return 0;
+	#endif
+

Please do no do this.

cpupower info
is designed to show general information related to powersaving features of your CPU.

For examle there has been (see changelog):
cpupower: Remove mc and smt power aware scheduler info/settings These kernel interfaces got removed by:

Unfortunately only -b (perf bias on Intel only) is left right now.

So if you cut this out for Power you do not see anything and the cmd is useless. Which is a pity, but for now makes sense.
Ideally you provide some tag/option which makes sense on power (e.g. whether run in OPAL mode and if provide some figures otherwise tell running in VM mode).

But if this is cut out something like this should do the same and is more flexible:
- Still allows additional cpupower info features for other CPUs later easily
- Should also cover AMD or other non-perf bias supporting CPUs to exclude perf_bias setting/info

If this one works for you, can you please re-submit with also handling the set cmd similar. If it works or you only slightly adjust, feel free to already add:

Thanks!

Thomas

power/cpupower/utils/cpupower-info.c renamed from power/cpupower/utils/cpupower-info.c.orig +4 -1
@@ -55,8 +55,11 @@
 		}
 	};
 
-	if (!params.params)
+	if (!params.params) {
 		params.params = 0x7;
+		if !(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS)
+			params.perf_bias = 0;
+	}
 
 	/* Default is: show output of CPU 0 only */
 	if (bitmask_isallclear(cpus_chosen))
#3 lore raw
In reply to Abhishek
Quoted 3 lines · CEST Abhishek

Hi Shuah,

Thanks for the review. Few comments below.

...

Quoted 12 lines

Since these two options are not being used by any other architecture except x86, I suggest these options should not even be shown for other architecture. So we can do something like this in cpupower.c :

static struct cmd_struct commands[] = {
          .............
(quoted diff) +2 -0
+#if defined (__x86_64__) || defined (__i386__)
         { "set",        cmd_set,        1    },
         { "info",        cmd_info,        0    },
+#endif
..............
Quoted 1 line

Is this Okay?

No, I expected you to add something meaningful for Power case...

Just kidding. If this works without any side-effects in not x86 case, this approach seem to be the best solution for now.

Thanks.

Thomas

#6 lore raw
In reply to Thomas Renninger

Hi Thomas,

Thanks for the review.

Quoted 39 lines · Thomas Renninger

Hi Abishek,

Quoted 17 lines · CEST Abhishek Goel

Cpupower tool has set and info options which are not being used by POWER machines. For powerpc, we will return directly for these two subcommands. This removes the ambiguous error message while using set option in case of power systems.

---
  tools/power/cpupower/utils/cpupower-info.c | 5 +++++
  tools/power/cpupower/utils/cpupower-set.c  | 5 +++++
  2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/tools/power/cpupower/utils/cpupower-info.c index 4c9d342b70ff..674b707a76af 100644

tools/power/cpupower/utils/cpupower-info.c int cmd_info(int argc, char **argv) · line 46

Quoted 8 lines
tools/power/cpupower/utils/cpupower-info.c +4 -0
@@ -39,6 +39,11 @@ int cmd_info(int argc, char **argv)
  	} params = {};
  	int ret = 0;
 
+	#ifdef __powerpc__
+	printf(_("Cannot read info as system does not support performance bias
 setting\n")); +	return 0;
+	#endif
+

Please do no do this.

cpupower info
is designed to show general information related to powersaving features of your CPU.

For examle there has been (see changelog):
cpupower: Remove mc and smt power aware scheduler info/settings These kernel interfaces got removed by:

Unfortunately only -b (perf bias on Intel only) is left right now.

Quoted 8 lines

So if you cut this out for Power you do not see anything and the cmd is useless. Which is a pity, but for now makes sense.
Ideally you provide some tag/option which makes sense on power (e.g. whether run in OPAL mode and if provide some figures otherwise tell running in VM mode). But if this is cut out something like this should do the same and is more flexible:
- Still allows additional cpupower info features for other CPUs later easily
- Should also cover AMD or other non-perf bias supporting CPUs to exclude perf_bias setting/info

As I have suggested in here : https://lkml.org/lkml/2019/9/12/159
We should cut out these two options as of now for other architecture except x86, since the current implementation of both these subcommands are very intel specific.
As you have already suggested, we can later on maybe change the documentation of info to be architecture specific and use info based on arch requirement.

Quoted 4 lines

If this one works for you, can you please re-submit with also handling the set cmd similar. If it works or you only slightly adjust, feel free to already add:

Yeah. Sure.

Quoted 12 lines

Thanks!

Thomas

power/cpupower/utils/cpupower-info.c renamed from power/cpupower/utils/cpupower-info.c.orig +0 -0
@@ -55,8 +55,11 @@
  		}
  	};

power/cpupower/utils/cpupower-info.c line 65

Quoted 10 lines
power/cpupower/utils/cpupower-info.c renamed from power/cpupower/utils/cpupower-info.c.orig +4 -1
 
-	if (!params.params)
+	if (!params.params) {
  		params.params = 0x7;
+		if !(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS)
+			params.perf_bias = 0;
+	}
 
  	/* Default is: show output of CPU 0 only */
  	if (bitmask_isallclear(cpus_chosen))

-- Abhishek

#4 lore raw
In reply to Thomas Renninger

Hi,

Quoted 18 lines · Thomas Renninger
Quoted 3 lines · CEST Abhishek

Hi Shuah,

Thanks for the review. Few comments below.

...

Quoted 12 lines

Since these two options are not being used by any other architecture except x86, I suggest these options should not even be shown for other architecture. So we can do something like this in cpupower.c :

static struct cmd_struct commands[] = {
           .............
(quoted diff) +2 -0
+#if defined (__x86_64__) || defined (__i386__)
          { "set",        cmd_set,        1    },
          { "info",        cmd_info,        0    },
+#endif
..............
Quoted 2 lines
Quoted 1 line

Is this Okay?

No, I expected you to add something meaningful for Power case...

Haha. Will add something meaningful later... (One of the suggestion has already been given by you)

Quoted 9 lines

Just kidding. If this works without any side-effects in not x86 case, this approach seem to be the best solution for now.

Thanks.

Thomas

-- Abhishek