Skip to content

Commit 57610d6

Browse files
committed
Merge tag 'power-utilities-for-v6.18-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Merge turbostat and x86_energy_perf_policy bug fixes for v6.18 merge window from Len Brown. * tag 'power-utilities-for-v6.18-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: 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
2 parents 2bc1adb + 66f4305 commit 57610d6

4 files changed

Lines changed: 129 additions & 50 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ int pmt_telemdir_sort(const struct dirent **a, const struct dirent **b)
18901890
sscanf((*a)->d_name, "telem%u", &aidx);
18911891
sscanf((*b)->d_name, "telem%u", &bidx);
18921892

1893-
return aidx >= bidx;
1893+
return (aidx > bidx) ? 1 : (aidx < bidx) ? -1 : 0;
18941894
}
18951895

18961896
const struct dirent *pmt_diriter_next(struct pmt_diriter_t *iter)

tools/power/x86/x86_energy_perf_policy/Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# SPDX-License-Identifier: GPL-2.0
22
CC = $(CROSS_COMPILE)gcc
3-
BUILD_OUTPUT := $(CURDIR)
3+
BUILD_OUTPUT := $(CURDIR)
44
PREFIX := /usr
55
DESTDIR :=
6+
DAY := $(shell date +%Y.%m.%d)
7+
SNAPSHOT = x86_energy_perf_policy-$(DAY)
8+
9+
610

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

34+
snapshot: x86_energy_perf_policy
35+
@rm -rf $(SNAPSHOT)
36+
@mkdir $(SNAPSHOT)
37+
@cp x86_energy_perf_policy Makefile x86_energy_perf_policy.c x86_energy_perf_policy.8 $(SNAPSHOT)
38+
39+
@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
40+
@echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> $(SNAPSHOT)/msr-index.h
41+
@echo "#define BIT(x) (1 << (x))" > $(SNAPSHOT)/bits.h
42+
@echo "#define BIT_ULL(nr) (1ULL << (nr))" >> $(SNAPSHOT)/bits.h
43+
@echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
44+
@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
45+
46+
@echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
47+
@echo '#define __must_be_array(arr) 0' >> $(SNAPSHOT)/build_bug.h
48+
49+
@echo PWD=. > $(SNAPSHOT)/Makefile
50+
@echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
51+
@echo "CFLAGS += -DBUILD_BUG_HEADER='\"build_bug.h\"'" >> $(SNAPSHOT)/Makefile
52+
@sed -e's/.*MSRHEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
53+
54+
@rm -f $(SNAPSHOT).tar.gz
55+
tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)
56+

tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.8

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.\" Distributed under the GPL, Copyleft 1994.
33
.TH X86_ENERGY_PERF_POLICY 8
44
.SH NAME
5-
x86_energy_perf_policy \- Manage Energy vs. Performance Policy via x86 Model Specific Registers
5+
x86_energy_perf_policy \- Manage Energy vs. Performance Policy
66
.SH SYNOPSIS
77
.B x86_energy_perf_policy
88
.RB "[ options ] [ scope ] [field \ value]"
@@ -19,9 +19,14 @@ x86_energy_perf_policy \- Manage Energy vs. Performance Policy via x86 Model Spe
1919
.SH DESCRIPTION
2020
\fBx86_energy_perf_policy\fP
2121
displays and updates energy-performance policy settings specific to
22-
Intel Architecture Processors. Settings are accessed via Model Specific Register (MSR)
23-
updates, no matter if the Linux cpufreq sub-system is enabled or not.
22+
Intel Architecture Processors. It summarizes settings available
23+
in standard Linux interfaces (eg. cpufreq),
24+
and also decodes underlying Model Specific Register (MSRs).
25+
While \fBx86_energy_perf_policy\fP can manage energy-performance policy
26+
using only MSR access, it prefers standard
27+
Linux kernel interfaces, when they are available.
2428

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

0 commit comments

Comments
 (0)