Commit 0f64b6ac authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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
parents 931688a4 56f79097
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -315,7 +315,17 @@ endif
	$(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h
	$(INSTALL_DATA) lib/powercap.h $(DESTDIR)${includedir}/powercap.h

install-tools: $(OUTPUT)cpupower
# SYSTEMD=false disables installation of the systemd unit file
SYSTEMD ?=	true

install-systemd:
	$(INSTALL) -d $(DESTDIR)${unitdir}
	sed 's|___CDIR___|${confdir}|; s|___LDIR___|${libexecdir}|' cpupower.service.in > '$(DESTDIR)${unitdir}/cpupower.service'
	$(SETPERM_DATA) '$(DESTDIR)${unitdir}/cpupower.service'

INSTALL_SYSTEMD := $(if $(filter true,$(strip $(SYSTEMD))),install-systemd)

install-tools: $(OUTPUT)cpupower $(INSTALL_SYSTEMD)
	$(INSTALL) -d $(DESTDIR)${bindir}
	$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
	$(INSTALL) -d $(DESTDIR)${bash_completion_dir}
@@ -324,9 +334,6 @@ install-tools: $(OUTPUT)cpupower
	$(INSTALL_DATA) cpupower-service.conf '$(DESTDIR)${confdir}'
	$(INSTALL) -d $(DESTDIR)${libexecdir}
	$(INSTALL_PROGRAM) cpupower.sh '$(DESTDIR)${libexecdir}/cpupower'
	$(INSTALL) -d $(DESTDIR)${unitdir}
	sed 's|___CDIR___|${confdir}|; s|___LDIR___|${libexecdir}|' cpupower.service.in > '$(DESTDIR)${unitdir}/cpupower.service'
	$(SETPERM_DATA) '$(DESTDIR)${unitdir}/cpupower.service'

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

.PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean help
.PHONY: all utils libcpupower update-po create-gmo install-lib install-systemd install-tools install-man install-gmo install uninstall clean help
+3 −4
Original line number Diff line number Diff line
@@ -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;
}
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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[--] "));
+1 −1
Original line number Diff line number Diff line
@@ -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;