Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH 0/1] cpupower: monitor: Show how a counter value is exported
@ 2026-08-18  9:55 Hemanth Selam
  2026-08-18  9:55 ` [PATCH 1/1] " Hemanth Selam
  0 siblings, 1 reply; 2+ messages in thread
From: Hemanth Selam @ 2026-08-18  9:55 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Hemanth Selam

Hi,

this picks up the ToDo in list_monitors() which asks to show more of the
capabilities of a counter.

"cpupower monitor -l" tells the name of a counter, the processor
hierarchy level it covers and its description, but it does not tell how
the value of the counter is exported. That is not obvious from the
description either: most counters are a percentage of the time spent in
a state, while for example the Mperf "Freq" counter reports MHz and the
RAPL zones report micro Joule. Without that information the numbers of
a measurement run are hard to interpret.

The value type is now printed behind the hierarchy level, using the
square bracket notation the hierarchy level already uses:

  [%]   The counter is a percentage of the time spent in the state.
  [abs] The counter is an absolute value, its unit depends on the
        counter, MHz for "Freq" or micro Joule for a RAPL zone.

The man page is updated in the same patch, right below the description
of the [T], [C], [P] and [M] hierarchy levels.

Note that "%" and "abs" are deliberately not single letters: [C] and
[P] are already taken by the Core and Package hierarchy levels, so
reusing them would render counters as "[P] [C]" or "[C] [P]", which
cannot be read unambiguously.

The second half of the ToDo, showing the time granularity of a counter,
is not implemented. There is no per state granularity information
today, only the per monitor overflow time which is already printed. It
would need a new cstate_t member every monitor has to fill in, so the
ToDo is kept, narrowed down to what is left to do.

Tested with the Mperf and Idle_Stats monitors:

  $ cpupower monitor -l
  Monitor "Mperf" (3 states) - Might overflow after 922000000 s
  C0	[T] [%] -> Processor Core not idle
  Cx	[T] [%] -> Processor Core in an idle state
  Freq	[T] [abs] -> Average Frequency (including boost) in MHz
  Monitor "Idle_Stats" (3 states) - Might overflow after 4294967295 s
  POLL	[T] [%] -> CPUIDLE CORE POLL IDLE
  C1	[T] [%] -> ACPI FFH MWAIT 0x0
  C2	[T] [%] -> ACPI IOPORT 0x814

Measurement runs, "cpupower monitor -i 1" and "cpupower monitor -m
Mperf -i 1", print the same output as before, only the listing changed.

Thanks,
Hemanth

Hemanth Selam (1):
  cpupower: monitor: Show how a counter value is exported

 tools/power/cpupower/man/cpupower-monitor.1   |  8 +++++++
 .../utils/idle_monitor/cpupower-monitor.c     | 22 ++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

-- 
2.43.7


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] cpupower: monitor: Show how a counter value is exported
  2026-08-18  9:55 [PATCH 0/1] cpupower: monitor: Show how a counter value is exported Hemanth Selam
@ 2026-08-18  9:55 ` Hemanth Selam
  0 siblings, 0 replies; 2+ messages in thread
From: Hemanth Selam @ 2026-08-18  9:55 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Hemanth Selam

"cpupower monitor -l" lists the name, the processor hierarchy level and
a description of every counter, but not how its value is exported. Some
counters are a percentage of the time spent in a state, others are
absolute values with their own unit, for example the Mperf "Freq"
counter reports MHz and the RAPL zones report micro Joule. Both cannot
be told apart from the listing.

Show the value type behind the hierarchy level and document it:

  [%]   The counter is a percentage of the time spent in the state.
  [abs] The counter is an absolute value, its unit depends on the
        counter, MHz for "Freq" or micro Joule for a RAPL zone.

Before:

  $ cpupower monitor -l
  Monitor "Mperf" (3 states) - Might overflow after 922000000 s
  C0	[T] -> Processor Core not idle
  Cx	[T] -> Processor Core in an idle state
  Freq	[T] -> Average Frequency (including boost) in MHz

After:

  $ cpupower monitor -l
  Monitor "Mperf" (3 states) - Might overflow after 922000000 s
  C0	[T] [%] -> Processor Core not idle
  Cx	[T] [%] -> Processor Core in an idle state
  Freq	[T] [abs] -> Average Frequency (including boost) in MHz

The time granularity part of the ToDo needs a new cstate_t member every
monitor has to fill in, keep it noted.

Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com>
---
 tools/power/cpupower/man/cpupower-monitor.1   |  8 +++++++
 .../utils/idle_monitor/cpupower-monitor.c     | 22 ++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/tools/power/cpupower/man/cpupower-monitor.1 b/tools/power/cpupower/man/cpupower-monitor.1
index 89af019f8dc4..c8008919627c 100644
--- a/tools/power/cpupower/man/cpupower-monitor.1
+++ b/tools/power/cpupower/man/cpupower-monitor.1
@@ -51,6 +51,14 @@ coverage in square brackets:
 .IP \(bu
 [M] \-> Machine/Platform wide counter
 .RE
+.IP \(bu
+How the counter is exported, in square brackets behind the hierarchy level:
+.RS 4
+.IP \(bu
+[%] \-> Percentage of the time spent in the state
+.IP \(bu
+[abs] \-> Absolute value, the unit depends on the counter
+.RE
 .RE
 .RE
 .PP
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index e8b3841d5c0f..376a1e30653a 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -269,6 +269,20 @@ static void parse_monitor_param(char *param)
 	avail_monitors = hits;
 }
 
+/*
+ * A monitor exports a counter either as a percentage of the time spent
+ * in the state or as an absolute value. Tell both apart, so that the
+ * numbers a measurement run prints can be interpreted.
+ */
+static const char *value_abbr(const cstate_t *state)
+{
+	if (state->get_count_percent)
+		return "%";
+	if (state->get_count)
+		return "abs";
+	return "?";
+}
+
 void list_monitors(void)
 {
 	unsigned int mon;
@@ -284,10 +298,12 @@ void list_monitors(void)
 		for (state = 0; state < monitors[mon]->hw_states_num; state++) {
 			s = monitors[mon]->hw_states[state];
 			/*
-			 * ToDo show more state capabilities:
-			 * percent, time (granlarity)
+			 * ToDo show the time granularity of a counter, this
+			 * needs a new cstate_t member every monitor has to
+			 * fill in.
 			 */
-			printf("%s\t[%c] -> %s\n", s.name, range_abbr[s.range],
+			printf("%s\t[%c] [%s] -> %s\n", s.name,
+			       range_abbr[s.range], value_abbr(&s),
 			       gettext(s.desc));
 		}
 	}
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-18  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18  9:55 [PATCH 0/1] cpupower: monitor: Show how a counter value is exported Hemanth Selam
2026-08-18  9:55 ` [PATCH 1/1] " Hemanth Selam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox