Commit Graph

1374 Commits

Author SHA1 Message Date
David Arcari 184b291b6a tools/power turbostat: version 2025.09.09
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 5e98a5e73edcc4114c5ad10596db87e24f50ee4d
Author: Len Brown <len.brown@intel.com>
Date:   Sat Aug 9 21:08:26 2025 -0400

    tools/power turbostat: version 2025.09.09

    Probe and display L3 Cache topology
    Add ability to average an added counter
            (useful for pre-integrated "counters", such as Watts)
    Break the limit of 64 built-in counters.
    Assorted bug fixes and minor feature tweaks

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:45 -04:00
David Arcari 4bba9fb6ae tools/power turbostat: Handle non-root legacy-uncore sysfs permissions
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit e60a13bcef206795d3ddf82f130fe8f570176d06
Author: Len Brown <len.brown@intel.com>
Date:   Sat Aug 9 16:31:31 2025 -0400

    tools/power turbostat: Handle non-root legacy-uncore sysfs permissions

    /sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/
    may be readable by all, but
    /sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/current_freq_khz
    may be readable only by root.

    Non-root turbostat users see complaints in this scenario.

    Fail probe of the interface if we can't read current_freq_khz.

    Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Original-patch-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:45 -04:00
David Arcari 5e81854f76 tools/power turbostat: standardize PER_THREAD_PARAMS
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 378e901160256d2ab66e45ffb97afaca51e65706
Author: Len Brown <len.brown@intel.com>
Date:   Fri Aug 8 19:30:07 2025 -0400

    tools/power turbostat: standardize PER_THREAD_PARAMS

    use a macro for PER_THREAD_PARAMS to make adding one later more clear.

    no functional change

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 6ca78b42af tools/power turbostat: Fix DMR support
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 3a088b07c4f10bf577f4a2392111704195a794ba
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Wed Jun 11 14:50:26 2025 +0800

    tools/power turbostat: Fix DMR support

    Together with the RAPL MSRs, there are more MSRs gone on DMR, including
    PLR (Perf Limit Reasons), and IRTL (Package cstate Interrupt Response
    Time Limit) MSRs. The configurable TDP info should also be retrieved
    from TPMI based Intel Speed Select Technology feature.

    Remove the access of these MSRs for DMR. Improve the DMR platform
    feature table to make it more readable at the same time.

    Fixes: 83075bd59de2 ("tools/power turbostat: Add initial support for DMR")
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 3606d3cd5a tools/power turbostat: add format "average" for external attributes
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit dcd1c379b0f179763956e8596ad99912165a95ec
Author: Michael Hebenstreit <michael.hebenstreit@intel.com>
Date:   Fri Aug 8 15:57:53 2025 -0400

    tools/power turbostat: add format "average" for external attributes

    External atributes with format "raw" are not printed in summary lines
    for nodes/packages (or with option -S). The new format "average"
    behaves like "raw" but also adds the summary data

    Signed-off-by: Michael Hebenstreit <michael.hebenstreit@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 38bdfda73a tools/power turbostat: delete GET_PKG()
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit a5015d945de6003cf813af2bb11189982f5b3d54
Author: Len Brown <len.brown@intel.com>
Date:   Tue Jul 22 00:17:04 2025 -0400

    tools/power turbostat: delete GET_PKG()

    pkg_base[pkg_id] is a simple array of structure pointers,
    let the compiler treat it that way.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 4dc1cd0606 tools/power turbostat: probe and display L3 cache topology
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 5f961fb2a7d8f4d89d64a9e2cd584738de5f9c58
Author: Len Brown <len.brown@intel.com>
Date:   Mon Jul 14 23:33:55 2025 -0400

    tools/power turbostat: probe and display L3 cache topology

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari c3039d85a7 tools/power turbostat: Support more than 64 built-in-counters
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 8d14a098b47cc7e5cfa703b9e015d6ca1074489a
Author: Len Brown <len.brown@intel.com>
Date:   Sat Jul 12 16:16:56 2025 -0400

    tools/power turbostat: Support more than 64 built-in-counters

    We have out-grown the ability to use a 64-bit memory location
    to inventory every possible built-in counter.
    Leverage the the CPU_SET(3) macros to break this barrier.

    Also, break the Joules & Watts counters into two,
    since we can no longer 'or' them together...

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 7b10b4add6 tools/power turbostat.8: Document Totl%C0, Any%C0, GFX%C0, CPUGFX% columns
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit d240b441b5cbb389f90fce37edb9ef76a3c9a42b
Author: Len Brown <len.brown@intel.com>
Date:   Mon Jun 23 13:24:25 2025 -0700

    tools/power turbostat.8: Document Totl%C0, Any%C0, GFX%C0, CPUGFX% columns

    Explain the meaning of the Totl%C0, Any%C0, GFX%C0, CPUGFX% columns.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 6295494223 tools/power turbostat: Fix bogus SysWatt for forked program
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 44207567fa64e995d4f2ec2d45af4c947cb1a465
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Tue Jun 17 20:48:59 2025 +0800

    tools/power turbostat: Fix bogus SysWatt for forked program

    Similar to delta_cpu(), delta_platform() is called in turbostat main
    loop. This ensures accurate SysWatt readings in periodic monitoring mode
    $ sudo turbostat -S -q --show power -i 1
    CoreTmp PkgTmp  PkgWatt CorWatt GFXWatt RAMWatt PKG_%   RAM_%   SysWatt
    60      61      6.21    1.13    0.16    0.00    0.00    0.00    13.07
    58      61      6.00    1.07    0.18    0.00    0.00    0.00    12.75
    58      61      5.74    1.05    0.17    0.00    0.00    0.00    12.22
    58      60      6.27    1.11    0.24    0.00    0.00    0.00    13.55

    However, delta_platform() is missing for forked program and causes bogus
    SysWatt reporting,
    $ sudo turbostat -S -q --show power sleep 1
    1.004736 sec
    CoreTmp PkgTmp  PkgWatt CorWatt GFXWatt RAMWatt PKG_%   RAM_%   SysWatt
    57      58      6.05    1.02    0.16    0.00    0.00    0.00    0.03

    Add missing delta_platform() for forked program.

    Fixes: e5f687b89bc2 ("tools/power turbostat: Add RAPL psys as a built-in counter")
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari b2db7857da tools/power turbostat: Handle cap_get_proc() ENOSYS
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit d34fe509f5f76d9dc36291242d67c6528027ebbd
Author: Calvin Owens <calvin@wbinvd.org>
Date:   Fri Jun 13 19:20:28 2025 -0700

    tools/power turbostat: Handle cap_get_proc() ENOSYS

    Kernels configured with CONFIG_MULTIUSER=n have no cap_get_proc().
    Check for ENOSYS to recognize this case, and continue on to
    attempt to access the requested MSRs (such as temperature).

    Signed-off-by: Calvin Owens <calvin@wbinvd.org>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari a038713dd1 tools/power turbostat: Fix build with musl
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 6ea0ec1b958a84aff9f03fb0ae4613a4d5bed3ea
Author: Calvin Owens <calvin@wbinvd.org>
Date:   Fri Jun 13 09:54:23 2025 -0700

    tools/power turbostat: Fix build with musl

    turbostat.c: In function 'parse_int_file':
        turbostat.c:5567:19: error: 'PATH_MAX' undeclared (first use in this function)
         5567 |         char path[PATH_MAX];
              |                   ^~~~~~~~

        turbostat.c: In function 'probe_graphics':
        turbostat.c:6787:19: error: 'PATH_MAX' undeclared (first use in this function)
         6787 |         char path[PATH_MAX];
              |                   ^~~~~~~~

    Signed-off-by: Calvin Owens <calvin@wbinvd.org>
    Reviewed-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:44 -04:00
David Arcari 778ad4ca89 tools/power turbostat: verify arguments to params --show and --hide
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit d44c40e4e30f6aa1ca8ed1c8b715d4c5829f0560
Author: Len Brown <len.brown@intel.com>
Date:   Tue Jun 10 18:07:49 2025 -0400

    tools/power turbostat: verify arguments to params --show and --hide

    $ sudo turbostat --quiet --show junk
    turbostat: Counter 'junk' can not be added.

    Previously, invalid arguments to --show and --hide were silently ignored

    Acked-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari dcb3b806a6 tools/power turbostat: regression fix: --show C1E%
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 5d939fbdd480cdf276eccc01eda3ed41e37d3f8a
Author: Len Brown <len.brown@intel.com>
Date:   Mon Jun 9 23:34:04 2025 -0400

    tools/power turbostat: regression fix: --show C1E%

    The new default idle counter groupings broke "--show C1E%" (or any other C-state %)

    Also delete a stray debug printf from the same offending commit.

    Reported-by: Zhang Rui <rui.zhang@intel.com>
    Fixes: ec4acd3166d8 ("tools/power turbostat: disable "cpuidle" invocation counters, by default")
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari 421ff0dd72 tools/power turbostat: version 2025.06.08
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 42fd37dcc432df1ea1987232d41bb84fcb7e150c
Author: Len Brown <len.brown@intel.com>
Date:   Sun Jun 8 12:31:59 2025 -0400

    tools/power turbostat: version 2025.06.08

    Add initial DMR support, which required smarter RAPL probe
    Fix AMD MSR RAPL energy reporting
    Add RAPL power limit configuration output
    Minor fixes

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari 98926ddccb tools/power turbostat: Add initial support for BartlettLake
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit d8c0f5d973004f2ac86375ea54fae9625ac594fb
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri Apr 18 14:04:26 2025 +0800

    tools/power turbostat: Add initial support for BartlettLake

    Add initial support for BartlettLake.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari 76a6638b00 tools/power turbostat: Add initial support for DMR
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 83075bd59de25f5c9238a583008540914946f23e
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Mon Mar 4 14:54:40 2024 +0800

    tools/power turbostat: Add initial support for DMR

    Add initial support for DMR.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari 09ee7d3a93 tools/power turbostat: Dump RAPL sysfs info
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 2a535d6cc3b4831cc6dc7e248f2fb4afeeec591d
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri May 30 14:01:31 2025 +0800

    tools/power turbostat: Dump RAPL sysfs info

    for example:

    intel-rapl:1: psys 28.0s:100W 976.0us:100W
    intel-rapl:0: package-0 28.0s:57W,max:15W 2.4ms:57W
    intel-rapl:0/intel-rapl:0:0: core disabled
    intel-rapl:0/intel-rapl:0:1: uncore disabled
    intel-rapl-mmio:0: package-0 28.0s:28W,max:15W 2.4ms:57W

    [lenb: simplified format]

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

    squish me

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari ec9eb73ba1 tools/power turbostat: Avoid probing the same perf counters
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 69078520fdf1525212a23a80dc79e1a75f2062f6
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri May 30 08:09:28 2025 +0800

    tools/power turbostat: Avoid probing the same perf counters

    For the RAPL package energy status counter, Intel and AMD share the same
    perf_subsys and perf_name, but with different MSR addresses.

    Both rapl_counter_arch_infos[0] and rapl_counter_arch_infos[1] are
    introduced to describe this counter for different Vendors.

    As a result, the perf counter is probed twice, and causes a failure in
    in get_rapl_counters() because expected_read_size and actual_read_size
    don't match.

    Fix the problem by skipping the already probed counter.

    Note, this is not a perfect fix. For example, if different
    vendors/platforms use the same MSR value for different purpose, the code
    can be fooled when it probes a rapl_counter_arch_infos[] entry that does
    not belong to the running Vendor/Platform.

    In a long run, better to put rapl_counter_arch_infos[] into the
    platform_features so that this becomes Vendor/Platform specific.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari 4e0337284e tools/power turbostat: Allow probing RAPL with platform_features->rapl_msrs cleared
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit ff3d019e98db83ce2b5eb395333bc2518b37f4f0
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 17:44:50 2025 +0800

    tools/power turbostat: Allow probing RAPL with platform_features->rapl_msrs cleared

    platform_features->rapl_msrs describes the RAPL MSRs supported. While
    RAPL Perf counters can be exposed from different kernel backend drivers,
    e.g. RAPL MSR I/F driver, or RAPL TPMI I/F driver.

    Thus, turbostat should first blindly probe all the available RAPL Perf
    counters, and falls back to the RAPL MSR counters if they are listed in
    platform_features->rapl_msrs.

    With this, platforms that don't have RAPL MSRs can clear the
    platform_features->rapl_msrs bits and use RAPL Perf counters only.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:43 -04:00
David Arcari aa8581e1aa tools/power turbostat: Clean up add perf/msr counter logic
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 0362337968ad252e6563fff131906a43450d8940
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 17:35:17 2025 +0800

    tools/power turbostat: Clean up add perf/msr counter logic

    Increase the code readability by moving the no_perf/no_msr flag and the
    cai->perf_name/cai->msr sanity checks into the counter probe functions.

    No functional change.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 071954c59e tools/power turbostat: Introduce add_msr_counter()
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 1ab2e19b4c52ee08700938d52024d85bd15c9721
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 15:58:51 2025 +0800

    tools/power turbostat: Introduce add_msr_counter()

    probe_rapl_msr() is reused for probing RAPL MSR counters, cstate MSR
    counters and MPERF/APERF/SMI MSR counters, thus its name is misleading.

    Similar to add_perf_counter(), introduce add_msr_counter() to probe a
    counter via MSR. Introduce wrapper function add_rapl_msr_counter() at
    the same time to add extra check for Zero return value for specified
    RAPL counters.

    No functional change intended.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 76969e7efb tools/power turbostat: Remove add_msr_perf_counter_()
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 3403e89f97ce71e473a5128ea389cb83bc27e7a9
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 17:40:08 2025 +0800

    tools/power turbostat: Remove add_msr_perf_counter_()

    As the only caller of add_msr_perf_counter_(), add_msr_perf_counter()
    just gives extra debug output on top. There is no need to keep both
    functions.

    Remove add_msr_perf_counter_() and move all the logic to
    add_msr_perf_counter().

    No functional change.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 816cd23831 tools/power turbostat: Remove add_cstate_perf_counter_()
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 4d6ced7bef959701533d1e5c003872e837318e38
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 15:43:59 2025 +0800

    tools/power turbostat: Remove add_cstate_perf_counter_()

    As the only caller of add_cstate_perf_counter_(),
    add_cstate_perf_counter() just gives extra debug output on top. There is
    no need to keep both functions.

    Remove add_cstate_perf_counter_() and move all the logic to
    add_cstate_perf_counter().

    No functional change.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 55872ea28d tools/power turbostat: Remove add_rapl_perf_counter_()
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit c8bca955da22269db80576c676eb50a5ef156832
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 12:06:22 2025 +0800

    tools/power turbostat: Remove add_rapl_perf_counter_()

    As the only caller of add_rapl_perf_counter_(), add_rapl_perf_counter()
    just gives extra debug output on top. There is no need to keep both
    functions.

    Remove add_rapl_perf_counter_() and move all the logic to
    add_rapl_perf_counter().

    No functional change.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 1cd92a101d tools/power turbostat: Quit early for unsupported RAPL counters
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 57b53787f0f7845eb30aedde75464aca37906985
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat May 17 10:26:14 2025 +0800

    tools/power turbostat: Quit early for unsupported RAPL counters

    Quit early for unsupported RAPL counters.

    No functional change.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari e7833158f0 tools/power turbostat: Always check rapl_joules flag
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit fdea6b883b05b101b6e85674e1c3f58234229bfa
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri May 30 14:00:33 2025 +0800

    tools/power turbostat: Always check rapl_joules flag

    rapl_joules bit should always be checked even if
    platform_features->rapl_msrs is not set or no_msr flag is used.

    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 69619d57d7 tools/power turbostat: Fix AMD package-energy reporting
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit adb49732c8c63665dd3476e8e6b7c67a0f851245
Author: Gautham R. Shenoy <gautham.shenoy@amd.com>
Date:   Thu May 29 17:18:25 2025 +0530

    tools/power turbostat: Fix AMD package-energy reporting

    commit 05a2f07db888 ("tools/power turbostat: read RAPL counters via
    perf") that adds support to read RAPL counters via perf defines the
    notion of a RAPL domain_id which is set to physical_core_id on
    platforms which support per_core_rapl counters (Eg: AMD processors
    Family 17h onwards) and is set to the physical_package_id on all the
    other platforms.

    However, the physical_core_id is only unique within a package and on
    platforms with multiple packages more than one core can have the same
    physical_core_id and thus the same domain_id. (For eg, the first cores
    of each package have the physical_core_id = 0). This results in all
    these cores with the same physical_core_id using the same entry in the
    rapl_counter_info_perdomain[]. Since rapl_perf_init() skips the
    perf-initialization for cores whose domain_ids have already been
    visited, cores that have the same physical_core_id always read the
    perf file corresponding to the physical_core_id of the first package
    and thus the package-energy is incorrectly reported to be the same
    value for different packages.

    Note: This issue only arises when RAPL counters are read via perf and
    not when they are read via MSRs since in the latter case the MSRs are
    read separately on each core.

    Fix this issue by associating each CPU with rapl_core_id which is
    unique across all the packages in the system.

    Fixes: 05a2f07db888 ("tools/power turbostat: read RAPL counters via perf")
    Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari 6774522c05 tools/power turbostat: Fix RAPL_GFX_ALL typo
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit b4a734d3839971f590ce8c435ea5b0d3762b37a8
Author: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Date:   Fri May 23 13:36:59 2025 +0530

    tools/power turbostat: Fix RAPL_GFX_ALL typo

    Fix typo in the currently unused RAPL_GFX_ALL macro definition.

    Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:42 -04:00
David Arcari efc09cc3a7 tools/power turbostat: Add Android support for MSR device handling
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 5663785ae02f66acf64f285a40e35abd21b8a7b2
Author: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Date:   Thu May 22 14:19:46 2025 +0530

    tools/power turbostat: Add Android support for MSR device handling

    It uses /dev/msrN device paths on Android instead of /dev/cpu/N/msr,
    updates error messages and permission checks to reflect the Android
    device path, and wraps platform-specific code with #if defined(ANDROID)
    to ensure correct behavior on both Android and non-Android systems.
    These changes improve compatibility and usability of turbostat on
    Android devices.

    Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:41 -04:00
David Arcari 8815b8595a tools/power turbostat.8: pm_domain wording fix
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit c967900fcb00927c1758c16130be5cd771993198
Author: Len Brown <len.brown@intel.com>
Date:   Fri Apr 18 17:54:39 2025 -0400

    tools/power turbostat.8: pm_domain wording fix

    turbostat.8: clarify that uncore "domains" are Power Management domains,
    aka pm_domains.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:41 -04:00
David Arcari cd56d1288e tools/power turbostat.8: fix typo: idle_pct should be pct_idle
JIRA: https://issues.redhat.com/browse/RHEL-110614

commit 394c1127abd9e8ee829bbfaddb959728d60b0cdc
Author: Len Brown <len.brown@intel.com>
Date:   Wed Apr 9 00:06:24 2025 -0400

    tools/power turbostat.8: fix typo: idle_pct should be pct_idle

    idle_pct should be pct_idle

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-08-31 08:16:41 -04:00
David Arcari 3b3ebdbd8d tools/power turbostat: v2025.05.06
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit 03e00e373cab981ad808271b2650700cfa0fbda6
Author: Len Brown <len.brown@intel.com>
Date:   Sun Apr 6 14:49:20 2025 -0400

    tools/power turbostat: v2025.05.06

    Support up to 8192 processors
    Add cpuidle governor debug telemetry, disabled by default
    Update default output to exclude cpuidle invocation counts
    Bug fixes

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 063f931059 tools/power turbostat: disable "cpuidle" invocation counters, by default
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit ec4acd3166d8a7a03b059d01b9c6f11a658e833f
Author: Len Brown <len.brown@intel.com>
Date:   Sun Apr 6 14:29:57 2025 -0400

    tools/power turbostat: disable "cpuidle" invocation counters, by default

    Create "pct_idle" counter group, the sofware notion of residency
    so it can now be singled out, independent of other counter groups.

    Create "cpuidle" group, the cpuidle invocation counts.
    Disable "cpuidle", by default.

    Create "swidle" = "cpuidle" + "pct_idle".
    Undocument "sysfs", the old name for "swidle", but keep it working
    for backwards compatibilty.

    Create "hwidle", all the HW idle counters

    Modify "idle", enabled by default
    "idle" = "hwidle" + "pct_idle" (and now excludes "cpuidle")

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 927094fa94 tools/power turbostat: re-factor sysfs code
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit 994633894f208a0151baaee1688ab3c431912553
Author: Len Brown <len.brown@intel.com>
Date:   Sun Apr 6 12:53:18 2025 -0400

    tools/power turbostat: re-factor sysfs code

    Probe cpuidle "sysfs" residency and counts separately,
    since soon we will make one disabled on, and the
    other disabled off.

    Clarify that some BIC (build-in-counters) are actually "groups".
    since we're about to re-name some of those groups.

    no functional change.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 80081bfa46 tools/power turbostat: Restore GFX sysfs fflush() call
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit f8b136ef2605c1bf62020462d10e35228760aa19
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Wed Mar 19 08:53:07 2025 +0800

    tools/power turbostat: Restore GFX sysfs fflush() call

    Do fflush() to discard the buffered data, before each read of the
    graphics sysfs knobs.

    Fixes: ba99a4fc8c24 ("tools/power turbostat: Remove unnecessary fflush() call")
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari eab4b830b4 tools/power turbostat: Document GNR UncMHz domain convention
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit 3ae8508663372b93c5556a887e96ed0ca5df0711
Author: Len Brown <len.brown@intel.com>
Date:   Sun Apr 6 12:23:22 2025 -0400

    tools/power turbostat: Document GNR UncMHz domain convention

    Document that on Intel Granite Rapids Systems,
    Uncore domains 0-2 are CPU domains, and
    uncore domains 3-4 are IO domains.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 271324c971 tools/power turbostat: report CoreThr per measurement interval
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit f729775f79a9c942c6c82ed6b44bd030afe10423
Author: Len Brown <len.brown@intel.com>
Date:   Sun Apr 6 11:18:39 2025 -0400

    tools/power turbostat: report CoreThr per measurement interval

    The CoreThr column displays total thermal throttling events
    since boot time.

    Change it to report events during the measurement interval.

    This is more useful for showing a user the current conditions.
    Total events since boot time are still available to the user via
    /sys/devices/system/cpu/cpu*/thermal_throttle/*

    Document CoreThr on turbostat.8

    Fixes: eae97e053fe30 ("turbostat: Support thermal throttle count print")
    Reported-by: Arjan van de Ven <arjan@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
    Cc: Chen Yu <yu.c.chen@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 5c0eb36005 tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit eb187540d13ae260b91dbca7257bc44bd83ca8c6
Author: Justin Ernst <justin.ernst@hpe.com>
Date:   Wed Mar 19 15:27:31 2025 -0500

    tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192

    On systems with >= 1024 cpus (in my case 1152), turbostat fails with the error output:
            "turbostat: /sys/fs/cgroup/cpuset.cpus.effective: cpu str malformat 0-1151"

    A similar error appears with the use of turbostat --cpu when the inputted cpu
    range contains a cpu number >= 1024:
            # turbostat -c 1100-1151
            "--cpu 1100-1151" malformed
            ...

    Both errors are caused by parse_cpu_str() reaching its limit of CPU_SUBSET_MAXCPUS.

    It's a good idea to limit the maximum cpu number being parsed, but 1024 is too low.
    For a small increase in compute and allocated memory, increasing CPU_SUBSET_MAXCPUS
    brings support for parsing cpu numbers >= 1024.

    Increase CPU_SUBSET_MAXCPUS to 8192, a common setting for CONFIG_NR_CPUS on x86_64.

    Signed-off-by: Justin Ernst <justin.ernst@hpe.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 3ef04859f1 tools/power turbostat: Add idle governor statistics reporting
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit ed625c61b85c2333324dca43146c4ebabf8b236f
Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date:   Sat Feb 8 13:53:19 2025 +0200

    tools/power turbostat: Add idle governor statistics reporting

    The idle governor provides the following per-idle state sysfs files:
      * above - Indicates overshoots, where a more shallow state should have
                been requested (if avaliale and enabled).
      * below - Indicates undershoots, where a deeper state should have been
                requested (if available and enabled).

    These files offer valuable insights into how effectively the Linux kernel
    idle governor selects idle states for a given workload. This commit adds
    support for these files in turbostat.

    Expose the contents of these files with the following naming convention:
    * C1: The number of times the C1 state was requested (existing counter).
    * C1+: The number of times the idle governor selected C1, but a deeper
      idle state should have been selected instead.
    * C1-: The number of times the idle governor selected C1, but a shallower
      idle state should have been selected instead.

    Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 05ec283030 tools/power turbostat: Fix names matching
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit 5132681dcd96b2a8c357b6e5d93e9876924bb80b
Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date:   Sat Feb 8 12:55:42 2025 +0200

    tools/power turbostat: Fix names matching

    Fix the 'find_msrp_by_name()' function which returns incorrect matches for
    cases like this:

    s1 = "C1-";
    find_msrp_by_name(head, s1);

    Inside 'find_msrp_by_name()':
    ...
    s2 = "C1"
    if !(strcnmp(s1, s2, len(s2)))
            // Incorrect match!
            return mp;

    Full strings should be match istead. Switch to 'strcmp()' to fix the problem.

    Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 647ac94d4c tools/power turbostat: Allow Zero return value for some RAPL registers
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit b312d880fb462d4759396950865ec914de9d253c
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Sat Feb 8 10:44:26 2025 +0800

    tools/power turbostat: Allow Zero return value for some RAPL registers

    turbostat aborted with below messages on a dual-package system,

       turbostat: turbostat.c:3744: rapl_counter_accumulate: Assertion `dst->unit == src->unit' failed.
       Aborted

    This is because
    1. the MSR_DRAM_PERF_STATUS returns Zero for one package, and non-Zero
       for another package
    2. probe_msr() treats Zero return value as a failure so this feature is
       enabled on one package, and disabled for another package.
    3. turbostat aborts because the feature is invalid on some package

    Unlike the RAPL energy counter registers, MSR_DRAM_PERF_STATUS can
    return Zero value, and this should not be treated as a failure.

    Fix the problem by allowing Zero return value for RAPL registers other
    than the energy counters.

    Fixes: 7c6fee25bdf5 ("tools/power turbostat: Check for non-zero value when MSR probing")
    Reported-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:40 -04:00
David Arcari 2a35850915 tools/power turbostat: Clustered Uncore MHz counters should honor show/hide options
JIRA: https://issues.redhat.com/browse/RHEL-86839

commit 1c7c7388e6c31f46b26a884d80b45efbad8237b2
Author: Len Brown <len.brown@intel.com>
Date:   Thu Feb 6 21:46:24 2025 -0600

    tools/power turbostat: Clustered Uncore MHz counters should honor show/hide options

    The clustered uncore frequency counters, UMHz*.*
    should honor the --show and --hide options.

    All non-specified counters should be implicityly hidden.
    But when --show was used, UMHz*.* showed up anyway:

    $ sudo turbostat -q -S --show Busy%
    Busy%  UMHz0.0  UMHz1.0  UMHz2.0  UMHz3.0  UMHz4.0

    Indeed, there was no string that can be used to explicitly
    show or hide clustered uncore counters.

    Even through they are dynamically probed and added,
    group the clustered UMHz*.* counters with the legacy
    built-in-counter "UncMHz" for show/hide.

    turbostat --show Busy%
            does not show UMHz*.*.
    turbostat --show UncMHz
            shows either UncMHz or UMHz*.*, if present
    turbostat --hide UncMHz
            hides either UncMHz or UMHz*.*, if present

    Reported-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
    Tested-by: Artem Bityutskiy <artem.bityutskiy@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-04-10 13:49:39 -04:00
David Arcari c7cdc6a5b2 tools/power turbostat: version 2025.02.02
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit 2c4627c8ced77855b106c7104ecab70837d53799
Author: Len Brown <len.brown@intel.com>
Date:   Sun Feb 2 10:43:02 2025 -0600

    tools/power turbostat: version 2025.02.02

    Summary of Changes since 2024.11.30:

    Fix regression in 2023.11.07 that affinitized forked child
    in one-shot mode.

    Harden one-shot mode against hotplug online/offline

    Enable RAPL SysWatt column by default.

    Add initial PTL, CWF platform support.

    Harden initial PMT code in response to early use.

    Enable first built-in PMT counter: CWF c1e residency

    Refuse to run on unsupported platforms without --force,
    to encourage updating to a version that supports the system,
    and to avoid no-so-useful measurement results.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari 3c1a222bb1 tools/power turbostat: Add CPU%c1e BIC for CWF
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit 5ce1e9bbb2a1d43cf9e613cb03e65ecdfd309fe9
Author: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Date:   Fri Jan 17 13:50:29 2025 +0100

    tools/power turbostat: Add CPU%c1e BIC for CWF

    Intel Clearwater Forest report PMT telemetry with GUID 0x14421519, which
    can be used to obtain module c1e residency counter of type tcore clock.

    Add early support for the counter by using heuristic that should work
    for the Clearwater Forest platforms.

    Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari db0bd95861 tools/power turbostat: Harden one-shot mode against cpu offline
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit 5499b5ac0b2c661cc37190a23a4aee9308b3d3ee
Author: Len Brown <len.brown@intel.com>
Date:   Mon Jan 27 20:58:42 2025 -0600

    tools/power turbostat: Harden one-shot mode against cpu offline

    when turbostat interval mode can't migrate to a CPU, it complains,
    prints no data, re-initializes with the new CPU configuration
    and starts a new interval.

    But this strategy in the face of a CPU hotplug offline during an interval
    doesn't help in one-shot mode.  When the missing CPU is discovered
    at the end of the interval, the forked program has already returned
    and there is nothing left for a new interval to measure.

    So instead of aborting get_coutners() and delta_cpu() if a missing CPU
    is detected, complain, but carry on and output what statistics are
    actually present.

    Use the same strategy for delta_cpu when aperf:mperf are observed
    to have been reset -- complain, but carry on and print data for
    the CPUs that are still present.

    Interval mode error handling is unchanged.

    One-shot mode can now do this:

    $ sudo chcpu -e 1 ; sudo ./turbostat --quiet --show PkgWatt,Busy%,CPU chcpu -d 1
    CPU 1 enabled
    CPU 1 disabled
    get_counters: Could not migrate to CPU 1
    ./turbostat: Counter reset detected
    0.036920 sec
    CPU     Busy%   PkgWatt
    -       0.00    10.00
    0       99.73   10.00
    1       0.00
    2       91.53
    3       16.83

    Suggested-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari ed6187b135 tools/power turbostat: Fix forked child affinity regression
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit b32c36975da48afc9089f8b61f7b2dcc40e479d2
Author: Len Brown <len.brown@intel.com>
Date:   Mon Jan 27 16:42:19 2025 -0600

    tools/power turbostat: Fix forked child affinity regression

    In "one-shot" mode, turbostat
    1. takes a counter snapshot
    2. forks and waits for a child
    3. takes the end counter snapshot and prints the result.

    But turbostat counter snapshots currently use affinity to travel
    around the system so that counter reads are "local", and this
    affinity must be cleared between #1 and #2 above.

    The offending commit removed that reset that allowed the child
    to run on cpu_present_set.

    Fix that issue, and improve upon the original by using
    cpu_possible_set for the child.  This allows the child
    to also run on CPUs that hotplug online during its runtime.

    Reported-by: Zhang Rui <rui.zhang@intel.com>
    Fixes: 7bb3fe27ad4f ("tools/power/turbostat: Obey allowed CPUs during startup")
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari 93f973c3ad tools/power turbostat: Add tcore clock PMT type
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit 1a202afeaa370970413846c2cb09b383875e753c
Author: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Date:   Fri Jan 17 13:36:59 2025 +0100

    tools/power turbostat: Add tcore clock PMT type

    Some PMT counters, for example module c1e residency on Intel Clearwater
    Forest, are reported using tcore clock type.

    Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari 11d4918948 tools/power turbostat: version 2025.01.14
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit a80e53472209b1c749e02e91ac62c053ac457099
Author: Len Brown <len.brown@intel.com>
Date:   Tue Dec 3 16:11:21 2024 -0500

    tools/power turbostat: version 2025.01.14

    Fix checkpatch whitespace issues since 2024.11.30

    Summary of Changes since 2024.11.30:

            Enable SysWatt by default.

            Add initial PTL, CWF platform support.

            Refuse to run on unsupported platforms without --force
            to avoid not-so-useful measurements mistakenly made
            using obsolete versions.

            Harden initial PMT code in response to early use.

    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00
David Arcari cc49d8f120 tools/power turbostat: Allow adding PMT counters directly by sysfs path
JIRA: https://issues.redhat.com/browse/RHEL-84464

commit 83fbeb9f9776cd044d36af606127f56206337bab
Author: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Date:   Thu Dec 12 19:11:34 2024 +0100

    tools/power turbostat: Allow adding PMT counters directly by sysfs path

    Allow user to add PMT counters by either identifying the source with:
      guid=%u,seq=%u
    or, since this patch, with direct sysfs path:
      path=%s, for example path=/sys/class/intel_pmt/telem5

    In the later case, the guid and sequence number will be infered
    by turbostat.

    Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-21 09:15:47 -04:00