Skip to content

Commit 0f64b6a

Browse files
committed
Merge branch 'pm-tools'
Merge cpupower utility updates for 6.20-rc1/7.0-rc1: - Fix miscellaneous problems in cpupower (Kaushlendra Kumar): * 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 - Improve cpupower installation procedure by making the systemd step optional and allowing users to disable the installation of systemd's unit file (João Marcos Costa) * pm-tools: cpupower: make systemd unit installation optional 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 931688a + 56f7909 commit 0f64b6a

5 files changed

Lines changed: 18 additions & 12 deletions

File tree

tools/power/cpupower/Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,17 @@ endif
315315
$(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h
316316
$(INSTALL_DATA) lib/powercap.h $(DESTDIR)${includedir}/powercap.h
317317

318-
install-tools: $(OUTPUT)cpupower
318+
# SYSTEMD=false disables installation of the systemd unit file
319+
SYSTEMD ?= true
320+
321+
install-systemd:
322+
$(INSTALL) -d $(DESTDIR)${unitdir}
323+
sed 's|___CDIR___|${confdir}|; s|___LDIR___|${libexecdir}|' cpupower.service.in > '$(DESTDIR)${unitdir}/cpupower.service'
324+
$(SETPERM_DATA) '$(DESTDIR)${unitdir}/cpupower.service'
325+
326+
INSTALL_SYSTEMD := $(if $(filter true,$(strip $(SYSTEMD))),install-systemd)
327+
328+
install-tools: $(OUTPUT)cpupower $(INSTALL_SYSTEMD)
319329
$(INSTALL) -d $(DESTDIR)${bindir}
320330
$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
321331
$(INSTALL) -d $(DESTDIR)${bash_completion_dir}
@@ -324,9 +334,6 @@ install-tools: $(OUTPUT)cpupower
324334
$(INSTALL_DATA) cpupower-service.conf '$(DESTDIR)${confdir}'
325335
$(INSTALL) -d $(DESTDIR)${libexecdir}
326336
$(INSTALL_PROGRAM) cpupower.sh '$(DESTDIR)${libexecdir}/cpupower'
327-
$(INSTALL) -d $(DESTDIR)${unitdir}
328-
sed 's|___CDIR___|${confdir}|; s|___LDIR___|${libexecdir}|' cpupower.service.in > '$(DESTDIR)${unitdir}/cpupower.service'
329-
$(SETPERM_DATA) '$(DESTDIR)${unitdir}/cpupower.service'
330337

331338
install-man:
332339
$(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
@@ -406,4 +413,4 @@ help:
406413
@echo ' uninstall - Remove previously installed files from the dir defined by "DESTDIR"'
407414
@echo ' cmdline or Makefile config block option (default: "")'
408415

409-
.PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean help
416+
.PHONY: all utils libcpupower update-po create-gmo install-lib install-systemd install-tools install-man install-gmo install uninstall clean help

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)