Skip to content

Commit c6e2a4c

Browse files
committed
Merge branch 'pm-tools'
Merge power management utilities updates for 6.13-rc1: - Update pm-graph to v5.13 (Todd Brandt). - Add documentation for some recently introduced cpupower utility options (Tor Vic). - Make cpupower inform users where cpufreq-bench.conf should be located when opening it fails (Peng Fan). - Allow overriding cross-compiling env params in cpupower (Peng Fan). - Add compile_commands.json to .gitignore in cpupower (John B. Wyatt IV). - Improve disable c_state block in cpupower bindings and add a test to confirm that CPU state is disabled to it (John B. Wyatt IV). - Add Chinese Simplified translation to cpupower (Kieran Moy). - Add checks for xgettext and msgfmt to cpupower (Siddharth Menon). * pm-tools: cpupower: add checks for xgettext and msgfmt cpupower: Add Chinese Simplified translation pm-graph v5.13 pm: cpupower: bindings: Add test to confirm cpu state is disabled pm: cpupower: bindings: Improve disable c_state block pm: cpupower: gitignore: Add compile_commands.json pm: cpupower: Makefile: Allow overriding cross-compiling env params pm: cpupower: bench: print config file path when open cpufreq-bench.conf fails tools/power/cpupower: Add documentation for some recently introduced options
2 parents 923c256 + 7954c4f commit c6e2a4c

File tree

8 files changed

+1072
-32
lines changed

8 files changed

+1072
-32
lines changed

tools/power/cpupower/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ debug/i386/intel_gsic
2727
debug/i386/powernow-k8-decode
2828
debug/x86_64/centrino-decode
2929
debug/x86_64/powernow-k8-decode
30+
31+
# Clang's compilation database file
32+
compile_commands.json

tools/power/cpupower/Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LIB_MIN= 1
5757

5858
PACKAGE = cpupower
5959
PACKAGE_BUGREPORT = linux-pm@vger.kernel.org
60-
LANGUAGES = de fr it cs pt ka
60+
LANGUAGES = de fr it cs pt ka zh_CN
6161

6262

6363
# Directory definitions. These are default and most probably
@@ -86,12 +86,12 @@ INSTALL_SCRIPT = ${INSTALL} -m 644
8686
# If you are running a cross compiler, you may want to set this
8787
# to something more interesting, like "arm-linux-". If you want
8888
# to compile vs uClibc, that can be done here as well.
89-
CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
90-
CC = $(CROSS)gcc
91-
LD = $(CROSS)gcc
92-
AR = $(CROSS)ar
93-
STRIP = $(CROSS)strip
94-
RANLIB = $(CROSS)ranlib
89+
CROSS ?= #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
90+
CC ?= $(CROSS)gcc
91+
LD ?= $(CROSS)gcc
92+
AR ?= $(CROSS)ar
93+
STRIP ?= $(CROSS)strip
94+
RANLIB ?= $(CROSS)ranlib
9595
HOSTCC = gcc
9696
MKDIR = mkdir
9797

@@ -218,17 +218,28 @@ else
218218
endif
219219
$(QUIET) $(STRIPCMD) $@
220220

221+
ifeq (, $(shell which xgettext))
222+
$(warning "Install xgettext to extract translatable strings.")
223+
else
221224
$(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
222225
$(ECHO) " GETTEXT " $@
223226
$(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
224227
--keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
228+
endif
225229

230+
ifeq (, $(shell which msgfmt))
231+
$(warning "Install msgfmt to generate binary message catalogs.")
232+
else
226233
$(OUTPUT)po/%.gmo: po/%.po
227234
$(ECHO) " MSGFMT " $@
228235
$(QUIET) msgfmt -o $@ po/$*.po
236+
endif
229237

230238
create-gmo: ${GMO_FILES}
231239

240+
ifeq (, $(shell which msgmerge))
241+
$(warning "Install msgmerge to merge translations.")
242+
else
232243
update-po: $(OUTPUT)po/$(PACKAGE).pot
233244
$(ECHO) " MSGMRG " $@
234245
$(QUIET) @for HLANG in $(LANGUAGES); do \
@@ -241,6 +252,7 @@ update-po: $(OUTPUT)po/$(PACKAGE).pot
241252
rm -f $(OUTPUT)po/$$HLANG.new.po; \
242253
fi; \
243254
done;
255+
endif
244256

245257
compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
246258
@V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT)

tools/power/cpupower/bench/parse.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
55
*/
66

7+
#include <errno.h>
78
#include <stdio.h>
89
#include <stdlib.h>
910
#include <stdarg.h>
@@ -165,8 +166,8 @@ int prepare_config(const char *path, struct config *config)
165166

166167
configfile = fopen(path, "r");
167168
if (configfile == NULL) {
168-
perror("fopen");
169-
fprintf(stderr, "error: unable to read configfile\n");
169+
fprintf(stderr, "error: unable to read configfile: %s, %s\n",
170+
path, strerror(errno));
170171
free(config);
171172
return 1;
172173
}

tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,38 @@
1515
print(f"cstate count error: return code: {cpu_cstates_count}")
1616

1717
"""
18-
Disable cstate (will fail if the above is 0, ex: a virtual machine)
18+
Disable cstate (will fail if the above returns is under 1, ex: a virtual machine)
1919
"""
2020
cstate_disabled = p.cpuidle_state_disable(0, 0, 1)
21-
if cpu_cstates_count == 0:
22-
print(f"CPU 0 has {cpu_cstates_count} c-states")
23-
else:
24-
print(f"cstate count error: return code: {cpu_cstates_count}")
2521

2622
match cstate_disabled:
2723
case 0:
2824
print(f"CPU state disabled")
2925
case -1:
3026
print(f"Idlestate not available")
27+
case -2:
28+
print(f"Disabling is not supported by the kernel")
29+
case -3:
30+
print(f"No write access to disable/enable C-states: try using sudo")
3131
case _:
32-
print(f"Not documented")
32+
print(f"Not documented: {cstate_disabled}")
33+
34+
"""
35+
Test cstate is disabled
36+
"""
37+
is_cstate_disabled = p.cpuidle_is_state_disabled(0, 0)
3338

39+
match is_cstate_disabled:
40+
case 1:
41+
print(f"CPU is disabled")
42+
case 0:
43+
print(f"CPU is enabled")
44+
case -1:
45+
print(f"Idlestate not available")
46+
case -2:
47+
print(f"Disabling is not supported by kernel")
48+
case _:
49+
print(f"Not documented: {is_cstate_disabled}")
3450

3551
# Pointer example
3652

tools/power/cpupower/man/cpupower-set.1

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cpupower\-set \- Set processor power related kernel or hardware configurations
44
.SH SYNOPSIS
55
.ft B
6-
.B cpupower set [ \-b VAL ]
6+
.B cpupower set [ \-b VAL | \-e POLICY | \-m MODE | \-t BOOL ]
77

88

99
.SH DESCRIPTION
@@ -19,7 +19,7 @@ described in the Options sections.
1919
Use \fBcpupower info \fP to read out current settings and whether they are
2020
supported on the system at all.
2121

22-
.SH Options
22+
.SH OPTIONS
2323
.PP
2424
\-\-perf-bias, \-b
2525
.RS 4
@@ -56,6 +56,40 @@ Use \fBcpupower -c all info -b\fP to verify.
5656
This options needs the msr kernel driver (CONFIG_X86_MSR) loaded.
5757
.RE
5858

59+
.PP
60+
\-\-epp, \-e
61+
.RS 4
62+
Sets the energy performance policy preference on supported Intel or AMD
63+
processors which use the Intel or AMD P-State cpufreq driver respectively.
64+
65+
Available policies can be found with
66+
\fBcat /sys/devices/system/cpu/cpufreq/policy0/energy_performance_available_preferences\fP :
67+
.RS 4
68+
default performance balance_performance balance_power power
69+
.RE
70+
71+
.RE
72+
73+
.PP
74+
\-\-amd\-pstate\-mode, \-m
75+
.RS 4
76+
Sets the AMD P-State mode for supported AMD processors.
77+
Available modes are "active", "guided" or "passive".
78+
79+
Refer to the AMD P-State kernel documentation for further information.
80+
81+
.RE
82+
83+
.PP
84+
\-\-turbo\-boost, \-t
85+
.RS 4
86+
This option is used to enable or disable the turbo boost feature on
87+
supported Intel and AMD processors.
88+
89+
This option takes as parameter either \fB1\fP to enable, or \fB0\fP to disable the feature.
90+
91+
.RE
92+
5993
.SH "SEE ALSO"
6094
cpupower-info(1), cpupower-monitor(1), powertop(1)
6195
.PP

0 commit comments

Comments
 (0)