Skip to contentSkip to conversation

cpupower update for Linux 6.20-rc1

GIT PULL Shuah Khan 2 participants 2 messages Jan 7 CPU power monitoring

lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

Hi Rafael,

Please pull the following cpupower update for Linux 6.20-rc1.

Fixes to miscellaneous problems in cpupower tool:

- idle_monitor: fix incorrect value logged after stop
- Fix inverted APERF capability check
- Use strcspn() to strip trailing newline
- Reset errno before strtoull()
- Show C0 in idle-info dump

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit 8f0b4cce4481fb22653697cced8d0d04027cb1e8:

Linux 6.19-rc1 (2025-12-14 16:05:07 +1200)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux tags/linux-cpupower-6.20-rc1

for you to fetch changes up to ff72619e11348ab189e232c59515dd5c33780d7c:

tools/power cpupower: Show C0 in idle-info dump (2025-12-15 12:33:29 -0700)

----------------------------------------------------------------
cpupower update for Linux 6.20-rc1

Fixes to miscellaneous problems in cpupower tool:

- idle_monitor: fix incorrect value logged after stop
- Fix inverted APERF capability check
- Use strcspn() to strip trailing newline
- Reset errno before strtoull()
- Show C0 in idle-info dump

----------------------------------------------------------------
Kaushlendra Kumar (5):
cpupower: idle_monitor: fix incorrect value logged after stop tools/cpupower: Fix inverted APERF capability check tools/cpupower: Use strcspn() to strip trailing newline tools/power cpupower: Reset errno before strtoull() tools/power cpupower: Show C0 in idle-info dump

 tools/power/cpupower/lib/cpuidle.c                      | 7 +++----
 tools/power/cpupower/utils/cpufreq-info.c               | 2 +-
 tools/power/cpupower/utils/cpuidle-info.c               | 2 +-
 tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

----------------------------------------------------------------

tools/power/cpupower/lib/cpuidle.c +3 -4
index f2c1139adf71..2fcb343d8e75 100644
@@ -150,6 +150,7 @@ unsigned long long cpuidle_state_get_one_value(unsigned int cpu,
 	if (len == 0)
 		return 0;
 
+	errno = 0;
 	value = strtoull(linebuf, &endp, 0);
 
 	if (endp == linebuf || errno == ERANGE)
@@ -193,8 +194,7 @@ static char *cpuidle_state_get_one_string(unsigned int cpu,
 	if (result == NULL)
 		return NULL;
 
-	if (result[strlen(result) - 1] == '\n')
-		result[strlen(result) - 1] = '\0';
+	result[strcspn(result, "\n")] = '\0';
 
 	return result;
 }
@@ -366,8 +366,7 @@ static char *sysfs_cpuidle_get_one_string(enum cpuidle_string which)
 	if (result == NULL)
 		return NULL;
 
-	if (result[strlen(result) - 1] == '\n')
-		result[strlen(result) - 1] = '\0';
+	result[strcspn(result, "\n")] = '\0';
 
 	return result;
 }
tools/power/cpupower/utils/cpufreq-info.c +1 -1
index 7d3732f5f2f6..5fe01e516817 100644
@@ -270,7 +270,7 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
 {
 	unsigned long freq;
 
-	if (cpupower_cpu_info.caps & CPUPOWER_CAP_APERF)
+	if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
 		return -EINVAL;
 
 	freq = cpufreq_get_freq_hardware(cpu);
tools/power/cpupower/utils/cpuidle-info.c +1 -1
index e0d17f0de3fe..81b4763a97d6 100644
@@ -111,7 +111,7 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
 	printf(_("max_cstate:              C%u\n"), cstates-1);
 	printf(_("maximum allowed latency: %lu usec\n"), max_allowed_cstate);
 	printf(_("states:\t\n"));
-	for (cstate = 1; cstate < cstates; cstate++) {
+	for (cstate = 0; cstate < cstates; cstate++) {
 		printf(_("    C%d:                  "
 			 "type[C%d] "), cstate, cstate);
 		printf(_("promotion[--] demotion[--] "));
tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c +1 -1
index 8b42c2f0a5b0..4225eff9833d 100644
@@ -70,7 +70,7 @@ static int cpuidle_stop(void)
 			current_count[cpu][state] =
 				cpuidle_state_time(cpu, state);
 			dprint("CPU %d - State: %d - Val: %llu\n",
-			       cpu, state, previous_count[cpu][state]);
+			       cpu, state, current_count[cpu][state]);
 		}
 	}
 	return 0;
#1 lore raw

Hi Shuah,

Quoted 50 lines · Shuah Khan

Hi Rafael,

Please pull the following cpupower update for Linux 6.20-rc1.

Fixes to miscellaneous problems in cpupower tool:

- idle_monitor: fix incorrect value logged after stop
- Fix inverted APERF capability check
- Use strcspn() to strip trailing newline
- Reset errno before strtoull()
- Show C0 in idle-info dump

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit 8f0b4cce4481fb22653697cced8d0d04027cb1e8:

   Linux 6.19-rc1 (2025-12-14 16:05:07 +1200)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux tags/linux-cpupower-6.20-rc1

for you to fetch changes up to ff72619e11348ab189e232c59515dd5c33780d7c:

   tools/power cpupower: Show C0 in idle-info dump (2025-12-15 12:33:29 -0700)

----------------------------------------------------------------
cpupower update for Linux 6.20-rc1

Fixes to miscellaneous problems in cpupower tool:

- idle_monitor: fix incorrect value logged after stop
- Fix inverted APERF capability check
- Use strcspn() to strip trailing newline
- Reset errno before strtoull()
- Show C0 in idle-info dump

----------------------------------------------------------------
Kaushlendra Kumar (5):
cpupower: idle_monitor: fix incorrect value logged after stop tools/cpupower: Fix inverted APERF capability check tools/cpupower: Use strcspn() to strip trailing newline tools/power cpupower: Reset errno before strtoull() tools/power cpupower: Show C0 in idle-info dump

Quoted 6 lines
  tools/power/cpupower/lib/cpuidle.c                      | 7 +++----
  tools/power/cpupower/utils/cpufreq-info.c               | 2 +-
  tools/power/cpupower/utils/cpuidle-info.c               | 2 +-
  tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 2 +-
  4 files changed, 6 insertions(+), 7 deletions(-)

----------------------------------------------------------------

Pulled and added to linux-pm.git/linux-next, thanks!