mirror-linux/tools/power/cpupower
Linus Torvalds 7f70725741 Kbuild updates for 6.18
- Extend modules.builtin.modinfo to include module aliases from
   MODULE_DEVICE_TABLE for builtin modules so that userspace tools (such
   as kmod) can verify that a particular module alias will be handled by
   a builtin module.
 
 - Bump the minimum version of LLVM for building the kernel to 15.0.0.
 
 - Upgrade several userspace API checks in headers_check.pl to errors.
 
 - Unify and consolidate CONFIG_WERROR / W=e handling.
 
 - Turn assembler and linker warnings into errors with CONFIG_WERROR /
   W=e.
 
 - Respect CONFIG_WERROR / W=e when building userspace programs
   (userprogs).
 
 - Enable -Werror unconditionally when building host programs
   (hostprogs).
 
 - Support copy_file_range() and data segment alignment in gen_init_cpio
   to improve performance on filesystems that support reflinks such as
   btrfs and XFS.
 
 - Miscellaneous small changes to scripts and configuration files.
 
 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQR74yXHMTGczQHYypIdayaRccAalgUCaNrp6QAKCRAdayaRccAa
 ljxRAP4hYocKXeWsiJzkTB199P4QUGWf220a9elBmtdJEed07gD/VBnCbSOxG3RO
 vS8qbJHwxUFL7a+mDV8RIVXSt99NpAg=
 =psG/
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild updates from Nathan Chancellor:

 - Extend modules.builtin.modinfo to include module aliases from
   MODULE_DEVICE_TABLE for builtin modules so that userspace tools (such
   as kmod) can verify that a particular module alias will be handled by
   a builtin module

 - Bump the minimum version of LLVM for building the kernel to 15.0.0

 - Upgrade several userspace API checks in headers_check.pl to errors

 - Unify and consolidate CONFIG_WERROR / W=e handling

 - Turn assembler and linker warnings into errors with CONFIG_WERROR /
   W=e

 - Respect CONFIG_WERROR / W=e when building userspace programs
   (userprogs)

 - Enable -Werror unconditionally when building host programs
   (hostprogs)

 - Support copy_file_range() and data segment alignment in gen_init_cpio
   to improve performance on filesystems that support reflinks such as
   btrfs and XFS

 - Miscellaneous small changes to scripts and configuration files

* tag 'kbuild-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux: (47 commits)
  modpost: Initialize builtin_modname to stop SIGSEGVs
  Documentation: kbuild: note CONFIG_DEBUG_EFI in reproducible builds
  kbuild: vmlinux.unstripped should always depend on .vmlinux.export.o
  modpost: Create modalias for builtin modules
  modpost: Add modname to mod_device_table alias
  scsi: Always define blogic_pci_tbl structure
  kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
  kbuild: keep .modinfo section in vmlinux.unstripped
  kbuild: always create intermediate vmlinux.unstripped
  s390: vmlinux.lds.S: Reorder sections
  KMSAN: Remove tautological checks
  objtool: Drop noinstr hack for KCSAN_WEAK_MEMORY
  lib/Kconfig.debug: Drop CLANG_VERSION check from DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  riscv: Remove ld.lld version checks from many TOOLCHAIN_HAS configs
  riscv: Unconditionally use linker relaxation
  riscv: Remove version check for LTO_CLANG selects
  powerpc: Drop unnecessary initializations in __copy_inst_from_kernel_nofault()
  mips: Unconditionally select ARCH_HAS_CURRENT_STACK_POINTER
  arm64: Remove tautological LLVM Kconfig conditions
  ARM: Clean up definition of ARM_HAS_GROUP_RELOCS
  ...
2025-10-01 20:58:51 -07:00
..
bench pm: cpupower: bench: Prevent NULL dereference on malloc failure 2025-02-19 13:48:08 -07:00
bindings/python cpupower: Improve Python binding's Makefile 2025-07-01 10:58:00 -06:00
debug treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_385.RULE 2022-06-10 14:51:36 +02:00
lib tools/cpupower: Fix incorrect size in cpuidle_state_disable() 2025-09-24 17:15:35 -06:00
man cpupower: Allow control of boost feature on non-x86 based systems with boost support. 2025-08-15 10:49:14 -06:00
po cpupower: Add Chinese Simplified translation 2024-10-15 17:18:12 -06:00
utils cpupower: Allow control of boost feature on non-x86 based systems with boost support. 2025-08-15 10:49:14 -06:00
.gitignore .gitignore: ignore compile_commands.json globally 2025-08-12 15:53:55 -07:00
Makefile cpupower: split unitdir from libdir in Makefile 2025-06-09 10:17:46 -06:00
README cpupower: do not install files to /etc/default/ 2025-05-13 16:06:28 -06:00
TODO tools/power/cpupower/{ToDo => TODO}: Rename the todo file 2022-01-24 09:07:11 -07:00
cpupower-completion.sh cpupower : Auto-completion for cpupower tool 2018-12-05 07:52:45 -07:00
cpupower-service.conf cpupower: do not install files to /etc/default/ 2025-05-13 16:06:28 -06:00
cpupower.service.in cpupower: do not install files to /etc/default/ 2025-05-13 16:06:28 -06:00
cpupower.sh cpupower: add a systemd service to run cpupower 2025-05-02 13:52:45 -06:00

README

The cpupower package consists of the following elements:

requirements
------------

On x86 pciutils is needed at runtime (-lpci).
For compilation pciutils-devel (pci/pci.h) and a gcc version
providing cpuid.h is needed.
For both it's not explicitly checked for (yet).


libcpupower
----------

"libcpupower" is a library which offers a unified access method for userspace
tools and programs to the cpufreq core and drivers in the Linux kernel. This
allows for code reduction in userspace tools, a clean implementation of
the interaction to the cpufreq core, and support for both the sysfs and proc
interfaces [depending on configuration, see below].


compilation and installation
----------------------------

There are 2 output directories - one for the build output and another for
the installation of the build results, that is the utility, library,
man pages, etc...

default directory
-----------------

In the case of default directory, build and install process requires no
additional parameters:

build
-----

$ make

The output directory for the 'make' command is the current directory and
its subdirs in the kernel tree:
tools/power/cpupower

install
-------

$ sudo make install

'make install' command puts targets to default system dirs:

-----------------------------------------------------------------------
| Installing file        |               System dir                   |
-----------------------------------------------------------------------
| libcpupower            | /usr/lib                                   |
-----------------------------------------------------------------------
| cpupower               | /usr/bin                                   |
-----------------------------------------------------------------------
| cpufreq-bench_plot.sh  | /usr/bin                                   |
-----------------------------------------------------------------------
| man pages              | /usr/man                                   |
-----------------------------------------------------------------------
| systemd service        | /usr/lib/systemd/system                    |
-----------------------------------------------------------------------
| systemd support script | /usr/libexec                               |
-----------------------------------------------------------------------

To put it in other words it makes build results available system-wide,
enabling any user to simply start using it without any additional steps

custom directory
----------------

There are 2 make's command-line variables 'O' and 'DESTDIR' that setup
appropriate dirs:
'O' - build directory
'DESTDIR' - installation directory. This variable could also be setup in
the 'CONFIGURATION' block of the "Makefile"

build
-----

$ make O=<your_custom_build_catalog>

Example:
$ make O=/home/hedin/prj/cpupower/build

install
-------

$ make O=<your_custom_build_catalog> DESTDIR=<your_custom_install_catalog>

Example:
$ make O=/home/hedin/prj/cpupower/build DESTDIR=/home/hedin/prj/cpupower \
> install

Notice that both variables 'O' and 'DESTDIR' have been provided. The reason
is that the build results are saved in the custom output dir defined by 'O'
variable. So, this dir is the source for the installation step. If only
'DESTDIR' were provided then the 'install' target would assume that the
build directory is the current one, build everything there and install
from the current dir.

The files will be installed to the following dirs:

-----------------------------------------------------------------------
| Installing file        |               System dir                   |
-----------------------------------------------------------------------
| libcpupower            | ${DESTDIR}/usr/lib                         |
-----------------------------------------------------------------------
| cpupower               | ${DESTDIR}/usr/bin                         |
-----------------------------------------------------------------------
| cpufreq-bench_plot.sh  | ${DESTDIR}/usr/bin                         |
-----------------------------------------------------------------------
| man pages              | ${DESTDIR}/usr/man                         |
-----------------------------------------------------------------------
| systemd service        | ${DESTDIR}/usr/lib/systemd/system          |
-----------------------------------------------------------------------
| systemd support script | ${DESTDIR}/usr/libexec                     |
-----------------------------------------------------------------------

If you look at the table for the default 'make' output dirs you will
notice that the only difference with the non-default case is the
${DESTDIR} prefix. So, the structure of the output dirs remains the same
regardles of the root output directory.


clean and uninstall
-------------------

'clean' target is intended for cleanup the build catalog from build results
'uninstall' target is intended for removing installed files from the
installation directory

default directory
-----------------

This case is a straightforward one:
$ make clean
$ make uninstall

custom directory
----------------

Use 'O' command line variable to remove previously built files from the
build dir:
$ make O=<your_custom_build_catalog> clean

Example:
$ make O=/home/hedin/prj/cpupower/build clean

Use 'DESTDIR' command line variable to uninstall previously installed files
from the given dir:
$ make DESTDIR=<your_custom_install_catalog>

Example:
make DESTDIR=/home/hedin/prj/cpupower uninstall


running the tool
----------------

default directory
-----------------

$ sudo cpupower

custom directory
----------------

When it comes to run the utility from the custom build catalog things
become a little bit complicated as 'just run' approach doesn't work.
Assuming that the current dir is '<your_custom_install_catalog>/usr',
issuing the following command:

$ sudo ./bin/cpupower
will produce the following error output:
./bin/cpupower: error while loading shared libraries: libcpupower.so.1:
cannot open shared object file: No such file or directory

The issue is that binary cannot find the 'libcpupower' library. So, we
shall point to the lib dir:
sudo LD_LIBRARY_PATH=lib64/ ./bin/cpupower

systemd service
---------------

A systemd service is also provided to run the cpupower utility at boot with
settings read from a configuration file.

If you want systemd to find the new service after the installation, the service
unit must have been installed in one of the system unit search path directories
(such as '/usr/lib/systemd/system/', which is the default location) and (unless
you are willing to wait for the next reboot) you need to issue the following
command:

$ sudo systemctl daemon-reload

If you want to enable this systemd service, edit '/etc/cpupower-service.conf'
(uncommenting at least one of the options, depending on your preferences)
and then issue the following command:

$ sudo systemctl enable --now cpupower.service


THANKS
------
Many thanks to Mattia Dongili who wrote the autotoolization and
libtoolization, the manpages and the italian language file for cpupower;
to Dave Jones for his feedback and his dump_psb tool; to Bruno Ducrot for his
powernow-k8-decode and intel_gsic tools as well as the french language file;
and to various others commenting on the previous (pre-)releases of 
cpupower.


        Dominik Brodowski