cpupower: Introduce powercap intel-rapl library helpers and powercap-info command
PATCH 1/2 cpupower: Introduce powercap intel-rapl library helpers and powercap-info command
Read out powercap zone information via:
cpupower powercap-info
and show the zone hierarchy to the user:
./cpupower powercap-info
Driver: intel-rapl
Powercap domain hierarchy:
Zone: package-0 (enabled)
Power consumption can be monitored in micro Watts
Zone: core (disabled)
Power consumption can be monitored in micro Watts
Zone: uncore (disabled)
Power consumption can be monitored in micro Watts
Zone: dram (disabled)
Power consumption can be monitored in micro Watts
There is a dummy -a option for powercap-info which can/should be used to show more detailed info later. Like that other args can be added easily later as well.
A enable/disable option via powercap-set subcommand is also an enhancement for later.
Also not all RAPL domains are shown. The func walking through RAPL subdomains is restricted and hardcoded to: "intel-rapl/intel-rapl:0"
On my system above powercap domains map to:
intel-rapl/intel-rapl:0
-> pack (age-0)
intel-rapl/intel-rapl:0/intel-rapl:0:0
-> core
intel-rapl/intel-rapl:0/intel-rapl:0:1
-> uncore
Missing ones on my system are:
intel-rapl-mmio/intel-rapl-mmio:0
-> pack (age-0)
intel-rapl/intel-rapl:1
-> psys
This could get enhanced in:
struct powercap_zone *powercap_init_zones() and adopted to walk through all intel-rapl zones, but also to other powercap drivers like dtpm (Dynamic Thermal Power Management framework), cmp with: drivers/powercap/dtpm_*
--- tools/power/cpupower/Makefile | 14 ++- tools/power/cpupower/utils/builtin.h | 2 + tools/power/cpupower/utils/cpupower.c | 1 + tools/power/cpupower/utils/powercap-info.c | 113 +++++++++++++++++++++ 4 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 tools/power/cpupower/utils/powercap-info.c
tools/power/cpupower/Makefile +10 -4
@@ -133,7 +133,7 @@ UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \ utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \ utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o \ - utils/cpuidle-set.o + utils/cpuidle-set.o utils/powercap-info.o UTIL_SRC := $(UTIL_OBJS:.o=.c)
@@ -143,9 +143,12 @@ UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ utils/helpers/bitmask.h \ utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def -LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h lib/acpi_cppc.h -LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c lib/acpi_cppc.c -LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o lib/acpi_cppc.o +LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h lib/acpi_cppc.h \ + lib/powercap.h +LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c lib/acpi_cppc.c \ + lib/powercap.c +LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o lib/acpi_cppc.o \ + lib/powercap.o LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS)) override CFLAGS += -pipe
@@ -276,6 +279,7 @@ install-lib: libcpupower $(INSTALL) -d $(DESTDIR)${includedir} $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h $(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h + $(INSTALL_DATA) lib/powercap.h $(DESTDIR)${includedir}/powercap.h install-tools: $(OUTPUT)cpupower $(INSTALL) -d $(DESTDIR)${bindir}
@@ -292,6 +296,7 @@ install-man: $(INSTALL_DATA) -D man/cpupower-set.1 $(DESTDIR)${mandir}/man1/cpupower-set.1 $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1 $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1 + $(INSTALL_DATA) -D man/cpupower-powercap-info.1 $(DESTDIR)${mandir}/man1/cpupower-powercap-info.1 install-gmo: create-gmo $(INSTALL) -d $(DESTDIR)${localedir}
@@ -321,6 +326,7 @@ uninstall: - rm -f $(DESTDIR)${mandir}/man1/cpupower-set.1 - rm -f $(DESTDIR)${mandir}/man1/cpupower-info.1 - rm -f $(DESTDIR)${mandir}/man1/cpupower-monitor.1 + - rm -f $(DESTDIR)${mandir}/man1/cpupower-powercap-info.1 - for HLANG in $(LANGUAGES); do \ rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ done;
tools/power/cpupower/utils/builtin.h +2 -0
@@ -8,6 +8,8 @@ extern int cmd_freq_set(int argc, const char **argv);extern int cmd_freq_info (int argc,const char **argv);extern int cmd_idle_set (int argc,const char **argv);extern int cmd_idle_info (int argc,const char **argv); +extern int cmd_cap_info (int argc,const char **argv); +extern int cmd_cap_set (int argc,const char **argv);extern int cmd_monitor (int argc,const char **argv);#endif
tools/power/cpupower/utils/cpupower.c +1 -0
@@ -54,6 +54,7 @@ static struct cmd_struct commands[] = { { "frequency-set", cmd_freq_set, 1 }, { "idle-info", cmd_idle_info, 0 }, { "idle-set", cmd_idle_set, 1 }, + { "powercap-info", cmd_cap_info, 0 }, { "set", cmd_set, 1 }, { "info", cmd_info, 0 }, { "monitor", cmd_monitor, 0 },
tools/power/cpupower/utils/powercap-info.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.37.1
Shuah Khan
maintainerHi Thomas,
Quoted 43 lines · Thomas Renninger
Read out powercap zone information via:
cpupower powercap-info
and show the zone hierarchy to the user:./cpupower powercap-info
Driver: intel-rapl
Powercap domain hierarchy:Zone: package-0 (enabled)
Power consumption can be monitored in micro WattsZone: core (disabled)
Power consumption can be monitored in micro WattsZone: uncore (disabled)
Power consumption can be monitored in micro WattsZone: dram (disabled)
Power consumption can be monitored in micro WattsThere is a dummy -a option for powercap-info which can/should be used to show more detailed info later. Like that other args can be added easily later as well.
A enable/disable option via powercap-set subcommand is also an enhancement for later.
Also not all RAPL domains are shown. The func walking through RAPL subdomains is restricted and hardcoded to: "intel-rapl/intel-rapl:0"
On my system above powercap domains map to:
intel-rapl/intel-rapl:0
-> pack (age-0)
intel-rapl/intel-rapl:0/intel-rapl:0:0
-> core
intel-rapl/intel-rapl:0/intel-rapl:0:1
-> uncoreMissing ones on my system are:
intel-rapl-mmio/intel-rapl-mmio:0
-> pack (age-0)intel-rapl/intel-rapl:1
-> psys
Quoted 7 lines
This could get enhanced in:
structpowercap_zone*powercap_init_zones()and adopted to walk through all intel-rapl zones, but also to other powercap drivers like dtpm (Dynamic Thermal Power Management framework), cmp with:drivers/powercap/dtpm_*
Thanks for the patch. A few comments below
Quoted 97 lines
Signed-off-by Thomas Renninger <[email protected]>CC Shuah Khan <[email protected]>--- tools/power/cpupower/Makefile | 14 ++- tools/power/cpupower/utils/builtin.h | 2 + tools/power/cpupower/utils/cpupower.c | 1 + tools/power/cpupower/utils/powercap-info.c | 113 +++++++++++++++++++++ 4 files changed, 126 insertions(+), 4 deletions(-)create mode 100644
tools/power/cpupower/utils/powercap-info.ctools/power/cpupower/Makefile +10
-4@@ -133,7 +133,7 @@ UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \ utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \ utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o \ - utils/cpuidle-set.o + utils/cpuidle-set.o utils/powercap-info.o UTIL_SRC := $(UTIL_OBJS:.o=.c)@@ -143,9 +143,12 @@ UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ utils/helpers/bitmask.h \ utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def -LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h lib/acpi_cppc.h -LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c lib/acpi_cppc.c -LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o lib/acpi_cppc.o +LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h lib/acpi_cppc.h \ + lib/powercap.h +LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c lib/acpi_cppc.c \ + lib/powercap.c +LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o lib/acpi_cppc.o \ + lib/powercap.o LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS)) override CFLAGS += -pipe@@ -276,6 +279,7 @@ install-lib: libcpupower $(INSTALL) -d $(DESTDIR)${includedir} $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h $(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h + $(INSTALL_DATA) lib/powercap.h $(DESTDIR)${includedir}/powercap.h install-tools: $(OUTPUT)cpupower $(INSTALL) -d $(DESTDIR)${bindir}@@ -292,6 +296,7 @@ install-man: $(INSTALL_DATA) -D man/cpupower-set.1 $(DESTDIR)${mandir}/man1/cpupower-set.1 $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1 $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1 + $(INSTALL_DATA) -D man/cpupower-powercap-info.1 $(DESTDIR)${mandir}/man1/cpupower-powercap-info.1 install-gmo: create-gmo $(INSTALL) -d $(DESTDIR)${localedir}@@ -321,6 +326,7 @@ uninstall: - rm -f $(DESTDIR)${mandir}/man1/cpupower-set.1 - rm -f $(DESTDIR)${mandir}/man1/cpupower-info.1 - rm -f $(DESTDIR)${mandir}/man1/cpupower-monitor.1 + - rm -f $(DESTDIR)${mandir}/man1/cpupower-powercap-info.1 - for HLANG in $(LANGUAGES); do \ rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ done;tools/power/cpupower/utils/builtin.h +2
-0@@ -8,6 +8,8 @@ extern int cmd_freq_set(int argc, const char **argv);extern int cmd_freq_info (int argc,const char **argv);extern int cmd_idle_set (int argc,const char **argv);extern int cmd_idle_info (int argc,const char **argv); +extern int cmd_cap_info (int argc,const char **argv); +extern int cmd_cap_set (int argc,const char **argv);extern int cmd_monitor (int argc,const char **argv);#endif tools/power/cpupower/utils/cpupower.c +1
-0@@ -54,6 +54,7 @@ static struct cmd_struct commands[] = { { "frequency-set", cmd_freq_set, 1 }, { "idle-info", cmd_idle_info, 0 }, { "idle-set", cmd_idle_set, 1 }, + { "powercap-info", cmd_cap_info, 0 }, { "set", cmd_set, 1 }, { "info", cmd_info, 0 }, { "monitor", cmd_monitor, 0 },tools/power/cpupower/utils/powercap-info.c new file +3
-0@@ -0,0 +1,113 @@ +#include <unistd.h> +#include <stdio.h> +#include <errno.h>
tools/power/cpupower/utils/powercap-info.c line 13
Quoted 10 lines
tools/power/cpupower/utils/powercap-info.c new file +10
-0+#include <stdlib.h> +#include <stdint.h> +#include <string.h> + +#include <getopt.h> + +#include "powercap.h" +#include "helpers/helpers.h" + +int powercap_show_all =0 ;
Globals don't need initualization to 0.
tools/power/cpupower/utils/powercap-info.c line 16
Quoted 3 lines
tools/power/cpupower/utils/powercap-info.c new file +3
-0+ +static struct option info_opts[] = +{
Open brace needs to be on the previous line. A few more errors about function definitions etc..
Please add SPDX to new files.
Running checkpatch will show you the errors.
Compile failed with ./lib/powercap.o: No such file or directory I installed libcpupower.so.0.0.1
thanks,
-- Shuah