linux/tools/power/cpupower/lib
John B. Wyatt IV f89cb9cba7 cpupower: Implement CPU physical core querying
This patch is also an issue report. get_cpu_topology will always save
into cpupower_topology a cores size of 0. The code to handle this looks
like it was commented out, and what is commented out is missing a curly
bracket.

https://elixir.bootlin.com/linux/v6.13.5/source/tools/power/cpupower/lib/cpupower.c#L206-L212

Inspiration was taken from psutil to implement this by querying
core_cpu_list. Instead of using a hashmap, I used a sorted array, and
counted the number of valid unique strings. The counting of this takes
place before the qsort for .pkg as the following code says it is
dependent on the order of that sort.

The previous code claimed Intel CPUs are not numbered correctly. I was
not able to reproduce that issue and removed that comment and the code.

This commit was tested with the libcpupower SWIG Python bindings and
performed correctly on 4 different setups. The most notable is the
Framework Intel laptop; a hybrid system of 4 P cores (8 threads) and 8 E
cores (8 threads).

The 4 setups: A 4 core virt-manager VM running Fedora 41 4c/4t (specs not
listed) was tested as a sanity test for VMs. A Lenovo Ryzen 7 Pro 7840HS
8c/16t. A Supermico Intel(R) Xeon(R) Gold 6330 CPU w/ 56c/112t with 2 CPU
sockets. A Framework 12th Gen Intel(R) Core(TM) i5-1240P with hybrid
cores.

CPU(s):                   16
  On-line CPU(s) list:    0-15
Vendor ID:                AuthenticAMD
  Model name:             AMD Ryzen 7 PRO 7840HS w/ Radeon 780M Graphics
    CPU family:           25
    Model:                116
    Thread(s) per core:   2
    Core(s) per socket:   8
    Socket(s):            1
    Stepping:             1

CPU(s):                   112
  On-line CPU(s) list:    0-111
Vendor ID:                GenuineIntel
  BIOS Vendor ID:         Intel(R) Corporation
  Model name:             Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz
    BIOS Model name:      Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz  CPU @ 2.0GHz
    BIOS CPU family:      179
    CPU family:           6
    Model:                106
    Thread(s) per core:   2
    Core(s) per socket:   28
    Socket(s):            2
    Stepping:             6

CPU(s):                   16
  On-line CPU(s) list:    0-15
Vendor ID:                GenuineIntel
  Model name:             12th Gen Intel(R) Core(TM) i5-1240P
    CPU family:           6
    Model:                154
    Thread(s) per core:   2
    Core(s) per socket:   12
    Socket(s):            1
    Stepping:             3

Link: https://lore.kernel.org/r/20250305210901.24177-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>
2025-03-06 13:27:57 -07:00
..
acpi_cppc.c
acpi_cppc.h
cpufreq.c cpupower: Add support for showing energy performance preference 2024-12-20 09:12:07 -07:00
cpufreq.h cpupower: Add support for showing energy performance preference 2024-12-20 09:12:07 -07:00
cpuidle.c tools/cpupower: display residency value in idle-info 2024-08-09 10:32:33 -06:00
cpuidle.h tools/cpupower: display residency value in idle-info 2024-08-09 10:32:33 -06:00
cpupower.c cpupower: Implement CPU physical core querying 2025-03-06 13:27:57 -07:00
cpupower.h cpupower: Implement CPU physical core querying 2025-03-06 13:27:57 -07:00
cpupower_intern.h cpupower: Add is_valid_path API 2023-07-18 16:06:44 -06:00
powercap.c pm:cpupower: Add missing powercap_set_enabled() stub function 2024-09-05 18:48:57 -06:00
powercap.h cpupower: Introduce powercap intel-rapl library and powercap-info command 2022-11-30 16:48:28 -07:00