summaryrefslogtreecommitdiff
path: root/tools/power/cpupower
AgeCommit message (Collapse)AuthorFilesLines
2025-01-14pm: cpupower: Add missing residency header changes in cpuidle.h to SWIGJohn B. Wyatt IV1-0/+2
"tools/cpupower: display residency value in idle-info" added a new function to cpuidle.h. This patch adds them to the bindings. Link: https://lore.kernel.org/linux-pm/20240809083728.266697-1-aboorvad@linux.ibm.com/ Tested by compiling both libcpupower and the headers; running the test script that does not use the functions as a basic sanity test. Link: https://lore.kernel.org/r/20250108221852.30771-1-jwyatt@redhat.com Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-27pm: cpupower: Add header changes for cpufreq.h to SWIG bindingsJohn B. Wyatt IV1-0/+3
"cpupower: Add support for showing energy performance preference" added two new functions to cpufreq.h. This patch adds them to the bindings. Link: https://lore.kernel.org/linux-pm/8dc731c3-6586-4265-ae6a-d93ed219a963@linuxfoundation.org/T/#t Tested by compiling both libcpupower and the headers; running the test script that does not use the functions as a basic sanity test. Link: https://lore.kernel.org/r/20241224062329.39606-1-jwyatt@redhat.com Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20pm: cpupower: Add install and uninstall options to bindings makefileJohn B. Wyatt IV2-0/+35
Installs the .so and .py files generated by SWIG to system's site packages directory. This allows the Python bindings to be used system wide. This commit also includes documentation on setting up and installing the Python bindings. Link: https://lore.kernel.org/r/20241219012606.38963-1-jwyatt@redhat.com Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Adjust whitespace for amd-pstate specific printsMario Limonciello1-4/+6
The amd-pstate section is grouped under boost, which isn't appropriate. Adjust the indentation so that it is it's own section. Link: https://lore.kernel.org/r/20241218191144.3440854-8-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Don't fetch maximum latency when EPP is enabledMario Limonciello1-0/+3
When EPP has been enabled the hardware will autonomously change frequencies on it's own and thus there is no latency with changing from the kernel. Avoid doing the maximum latency check when EPP is found. This will apply to both amd-pstate and intel-pstate drivers. Link: https://lore.kernel.org/r/20241218191144.3440854-7-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Add support for showing energy performance preferenceMario Limonciello3-1/+46
The EPP value is useful for characterization of performance. Show it in cpupower frequency-info output. Link: https://lore.kernel.org/r/20241218191144.3440854-6-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Don't try to read frequency from hardware when kernel uses aperfmperfMario Limonciello1-1/+6
When the amd-pstate is in use frequency is set by the hardware and measured by the kernel through using the aperf and mperf registers. There is no direct call to the hardware to indicate current frequency. Detect that this feature is in use and skip the check. Link: https://lore.kernel.org/r/20241218191144.3440854-5-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Add support for amd-pstate preferred core rankingsMario Limonciello1-0/+8
The rankings are useful information to determine if the scheduler is placing tasks appropriately for the hardware. Link: https://lore.kernel.org/r/20241218191144.3440854-4-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Add support for parsing 'enabled' or 'disabled' strings from tableMario Limonciello1-0/+4
When cpufreq_get_sysfs_value_from_table() is passed a table with kernel strings that report 'enabled' or 'disabled' it always returns 0 because these can't cleanly convert to integers. Explicitly look for enabled or disabled strings from the kernel to handle this. Link: https://lore.kernel.org/r/20241218191144.3440854-3-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-20cpupower: Remove spurious return statementMario Limonciello1-1/+0
print_duration() has a return; statement at the end of the function that is not necessary as it's a void function. Link: https://lore.kernel.org/r/20241218191144.3440854-2-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-16cpupower: fix TSC MHz calculationHe Rongguang1-6/+9
Commit 'cpupower: Make TSC read per CPU for Mperf monitor' (c2adb1877b7) changes TSC counter reads per cpu, but left time diff global (from start of all cpus to end of all cpus), thus diff(time) is too large for a cpu's tsc counting, resulting in far less than acutal TSC_Mhz and thus `cpupower monitor` showing far less than actual cpu realtime frequency. /proc/cpuinfo shows frequency: cat /proc/cpuinfo | egrep -e 'processor' -e 'MHz' ... processor : 171 cpu MHz : 4108.498 ... before fix (System 100% busy): | Mperf || Idle_Stats CPU| C0 | Cx | Freq || POLL | C1 | C2 171| 0.77| 99.23| 2279|| 0.00| 0.00| 0.00 after fix (System 100% busy): | Mperf || Idle_Stats CPU| C0 | Cx | Freq || POLL | C1 | C2 171| 0.46| 99.54| 4095|| 0.00| 0.00| 0.00 Fixes: c2adb1877b76 ("cpupower: Make TSC read per CPU for Mperf monitor") Signed-off-by: He Rongguang <herongguang@linux.alibaba.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-10cpupower: revise is_valid flag handling for idle_monitorwangfushuai4-6/+6
The is_valid flag should reflect the validity state of both the XXX_start and XXX_stop functions. But the use of '=' in XXX_stop overwrites the validity state set by XXX_start. This commit changes '=' to '|=' in XXX_stop to preserve and combine the validity state of XXX_start and XXX_stop. Signed-off-by: wangfushuai <wangfushuai@baidu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-12-10pm: cpupower: Makefile: Fix cross compilationPeng Fan1-0/+8
After commit f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross-compiling env params") we would fail to cross compile cpupower in buildroot which uses the recipe at [1] where only the CROSS variable is being set. The issue here is the use of the lazy evaluation for all variables: CC, LD, AR, STRIP, RANLIB, rather than just CROSS. [1]: https://git.buildroot.net/buildroot/tree/package/linux-tools/linux-tool-cpupower.mk.in Fixes: f79473ed9220 ("pm: cpupower: Makefile: Allow overriding cross-compiling env params") Reported-by: Florian Fainelli <florian.fainelli@broadcom.com> Closes: https://lore.kernel.org/all/2bbabd2c-24ef-493c-a199-594e5dada3da@broadcom.com/ Signed-off-by: Peng Fan <peng.fan@nxp.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-22cpupower: add checks for xgettext and msgfmtSiddharth Menon1-0/+12
Check whether xgettext and msgfmt are available on the system before attempting to generate GNU gettext Language Translations. In case of missing dependency, generate error message directing user to install the necessary package. Tested-by: John B. Wyatt IV <jwyatt@redhat.com> Tested-by: John B. Wyatt IV <sageofredondo@gmail.com> Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Siddharth Menon <simeddon@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-16cpupower: Add Chinese Simplified translationKieran Moy2-1/+943
Add Chinese Simplified translations for cpufrequtils package. Signed-off-by: Kieran Moy <kfatyuip@gmail.com> Reviewed-by: Candice Cheng <ccheng@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-02pm: cpupower: bindings: Add test to confirm cpu state is disabledJohn B. Wyatt IV1-0/+16
Add a simple test to confirm and print out the cpu state. Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-02pm: cpupower: bindings: Improve disable c_state blockJohn B. Wyatt IV1-6/+6
This commit fixes a bad comment, removes an unneeded code block, and catches a few more states that cpuidle_state_disable with the test script. Part of the motivation for this commit was I kept forgetting to use sudo. Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-30pm: cpupower: gitignore: Add compile_commands.jsonJohn B. Wyatt IV1-0/+3
A compile_commands.json file is used by the LSP in tools like VSCode and Neovim to look up function and type information. The file is specific to the state of the current system; add it to the gitignore. Note: the kernel root's gitignore has a similar entry: /compile_commands.json I am not sure why they use '/' for a file as it is used for directories. Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-30pm: cpupower: Makefile: Allow overriding cross-compiling env paramsPeng Fan1-6/+6
Allow overriding the cross-comple env parameters to make it easier for Yocto users. Then cross-compiler toolchains to build cpupower with only two steps: - source (toolchain path)/environment-setup-armv8a-poky-linux - make Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-30pm: cpupower: bench: print config file path when open cpufreq-bench.conf failsPeng Fan1-2/+3
Print out the config file path when fopen failed. It will be easy for users to know where to create the file. Since we are here, use strerror to drop the usage of perror. Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-30tools/power/cpupower: Add documentation for some recently introduced optionsTor Vic1-2/+36
The 'cpupower-set' tool has been enhanced with new features: commit f2ab5557119a ("cpupower: Add EPP value change support") commit df8776b03689 ("cpupower: Add support for amd_pstate mode change") commit eb426fc6bdd6 ("cpupower: Add turbo-boost support in cpupower") However, the corresponding manpage was never updated. Add a basic description of these new options to the existing manpage. Commit description updated to fix checkpatch errors: Shuah Khan Signed-off-by: Tor Vic <torvic9@mailbox.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-23pm: cpupower: Clean up bindings gitignoreJohn B. Wyatt IV1-2/+1
Add SPDX identifier to the gitignore. Remove the comment and .i file since the file it references was removed in another patch. This patch depends on Min-Hua Chen's 'pm: cpupower: rename raw_pylibcpupower.i'. Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-13pm: cpupower: rename raw_pylibcpupower.iMin-Hua Chen2-2/+2
The raw_pylibcpupower.i is removed unexpectedly after 'make mrproper' We can reproduce the error by performing the following steps: cd linux-next make mrproper cd tools/power/cpupower/bindings/python make We will get an error message: make: *** No rule to make target 'raw_pylibcpupower.i', needed by 'raw_pylibcpupower_wrap.c'. Stop. The root cause: The *.i files are already used for pre-processor output files and the kernel removes all the *.i files by 'make mrproper'. That explains why the raw_pylibcpupower.i is removed by 'make mrproper'. To fix it, Follow John's suggestion to rename raw_pylibcpupower.i to raw_pylibcpupower.swg. See: https://www.swig.org/Doc4.2/SWIG.html Reviewed-by: John B. Wyatt IV <jwyatt@redhat.com> Reviewed-by: John B. Wyatt IV <sageofredondo@gmail.com> Tested-by: John B. Wyatt IV <jwyatt@redhat.com> Tested-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-06pm:cpupower: Add error warning when SWIG is not installedJohn B. Wyatt IV1-9/+11
Add error message to better explain to the user when SWIG and python-config is missing from the path. Makefile was cleaned up and unneeded elements were removed. Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-06pm:cpupower: Include test_raw_pylibcpupower.pyJohn B. Wyatt IV1-0/+42
This script demonstrates how to make use of, and tests, the bindings. In the future, this script could become part of a larger test suite to test the bindings and libcpupower. Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-06pm:cpupower: Add SWIG bindings files for libcpupowerJohn B. Wyatt IV4-0/+345
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. Added suggestions from Shuah Khan for the README and license discussion. 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 https://swig.org/legal.html and [1] for more details. [1] https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup/ Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-09-06pm:cpupower: Add missing powercap_set_enabled() stub functionJohn B. Wyatt IV1-0/+8
There was a symbol listed in the powercap.h file that was not implemented. Implement it with a stub return of 0. Programs like SWIG require that functions that are defined in the headers be implemented. Fixes: c2294c1496b7 ("cpupower: Introduce powercap intel-rapl library and powercap-info command") Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-08-09tools/cpupower: display residency value in idle-infoAboorva Devarajan3-0/+14
Update cpuidle tool to display the residency value of cpuidle states. This addition provides a clearer and more detailed view of idle state information when using cpuidle-info. -------------------------------- Before Patch: -------------------------------- $ cpupower idle-info CPUidle driver: intel_idle CPUidle governor: menu analyzing CPU 28: Number of idle states: 3 Available idle states: POLL C1 C1E POLL: Flags/Description: CPUIDLE CORE POLL IDLE Latency: 0 Usage: 7448 Duration: 207170 C1: Flags/Description: MWAIT 0x00 Latency: 2 Usage: 7023 Duration: 3736853 C1E: Flags/Description: MWAIT 0x01 Latency: 10 Usage: 18468 Duration: 11396212 -------------------------------- After Patch: -------------------------------- $ cpupower idle-info CPUidle driver: intel_idle CPUidle governor: menu analyzing CPU 12: Number of idle states: 3 Available idle states: POLL C1 C1E POLL: Flags/Description: CPUIDLE CORE POLL IDLE Latency: 0 Residency: 0 Usage: 1950 Duration: 38458 C1: Flags/Description: MWAIT 0x00 Latency: 2 Residency: 2 Usage: 10688 Duration: 7133020 C1E: Flags/Description: MWAIT 0x01 Latency: 10 Residency: 20 Usage: 22356 Duration: 15687259 -------------------------------- Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-07-03cpupower: fix lib default installation pathRoman Storozhenko1-9/+1
Invocation the tool built with the default settings fails: $ cpupower cpupower: error while loading shared libraries: libcpupower.so.1: cannot open shared object file: No such file or directory The issue is that Makefile puts the library to "/usr/lib64" dir for a 64 bit machine. This is wrong. According to the "File hierarchy standard specification: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf "/usr/lib<qual>" dirs are intended for alternative-format libraries (e.g., "/usr/lib32" for 32-bit libraries on a 64-bit machine (optional)). The utility is built for the current machine and doesn't handle 'CROSS_COMPILE' and 'ARCH' env variables. It also doesn't change bit depth. So the result is always the same - binary for x86_64 architecture. Therefore the library should be put in the '/usr/lib' dir regardless of the build options. This is the case for all the distros that comply with the 'File Hierarchy Standard 3.0" by Linux Foundation. Most of the distros comply with it. For example, one can check this by examining the "/usr/lb64" dir on debian-based distros and find that it contains only "/usr/lib64/ld-linux-x86-64.so.2". And examine that "/usr/lib" contains both 32 and 64 bit code: find /usr/lib -name "*.so*" -type f | xargs file | grep 32-bit find /usr/lib -name "*.so*" -type f | xargs file | grep 64-bit Fix the issue by changing library destination dir to "/usr/lib". Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-29cpupower: Disable direct build of the 'bench' subprojectRoman Storozhenko1-0/+5
Execution of the 'make' command in the 'bench' subfolder causes the following error: $ make O=cpupower/build/ DESTDIR=cpupower/install/ -j8 " CC " cpupower/build//main.o " CC " cpupower/build//parse.o /bin/sh: 1: " CC "cpupower/build//system.o CC : not found make: *** [Makefile:21: cpupower/build//main.o] Error 127 make: *** Waiting for unfinished jobs.... /bin/sh: 1: CC : not found /bin/sh: 1: CC : not found make: *** [Makefile:21: cpupower/build//parse.o] Error 127 make: *** [Makefile:21: cpupower/build//system.o] Error 127 The makefile uses variables defined in the main project makefile and it is not intended to run standalone. The reason is that 'bench' subproject depends on the 'libcpupower' library, see the 'compile-bench' target in the main makefile. Add a check that prevents standalone execution of the 'bench' makefile. Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-20cpupower: Change the var type of the 'monitor' subcommand display modeRoman Storozhenko1-1/+1
There is a type 'enum operation_mode_e' contains the display modes of the 'monitor' subcommand. This type isn't used though, instead the variable 'mode' is of a simple 'int' type. Change 'mode' variable type from 'int' to 'enum operation_mode_e' in order to improve compiler type checking. Built and tested this with different monitor cmdline params. Everything works as expected, that is nothing changed and no regressions encountered. Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-20cpupower: Remove absent 'v' parameter from monitor man pageRoman Storozhenko1-5/+0
Remove not supported '-v' parameter from the cpupower's 'monitor' command description. There is a '-v' parameter described in cpupower's 'monitor' command man page. It isn't supported at the moment, and perhaps has never been supported. When I run the monitor with this parameter I get the following: $ sudo LD_LIBRARY_PATH=lib64/ bin/cpupower monitor -v monitor: invalid option -- 'v' invalid or unknown argument $ sudo LD_LIBRARY_PATH=lib64/ bin/cpupower monitor -V monitor: invalid option -- 'V' invalid or unknown argument Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-18cpupower: Improve cpupower build process descriptionRoman Storozhenko1-10/+150
Enhance cpupower build process description with the information on building and installing the utility to the user defined directories as well as with the information on the way of running the utility from the custom defined installation directory. Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-18cpupower: Add 'help' target to the main MakefileRoman Storozhenko1-1/+36
Make "cpupower" building process more user friendly by adding 'help' target to the main makefile. This target describes various build and cleaning options available to the user. Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-06-18cpupower: Replace a dead reference link with working onesRoman Storozhenko1-3/+5
Replace a dead reference link to a turbo boost technology description with a reference to a root page of the technology on the Intel site, and add another one, describing power management technology, which includes short description of the turbo boost. Signed-off-by: Roman Storozhenko <romeusmeister@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-05-28tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUsDhananjay Ugwekar1-3/+23
Update cpupower's P-State frequency calculation and reporting with AMD Family 1Ah+ processors, when using the acpi-cpufreq driver. This is due to a change in the PStateDef MSR layout in AMD Family 1Ah+. Tested on 4th and 5th Gen AMD EPYC system Signed-off-by: Ananth Narayan <Ananth.Narayan@amd.com> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-03-06Fix cpupower-frequency-info.1 man page typoJan Kratochvil1-1/+1
cpupower-frequency-info.1 man page type is incorrect for related-cpus. Fix it. utils/cpufreq-info.c {"related-cpus", no_argument, NULL, 'r'}, {"affected-cpus", no_argument, NULL, 'a'}, Fixed changelog before applying: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Jan Kratochvil <jan@jankratochvil.net> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-01-22tools cpupower bench: Override CFLAGS assignmentsStanley Chan1-1/+1
Allow user to specify outside CFLAGS values as make argument Corrects an issue where CFLAGS is passed as a make argument for cpupower, but bench's makefile does not inherit and append to them. Signed-off-by: Stanley Chan <schan@cloudflare.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-10-25cpupower: fix reference to nonexistent documentVegard Nossum1-1/+1
This file was renamed from .txt to .rst and left a dangling reference. Fix it. Fixes: 151f4e2bdc7a ("docs: power: convert docs to ReST and rename to *.rst") Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Mark Brown <broonie@kernel.org> Cc: Srivatsa S. Bhat (VMware) <srivatsa@csail.mit.edu> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Len Brown <len.brown@intel.com> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-08-17cpupower: Add Georgian translation to Makefile LANGUAGESShuah Khan1-1/+1
Commit 4680b734e729 ("cpupower: Add Georgian translation") added new language support. This change didn't add "ka" to Makefile LANGUAGES variable. Add it now. Reported-by: Temuri Doghonadze <temuri.doghonadze@gmail.com> Reported-by: Zurab Kargareteli <zuraxt@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Fix cpuidle_set to accept only numeric values for idle-set operation.Likhitha Korrapati1-9/+7
For both the d and e options in 'cpupower idle_set' command, an atoi() conversion is done without checking if the input argument is all numeric. So, an atoi conversion is done on any character provided as input and the CPU idle_set operation continues with that integer value, which may not be what is intended or entirely correct. The output of cpuidle-set before patch is as follows: [root@xxx cpupower]# cpupower idle-set -e 1$ Idlestate 1 enabled on CPU 0 [snip] Idlestate 1 enabled on CPU 47 [root@xxx cpupower]# cpupower idle-set -e 11 Idlestate 11 not available on CPU 0 [snip] Idlestate 11 not available on CPU 47 [root@xxx cpupower]# cpupower idle-set -d 12 Idlestate 12 not available on CPU 0 [snip] Idlestate 12 not available on CPU 47 [root@xxx cpupower]# cpupower idle-set -d qw Idlestate 0 disabled on CPU 0 [snip] Idlestate 0 disabled on CPU 47 This patch adds a check for both d and e options in cpuidle-set.c to see that the idle_set value is all numeric before doing a string-to-int conversion using strtol(). The output of cpuidle-set after the patch is as below: [root@xxx cpupower]# ./cpupower idle-set -e 1$ Bad idle_set value: 1$. Integer expected [root@xxx cpupower]# ./cpupower idle-set -e 11 Idlestate 11 not available on CPU 0 [snip] Idlestate 11 not available on CPU 47 [root@xxx cpupower]# ./cpupower idle-set -d 12 Idlestate 12 not available on CPU 0 [snip] Idlestate 12 not available on CPU 47 [root@xxx cpupower]# ./cpupower idle-set -d qw Bad idle_set value: qw. Integer expected Signed-off-by: Brahadambal Srinivasan <latha@linux.vnet.ibm.com> Signed-off-by: Likhitha Korrapati <likhitha@linux.ibm.com> Tested-by: Pavithra Prakash <pavrampu@linux.vnet.ibm.com> Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Add turbo-boost support in cpupowerWyes Karny3-1/+42
If boost sysfs (/sys/devices/system/cpu/cpufreq/boost) file is present turbo-boost is feature is supported in the hardware. By default this feature should be enabled. But to disable/enable it write to the sysfs file. Use the same to control this feature via cpupower. To enable: cpupower set --turbo-boost 1 To disable: cpupower set --turbo-boost 0 Acked-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Tested-by: Perry Yuan <Perry.Yuan@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Add support for amd_pstate mode changeWyes Karny3-2/+43
amd_pstate supports changing of its mode dynamically via `status` sysfs file. Add the same capability in cpupower. To change the mode to active mode use below command: cpupower set --amd-pstate-mode active Acked-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Tested-by: Perry Yuan <Perry.Yuan@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Add EPP value change supportWyes Karny3-1/+46
amd_pstate and intel_pstate active mode drivers support energy performance preference feature. Through this user can convey it's energy/performance preference to platform. Add this value change capability to cpupower. To change the EPP value use below command: cpupower set --epp performance Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Tested-by: Perry Yuan <Perry.Yuan@amd.com> Acked-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Add is_valid_path APIWyes Karny2-0/+8
Add is_valid_path API to check whether the sysfs file is present or not. Suggested-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Tested-by: Perry Yuan <Perry.Yuan@amd.com> Acked-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-19cpupower: Recognise amd-pstate active mode driverWyes Karny1-1/+1
amd-pstate active mode driver name is "amd-pstate-epp". Use common prefix for string matching condition to recognise amd-pstate active mode driver. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Perry Yuan <Perry.Yuan@amd.com> Acked-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-07-13cpupower: Bump soname versionBen Hutchings1-1/+1
Several functions in the libcpupower API are renamed or removed in Linux 4.7. This is an backward-incompatible ABI change, so the library soname should change from libcpupower.so.0 to libcpupower.so.1. Fixes: ac5a181d065d ("cpupower: Add cpuidle parts into library") Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Salvatore Bonaccorso <carnil@debian.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-05-08cpupower: Make TSC read per CPU for Mperf monitorWyes Karny1-17/+14
System-wide TSC read could cause a drift in C0 percentage calculation. Because if first TSC is read and then one by one mperf is read for all cpus, this introduces drift between mperf reading of later CPUs and TSC reading. To lower this drift read TSC per CPU and also just after mperf read. This technique improves C0 percentage calculation in Mperf monitor. Before fix: (System 100% busy) | Mperf || RAPL || Idle_Stats PKG|CORE| CPU| C0 | Cx | Freq || pack | core || POLL | C1 | C2 0| 0| 0| 87.15| 12.85| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 0| 256| 84.62| 15.38| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 1| 1| 87.15| 12.85| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 1| 257| 84.08| 15.92| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 2| 2| 86.61| 13.39| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 2| 258| 83.26| 16.74| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 3| 3| 86.61| 13.39| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 3| 259| 83.60| 16.40| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 4| 4| 86.33| 13.67| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 4| 260| 83.33| 16.67| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 5| 5| 86.06| 13.94| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 5| 261| 83.05| 16.95| 2695||168659003|3970468|| 0.00| 0.00| 0.00 0| 6| 6| 85.51| 14.49| 2695||168659003|3970468|| 0.00| 0.00| 0.00 After fix: (System 100% busy) | Mperf || RAPL || Idle_Stats PKG|CORE| CPU| C0 | Cx | Freq || pack | core || POLL | C1 | C2 0| 0| 0| 98.03| 1.97| 2415||163295480|3811189|| 0.00| 0.00| 0.00 0| 0| 256| 98.50| 1.50| 2394||163295480|3811189|| 0.00| 0.00| 0.00 0| 1| 1| 99.99| 0.01| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 1| 257| 99.99| 0.01| 2375||163295480|3811189|| 0.00| 0.00| 0.00 0| 2| 2| 99.99| 0.01| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 2| 258|100.00| 0.00| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 3| 3|100.00| 0.00| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 3| 259| 99.99| 0.01| 2435||163295480|3811189|| 0.00| 0.00| 0.00 0| 4| 4|100.00| 0.00| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 4| 260|100.00| 0.00| 2435||163295480|3811189|| 0.00| 0.00| 0.00 0| 5| 5| 99.99| 0.01| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 5| 261|100.00| 0.00| 2435||163295480|3811189|| 0.00| 0.00| 0.00 0| 6| 6|100.00| 0.00| 2401||163295480|3811189|| 0.00| 0.00| 0.00 0| 6| 262|100.00| 0.00| 2435||163295480|3811189|| 0.00| 0.00| 0.00 Cc: Thomas Renninger <trenn@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Dominik Brodowski <linux@dominikbrodowski.net> Fixes: 7fe2f6399a84 ("cpupowerutils - cpufrequtils extended with quite some features") Signed-off-by: Wyes Karny <wyes.karny@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-05-08cpupower:Fix resource leaks in sysfs_get_enabled()Hao Zeng1-7/+16
The sysfs_get_enabled() opened file processor not closed, may cause a file handle leak. Putting error handling and resource cleanup code together makes the code easy to maintain and read. Removed the unnecessary else if branch from the original function, as it should return an error in cases other than '0'. Signed-off-by: Hao Zeng <zenghao@kylinos.cn> Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-12-01cpupower: rapl monitor - shows the used power consumption in uj for each ↵Thomas Renninger4-3/+154
rapl domain This CPU power monitor shows the power consumption as exposed by the powercap subsystem, cmp with: Documentation/power/powercap/powercap.rst cpupower monitor -m RAPL | RAPL CPU| pack | core | unco 0|6853926|967832|442381 8|6853926|967832|442381 1|6853926|967832|442381 9|6853926|967832|442381 Unfortunately RAPL domains cannot be directly mapped to the corresponding CPU socket/package, core it belongs to. Not sure this is possible at all with the current data exposed from the kernel. Still it can be worthful information for developers trying to optimize power consumption of workloads or their system in general. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Zhang Rui <rui.zhang@intel.com> CC: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>