Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pm-tools'

Merge power management tools updates for 5.19-rc1:

- Update turbostat to version 2022.04.16 including the following
changes:

* No build warnings with -Wextra (Len Brown).
* Tweak --show and --hide capability (Len Brown).
* Be more useful as non-root (Len Brown).
* Fix ICX DRAM power numbers (Len Brown).
* Fix dump for AMD cpus (Dan Merillat).
* Add Power Limit4 support (Sumeet Pawnikar).
* Print power values upto three decimal (Sumeet Pawnikar).
* Allow -e for all names (Zephaniah E. Loss-Cutler-Hull).
* Allow printing header every N iterations (Zephaniah E.
Loss-Cutler-Hull).
* Support thermal throttle count print (Chen Yu).

* pm-tools:
tools/power turbostat: version 2022.04.16
tools/power turbostat: No build warnings with -Wextra
tools/power turbostat: be more useful as non-root
tools/power turbostat: fix ICX DRAM power numbers
tools/power turbostat: Support thermal throttle count print
tools/power turbostat: Allow printing header every N iterations
tools/power turbostat: Allow -e for all names.
tools/power turbostat: print power values upto three decimal
tools/power turbostat: Add Power Limit4 support
tools/power turbostat: fix dump for AMD cpus
tools/power turbostat: tweak --show and --hide capability

+389 -210
+1
arch/x86/include/asm/msr-index.h
··· 312 312 313 313 /* Run Time Average Power Limiting (RAPL) Interface */ 314 314 315 + #define MSR_VR_CURRENT_CONFIG 0x00000601 315 316 #define MSR_RAPL_POWER_UNIT 0x00000606 316 317 317 318 #define MSR_PKG_POWER_LIMIT 0x00000610
+1 -1
tools/power/x86/turbostat/Makefile
··· 9 9 endif 10 10 11 11 turbostat : turbostat.c 12 - override CFLAGS += -O2 -Wall -I../../../include 12 + override CFLAGS += -O2 -Wall -Wextra -I../../../include 13 13 override CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"' 14 14 override CFLAGS += -DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"' 15 15 override CFLAGS += -D_FILE_OFFSET_BITS=64
+1 -1
tools/power/x86/turbostat/turbostat.8
··· 292 292 must be run as root. 293 293 Alternatively, non-root users can be enabled to run turbostat this way: 294 294 295 - # setcap cap_sys_rawio=ep ./turbostat 295 + # setcap cap_sys_admin,cap_sys_rawio,cap_sys_nice=+ep ./turbostat 296 296 297 297 # chmod +r /dev/cpu/*/msr 298 298
+386 -208
tools/power/x86/turbostat/turbostat.c
··· 3 3 * turbostat -- show CPU frequency and C-state residency 4 4 * on modern Intel and AMD processors. 5 5 * 6 - * Copyright (c) 2021 Intel Corporation. 6 + * Copyright (c) 2022 Intel Corporation. 7 7 * Len Brown <len.brown@intel.com> 8 8 */ 9 9 ··· 37 37 #include <asm/unistd.h> 38 38 #include <stdbool.h> 39 39 40 + #define UNUSED(x) (void)(x) 41 + 42 + /* 43 + * This list matches the column headers, except 44 + * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time 45 + * 2. Core and CPU are moved to the end, we can't have strings that contain them 46 + * matching on them for --show and --hide. 47 + */ 48 + 49 + /* 50 + * buffer size used by sscanf() for added column names 51 + * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters 52 + */ 53 + #define NAME_BYTES 20 54 + #define PATH_BYTES 128 55 + 56 + enum counter_scope { SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE }; 57 + enum counter_type { COUNTER_ITEMS, COUNTER_CYCLES, COUNTER_SECONDS, COUNTER_USEC }; 58 + enum counter_format { FORMAT_RAW, FORMAT_DELTA, FORMAT_PERCENT }; 59 + 60 + struct msr_counter { 61 + unsigned int msr_num; 62 + char name[NAME_BYTES]; 63 + char path[PATH_BYTES]; 64 + unsigned int width; 65 + enum counter_type type; 66 + enum counter_format format; 67 + struct msr_counter *next; 68 + unsigned int flags; 69 + #define FLAGS_HIDE (1 << 0) 70 + #define FLAGS_SHOW (1 << 1) 71 + #define SYSFS_PERCPU (1 << 1) 72 + }; 73 + 74 + struct msr_counter bic[] = { 75 + { 0x0, "usec", "", 0, 0, 0, NULL, 0 }, 76 + { 0x0, "Time_Of_Day_Seconds", "", 0, 0, 0, NULL, 0 }, 77 + { 0x0, "Package", "", 0, 0, 0, NULL, 0 }, 78 + { 0x0, "Node", "", 0, 0, 0, NULL, 0 }, 79 + { 0x0, "Avg_MHz", "", 0, 0, 0, NULL, 0 }, 80 + { 0x0, "Busy%", "", 0, 0, 0, NULL, 0 }, 81 + { 0x0, "Bzy_MHz", "", 0, 0, 0, NULL, 0 }, 82 + { 0x0, "TSC_MHz", "", 0, 0, 0, NULL, 0 }, 83 + { 0x0, "IRQ", "", 0, 0, 0, NULL, 0 }, 84 + { 0x0, "SMI", "", 32, 0, FORMAT_DELTA, NULL, 0 }, 85 + { 0x0, "sysfs", "", 0, 0, 0, NULL, 0 }, 86 + { 0x0, "CPU%c1", "", 0, 0, 0, NULL, 0 }, 87 + { 0x0, "CPU%c3", "", 0, 0, 0, NULL, 0 }, 88 + { 0x0, "CPU%c6", "", 0, 0, 0, NULL, 0 }, 89 + { 0x0, "CPU%c7", "", 0, 0, 0, NULL, 0 }, 90 + { 0x0, "ThreadC", "", 0, 0, 0, NULL, 0 }, 91 + { 0x0, "CoreTmp", "", 0, 0, 0, NULL, 0 }, 92 + { 0x0, "CoreCnt", "", 0, 0, 0, NULL, 0 }, 93 + { 0x0, "PkgTmp", "", 0, 0, 0, NULL, 0 }, 94 + { 0x0, "GFX%rc6", "", 0, 0, 0, NULL, 0 }, 95 + { 0x0, "GFXMHz", "", 0, 0, 0, NULL, 0 }, 96 + { 0x0, "Pkg%pc2", "", 0, 0, 0, NULL, 0 }, 97 + { 0x0, "Pkg%pc3", "", 0, 0, 0, NULL, 0 }, 98 + { 0x0, "Pkg%pc6", "", 0, 0, 0, NULL, 0 }, 99 + { 0x0, "Pkg%pc7", "", 0, 0, 0, NULL, 0 }, 100 + { 0x0, "Pkg%pc8", "", 0, 0, 0, NULL, 0 }, 101 + { 0x0, "Pkg%pc9", "", 0, 0, 0, NULL, 0 }, 102 + { 0x0, "Pk%pc10", "", 0, 0, 0, NULL, 0 }, 103 + { 0x0, "CPU%LPI", "", 0, 0, 0, NULL, 0 }, 104 + { 0x0, "SYS%LPI", "", 0, 0, 0, NULL, 0 }, 105 + { 0x0, "PkgWatt", "", 0, 0, 0, NULL, 0 }, 106 + { 0x0, "CorWatt", "", 0, 0, 0, NULL, 0 }, 107 + { 0x0, "GFXWatt", "", 0, 0, 0, NULL, 0 }, 108 + { 0x0, "PkgCnt", "", 0, 0, 0, NULL, 0 }, 109 + { 0x0, "RAMWatt", "", 0, 0, 0, NULL, 0 }, 110 + { 0x0, "PKG_%", "", 0, 0, 0, NULL, 0 }, 111 + { 0x0, "RAM_%", "", 0, 0, 0, NULL, 0 }, 112 + { 0x0, "Pkg_J", "", 0, 0, 0, NULL, 0 }, 113 + { 0x0, "Cor_J", "", 0, 0, 0, NULL, 0 }, 114 + { 0x0, "GFX_J", "", 0, 0, 0, NULL, 0 }, 115 + { 0x0, "RAM_J", "", 0, 0, 0, NULL, 0 }, 116 + { 0x0, "Mod%c6", "", 0, 0, 0, NULL, 0 }, 117 + { 0x0, "Totl%C0", "", 0, 0, 0, NULL, 0 }, 118 + { 0x0, "Any%C0", "", 0, 0, 0, NULL, 0 }, 119 + { 0x0, "GFX%C0", "", 0, 0, 0, NULL, 0 }, 120 + { 0x0, "CPUGFX%", "", 0, 0, 0, NULL, 0 }, 121 + { 0x0, "Core", "", 0, 0, 0, NULL, 0 }, 122 + { 0x0, "CPU", "", 0, 0, 0, NULL, 0 }, 123 + { 0x0, "APIC", "", 0, 0, 0, NULL, 0 }, 124 + { 0x0, "X2APIC", "", 0, 0, 0, NULL, 0 }, 125 + { 0x0, "Die", "", 0, 0, 0, NULL, 0 }, 126 + { 0x0, "GFXAMHz", "", 0, 0, 0, NULL, 0 }, 127 + { 0x0, "IPC", "", 0, 0, 0, NULL, 0 }, 128 + { 0x0, "CoreThr", "", 0, 0, 0, NULL, 0 }, 129 + }; 130 + 131 + #define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter)) 132 + #define BIC_USEC (1ULL << 0) 133 + #define BIC_TOD (1ULL << 1) 134 + #define BIC_Package (1ULL << 2) 135 + #define BIC_Node (1ULL << 3) 136 + #define BIC_Avg_MHz (1ULL << 4) 137 + #define BIC_Busy (1ULL << 5) 138 + #define BIC_Bzy_MHz (1ULL << 6) 139 + #define BIC_TSC_MHz (1ULL << 7) 140 + #define BIC_IRQ (1ULL << 8) 141 + #define BIC_SMI (1ULL << 9) 142 + #define BIC_sysfs (1ULL << 10) 143 + #define BIC_CPU_c1 (1ULL << 11) 144 + #define BIC_CPU_c3 (1ULL << 12) 145 + #define BIC_CPU_c6 (1ULL << 13) 146 + #define BIC_CPU_c7 (1ULL << 14) 147 + #define BIC_ThreadC (1ULL << 15) 148 + #define BIC_CoreTmp (1ULL << 16) 149 + #define BIC_CoreCnt (1ULL << 17) 150 + #define BIC_PkgTmp (1ULL << 18) 151 + #define BIC_GFX_rc6 (1ULL << 19) 152 + #define BIC_GFXMHz (1ULL << 20) 153 + #define BIC_Pkgpc2 (1ULL << 21) 154 + #define BIC_Pkgpc3 (1ULL << 22) 155 + #define BIC_Pkgpc6 (1ULL << 23) 156 + #define BIC_Pkgpc7 (1ULL << 24) 157 + #define BIC_Pkgpc8 (1ULL << 25) 158 + #define BIC_Pkgpc9 (1ULL << 26) 159 + #define BIC_Pkgpc10 (1ULL << 27) 160 + #define BIC_CPU_LPI (1ULL << 28) 161 + #define BIC_SYS_LPI (1ULL << 29) 162 + #define BIC_PkgWatt (1ULL << 30) 163 + #define BIC_CorWatt (1ULL << 31) 164 + #define BIC_GFXWatt (1ULL << 32) 165 + #define BIC_PkgCnt (1ULL << 33) 166 + #define BIC_RAMWatt (1ULL << 34) 167 + #define BIC_PKG__ (1ULL << 35) 168 + #define BIC_RAM__ (1ULL << 36) 169 + #define BIC_Pkg_J (1ULL << 37) 170 + #define BIC_Cor_J (1ULL << 38) 171 + #define BIC_GFX_J (1ULL << 39) 172 + #define BIC_RAM_J (1ULL << 40) 173 + #define BIC_Mod_c6 (1ULL << 41) 174 + #define BIC_Totl_c0 (1ULL << 42) 175 + #define BIC_Any_c0 (1ULL << 43) 176 + #define BIC_GFX_c0 (1ULL << 44) 177 + #define BIC_CPUGFX (1ULL << 45) 178 + #define BIC_Core (1ULL << 46) 179 + #define BIC_CPU (1ULL << 47) 180 + #define BIC_APIC (1ULL << 48) 181 + #define BIC_X2APIC (1ULL << 49) 182 + #define BIC_Die (1ULL << 50) 183 + #define BIC_GFXACTMHz (1ULL << 51) 184 + #define BIC_IPC (1ULL << 52) 185 + #define BIC_CORE_THROT_CNT (1ULL << 53) 186 + 187 + #define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die ) 188 + #define BIC_THERMAL_PWR ( BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__) 189 + #define BIC_FREQUENCY ( BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz ) 190 + #define BIC_IDLE ( BIC_sysfs | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX) 191 + #define BIC_OTHER ( BIC_IRQ | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC) 192 + 193 + #define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC) 194 + 195 + unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT); 196 + unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs | BIC_APIC | BIC_X2APIC; 197 + 198 + #define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME) 199 + #define DO_BIC_READ(COUNTER_NAME) (bic_present & COUNTER_NAME) 200 + #define ENABLE_BIC(COUNTER_NAME) (bic_enabled |= COUNTER_NAME) 201 + #define BIC_PRESENT(COUNTER_BIT) (bic_present |= COUNTER_BIT) 202 + #define BIC_NOT_PRESENT(COUNTER_BIT) (bic_present &= ~COUNTER_BIT) 203 + #define BIC_IS_ENABLED(COUNTER_BIT) (bic_enabled & COUNTER_BIT) 204 + 40 205 char *proc_stat = "/proc/stat"; 41 206 FILE *outf; 42 207 int *fd_percpu; ··· 213 48 unsigned int model_orig; 214 49 215 50 unsigned int num_iterations; 51 + unsigned int header_iterations; 216 52 unsigned int debug; 217 53 unsigned int quiet; 218 54 unsigned int shown; ··· 325 159 326 160 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 327 161 328 - /* 329 - * buffer size used by sscanf() for added column names 330 - * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters 331 - */ 332 - #define NAME_BYTES 20 333 - #define PATH_BYTES 128 334 - 335 162 int backwards_count; 336 163 char *progname; 337 164 ··· 364 205 unsigned int core_temp_c; 365 206 unsigned int core_energy; /* MSR_CORE_ENERGY_STAT */ 366 207 unsigned int core_id; 208 + unsigned long long core_throt_cnt; 367 209 unsigned long long counter[MAX_ADDED_COUNTERS]; 368 210 } *core_even, *core_odd; 369 211 ··· 414 254 (core_no)) 415 255 416 256 #define GET_PKG(pkg_base, pkg_no) (pkg_base + pkg_no) 417 - 418 - enum counter_scope { SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE }; 419 - enum counter_type { COUNTER_ITEMS, COUNTER_CYCLES, COUNTER_SECONDS, COUNTER_USEC }; 420 - enum counter_format { FORMAT_RAW, FORMAT_DELTA, FORMAT_PERCENT }; 421 - 422 - struct msr_counter { 423 - unsigned int msr_num; 424 - char name[NAME_BYTES]; 425 - char path[PATH_BYTES]; 426 - unsigned int width; 427 - enum counter_type type; 428 - enum counter_format format; 429 - struct msr_counter *next; 430 - unsigned int flags; 431 - #define FLAGS_HIDE (1 << 0) 432 - #define FLAGS_SHOW (1 << 1) 433 - #define SYSFS_PERCPU (1 << 1) 434 - }; 435 257 436 258 /* 437 259 * The accumulated sum of MSR is defined as a monotonic ··· 664 522 665 523 /* counter for cpu_num, including user + kernel and all processes */ 666 524 fd = perf_event_open(&pea, -1, cpu_num, -1, 0); 667 - if (fd == -1) 668 - err(-1, "cpu%d: perf instruction counter\n", cpu_num); 525 + if (fd == -1) { 526 + warn("cpu%d: perf instruction counter", cpu_num); 527 + BIC_NOT_PRESENT(BIC_IPC); 528 + } 669 529 670 530 return fd; 671 531 } ··· 694 550 return 0; 695 551 } 696 552 697 - /* 698 - * This list matches the column headers, except 699 - * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time 700 - * 2. Core and CPU are moved to the end, we can't have strings that contain them 701 - * matching on them for --show and --hide. 702 - */ 703 - struct msr_counter bic[] = { 704 - { 0x0, "usec" }, 705 - { 0x0, "Time_Of_Day_Seconds" }, 706 - { 0x0, "Package" }, 707 - { 0x0, "Node" }, 708 - { 0x0, "Avg_MHz" }, 709 - { 0x0, "Busy%" }, 710 - { 0x0, "Bzy_MHz" }, 711 - { 0x0, "TSC_MHz" }, 712 - { 0x0, "IRQ" }, 713 - { 0x0, "SMI", "", 32, 0, FORMAT_DELTA, NULL }, 714 - { 0x0, "sysfs" }, 715 - { 0x0, "CPU%c1" }, 716 - { 0x0, "CPU%c3" }, 717 - { 0x0, "CPU%c6" }, 718 - { 0x0, "CPU%c7" }, 719 - { 0x0, "ThreadC" }, 720 - { 0x0, "CoreTmp" }, 721 - { 0x0, "CoreCnt" }, 722 - { 0x0, "PkgTmp" }, 723 - { 0x0, "GFX%rc6" }, 724 - { 0x0, "GFXMHz" }, 725 - { 0x0, "Pkg%pc2" }, 726 - { 0x0, "Pkg%pc3" }, 727 - { 0x0, "Pkg%pc6" }, 728 - { 0x0, "Pkg%pc7" }, 729 - { 0x0, "Pkg%pc8" }, 730 - { 0x0, "Pkg%pc9" }, 731 - { 0x0, "Pk%pc10" }, 732 - { 0x0, "CPU%LPI" }, 733 - { 0x0, "SYS%LPI" }, 734 - { 0x0, "PkgWatt" }, 735 - { 0x0, "CorWatt" }, 736 - { 0x0, "GFXWatt" }, 737 - { 0x0, "PkgCnt" }, 738 - { 0x0, "RAMWatt" }, 739 - { 0x0, "PKG_%" }, 740 - { 0x0, "RAM_%" }, 741 - { 0x0, "Pkg_J" }, 742 - { 0x0, "Cor_J" }, 743 - { 0x0, "GFX_J" }, 744 - { 0x0, "RAM_J" }, 745 - { 0x0, "Mod%c6" }, 746 - { 0x0, "Totl%C0" }, 747 - { 0x0, "Any%C0" }, 748 - { 0x0, "GFX%C0" }, 749 - { 0x0, "CPUGFX%" }, 750 - { 0x0, "Core" }, 751 - { 0x0, "CPU" }, 752 - { 0x0, "APIC" }, 753 - { 0x0, "X2APIC" }, 754 - { 0x0, "Die" }, 755 - { 0x0, "GFXAMHz" }, 756 - { 0x0, "IPC" }, 757 - }; 758 - 759 - #define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter)) 760 - #define BIC_USEC (1ULL << 0) 761 - #define BIC_TOD (1ULL << 1) 762 - #define BIC_Package (1ULL << 2) 763 - #define BIC_Node (1ULL << 3) 764 - #define BIC_Avg_MHz (1ULL << 4) 765 - #define BIC_Busy (1ULL << 5) 766 - #define BIC_Bzy_MHz (1ULL << 6) 767 - #define BIC_TSC_MHz (1ULL << 7) 768 - #define BIC_IRQ (1ULL << 8) 769 - #define BIC_SMI (1ULL << 9) 770 - #define BIC_sysfs (1ULL << 10) 771 - #define BIC_CPU_c1 (1ULL << 11) 772 - #define BIC_CPU_c3 (1ULL << 12) 773 - #define BIC_CPU_c6 (1ULL << 13) 774 - #define BIC_CPU_c7 (1ULL << 14) 775 - #define BIC_ThreadC (1ULL << 15) 776 - #define BIC_CoreTmp (1ULL << 16) 777 - #define BIC_CoreCnt (1ULL << 17) 778 - #define BIC_PkgTmp (1ULL << 18) 779 - #define BIC_GFX_rc6 (1ULL << 19) 780 - #define BIC_GFXMHz (1ULL << 20) 781 - #define BIC_Pkgpc2 (1ULL << 21) 782 - #define BIC_Pkgpc3 (1ULL << 22) 783 - #define BIC_Pkgpc6 (1ULL << 23) 784 - #define BIC_Pkgpc7 (1ULL << 24) 785 - #define BIC_Pkgpc8 (1ULL << 25) 786 - #define BIC_Pkgpc9 (1ULL << 26) 787 - #define BIC_Pkgpc10 (1ULL << 27) 788 - #define BIC_CPU_LPI (1ULL << 28) 789 - #define BIC_SYS_LPI (1ULL << 29) 790 - #define BIC_PkgWatt (1ULL << 30) 791 - #define BIC_CorWatt (1ULL << 31) 792 - #define BIC_GFXWatt (1ULL << 32) 793 - #define BIC_PkgCnt (1ULL << 33) 794 - #define BIC_RAMWatt (1ULL << 34) 795 - #define BIC_PKG__ (1ULL << 35) 796 - #define BIC_RAM__ (1ULL << 36) 797 - #define BIC_Pkg_J (1ULL << 37) 798 - #define BIC_Cor_J (1ULL << 38) 799 - #define BIC_GFX_J (1ULL << 39) 800 - #define BIC_RAM_J (1ULL << 40) 801 - #define BIC_Mod_c6 (1ULL << 41) 802 - #define BIC_Totl_c0 (1ULL << 42) 803 - #define BIC_Any_c0 (1ULL << 43) 804 - #define BIC_GFX_c0 (1ULL << 44) 805 - #define BIC_CPUGFX (1ULL << 45) 806 - #define BIC_Core (1ULL << 46) 807 - #define BIC_CPU (1ULL << 47) 808 - #define BIC_APIC (1ULL << 48) 809 - #define BIC_X2APIC (1ULL << 49) 810 - #define BIC_Die (1ULL << 50) 811 - #define BIC_GFXACTMHz (1ULL << 51) 812 - #define BIC_IPC (1ULL << 52) 813 - 814 - #define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die ) 815 - #define BIC_THERMAL_PWR ( BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__) 816 - #define BIC_FREQUENCY ( BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz ) 817 - #define BIC_IDLE ( BIC_sysfs | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX) 818 - #define BIC_OTHER ( BIC_IRQ | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC) 819 - 820 - #define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC) 821 - 822 - unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT); 823 - unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs | BIC_APIC | BIC_X2APIC; 824 - 825 - #define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME) 826 - #define DO_BIC_READ(COUNTER_NAME) (bic_present & COUNTER_NAME) 827 - #define ENABLE_BIC(COUNTER_NAME) (bic_enabled |= COUNTER_NAME) 828 - #define BIC_PRESENT(COUNTER_BIT) (bic_present |= COUNTER_BIT) 829 - #define BIC_NOT_PRESENT(COUNTER_BIT) (bic_present &= ~COUNTER_BIT) 830 - #define BIC_IS_ENABLED(COUNTER_BIT) (bic_enabled & COUNTER_BIT) 831 - 832 553 #define MAX_DEFERRED 16 554 + char *deferred_add_names[MAX_DEFERRED]; 833 555 char *deferred_skip_names[MAX_DEFERRED]; 556 + int deferred_add_index; 834 557 int deferred_skip_index; 835 558 836 559 /* ··· 731 720 " -l, --list list column headers only\n" 732 721 " -n, --num_iterations num\n" 733 722 " number of the measurement iterations\n" 723 + " -N, --header_iterations num\n" 724 + " print header every num iterations\n" 734 725 " -o, --out file\n" 735 726 " create or truncate \"file\" for all output\n" 736 727 " -q, --quiet skip decoding system configuration header\n" ··· 754 741 */ 755 742 unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode) 756 743 { 757 - int i; 744 + unsigned int i; 758 745 unsigned long long retval = 0; 759 746 760 747 while (name_list) { ··· 765 752 if (comma) 766 753 *comma = '\0'; 767 754 768 - if (!strcmp(name_list, "all")) 769 - return ~0; 770 - if (!strcmp(name_list, "topology")) 771 - return BIC_TOPOLOGY; 772 - if (!strcmp(name_list, "power")) 773 - return BIC_THERMAL_PWR; 774 - if (!strcmp(name_list, "idle")) 775 - return BIC_IDLE; 776 - if (!strcmp(name_list, "frequency")) 777 - return BIC_FREQUENCY; 778 - if (!strcmp(name_list, "other")) 779 - return BIC_OTHER; 780 - if (!strcmp(name_list, "all")) 781 - return 0; 782 - 783 755 for (i = 0; i < MAX_BIC; ++i) { 784 756 if (!strcmp(name_list, bic[i].name)) { 785 757 retval |= (1ULL << i); 786 758 break; 787 759 } 760 + if (!strcmp(name_list, "all")) { 761 + retval |= ~0; 762 + break; 763 + } else if (!strcmp(name_list, "topology")) { 764 + retval |= BIC_TOPOLOGY; 765 + break; 766 + } else if (!strcmp(name_list, "power")) { 767 + retval |= BIC_THERMAL_PWR; 768 + break; 769 + } else if (!strcmp(name_list, "idle")) { 770 + retval |= BIC_IDLE; 771 + break; 772 + } else if (!strcmp(name_list, "frequency")) { 773 + retval |= BIC_FREQUENCY; 774 + break; 775 + } else if (!strcmp(name_list, "other")) { 776 + retval |= BIC_OTHER; 777 + break; 778 + } 779 + 788 780 } 789 781 if (i == MAX_BIC) { 790 782 if (mode == SHOW_LIST) { 791 - fprintf(stderr, "Invalid counter name: %s\n", name_list); 792 - exit(-1); 793 - } 794 - deferred_skip_names[deferred_skip_index++] = name_list; 795 - if (debug) 796 - fprintf(stderr, "deferred \"%s\"\n", name_list); 797 - if (deferred_skip_index >= MAX_DEFERRED) { 798 - fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", 799 - MAX_DEFERRED, name_list); 800 - help(); 801 - exit(1); 783 + deferred_add_names[deferred_add_index++] = name_list; 784 + if (deferred_add_index >= MAX_DEFERRED) { 785 + fprintf(stderr, "More than max %d un-recognized --add options '%s'\n", 786 + MAX_DEFERRED, name_list); 787 + help(); 788 + exit(1); 789 + } 790 + } else { 791 + deferred_skip_names[deferred_skip_index++] = name_list; 792 + if (debug) 793 + fprintf(stderr, "deferred \"%s\"\n", name_list); 794 + if (deferred_skip_index >= MAX_DEFERRED) { 795 + fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", 796 + MAX_DEFERRED, name_list); 797 + help(); 798 + exit(1); 799 + } 802 800 } 803 801 } 804 802 ··· 895 871 896 872 if (DO_BIC(BIC_CoreTmp)) 897 873 outp += sprintf(outp, "%sCoreTmp", (printed++ ? delim : "")); 874 + 875 + if (DO_BIC(BIC_CORE_THROT_CNT)) 876 + outp += sprintf(outp, "%sCoreThr", (printed++ ? delim : "")); 898 877 899 878 if (do_rapl && !rapl_joules) { 900 879 if (DO_BIC(BIC_CorWatt) && (do_rapl & RAPL_PER_CORE_ENERGY)) ··· 1038 1011 outp += sprintf(outp, "c6: %016llX\n", c->c6); 1039 1012 outp += sprintf(outp, "c7: %016llX\n", c->c7); 1040 1013 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); 1014 + outp += sprintf(outp, "cpu_throt_count: %016llX\n", c->core_throt_cnt); 1041 1015 outp += sprintf(outp, "Joules: %0X\n", c->core_energy); 1042 1016 1043 1017 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { ··· 1253 1225 if (DO_BIC(BIC_CoreTmp)) 1254 1226 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); 1255 1227 1228 + /* Core throttle count */ 1229 + if (DO_BIC(BIC_CORE_THROT_CNT)) 1230 + outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->core_throt_cnt); 1231 + 1256 1232 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { 1257 1233 if (mp->format == FORMAT_RAW) { 1258 1234 if (mp->width == 32) ··· 1343 1311 if (DO_BIC(BIC_PkgWatt)) 1344 1312 outp += 1345 1313 sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units / interval_float); 1314 + 1346 1315 if (DO_BIC(BIC_CorWatt) && !(do_rapl & RAPL_PER_CORE_ENERGY)) 1347 1316 outp += 1348 1317 sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units / interval_float); ··· 1419 1386 1420 1387 void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) 1421 1388 { 1422 - static int printed; 1389 + static int count; 1423 1390 1424 - if (!printed || !summary_only) 1391 + if ((!count || (header_iterations && !(count % header_iterations))) || !summary_only) 1425 1392 print_header("\t"); 1426 1393 1427 1394 format_counters(&average.threads, &average.cores, &average.packages); 1428 1395 1429 - printed = 1; 1396 + count++; 1430 1397 1431 1398 if (summary_only) 1432 1399 return; ··· 1500 1467 old->c6 = new->c6 - old->c6; 1501 1468 old->c7 = new->c7 - old->c7; 1502 1469 old->core_temp_c = new->core_temp_c; 1470 + old->core_throt_cnt = new->core_throt_cnt; 1503 1471 old->mc6_us = new->mc6_us - old->mc6_us; 1504 1472 1505 1473 DELTA_WRAP32(new->core_energy, old->core_energy); ··· 1660 1626 c->mc6_us = 0; 1661 1627 c->core_temp_c = 0; 1662 1628 c->core_energy = 0; 1629 + c->core_throt_cnt = 0; 1663 1630 1664 1631 p->pkg_wtd_core_c0 = 0; 1665 1632 p->pkg_any_core_c0 = 0; ··· 1745 1710 average.cores.mc6_us += c->mc6_us; 1746 1711 1747 1712 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); 1713 + average.cores.core_throt_cnt = MAX(average.cores.core_throt_cnt, c->core_throt_cnt); 1748 1714 1749 1715 average.cores.core_energy += c->core_energy; 1750 1716 ··· 2023 1987 fprintf(outf, "cpu%d: BIOS BUG: apic 0x%x x2apic 0x%x\n", t->cpu_id, t->apic_id, t->x2apic_id); 2024 1988 } 2025 1989 1990 + int get_core_throt_cnt(int cpu, unsigned long long *cnt) 1991 + { 1992 + char path[128 + PATH_BYTES]; 1993 + unsigned long long tmp; 1994 + FILE *fp; 1995 + int ret; 1996 + 1997 + sprintf(path, "/sys/devices/system/cpu/cpu%d/thermal_throttle/core_throttle_count", cpu); 1998 + fp = fopen(path, "r"); 1999 + if (!fp) 2000 + return -1; 2001 + ret = fscanf(fp, "%lld", &tmp); 2002 + if (ret != 1) 2003 + return -1; 2004 + fclose(fp); 2005 + *cnt = tmp; 2006 + 2007 + return 0; 2008 + } 2009 + 2026 2010 /* 2027 2011 * get_counters(...) 2028 2012 * migrate to cpu ··· 2184 2128 return -9; 2185 2129 c->core_temp_c = tj_max - ((msr >> 16) & 0x7F); 2186 2130 } 2131 + 2132 + if (DO_BIC(BIC_CORE_THROT_CNT)) 2133 + get_core_throt_cnt(cpu, &c->core_throt_cnt); 2187 2134 2188 2135 if (do_rapl & RAPL_AMD_F17H) { 2189 2136 if (get_msr(cpu, MSR_CORE_ENERGY_STAT, &msr)) ··· 2487 2428 if (!genuine_intel) 2488 2429 return 0; 2489 2430 2431 + if (family != 6) 2432 + return 0; 2433 + 2490 2434 switch (model) { 2491 2435 case INTEL_FAM6_ATOM_GOLDMONT: 2492 2436 case INTEL_FAM6_SKYLAKE_X: ··· 2497 2435 case INTEL_FAM6_ATOM_GOLDMONT_D: 2498 2436 case INTEL_FAM6_ATOM_TREMONT_D: 2499 2437 return 1; 2438 + default: 2439 + return 0; 2500 2440 } 2501 - return 0; 2502 2441 } 2503 2442 2504 2443 static void dump_turbo_ratio_limits(int family, int model) ··· 3090 3027 */ 3091 3028 int count_cpus(int cpu) 3092 3029 { 3030 + UNUSED(cpu); 3031 + 3093 3032 topo.num_cpus++; 3094 3033 return 0; 3095 3034 } ··· 3426 3361 int i, ret; 3427 3362 int cpu = t->cpu_id; 3428 3363 3364 + UNUSED(c); 3365 + UNUSED(p); 3366 + 3429 3367 for (i = IDX_PKG_ENERGY; i < IDX_COUNT; i++) { 3430 3368 unsigned long long msr_cur, msr_last; 3431 3369 off_t offset; ··· 3455 3387 3456 3388 static void msr_record_handler(union sigval v) 3457 3389 { 3390 + UNUSED(v); 3391 + 3458 3392 for_all_cpus(update_msr_sum, EVEN_COUNTERS); 3459 3393 } 3460 3394 ··· 3509 3439 /* 3510 3440 * set_my_sched_priority(pri) 3511 3441 * return previous 3442 + * 3443 + * if non-root, do this: 3444 + * # /sbin/setcap cap_sys_rawio,cap_sys_nice=+ep /usr/bin/turbostat 3512 3445 */ 3513 3446 int set_my_sched_priority(int priority) 3514 3447 { ··· 3530 3457 errno = 0; 3531 3458 retval = getpriority(PRIO_PROCESS, 0); 3532 3459 if (retval != priority) 3533 - err(-1, "getpriority(%d) != setpriority(%d)", retval, priority); 3460 + err(retval, "getpriority(%d) != setpriority(%d)", retval, priority); 3534 3461 3535 3462 return original_priority; 3536 3463 } ··· 3539 3466 { 3540 3467 int retval; 3541 3468 int restarted = 0; 3542 - int done_iters = 0; 3469 + unsigned int done_iters = 0; 3543 3470 3544 3471 setup_signal_handler(); 3545 3472 ··· 3751 3678 break; 3752 3679 case INTEL_FAM6_ATOM_SILVERMONT: /* BYT */ 3753 3680 no_MSR_MISC_PWR_MGMT = 1; 3681 + /* FALLTHRU */ 3754 3682 case INTEL_FAM6_ATOM_SILVERMONT_D: /* AVN */ 3755 3683 pkg_cstate_limits = slv_pkg_cstate_limits; 3756 3684 break; ··· 3795 3721 if (!genuine_intel) 3796 3722 return 0; 3797 3723 3724 + if (family != 6) 3725 + return 0; 3726 + 3798 3727 switch (model) { 3799 3728 case INTEL_FAM6_ATOM_SILVERMONT: 3800 3729 case INTEL_FAM6_ATOM_SILVERMONT_MID: ··· 3813 3736 if (!genuine_intel) 3814 3737 return 0; 3815 3738 3739 + if (family != 6) 3740 + return 0; 3741 + 3816 3742 switch (model) { 3817 3743 case INTEL_FAM6_ATOM_GOLDMONT_D: 3818 3744 return 1; ··· 3827 3747 { 3828 3748 3829 3749 if (!genuine_intel) 3750 + return 0; 3751 + 3752 + if (family != 6) 3830 3753 return 0; 3831 3754 3832 3755 switch (model) { ··· 3845 3762 if (!genuine_intel) 3846 3763 return 0; 3847 3764 3765 + if (family != 6) 3766 + return 0; 3767 + 3848 3768 switch (model) { 3849 3769 case INTEL_FAM6_SKYLAKE_X: 3850 3770 return 1; ··· 3859 3773 { 3860 3774 3861 3775 if (!genuine_intel) 3776 + return 0; 3777 + 3778 + if (family != 6) 3862 3779 return 0; 3863 3780 3864 3781 switch (model) { ··· 3876 3787 if (!genuine_intel) 3877 3788 return 0; 3878 3789 3790 + if (family != 6) 3791 + return 0; 3792 + 3879 3793 switch (model) { 3880 3794 case INTEL_FAM6_ATOM_TREMONT: 3881 3795 return 1; ··· 3891 3799 if (!genuine_intel) 3892 3800 return 0; 3893 3801 3802 + if (family != 6) 3803 + return 0; 3804 + 3894 3805 switch (model) { 3895 3806 case INTEL_FAM6_ATOM_TREMONT_D: 3896 3807 return 1; ··· 3904 3809 int has_turbo_ratio_limit(unsigned int family, unsigned int model) 3905 3810 { 3906 3811 if (has_slv_msrs(family, model)) 3812 + return 0; 3813 + 3814 + if (family != 6) 3907 3815 return 0; 3908 3816 3909 3817 switch (model) { ··· 4223 4125 char *epb_string; 4224 4126 int cpu, epb; 4225 4127 4128 + UNUSED(c); 4129 + UNUSED(p); 4130 + 4226 4131 if (!has_epb) 4227 4132 return 0; 4228 4133 ··· 4271 4170 { 4272 4171 unsigned long long msr; 4273 4172 int cpu; 4173 + 4174 + UNUSED(c); 4175 + UNUSED(p); 4274 4176 4275 4177 if (!has_hwp) 4276 4178 return 0; ··· 4357 4253 { 4358 4254 unsigned long long msr; 4359 4255 int cpu; 4256 + 4257 + UNUSED(c); 4258 + UNUSED(p); 4360 4259 4361 4260 cpu = t->cpu_id; 4362 4261 ··· 4466 4359 4467 4360 double get_tdp_amd(unsigned int family) 4468 4361 { 4362 + UNUSED(family); 4363 + 4469 4364 /* This is the max stock TDP of HEDT/Server Fam17h+ chips */ 4470 4365 return 280.0; 4471 4366 } ··· 4485 4376 case INTEL_FAM6_BROADWELL_X: /* BDX */ 4486 4377 case INTEL_FAM6_SKYLAKE_X: /* SKX */ 4487 4378 case INTEL_FAM6_XEON_PHI_KNL: /* KNL */ 4379 + case INTEL_FAM6_ICELAKE_X: /* ICX */ 4488 4380 return (rapl_dram_energy_units = 15.3 / 1000000); 4489 4381 default: 4490 4382 return (rapl_energy_units); ··· 4669 4559 unsigned int has_rapl = 0; 4670 4560 double tdp; 4671 4561 4562 + UNUSED(model); 4563 + 4672 4564 if (max_extended_level >= 0x80000007) { 4673 4565 __cpuid(0x80000007, eax, ebx, ecx, edx); 4674 4566 /* RAPL (Fam 17h+) */ ··· 4729 4617 case INTEL_FAM6_HASWELL_L: /* HSW */ 4730 4618 case INTEL_FAM6_HASWELL_G: /* HSW */ 4731 4619 do_gfx_perf_limit_reasons = 1; 4620 + /* FALLTHRU */ 4732 4621 case INTEL_FAM6_HASWELL_X: /* HSX */ 4733 4622 do_core_perf_limit_reasons = 1; 4734 4623 do_ring_perf_limit_reasons = 1; ··· 4755 4642 unsigned long long msr; 4756 4643 unsigned int dts, dts2; 4757 4644 int cpu; 4645 + 4646 + UNUSED(c); 4647 + UNUSED(p); 4758 4648 4759 4649 if (!(do_dts || do_ptm)) 4760 4650 return 0; ··· 4814 4698 4815 4699 void print_power_limit_msr(int cpu, unsigned long long msr, char *label) 4816 4700 { 4817 - fprintf(outf, "cpu%d: %s: %sabled (%f Watts, %f sec, clamp %sabled)\n", 4701 + fprintf(outf, "cpu%d: %s: %sabled (%0.3f Watts, %f sec, clamp %sabled)\n", 4818 4702 cpu, label, 4819 4703 ((msr >> 15) & 1) ? "EN" : "DIS", 4820 4704 ((msr >> 0) & 0x7FFF) * rapl_power_units, ··· 4829 4713 unsigned long long msr; 4830 4714 const char *msr_name; 4831 4715 int cpu; 4716 + 4717 + UNUSED(c); 4718 + UNUSED(p); 4832 4719 4833 4720 if (!do_rapl) 4834 4721 return 0; ··· 4881 4762 cpu, msr, (msr >> 63) & 1 ? "" : "UN"); 4882 4763 4883 4764 print_power_limit_msr(cpu, msr, "PKG Limit #1"); 4884 - fprintf(outf, "cpu%d: PKG Limit #2: %sabled (%f Watts, %f* sec, clamp %sabled)\n", 4765 + fprintf(outf, "cpu%d: PKG Limit #2: %sabled (%0.3f Watts, %f* sec, clamp %sabled)\n", 4885 4766 cpu, 4886 4767 ((msr >> 47) & 1) ? "EN" : "DIS", 4887 4768 ((msr >> 32) & 0x7FFF) * rapl_power_units, 4888 4769 (1.0 + (((msr >> 54) & 0x3) / 4.0)) * (1 << ((msr >> 49) & 0x1F)) * rapl_time_units, 4889 4770 ((msr >> 48) & 1) ? "EN" : "DIS"); 4771 + 4772 + if (get_msr(cpu, MSR_VR_CURRENT_CONFIG, &msr)) 4773 + return -9; 4774 + 4775 + fprintf(outf, "cpu%d: MSR_VR_CURRENT_CONFIG: 0x%08llx\n", cpu, msr); 4776 + fprintf(outf, "cpu%d: PKG Limit #4: %f Watts (%slocked)\n", 4777 + cpu, ((msr >> 0) & 0x1FFF) * rapl_power_units, (msr >> 31) & 1 ? "" : "UN"); 4890 4778 } 4891 4779 4892 4780 if (do_rapl & RAPL_DRAM_POWER_INFO) { ··· 4956 4830 if (!genuine_intel) 4957 4831 return 0; 4958 4832 4833 + if (family != 6) 4834 + return 0; 4835 + 4959 4836 switch (model) { 4960 4837 case INTEL_FAM6_SANDYBRIDGE: 4961 4838 case INTEL_FAM6_SANDYBRIDGE_X: ··· 5002 4873 if (!genuine_intel) 5003 4874 return 0; 5004 4875 4876 + if (family != 6) 4877 + return 0; 4878 + 5005 4879 switch (model) { 5006 4880 case INTEL_FAM6_HASWELL_L: /* HSW */ 5007 4881 case INTEL_FAM6_BROADWELL: /* BDW */ ··· 5031 4899 if (!genuine_intel) 5032 4900 return 0; 5033 4901 4902 + if (family != 6) 4903 + return 0; 4904 + 5034 4905 switch (model) { 5035 4906 case INTEL_FAM6_SKYLAKE_L: /* SKL */ 5036 4907 case INTEL_FAM6_CANNONLAKE_L: /* CNL */ ··· 5046 4911 { 5047 4912 if (!genuine_intel) 5048 4913 return 0; 4914 + 4915 + if (family != 6) 4916 + return 0; 4917 + 5049 4918 switch (model) { 5050 4919 case INTEL_FAM6_ATOM_SILVERMONT: /* BYT */ 5051 4920 case INTEL_FAM6_ATOM_SILVERMONT_D: /* AVN */ ··· 5062 4923 { 5063 4924 if (!genuine_intel) 5064 4925 return 0; 4926 + 4927 + if (family != 6) 4928 + return 0; 4929 + 5065 4930 switch (model) { 5066 4931 case INTEL_FAM6_XEON_PHI_KNL: /* KNL */ 5067 4932 return 1; ··· 5076 4933 int is_cnl(unsigned int family, unsigned int model) 5077 4934 { 5078 4935 if (!genuine_intel) 4936 + return 0; 4937 + 4938 + if (family != 6) 5079 4939 return 0; 5080 4940 5081 4941 switch (model) { ··· 5135 4989 { 5136 4990 unsigned int eax, ebx, ecx, edx; 5137 4991 4992 + UNUSED(c); 4993 + UNUSED(p); 4994 + 5138 4995 if (!genuine_intel) 5139 4996 return 0; 5140 4997 ··· 5173 5024 unsigned long long msr; 5174 5025 unsigned int tcc_default, tcc_offset; 5175 5026 int cpu; 5027 + 5028 + UNUSED(c); 5029 + UNUSED(p); 5176 5030 5177 5031 /* tj_max is used only for dts or ptm */ 5178 5032 if (!(do_dts || do_ptm)) ··· 5724 5572 else 5725 5573 BIC_NOT_PRESENT(BIC_CPU_LPI); 5726 5574 5575 + if (!access("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", R_OK)) 5576 + BIC_PRESENT(BIC_CORE_THROT_CNT); 5577 + else 5578 + BIC_NOT_PRESENT(BIC_CORE_THROT_CNT); 5579 + 5727 5580 if (!access(sys_lpi_file_sysfs, R_OK)) { 5728 5581 sys_lpi_file = sys_lpi_file_sysfs; 5729 5582 BIC_PRESENT(BIC_SYS_LPI); ··· 5756 5599 return 1; 5757 5600 else 5758 5601 return 0; 5759 - } 5760 - 5761 - int open_dev_cpu_msr(int dummy1) 5762 - { 5763 - return 0; 5764 5602 } 5765 5603 5766 5604 void topology_probe() ··· 6048 5896 6049 5897 if (!quiet && do_irtl_snb) 6050 5898 print_irtl(); 5899 + 5900 + if (DO_BIC(BIC_IPC)) 5901 + (void)get_instr_count_fd(base_cpu); 6051 5902 } 6052 5903 6053 5904 int fork_it(char **argv) ··· 6128 5973 6129 5974 void print_version() 6130 5975 { 6131 - fprintf(outf, "turbostat version 21.05.04" " - Len Brown <lenb@kernel.org>\n"); 5976 + fprintf(outf, "turbostat version 2022.04.16 - Len Brown <lenb@kernel.org>\n"); 6132 5977 } 6133 5978 6134 5979 int add_counter(unsigned int msr_num, char *path, char *name, ··· 6293 6138 } 6294 6139 } 6295 6140 6141 + int is_deferred_add(char *name) 6142 + { 6143 + int i; 6144 + 6145 + for (i = 0; i < deferred_add_index; ++i) 6146 + if (!strcmp(name, deferred_add_names[i])) 6147 + return 1; 6148 + return 0; 6149 + } 6150 + 6296 6151 int is_deferred_skip(char *name) 6297 6152 { 6298 6153 int i; ··· 6320 6155 FILE *input; 6321 6156 int state; 6322 6157 char *sp; 6323 - 6324 - if (!DO_BIC(BIC_sysfs)) 6325 - return; 6326 6158 6327 6159 for (state = 10; state >= 0; --state) { 6328 6160 ··· 6342 6180 fclose(input); 6343 6181 6344 6182 sprintf(path, "cpuidle/state%d/time", state); 6183 + 6184 + if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf)) 6185 + continue; 6345 6186 6346 6187 if (is_deferred_skip(name_buf)) 6347 6188 continue; ··· 6370 6205 remove_underbar(name_buf); 6371 6206 6372 6207 sprintf(path, "cpuidle/state%d/usage", state); 6208 + 6209 + if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf)) 6210 + continue; 6373 6211 6374 6212 if (is_deferred_skip(name_buf)) 6375 6213 continue; ··· 6481 6313 { "interval", required_argument, 0, 'i' }, 6482 6314 { "IPC", no_argument, 0, 'I' }, 6483 6315 { "num_iterations", required_argument, 0, 'n' }, 6316 + { "header_iterations", required_argument, 0, 'N' }, 6484 6317 { "help", no_argument, 0, 'h' }, 6485 6318 { "hide", required_argument, 0, 'H' }, // meh, -h taken by --help 6486 6319 { "Joules", no_argument, 0, 'J' }, ··· 6563 6394 exit(2); 6564 6395 } 6565 6396 break; 6397 + case 'N': 6398 + header_iterations = strtod(optarg, NULL); 6399 + 6400 + if (header_iterations <= 0) { 6401 + fprintf(outf, "iterations %d should be positive number\n", header_iterations); 6402 + exit(2); 6403 + } 6404 + break; 6566 6405 case 's': 6567 6406 /* 6568 6407 * --show: show only those specified ··· 6609 6432 6610 6433 turbostat_init(); 6611 6434 6435 + msr_sum_record(); 6436 + 6612 6437 /* dump counters and exit */ 6613 6438 if (dump_only) 6614 6439 return get_and_dump_counters(); ··· 6622 6443 return 0; 6623 6444 } 6624 6445 6625 - msr_sum_record(); 6626 6446 /* 6627 6447 * if any params left, it must be a command to fork 6628 6448 */