[GIT PULL] cpupower update for Linux 6.20-rc1
From: Shuah Khan
Date: Tue Jan 06 2026 - 19:08:58 EST
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(-)
----------------------------------------------------------------diff --git a/tools/power/cpupower/lib/cpuidle.c b/tools/power/cpupower/lib/cpuidle.c
index f2c1139adf71..2fcb343d8e75 100644
--- a/tools/power/cpupower/lib/cpuidle.c
+++ b/tools/power/cpupower/lib/cpuidle.c
@@ -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;
}
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
index 7d3732f5f2f6..5fe01e516817 100644
--- a/tools/power/cpupower/utils/cpufreq-info.c
+++ b/tools/power/cpupower/utils/cpufreq-info.c
@@ -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);
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index e0d17f0de3fe..81b4763a97d6 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -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[--] "));
diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
index 8b42c2f0a5b0..4225eff9833d 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
@@ -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;