Skip to content

Commit 2064fe4

Browse files
committed
Merge tag 'linux-cpupower-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux
Pull a cpupower utility update for Linux 6.20-rc1 from Shuah Khan: "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" * tag 'linux-cpupower-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux: tools/power cpupower: Show C0 in idle-info dump tools/power cpupower: Reset errno before strtoull() tools/cpupower: Use strcspn() to strip trailing newline tools/cpupower: Fix inverted APERF capability check cpupower: idle_monitor: fix incorrect value logged after stop
2 parents 9ace475 + ff72619 commit 2064fe4

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

tools/power/cpupower/lib/cpuidle.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ unsigned long long cpuidle_state_get_one_value(unsigned int cpu,
150150
if (len == 0)
151151
return 0;
152152

153+
errno = 0;
153154
value = strtoull(linebuf, &endp, 0);
154155

155156
if (endp == linebuf || errno == ERANGE)
@@ -193,8 +194,7 @@ static char *cpuidle_state_get_one_string(unsigned int cpu,
193194
if (result == NULL)
194195
return NULL;
195196

196-
if (result[strlen(result) - 1] == '\n')
197-
result[strlen(result) - 1] = '\0';
197+
result[strcspn(result, "\n")] = '\0';
198198

199199
return result;
200200
}
@@ -366,8 +366,7 @@ static char *sysfs_cpuidle_get_one_string(enum cpuidle_string which)
366366
if (result == NULL)
367367
return NULL;
368368

369-
if (result[strlen(result) - 1] == '\n')
370-
result[strlen(result) - 1] = '\0';
369+
result[strcspn(result, "\n")] = '\0';
371370

372371
return result;
373372
}

tools/power/cpupower/utils/cpufreq-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
270270
{
271271
unsigned long freq;
272272

273-
if (cpupower_cpu_info.caps & CPUPOWER_CAP_APERF)
273+
if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
274274
return -EINVAL;
275275

276276
freq = cpufreq_get_freq_hardware(cpu);

tools/power/cpupower/utils/cpuidle-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
111111
printf(_("max_cstate: C%u\n"), cstates-1);
112112
printf(_("maximum allowed latency: %lu usec\n"), max_allowed_cstate);
113113
printf(_("states:\t\n"));
114-
for (cstate = 1; cstate < cstates; cstate++) {
114+
for (cstate = 0; cstate < cstates; cstate++) {
115115
printf(_(" C%d: "
116116
"type[C%d] "), cstate, cstate);
117117
printf(_("promotion[--] demotion[--] "));

tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int cpuidle_stop(void)
7070
current_count[cpu][state] =
7171
cpuidle_state_time(cpu, state);
7272
dprint("CPU %d - State: %d - Val: %llu\n",
73-
cpu, state, previous_count[cpu][state]);
73+
cpu, state, current_count[cpu][state]);
7474
}
7575
}
7676
return 0;

0 commit comments

Comments
 (0)