cpupower second update for Linux 6.12-rc1
Shuah Khan
maintainerHi Rafael,
Please pull the following cpupower second update for Linux 6.12-rc1.
This cpupower second update for Linux 6.12-rc1 consists of a fix and a new feature.
-- adds missing powercap_set_enabled() stub function -- adds SWIG bindings files for libcpupower
SWIG is a tool packaged in Fedora and other distros that can generate bindings from C and C++ code for several languages including Python, Perl, and Go.
These bindings allows users to easily write scripts that use and extend libcpupower's functionality. Currently, only Python is provided in the makefile, but additional languages may be added if there is demand.
Note that while SWIG itself is GPL v3+ licensed; the resulting output, the bindings code, is permissively licensed + the license of the .o files. Please see the following for more details.
- https://swig.org/legal.html.
- https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 76fb981ad6774b82f06703c896b492c8659b543b:
tools/cpupower: display residency value in idle-info (2024-08-09 10:32:33 -0600)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux tags/linux-cpupower-6.12-rc1-2
for you to fetch changes up to 80e67f1802d0fc21543216557a68320c71d7dbe1:
pm:cpupower: Add error warning when SWIG is not installed (2024-09-06 10:58:35 -0600)
----------------------------------------------------------------
linux-cpupower-6.12-rc1-2
This cpupower second update for Linux 6.12-rc1 consists of a fix and a new feature.
-- adds missing powercap_set_enabled() stub function -- adds SWIG bindings files for libcpupower
SWIG is a tool packaged in Fedora and other distros that can generate bindings from C and C++ code for several languages including Python, Perl, and Go.
These bindings allows users to easily write scripts that use and extend libcpupower's functionality. Currently, only Python is provided in the makefile, but additional languages may be added if there is demand.
Note that while SWIG itself is GPL v3+ licensed; the resulting output, the bindings code, is permissively licensed + the license of the .o files. Please see the following for more details.
- https://swig.org/legal.html.
- https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup
----------------------------------------------------------------
John B. Wyatt IV (5):
pm:cpupower: Add missing powercap_set_enabled() stub function pm:cpupower: Add SWIG bindings files for libcpupower pm:cpupower: Include test_raw_pylibcpupower.py
MAINTAINERS: Add Maintainers for SWIG Python bindings pm:cpupower: Add error warning when SWIG is not installed
MAINTAINERS | 3 + tools/power/cpupower/bindings/python/.gitignore | 8 + tools/power/cpupower/bindings/python/Makefile | 33 +++ tools/power/cpupower/bindings/python/README | 59 +++++ .../cpupower/bindings/python/raw_pylibcpupower.i | 247 +++++++++++++++++++++ .../bindings/python/test_raw_pylibcpupower.py | 42 ++++ tools/power/cpupower/lib/powercap.c | 8 + 7 files changed, 400 insertions(+) create mode 100644 tools/power/cpupower/bindings/python/.gitignore create mode 100644 tools/power/cpupower/bindings/python/Makefile create mode 100644 tools/power/cpupower/bindings/python/README create mode 100644 tools/power/cpupower/bindings/python/raw_pylibcpupower.i create mode 100755 tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py
----------------------------------------------------------------
MAINTAINERS +3 -0
@@ -5819,6 +5819,9 @@ CPU POWER MONITORING SUBSYSTEM M: Thomas Renninger <[email protected]> M: Shuah Khan <[email protected]> M: Shuah Khan <[email protected]> +M: John B. Wyatt IV <[email protected]> +M: John B. Wyatt IV <[email protected]> +M: John Kacur <[email protected]> L: [email protected] S: Maintained F: tools/power/cpupower/
tools/power/cpupower/bindings/python/.gitignore new file +8 -0
@@ -0,0 +1,8 @@ +__pycache__/ +raw_pylibcpupower_wrap.c +*.o +*.so +*.py +!test_raw_pylibcpupower.py +# git keeps ignoring this file, use git add -f raw_libcpupower.i +!raw_pylibcpupower.i
tools/power/cpupower/bindings/python/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Makefile for libcpupower's Python bindings +# +# This Makefile expects you have already run the makefile for cpupower to build +# the .o files in the lib directory for the bindings to be created. + +CC := gcc +HAVE_SWIG := $(shell if which swig >/dev/null 2>&1; then echo 1; else echo 0; fi) +HAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; else echo 0; fi) + +LIB_DIR := ../../lib +PY_INCLUDE = $(firstword $(shell python-config --includes)) +OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o) + +all: _raw_pylibcpupower.so + +_raw_pylibcpupower.so: raw_pylibcpupower_wrap.o + $(CC) -shared $(OBJECTS_LIB) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so + +raw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c + $(CC) -fPIC -c raw_pylibcpupower_wrap.c $(PY_INCLUDE) + +raw_pylibcpupower_wrap.c: raw_pylibcpupower.i +ifeq ($(HAVE_SWIG),0) + $(error "swig was not found. Make sure you have it installed and in the PATH to generate the bindings.") +else ifeq ($(HAVE_PYCONFIG),0) + $(error "python-config was not found. Make sure you have it installed and in the PATH to generate the bindings.") +endif + swig -python raw_pylibcpupower.i + +# Will only clean the bindings folder; will not clean the actual cpupower folder +clean: + rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so
tools/power/cpupower/bindings/python/README new file +59 -0
59 lines not on this page · raw message
tools/power/cpupower/bindings/python/raw_pylibcpupower.i new file +247 -0
247 lines not on this page · raw message
tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py new file +42 -0
42 lines not on this page · raw message
tools/power/cpupower/lib/powercap.c +8 -0
@@ -77,6 +77,14 @@ int powercap_get_enabled(int *mode)return sysfs_get_enabled (path, mode); } +/* +* TODO: implement function. Returns dummy 0 for now. +*/ +int powercap_set_enabled (int mode) +{ +return 0 ; +} +/* * Hardcoded, because rapl is the only powercap implementation - * this needs to get more generic if more powercap implementations
Hi Shuah,
Quoted 84 lines · Shuah Khan
Hi Rafael,
Please pull the following cpupower second update for Linux 6.12-rc1.
This cpupower second update for Linux 6.12-rc1 consists of a fix and a new feature.
-- adds missing
powercap_set_enabled()stub function -- adds SWIG bindings files for libcpupowerSWIG is a tool packaged in Fedora and other distros that can generate bindings from C and C++ code for several languages including Python, Perl, and Go.
These bindings allows users to easily write scripts that use and extend libcpupower's functionality. Currently, only Python is provided in the makefile, but additional languages may be added if there is demand.
Note that while SWIG itself is GPL v3+ licensed; the resulting output, the bindings code, is permissively licensed + the license of the .o files. Please see the following for more details.
- https://swig.org/legal.html.
- https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackupdiff is attached.
thanks,
-- Shuah----------------------------------------------------------------
The following changes since commit76fb981ad6774b82f06703c896b492c8659b543b:tools/cpupower: display residency value in idle-info (2024-08-09 10:32:33 -0600)are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux tags/linux-cpupower-6.12-rc1-2for you to fetch changes up to
80e67f1802d0fc21543216557a68320c71d7dbe1:pm:cpupower: Add error warning when SWIG is not installed (2024-09-06 10:58:35 -0600)
----------------------------------------------------------------
linux-cpupower-6.12-rc1-2This cpupower second update for Linux 6.12-rc1 consists of a fix and a new feature.
-- adds missing
powercap_set_enabled()stub function -- adds SWIG bindings files for libcpupowerSWIG is a tool packaged in Fedora and other distros that can generate bindings from C and C++ code for several languages including Python, Perl, and Go.
These bindings allows users to easily write scripts that use and extend libcpupower's functionality. Currently, only Python is provided in the makefile, but additional languages may be added if there is demand.
Note that while SWIG itself is GPL v3+ licensed; the resulting output, the bindings code, is permissively licensed + the license of the .o files. Please see the following for more details.
- https://swig.org/legal.html.
- https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup----------------------------------------------------------------
John B. Wyatt IV (5):
pm:cpupower: Add missingpowercap_set_enabled()stub function pm:cpupower: Add SWIG bindings files for libcpupower pm:cpupower: Includetest_raw_pylibcpupower.py
MAINTAINERS: Add Maintainers for SWIG Python bindings pm:cpupower: Add error warning when SWIG is not installedMAINTAINERS | 3 + tools/power/cpupower/bindings/python/.gitignore | 8 + tools/power/cpupower/bindings/python/Makefile | 33 +++ tools/power/cpupower/bindings/python/README | 59 +++++ .../cpupower/bindings/python/raw_pylibcpupower.i | 247 +++++++++++++++++++++ .../bindings/python/test_raw_pylibcpupower.py | 42 ++++ tools/power/cpupower/lib/powercap.c | 8 + 7 files changed, 400 insertions(+)
Quoted 6 lines
create mode 100644
tools/power/cpupower/bindings/python/.gitignorecreate mode 100644tools/power/cpupower/bindings/python/Makefilecreate mode 100644tools/power/cpupower/bindings/python/READMEcreate mode 100644tools/power/cpupower/bindings/python/raw_pylibcpupower.icreate mode 100755tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py
----------------------------------------------------------------
Pulled and added to the linux-next branch in linux-pm.git, thanks!