Commit 40d2cf9c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-tools'

Merge power management utilities updates for 6.18-rc1:

 - Fix and clean up the x86_energy_perf_policy utility and update its
   documentation (Len Brown, Kaushlendra Kumar)

 - Fix incorrect sorting of PMT telemetry in turbostat (Kaushlendra
   Kumar)

 - Fix incorrect size in cpuidle_state_disable() and the error return
   value of cpupower_write_sysfs() in cpupower (Kaushlendra Kumar)

* pm-tools:
  tools/power x86_energy_perf_policy.8: Emphasize preference for SW interfaces
  tools/power x86_energy_perf_policy: Add make snapshot target
  tools/power x86_energy_perf_policy: Prefer driver HWP limits
  tools/power x86_energy_perf_policy: EPB access is only via sysfs
  tools/power x86_energy_perf_policy: Prepare for MSR/sysfs refactoring
  tools/power x86_energy_perf_policy: Enhance HWP enable
  tools/power x86_energy_perf_policy: Enhance HWP enabled check
  tools/power x86_energy_perf_policy: Fix incorrect fopen mode usage
  tools/power turbostat: Fix incorrect sorting of PMT telemetry
  tools/cpupower: Fix incorrect size in cpuidle_state_disable()
  tools/cpupower: fix error return value in cpupower_write_sysfs()
parents f58f86df 17eb8812
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ int cpuidle_state_disable(unsigned int cpu,
{
	char value[SYSFS_PATH_MAX];
	int bytes_written;
	int len;

	if (cpuidle_state_count(cpu) <= idlestate)
		return -1;
@@ -241,10 +242,10 @@ int cpuidle_state_disable(unsigned int cpu,
				 idlestate_value_files[IDLESTATE_DISABLE]))
		return -2;

	snprintf(value, SYSFS_PATH_MAX, "%u", disable);
	len = snprintf(value, SYSFS_PATH_MAX, "%u", disable);

	bytes_written = cpuidle_state_write_file(cpu, idlestate, "disable",
						   value, sizeof(disable));
						   value, len);
	if (bytes_written)
		return 0;
	return -3;
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen)
	if (numwritten < 1) {
		perror(path);
		close(fd);
		return -1;
		return 0;
	}

	close(fd);
+1 −1
Original line number Diff line number Diff line
@@ -1890,7 +1890,7 @@ int pmt_telemdir_sort(const struct dirent **a, const struct dirent **b)
	sscanf((*a)->d_name, "telem%u", &aidx);
	sscanf((*b)->d_name, "telem%u", &bidx);

	return aidx >= bidx;
	return (aidx > bidx) ? 1 : (aidx < bidx) ? -1 : 0;
}

const struct dirent *pmt_diriter_next(struct pmt_diriter_t *iter)
+28 −1
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@ CC = $(CROSS_COMPILE)gcc
BUILD_OUTPUT	:= $(CURDIR)
PREFIX		:= /usr
DESTDIR		:=
DAY		:= $(shell date +%Y.%m.%d)
SNAPSHOT	= x86_energy_perf_policy-$(DAY)



ifeq ("$(origin O)", "command line")
	BUILD_OUTPUT := $(O)
@@ -27,3 +31,26 @@ install : x86_energy_perf_policy
	install -d  $(DESTDIR)$(PREFIX)/share/man/man8
	install -m 644 x86_energy_perf_policy.8 $(DESTDIR)$(PREFIX)/share/man/man8

snapshot: x86_energy_perf_policy
	@rm -rf $(SNAPSHOT)
	@mkdir $(SNAPSHOT)
	@cp x86_energy_perf_policy Makefile x86_energy_perf_policy.c x86_energy_perf_policy.8 $(SNAPSHOT)

	@sed -e 's/^#include <linux\/bits.h>/#include "bits.h"/' -e 's/u64/unsigned long long/' ../../../../arch/x86/include/asm/msr-index.h > $(SNAPSHOT)/msr-index.h
	@echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> $(SNAPSHOT)/msr-index.h
	@echo "#define BIT(x) (1 << (x))" > $(SNAPSHOT)/bits.h
	@echo "#define BIT_ULL(nr) (1ULL << (nr))" >> $(SNAPSHOT)/bits.h
	@echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
	@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h

	@echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
	@echo '#define __must_be_array(arr) 0' >> $(SNAPSHOT)/build_bug.h

	@echo PWD=. > $(SNAPSHOT)/Makefile
	@echo "CFLAGS +=	-DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
	@echo "CFLAGS +=	-DBUILD_BUG_HEADER='\"build_bug.h\"'" >> $(SNAPSHOT)/Makefile
	@sed -e's/.*MSRHEADER.*//' Makefile >> $(SNAPSHOT)/Makefile

	@rm -f $(SNAPSHOT).tar.gz
	tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)
+11 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
.\"  Distributed under the GPL, Copyleft 1994.
.TH X86_ENERGY_PERF_POLICY 8
.SH NAME
x86_energy_perf_policy \- Manage Energy vs. Performance Policy via x86 Model Specific Registers
x86_energy_perf_policy \- Manage Energy vs. Performance Policy
.SH SYNOPSIS
.B x86_energy_perf_policy
.RB "[ options ] [ scope ] [field \ value]"
@@ -19,9 +19,14 @@ x86_energy_perf_policy \- Manage Energy vs. Performance Policy via x86 Model Spe
.SH DESCRIPTION
\fBx86_energy_perf_policy\fP
displays and updates energy-performance policy settings specific to
Intel Architecture Processors.  Settings are accessed via Model Specific Register (MSR)
updates, no matter if the Linux cpufreq sub-system is enabled or not.
Intel Architecture Processors.  It summarizes settings available
in standard Linux interfaces (eg. cpufreq),
and also decodes underlying Model Specific Register (MSRs).
While \fBx86_energy_perf_policy\fP can manage energy-performance policy
using only MSR access, it prefers standard
Linux kernel interfaces, when they are available.

.SH BACKGROUND
Policy in MSR_IA32_ENERGY_PERF_BIAS (EPB)
may affect a wide range of hardware decisions,
such as how aggressively the hardware enters and exits CPU idle states (C-states)
@@ -200,7 +205,9 @@ runs only as root.
.SH FILES
.ta
.nf
/dev/cpu/*/msr
EPB: /sys/devices/system/cpu/cpu*/power/energy_perf_bias
EPP: /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
MSR: /dev/cpu/*/msr
.fi
.SH "SEE ALSO"
.nf
Loading