Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v2] cpupower: monitor: Show how a counter value is exported
@ 2026-09-07 12:07 Hemanth Selam
  0 siblings, 0 replies; only message in thread
From: Hemanth Selam @ 2026-09-07 12:07 UTC (permalink / raw)
  To: Shuah Khan, Thomas Renninger
  Cc: Shuah Khan, John B. Wyatt IV, John Kacur, linux-pm, linux-kernel

"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 check mirrors the one print_results() already makes when it decides
how to read a counter, so no new helper is needed.

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

Assisted-by: Cursor:claude-opus-5
Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com>
---

Notes:
    Changes since v1:
     - drop the value_abbr() helper and check s.get_count_percent inline at
       the printf, as Shuah Khan asked; it matches what print_results()
       already does a few lines above

 tools/power/cpupower/man/cpupower-monitor.1              | 8 ++++++++
 .../power/cpupower/utils/idle_monitor/cpupower-monitor.c | 9 ++++++---
 2 files changed, 14 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..df00e82eb820 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -284,10 +284,13 @@ 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],
+			       s.get_count_percent ? "%" : "abs",
 			       gettext(s.desc));
 		}
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-07 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07 12:07 [PATCH v2] cpupower: monitor: Show how a counter value is exported Hemanth Selam

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