Lines Matching +full:ecx +full:- +full:1000
1 // SPDX-License-Identifier: GPL-2.0-only
3 * turbostat -- show CPU frequency and C-state residency
135 /* Indicates cores energy collection is per-core,
136 * not per-package. */
144 /* MSRs that are not yet in the kernel-provided header. */
153 * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters
191 unsigned long long mc6_us; /* duplicate as per-core for now, even though per module */
282 /* get_msr_sum() = sum + (get_msr() - last) */
318 offset = -1; in idx_to_offset()
347 idx = -1; in offset_to_idx()
391 int logical_node_id; /* 0-based count within the package */
426 * skip non-present cpus
447 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus()
468 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) in cpu_migrate()
469 return -1; in cpu_migrate()
486 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root", pathname); in get_msr_fd()
500 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
507 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
509 * matching on them for --show and --hide.
637 * HIDE_LIST - hide this list of counters, show the rest [default]
638 * SHOW_LIST - show this list of counters, hide the rest
645 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" in help()
649 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" in help()
651 " -a, --add add a counter\n" in help()
652 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" in help()
653 " -c, --cpu cpu-set limit output to summary plus cpu-set:\n" in help()
654 " {core | package | j,k,l..m,n-p }\n" in help()
655 " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n" in help()
656 " -D, --Dump displays the raw counter values\n" in help()
657 " -e, --enable [all | column]\n" in help()
659 " -H, --hide [column|column,column,...]\n" in help()
661 " -i, --interval sec.subsec\n" in help()
662 " Override default 5-second measurement interval\n" in help()
663 " -J, --Joules displays energy in Joules instead of Watts\n" in help()
664 " -l, --list list column headers only\n" in help()
665 " -n, --num_iterations num\n" in help()
667 " -o, --out file\n" in help()
669 " -q, --quiet skip decoding system configuration header\n" in help()
670 " -s, --show [column|column,column,...]\n" in help()
672 " -S, --Summary\n" in help()
673 " limits output to 1-line system summary per interval\n" in help()
674 " -T, --TCC temperature\n" in help()
677 " -h, --help print this help message\n" in help()
678 " -v, --version print version information\n" in help()
713 exit(-1); in bic_lookup()
719 fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", in bic_lookup()
777 for (mp = sys.tp; mp; mp = mp->next) { in print_header()
779 if (mp->format == FORMAT_RAW) { in print_header()
780 if (mp->width == 64) in print_header()
781 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name); in print_header()
783 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name); in print_header()
785 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
786 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name); in print_header()
788 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name); in print_header()
815 for (mp = sys.cp; mp; mp = mp->next) { in print_header()
816 if (mp->format == FORMAT_RAW) { in print_header()
817 if (mp->width == 64) in print_header()
818 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
820 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
822 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
823 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
825 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
896 for (mp = sys.pp; mp; mp = mp->next) { in print_header()
897 if (mp->format == FORMAT_RAW) { in print_header()
898 if (mp->width == 64) in print_header()
899 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
901 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
903 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
904 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
906 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
923 t->cpu_id, t->flags); in dump_counters()
924 outp += sprintf(outp, "TSC: %016llX\n", t->tsc); in dump_counters()
925 outp += sprintf(outp, "aperf: %016llX\n", t->aperf); in dump_counters()
926 outp += sprintf(outp, "mperf: %016llX\n", t->mperf); in dump_counters()
927 outp += sprintf(outp, "c1: %016llX\n", t->c1); in dump_counters()
930 outp += sprintf(outp, "IRQ: %lld\n", t->irq_count); in dump_counters()
932 outp += sprintf(outp, "SMI: %d\n", t->smi_count); in dump_counters()
934 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in dump_counters()
936 i, mp->msr_num, t->counter[i]); in dump_counters()
941 outp += sprintf(outp, "core: %d\n", c->core_id); in dump_counters()
942 outp += sprintf(outp, "c3: %016llX\n", c->c3); in dump_counters()
943 outp += sprintf(outp, "c6: %016llX\n", c->c6); in dump_counters()
944 outp += sprintf(outp, "c7: %016llX\n", c->c7); in dump_counters()
945 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); in dump_counters()
946 outp += sprintf(outp, "Joules: %0X\n", c->core_energy); in dump_counters()
948 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in dump_counters()
950 i, mp->msr_num, c->counter[i]); in dump_counters()
952 outp += sprintf(outp, "mc6_us: %016llX\n", c->mc6_us); in dump_counters()
956 outp += sprintf(outp, "package: %d\n", p->package_id); in dump_counters()
958 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); in dump_counters()
959 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); in dump_counters()
960 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); in dump_counters()
961 outp += sprintf(outp, "CPU + GFX: %016llX\n", p->pkg_both_core_gfxe_c0); in dump_counters()
963 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); in dump_counters()
965 outp += sprintf(outp, "pc3: %016llX\n", p->pc3); in dump_counters()
967 outp += sprintf(outp, "pc6: %016llX\n", p->pc6); in dump_counters()
969 outp += sprintf(outp, "pc7: %016llX\n", p->pc7); in dump_counters()
970 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); in dump_counters()
971 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); in dump_counters()
972 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); in dump_counters()
973 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi); in dump_counters()
974 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi); in dump_counters()
975 outp += sprintf(outp, "Joules PKG: %0llX\n", p->energy_pkg); in dump_counters()
976 outp += sprintf(outp, "Joules COR: %0llX\n", p->energy_cores); in dump_counters()
977 outp += sprintf(outp, "Joules GFX: %0llX\n", p->energy_gfx); in dump_counters()
978 outp += sprintf(outp, "Joules RAM: %0llX\n", p->energy_dram); in dump_counters()
980 p->rapl_pkg_perf_status); in dump_counters()
982 p->rapl_dram_perf_status); in dump_counters()
983 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c); in dump_counters()
985 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in dump_counters()
987 i, mp->msr_num, p->counter[i]); in dump_counters()
1010 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1014 if (show_pkg_only && !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1017 /*if not summary line and --cpu is used */ in format_counters()
1019 (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) in format_counters()
1026 timersub(&t->tv_end, &t->tv_begin, &tv); in format_counters()
1032 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec); in format_counters()
1034 interval_float = t->tv_delta.tv_sec + t->tv_delta.tv_usec/1000000.0; in format_counters()
1036 tsc = t->tsc * tsc_tweak; in format_counters()
1041 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1043 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1045 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1047 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1049 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1051 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1053 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1057 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); in format_counters()
1059 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1063 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].die_id); in format_counters()
1065 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1071 cpus[t->cpu_id].physical_node_id); in format_counters()
1073 outp += sprintf(outp, "%s-", in format_counters()
1078 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); in format_counters()
1080 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1083 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); in format_counters()
1085 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id); in format_counters()
1087 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id); in format_counters()
1092 1.0 / units * t->aperf / interval_float); in format_counters()
1095 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->mperf/tsc); in format_counters()
1099 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), base_hz / units * t->aperf / t->mperf); in format_counters()
1102 tsc / units * t->aperf / t->mperf / interval_float); in format_counters()
1106 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 * t->tsc/units/interval_float); in format_counters()
1111 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1113 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1118 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->smi_count); in format_counters()
1121 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in format_counters()
1122 if (mp->format == FORMAT_RAW) { in format_counters()
1123 if (mp->width == 32) in format_counters()
1124 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) t->counter[i]); in format_counters()
1126 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1127 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1128 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1129 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1131 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1132 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1133 if (mp->type == COUNTER_USEC) in format_counters()
1134 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), t->counter[i]/interval_float/10000); in format_counters()
1136 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->counter[i]/tsc); in format_counters()
1142 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->c1/tsc); in format_counters()
1145 /* print per-core data only for 1st thread in core */ in format_counters()
1146 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1150 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3/tsc); in format_counters()
1152 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6/tsc); in format_counters()
1154 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c7/tsc); in format_counters()
1158 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->mc6_us / tsc); in format_counters()
1161 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); in format_counters()
1163 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in format_counters()
1164 if (mp->format == FORMAT_RAW) { in format_counters()
1165 if (mp->width == 32) in format_counters()
1166 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) c->counter[i]); in format_counters()
1168 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1169 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1170 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1171 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1173 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1174 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1175 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->counter[i]/tsc); in format_counters()
1182 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units / interva… in format_counters()
1184 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units); in format_counters()
1186 /* print per-package data only for 1st core in package */ in format_counters()
1187 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1192 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->pkg_temp_c); in format_counters()
1196 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
1200 p->gfx_rc6_ms / 10.0 / interval_float); in format_counters()
1206 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz); in format_counters()
1210 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_act_mhz); in format_counters()
1214 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0/tsc); in format_counters()
1216 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0/tsc); in format_counters()
1218 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0/tsc); in format_counters()
1220 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0/tsc); in format_counters()
1223 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2/tsc); in format_counters()
1225 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc3/tsc); in format_counters()
1227 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc6/tsc); in format_counters()
1229 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc7/tsc); in format_counters()
1231 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc8/tsc); in format_counters()
1233 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc9/tsc); in format_counters()
1235 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10/tsc); in format_counters()
1238 …outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->cpu_lpi / 1000000.0 / interva… in format_counters()
1240 …outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->sys_lpi / 1000000.0 / interva… in format_counters()
1243 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units / interval… in format_counters()
1245 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units / interv… in format_counters()
1247 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units / interval… in format_counters()
1249 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units / in… in format_counters()
1251 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units); in format_counters()
1253 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units); in format_counters()
1255 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units); in format_counters()
1257 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units); in format_counters()
1259 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), 100.0 * p->rapl_pkg_perf_status * rapl_time_… in format_counters()
1261 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), 100.0 * p->rapl_dram_perf_status * rapl_time… in format_counters()
1263 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in format_counters()
1264 if (mp->format == FORMAT_RAW) { in format_counters()
1265 if (mp->width == 32) in format_counters()
1266 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) p->counter[i]); in format_counters()
1268 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1269 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1270 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1271 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1273 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1274 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1275 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->counter[i]/tsc); in format_counters()
1280 if (*(outp - 1) != '\n') in format_counters()
1324 old = ((((unsigned long long)new << 32) - ((unsigned long long)old << 32)) >> 32);
1334 old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0; in delta_package()
1336 old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0; in delta_package()
1338 old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0; in delta_package()
1340 old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0; in delta_package()
1342 old->pc2 = new->pc2 - old->pc2; in delta_package()
1344 old->pc3 = new->pc3 - old->pc3; in delta_package()
1346 old->pc6 = new->pc6 - old->pc6; in delta_package()
1348 old->pc7 = new->pc7 - old->pc7; in delta_package()
1349 old->pc8 = new->pc8 - old->pc8; in delta_package()
1350 old->pc9 = new->pc9 - old->pc9; in delta_package()
1351 old->pc10 = new->pc10 - old->pc10; in delta_package()
1352 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi; in delta_package()
1353 old->sys_lpi = new->sys_lpi - old->sys_lpi; in delta_package()
1354 old->pkg_temp_c = new->pkg_temp_c; in delta_package()
1357 if (old->gfx_rc6_ms > new->gfx_rc6_ms) in delta_package()
1358 old->gfx_rc6_ms = -1; in delta_package()
1360 old->gfx_rc6_ms = new->gfx_rc6_ms - old->gfx_rc6_ms; in delta_package()
1362 old->gfx_mhz = new->gfx_mhz; in delta_package()
1363 old->gfx_act_mhz = new->gfx_act_mhz; in delta_package()
1365 old->energy_pkg = new->energy_pkg - old->energy_pkg; in delta_package()
1366 old->energy_cores = new->energy_cores - old->energy_cores; in delta_package()
1367 old->energy_gfx = new->energy_gfx - old->energy_gfx; in delta_package()
1368 old->energy_dram = new->energy_dram - old->energy_dram; in delta_package()
1369 old->rapl_pkg_perf_status = new->rapl_pkg_perf_status - old->rapl_pkg_perf_status; in delta_package()
1370 old->rapl_dram_perf_status = new->rapl_dram_perf_status - old->rapl_dram_perf_status; in delta_package()
1372 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in delta_package()
1373 if (mp->format == FORMAT_RAW) in delta_package()
1374 old->counter[i] = new->counter[i]; in delta_package()
1376 old->counter[i] = new->counter[i] - old->counter[i]; in delta_package()
1388 old->c3 = new->c3 - old->c3; in delta_core()
1389 old->c6 = new->c6 - old->c6; in delta_core()
1390 old->c7 = new->c7 - old->c7; in delta_core()
1391 old->core_temp_c = new->core_temp_c; in delta_core()
1392 old->mc6_us = new->mc6_us - old->mc6_us; in delta_core()
1394 DELTA_WRAP32(new->core_energy, old->core_energy); in delta_core()
1396 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in delta_core()
1397 if (mp->format == FORMAT_RAW) in delta_core()
1398 old->counter[i] = new->counter[i]; in delta_core()
1400 old->counter[i] = new->counter[i] - old->counter[i]; in delta_core()
1413 * old = new - old
1424 new->apic_id = old->apic_id; in delta_thread()
1426 new->x2apic_id = old->x2apic_id; in delta_thread()
1431 * over-write old w/ new so we can print end of interval values in delta_thread()
1434 timersub(&new->tv_begin, &old->tv_begin, &old->tv_delta); in delta_thread()
1435 old->tv_begin = new->tv_begin; in delta_thread()
1436 old->tv_end = new->tv_end; in delta_thread()
1438 old->tsc = new->tsc - old->tsc; in delta_thread()
1441 if (old->tsc < (1000 * 1000)) in delta_thread()
1442 errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n" in delta_thread()
1443 "You can disable all c-states by booting with \"idle=poll\"\n" in delta_thread()
1446 old->c1 = new->c1 - old->c1; in delta_thread()
1450 if ((new->aperf > old->aperf) && (new->mperf > old->mperf)) { in delta_thread()
1451 old->aperf = new->aperf - old->aperf; in delta_thread()
1452 old->mperf = new->mperf - old->mperf; in delta_thread()
1454 return -1; in delta_thread()
1467 * it is possible for mperf's non-halted cycles + idle states in delta_thread()
1470 if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) in delta_thread()
1471 old->c1 = 0; in delta_thread()
1474 old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 in delta_thread()
1475 - core_delta->c6 - core_delta->c7; in delta_thread()
1479 if (old->mperf == 0) { in delta_thread()
1481 fprintf(outf, "cpu%d MPERF 0!\n", old->cpu_id); in delta_thread()
1482 old->mperf = 1; /* divide by 0 protection */ in delta_thread()
1486 old->irq_count = new->irq_count - old->irq_count; in delta_thread()
1489 old->smi_count = new->smi_count - old->smi_count; in delta_thread()
1491 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in delta_thread()
1492 if (mp->format == FORMAT_RAW) in delta_thread()
1493 old->counter[i] = new->counter[i]; in delta_thread()
1495 old->counter[i] = new->counter[i] - old->counter[i]; in delta_thread()
1507 if (t->flags & CPU_IS_FIRST_THREAD_IN_CORE) in delta_cpu()
1516 if (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE) in delta_cpu()
1527 t->tv_begin.tv_sec = 0; in clear_counters()
1528 t->tv_begin.tv_usec = 0; in clear_counters()
1529 t->tv_end.tv_sec = 0; in clear_counters()
1530 t->tv_end.tv_usec = 0; in clear_counters()
1531 t->tv_delta.tv_sec = 0; in clear_counters()
1532 t->tv_delta.tv_usec = 0; in clear_counters()
1534 t->tsc = 0; in clear_counters()
1535 t->aperf = 0; in clear_counters()
1536 t->mperf = 0; in clear_counters()
1537 t->c1 = 0; in clear_counters()
1539 t->irq_count = 0; in clear_counters()
1540 t->smi_count = 0; in clear_counters()
1543 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE; in clear_counters()
1545 c->c3 = 0; in clear_counters()
1546 c->c6 = 0; in clear_counters()
1547 c->c7 = 0; in clear_counters()
1548 c->mc6_us = 0; in clear_counters()
1549 c->core_temp_c = 0; in clear_counters()
1550 c->core_energy = 0; in clear_counters()
1552 p->pkg_wtd_core_c0 = 0; in clear_counters()
1553 p->pkg_any_core_c0 = 0; in clear_counters()
1554 p->pkg_any_gfxe_c0 = 0; in clear_counters()
1555 p->pkg_both_core_gfxe_c0 = 0; in clear_counters()
1557 p->pc2 = 0; in clear_counters()
1559 p->pc3 = 0; in clear_counters()
1561 p->pc6 = 0; in clear_counters()
1563 p->pc7 = 0; in clear_counters()
1564 p->pc8 = 0; in clear_counters()
1565 p->pc9 = 0; in clear_counters()
1566 p->pc10 = 0; in clear_counters()
1567 p->cpu_lpi = 0; in clear_counters()
1568 p->sys_lpi = 0; in clear_counters()
1570 p->energy_pkg = 0; in clear_counters()
1571 p->energy_dram = 0; in clear_counters()
1572 p->energy_cores = 0; in clear_counters()
1573 p->energy_gfx = 0; in clear_counters()
1574 p->rapl_pkg_perf_status = 0; in clear_counters()
1575 p->rapl_dram_perf_status = 0; in clear_counters()
1576 p->pkg_temp_c = 0; in clear_counters()
1578 p->gfx_rc6_ms = 0; in clear_counters()
1579 p->gfx_mhz = 0; in clear_counters()
1580 p->gfx_act_mhz = 0; in clear_counters()
1581 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) in clear_counters()
1582 t->counter[i] = 0; in clear_counters()
1584 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) in clear_counters()
1585 c->counter[i] = 0; in clear_counters()
1587 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) in clear_counters()
1588 p->counter[i] = 0; in clear_counters()
1596 /* copy un-changing apic_id's */ in sum_counters()
1598 average.threads.apic_id = t->apic_id; in sum_counters()
1600 average.threads.x2apic_id = t->x2apic_id; in sum_counters()
1604 average.threads.tv_begin = t->tv_begin; in sum_counters()
1607 average.threads.tv_end = t->tv_end; in sum_counters()
1609 average.threads.tsc += t->tsc; in sum_counters()
1610 average.threads.aperf += t->aperf; in sum_counters()
1611 average.threads.mperf += t->mperf; in sum_counters()
1612 average.threads.c1 += t->c1; in sum_counters()
1614 average.threads.irq_count += t->irq_count; in sum_counters()
1615 average.threads.smi_count += t->smi_count; in sum_counters()
1617 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in sum_counters()
1618 if (mp->format == FORMAT_RAW) in sum_counters()
1620 average.threads.counter[i] += t->counter[i]; in sum_counters()
1623 /* sum per-core values only for 1st thread in core */ in sum_counters()
1624 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in sum_counters()
1627 average.cores.c3 += c->c3; in sum_counters()
1628 average.cores.c6 += c->c6; in sum_counters()
1629 average.cores.c7 += c->c7; in sum_counters()
1630 average.cores.mc6_us += c->mc6_us; in sum_counters()
1632 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); in sum_counters()
1634 average.cores.core_energy += c->core_energy; in sum_counters()
1636 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in sum_counters()
1637 if (mp->format == FORMAT_RAW) in sum_counters()
1639 average.cores.counter[i] += c->counter[i]; in sum_counters()
1642 /* sum per-pkg values only for 1st core in pkg */ in sum_counters()
1643 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in sum_counters()
1647 average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0; in sum_counters()
1649 average.packages.pkg_any_core_c0 += p->pkg_any_core_c0; in sum_counters()
1651 average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0; in sum_counters()
1653 average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0; in sum_counters()
1655 average.packages.pc2 += p->pc2; in sum_counters()
1657 average.packages.pc3 += p->pc3; in sum_counters()
1659 average.packages.pc6 += p->pc6; in sum_counters()
1661 average.packages.pc7 += p->pc7; in sum_counters()
1662 average.packages.pc8 += p->pc8; in sum_counters()
1663 average.packages.pc9 += p->pc9; in sum_counters()
1664 average.packages.pc10 += p->pc10; in sum_counters()
1666 average.packages.cpu_lpi = p->cpu_lpi; in sum_counters()
1667 average.packages.sys_lpi = p->sys_lpi; in sum_counters()
1669 average.packages.energy_pkg += p->energy_pkg; in sum_counters()
1670 average.packages.energy_dram += p->energy_dram; in sum_counters()
1671 average.packages.energy_cores += p->energy_cores; in sum_counters()
1672 average.packages.energy_gfx += p->energy_gfx; in sum_counters()
1674 average.packages.gfx_rc6_ms = p->gfx_rc6_ms; in sum_counters()
1675 average.packages.gfx_mhz = p->gfx_mhz; in sum_counters()
1676 average.packages.gfx_act_mhz = p->gfx_act_mhz; in sum_counters()
1678 average.packages.pkg_temp_c = MAX(average.packages.pkg_temp_c, p->pkg_temp_c); in sum_counters()
1680 average.packages.rapl_pkg_perf_status += p->rapl_pkg_perf_status; in sum_counters()
1681 average.packages.rapl_dram_perf_status += p->rapl_dram_perf_status; in sum_counters()
1683 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in sum_counters()
1684 if (mp->format == FORMAT_RAW) in sum_counters()
1686 average.packages.counter[i] += p->counter[i]; in sum_counters()
1741 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in compute_average()
1742 if (mp->format == FORMAT_RAW) in compute_average()
1744 if (mp->type == COUNTER_ITEMS) { in compute_average()
1751 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in compute_average()
1752 if (mp->format == FORMAT_RAW) in compute_average()
1754 if (mp->type == COUNTER_ITEMS) { in compute_average()
1760 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in compute_average()
1761 if (mp->format == FORMAT_RAW) in compute_average()
1763 if (mp->type == COUNTER_ITEMS) { in compute_average()
1815 if (mp->msr_num != 0) { in get_mp()
1816 if (get_msr(cpu, mp->msr_num, counterp)) in get_mp()
1817 return -1; in get_mp()
1821 if (mp->flags & SYSFS_PERCPU) { in get_mp()
1823 cpu, mp->path); in get_mp()
1827 *counterp = snapshot_sysfs_counter(mp->path); in get_mp()
1836 unsigned int eax, ebx, ecx, edx; in get_apic_id() local
1839 eax = ebx = ecx = edx = 0; in get_apic_id()
1840 __cpuid(1, eax, ebx, ecx, edx); in get_apic_id()
1842 t->apic_id = (ebx >> 24) & 0xff; in get_apic_id()
1854 eax = ebx = ecx = edx = 0; in get_apic_id()
1855 __cpuid(0x80000001, eax, ebx, ecx, edx); in get_apic_id()
1856 topology_extensions = ecx & (1 << 22); in get_apic_id()
1861 eax = ebx = ecx = edx = 0; in get_apic_id()
1862 __cpuid(0x8000001e, eax, ebx, ecx, edx); in get_apic_id()
1864 t->x2apic_id = eax; in get_apic_id()
1874 ecx = 0; in get_apic_id()
1875 __cpuid(0xb, eax, ebx, ecx, edx); in get_apic_id()
1876 t->x2apic_id = edx; in get_apic_id()
1878 if (debug && (t->apic_id != (t->x2apic_id & 0xff))) in get_apic_id()
1880 t->cpu_id, t->apic_id, t->x2apic_id); in get_apic_id()
1890 int cpu = t->cpu_id; in get_counters()
1898 return -1; in get_counters()
1901 gettimeofday(&t->tv_begin, (struct timezone *)NULL); in get_counters()
1906 t->tsc = rdtsc(); /* we are running on local CPU of interest */ in get_counters()
1919 * varies by a large amount, we re-read them. in get_counters()
1927 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
1928 return -3; in get_counters()
1930 t->tsc = rdtsc(); /* re-read close to APERF */ in get_counters()
1932 tsc_before = t->tsc; in get_counters()
1934 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
1935 return -3; in get_counters()
1939 if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) in get_counters()
1940 return -4; in get_counters()
1944 aperf_time = tsc_between - tsc_before; in get_counters()
1945 mperf_time = tsc_after - tsc_between; in get_counters()
1961 t->aperf = t->aperf * aperf_mperf_multiplier; in get_counters()
1962 t->mperf = t->mperf * aperf_mperf_multiplier; in get_counters()
1966 t->irq_count = irqs_per_cpu[cpu]; in get_counters()
1969 return -5; in get_counters()
1970 t->smi_count = msr & 0xFFFFFFFF; in get_counters()
1973 if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) in get_counters()
1974 return -6; in get_counters()
1977 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in get_counters()
1978 if (get_mp(cpu, mp, &t->counter[i])) in get_counters()
1979 return -10; in get_counters()
1983 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in get_counters()
1987 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) in get_counters()
1988 return -6; in get_counters()
1992 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
1993 return -7; in get_counters()
1995 if (get_msr(cpu, MSR_KNL_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
1996 return -7; in get_counters()
2000 if (get_msr(cpu, MSR_CORE_C7_RESIDENCY, &c->c7)) in get_counters()
2001 return -8; in get_counters()
2004 if (get_msr(cpu, MSR_MODULE_C6_RES_MS, &c->mc6_us)) in get_counters()
2005 return -8; in get_counters()
2009 return -9; in get_counters()
2010 c->core_temp_c = tcc_activation_temp - ((msr >> 16) & 0x7F); in get_counters()
2015 return -14; in get_counters()
2016 c->core_energy = msr & 0xFFFFFFFF; in get_counters()
2019 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in get_counters()
2020 if (get_mp(cpu, mp, &c->counter[i])) in get_counters()
2021 return -10; in get_counters()
2025 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in get_counters()
2029 if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) in get_counters()
2030 return -10; in get_counters()
2033 if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0)) in get_counters()
2034 return -11; in get_counters()
2037 if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0)) in get_counters()
2038 return -12; in get_counters()
2041 if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0)) in get_counters()
2042 return -13; in get_counters()
2045 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) in get_counters()
2046 return -9; in get_counters()
2049 if (get_msr(cpu, MSR_ATOM_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2050 return -10; in get_counters()
2052 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2053 return -10; in get_counters()
2058 if (get_msr(cpu, MSR_PKG_C2_RESIDENCY, &p->pc2)) in get_counters()
2059 return -11; in get_counters()
2061 if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) in get_counters()
2062 return -12; in get_counters()
2064 if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) in get_counters()
2065 return -13; in get_counters()
2067 if (get_msr(cpu, MSR_PKG_C9_RESIDENCY, &p->pc9)) in get_counters()
2068 return -13; in get_counters()
2070 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) in get_counters()
2071 return -13; in get_counters()
2074 p->cpu_lpi = cpuidle_cur_cpu_lpi_us; in get_counters()
2076 p->sys_lpi = cpuidle_cur_sys_lpi_us; in get_counters()
2080 return -13; in get_counters()
2081 p->energy_pkg = msr; in get_counters()
2085 return -14; in get_counters()
2086 p->energy_cores = msr; in get_counters()
2090 return -15; in get_counters()
2091 p->energy_dram = msr; in get_counters()
2095 return -16; in get_counters()
2096 p->energy_gfx = msr; in get_counters()
2100 return -16; in get_counters()
2101 p->rapl_pkg_perf_status = msr; in get_counters()
2105 return -16; in get_counters()
2106 p->rapl_dram_perf_status = msr; in get_counters()
2110 return -13; in get_counters()
2111 p->energy_pkg = msr; in get_counters()
2115 return -17; in get_counters()
2116 p->pkg_temp_c = tcc_activation_temp - ((msr >> 16) & 0x7F); in get_counters()
2120 p->gfx_rc6_ms = gfx_cur_rc6_ms; in get_counters()
2123 p->gfx_mhz = gfx_cur_mhz; in get_counters()
2126 p->gfx_act_mhz = gfx_act_mhz; in get_counters()
2128 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in get_counters()
2129 if (get_mp(cpu, mp, &p->counter[i])) in get_counters()
2130 return -10; in get_counters()
2133 gettimeofday(&t->tv_end, (struct timezone *)NULL); in get_counters()
2200 fprintf(outf, "cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", in dump_nhm_platform_info()
2427 * [0] -- Reserved in dump_knl_turbo_ratio_limits()
2428 * [7:1] -- Base value of number of active cores of bucket 1. in dump_knl_turbo_ratio_limits()
2429 * [15:8] -- Base value of freq ratio of bucket 1. in dump_knl_turbo_ratio_limits()
2430 * [20:16] -- +ve delta of number of active cores of bucket 2. in dump_knl_turbo_ratio_limits()
2433 * [23:21] -- Negative delta of freq ratio of bucket 2. in dump_knl_turbo_ratio_limits()
2435 * freq ratio of bucket 1 - delta in dump_knl_turbo_ratio_limits()
2436 * [28:24]-- +ve delta of number of active cores of bucket 3. in dump_knl_turbo_ratio_limits()
2437 * [31:29]-- -ve delta of freq ratio of bucket 3. in dump_knl_turbo_ratio_limits()
2438 * [36:32]-- +ve delta of number of active cores of bucket 4. in dump_knl_turbo_ratio_limits()
2439 * [39:37]-- -ve delta of freq ratio of bucket 4. in dump_knl_turbo_ratio_limits()
2440 * [44:40]-- +ve delta of number of active cores of bucket 5. in dump_knl_turbo_ratio_limits()
2441 * [47:45]-- -ve delta of freq ratio of bucket 5. in dump_knl_turbo_ratio_limits()
2442 * [52:48]-- +ve delta of number of active cores of bucket 6. in dump_knl_turbo_ratio_limits()
2443 * [55:53]-- -ve delta of freq ratio of bucket 6. in dump_knl_turbo_ratio_limits()
2444 * [60:56]-- +ve delta of number of active cores of bucket 7. in dump_knl_turbo_ratio_limits()
2445 * [63:61]-- -ve delta of freq ratio of bucket 7. in dump_knl_turbo_ratio_limits()
2457 ratio[b_nr + 1] = ratio[b_nr] - delta_ratio; in dump_knl_turbo_ratio_limits()
2461 for (i = buckets_no - 1; i >= 0; i--) in dump_knl_turbo_ratio_limits()
2462 if (i > 0 ? ratio[i] != ratio[i - 1] : 1) in dump_knl_turbo_ratio_limits()
2477 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)", in dump_nhm_cst_cfg()
2478 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", in dump_nhm_cst_cfg()
2479 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", in dump_nhm_cst_cfg()
2480 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", in dump_nhm_cst_cfg()
2481 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", in dump_nhm_cst_cfg()
2488 fprintf(outf, ", automatic c-state conversion=%s", in dump_nhm_cst_cfg()
2692 cpus[cpu].logical_node_id = -1; in set_node_data()
2701 if (cpus[cpu].logical_node_id != -1) in set_node_data()
2731 int cpu = thiscpu->logical_cpu_id; in get_physical_node_id()
2742 return -1; in get_physical_node_id()
2751 int cpu = thiscpu->logical_cpu_id; in get_thread_siblings()
2756 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); in get_thread_siblings()
2757 if (thiscpu->thread_id < 0) in get_thread_siblings()
2758 thiscpu->thread_id = thread_id++; in get_thread_siblings()
2759 if (!thiscpu->put_ids) in get_thread_siblings()
2760 return -1; in get_thread_siblings()
2763 CPU_ZERO_S(size, thiscpu->put_ids); in get_thread_siblings()
2771 return -1; in get_thread_siblings()
2774 offset -= BITMASK_SIZE; in get_thread_siblings()
2781 if (sib_core == thiscpu->physical_core_id) { in get_thread_siblings()
2782 CPU_SET_S(so, size, thiscpu->put_ids); in get_thread_siblings()
2793 return CPU_COUNT_S(size, thiscpu->put_ids); in get_thread_siblings()
2798 * skip non-present cpus
2824 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus_2()
2885 fprintf(outf, "turbostat: re-initialized with num_cpus %d\n", topo.num_cpus); in re_initialize()
2907 topo.max_cpu_num--; /* 0 based */ in set_max_cpu_num()
2927 cpus[cpu].thread_id = -1; in init_thread_id()
3089 return -1; in snapshot_cpu_lpi_us()
3113 return -1; in snapshot_sys_lpi_us()
3210 rest.tv_nsec = (tout.tv_usec % 1000000) * 1000; in do_sleep()
3227 /* get_msr_sum() = sum + (get_msr() - last) */ in get_msr_sum()
3244 int cpu = t->cpu_id; in update_msr_sum()
3294 if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) { in msr_sum_record()
3310 if (timer_settime(timerid, 0, &its, NULL) == -1) { in msr_sum_record()
3336 if (retval < -1) { in turbostat_loop()
3338 } else if (retval == -1) { in turbostat_loop()
3358 if (retval < -1) { in turbostat_loop()
3360 } else if (retval == -1) { in turbostat_loop()
3381 if (retval < -1) { in turbostat_loop()
3383 } else if (retval == -1) { in turbostat_loop()
3411 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); in check_dev_msr()
3426 err(-6, "cap_get_proc\n"); in check_for_cap_sys_rawio()
3429 err(-6, "cap_get\n"); in check_for_cap_sys_rawio()
3437 if (cap_free(caps) == -1) in check_for_cap_sys_rawio()
3438 err(-6, "cap_free\n"); in check_for_cap_sys_rawio()
3463 exit(-6); in check_permissions()
3500 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in probe_nhm_msrs()
3501 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in probe_nhm_msrs()
3644 /* Nehalem compatible, but do not include turbo-ratio limit support */ in has_turbo_ratio_limit()
3645 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in has_turbo_ratio_limit()
3646 case INTEL_FAM6_XEON_PHI_KNL: /* PHI - Knights Landing (different MSR definition) */ in has_turbo_ratio_limit()
3839 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in dump_sysfs_cstate_config()
3840 sp = strchr(name_buf, '-'); in dump_sysfs_cstate_config()
3927 cpu = t->cpu_id; in print_epb()
3929 /* EPB is per-package */ in print_epb()
3930 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_epb()
3935 return -1; in print_epb()
3971 cpu = t->cpu_id; in print_hwp()
3973 /* MSR_HWP_CAPABILITIES is per-package */ in print_hwp()
3974 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_hwp()
3979 return -1; in print_hwp()
3986 cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
4045 ((msr) & 0x1) ? "" : "No-", in print_hwp()
4046 ((msr) & 0x2) ? "" : "No-"); in print_hwp()
4059 cpu = t->cpu_id; in print_perf_limit()
4061 /* per-package */ in print_perf_limit()
4062 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_perf_limit()
4067 return -1; in print_perf_limit()
4082 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4083 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
4097 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4098 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
4112 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4121 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4133 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4140 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4176 * Energy units are either hard-coded, or come from RAPL Energy Unit MSR.
4355 unsigned int eax, ebx, ecx, edx; in rapl_probe_amd() local
4360 __cpuid(0x80000007, eax, ebx, ecx, edx); in rapl_probe_amd()
4380 rapl_time_units = ldexp(1.0, -(msr >> 16 & 0xf)); in rapl_probe_amd()
4381 rapl_energy_units = ldexp(1.0, -(msr >> 8 & 0x1f)); in rapl_probe_amd()
4382 rapl_power_units = ldexp(1.0, -(msr & 0xf)); in rapl_probe_amd()
4440 cpu = t->cpu_id; in print_thermal()
4442 /* DTS is per-core, no need to print for each thread */ in print_thermal()
4443 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in print_thermal()
4448 return -1; in print_thermal()
4451 if (do_ptm && (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) { in print_thermal()
4457 cpu, msr, tcc_activation_temp - dts); in print_thermal()
4465 cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); in print_thermal()
4477 fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", in print_thermal()
4478 cpu, msr, tcc_activation_temp - dts, resolution); in print_thermal()
4486 cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); in print_thermal()
4514 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_rapl()
4517 cpu = t->cpu_id; in print_rapl()
4520 return -1; in print_rapl()
4526 return -1; in print_rapl()
4530 return -1; in print_rapl()
4539 return -5; in print_rapl()
4542 fprintf(outf, "cpu%d: MSR_PKG_POWER_INFO: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4553 return -9; in print_rapl()
4569 return -6; in print_rapl()
4571 fprintf(outf, "cpu%d: MSR_DRAM_POWER_INFO,: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4580 return -9; in print_rapl()
4588 return -7; in print_rapl()
4594 return -9; in print_rapl()
4601 return -8; in print_rapl()
4606 return -9; in print_rapl()
4787 * but also allow cmdline over-ride with -T.
4789 * Several MSR temperature values are in units of degrees-C
4809 tcc = target_c - offset_c; in read_tcc_activation_temp()
4812 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in read_tcc_activation_temp()
4824 /* this is a per-package concept */ in set_temperature_target()
4825 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in set_temperature_target()
4839 fprintf(outf, "Guessing tjMax %d C, Please use -T to specify\n", tcc_activation_temp); in set_temperature_target()
4851 msr & FEAT_CTL_LOCKED ? "" : "UN-", in decode_feature_control_msr()
4865 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", in decode_misc_enable_msr()
4866 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", in decode_misc_enable_msr()
4867 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-", in decode_misc_enable_msr()
4868 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", in decode_misc_enable_msr()
4869 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); in decode_misc_enable_msr()
4880 …f, "cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1… in decode_misc_feature_control()
4882 msr & (0 << 0) ? "No-" : "", in decode_misc_feature_control()
4883 msr & (1 << 0) ? "No-" : "", in decode_misc_feature_control()
4884 msr & (2 << 0) ? "No-" : "", in decode_misc_feature_control()
4885 msr & (3 << 0) ? "No-" : ""); in decode_misc_feature_control()
4905 …fprintf(outf, "cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)… in decode_misc_pwr_mgmt_msr()
4922 fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", in decode_c6_demotion_policy_msr()
4926 fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", in decode_c6_demotion_policy_msr()
4937 case INTEL_FAM6_NEHALEM_EP: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */ in intel_model_duplicates()
4938 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in intel_model_duplicates()
4939 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ in intel_model_duplicates()
4940 case INTEL_FAM6_WESTMERE: /* Westmere Client - Clarkdale, Arrandale */ in intel_model_duplicates()
4941 case INTEL_FAM6_WESTMERE_EP: /* Westmere EP - Gulftown */ in intel_model_duplicates()
4944 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in intel_model_duplicates()
4945 case INTEL_FAM6_WESTMERE_EX: /* Westmere-EX Xeon - Eagleton */ in intel_model_duplicates()
4952 case INTEL_FAM6_BROADWELL_D: /* BDX-DE */ in intel_model_duplicates()
5009 unsigned int eax, ebx, ecx, edx; in process_cpuid() local
5013 eax = ebx = ecx = edx = 0; in process_cpuid()
5015 __cpuid(0, max_level, ebx, ecx, edx); in process_cpuid()
5017 if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) in process_cpuid()
5019 else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) in process_cpuid()
5021 else if (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e) in process_cpuid()
5026 (char *)&ebx, (char *)&edx, (char *)&ecx); in process_cpuid()
5028 __cpuid(1, fms, ebx, ecx, edx); in process_cpuid()
5036 ecx_flags = ecx; in process_cpuid()
5044 ebx = ecx = edx = 0; in process_cpuid()
5045 __cpuid(0x80000000, max_extended_level, ebx, ecx, edx); in process_cpuid()
5051 ecx_flags & (1 << 0) ? "SSE3" : "-", in process_cpuid()
5052 ecx_flags & (1 << 3) ? "MONITOR" : "-", in process_cpuid()
5053 ecx_flags & (1 << 6) ? "SMX" : "-", in process_cpuid()
5054 ecx_flags & (1 << 7) ? "EIST" : "-", in process_cpuid()
5055 ecx_flags & (1 << 8) ? "TM2" : "-", in process_cpuid()
5056 edx_flags & (1 << 4) ? "TSC" : "-", in process_cpuid()
5057 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
5058 edx_flags & (1 << 22) ? "ACPI-TM" : "-", in process_cpuid()
5059 edx_flags & (1 << 28) ? "HT" : "-", in process_cpuid()
5060 edx_flags & (1 << 29) ? "TM" : "-"); in process_cpuid()
5071 * Non-Stop TSC is advertised by CPUID.EAX=0x80000007: EDX.bit8 in process_cpuid()
5074 __cpuid(0x80000007, eax, ebx, ecx, edx); in process_cpuid()
5079 * APERF/MPERF is advertised by CPUID.EAX=0x6: ECX.bit0 in process_cpuid()
5083 __cpuid(0x6, eax, ebx, ecx, edx); in process_cpuid()
5084 has_aperf = ecx & (1 << 0); in process_cpuid()
5102 has_epb = ecx & (1 << 3); in process_cpuid()
5107 has_aperf ? "" : "No-", in process_cpuid()
5108 has_turbo ? "" : "No-", in process_cpuid()
5109 do_dts ? "" : "No-", in process_cpuid()
5110 do_ptm ? "" : "No-", in process_cpuid()
5111 has_hwp ? "" : "No-", in process_cpuid()
5112 has_hwp_notify ? "" : "No-", in process_cpuid()
5113 has_hwp_activity_window ? "" : "No-", in process_cpuid()
5114 has_hwp_epp ? "" : "No-", in process_cpuid()
5115 has_hwp_pkg ? "" : "No-", in process_cpuid()
5116 has_epb ? "" : "No-"); in process_cpuid()
5125 ecx = 0; in process_cpuid()
5127 __cpuid_count(0x7, 0, eax, ebx, ecx, edx); in process_cpuid()
5130 fprintf(outf, "CPUID(7): %sSGX\n", has_sgx ? "" : "No-"); in process_cpuid()
5333 if (isdigit(dirp->d_name[0])) in dir_filter()
5501 (*t)[i].cpu_id = -1; in allocate_counters()
5508 (*c)[i].core_id = -1; in allocate_counters()
5538 /* Workaround for systems where physical_node_id==-1 in init_counter()
5539 * and logical_node_id==(-1 - topo.num_cpus) in init_counter()
5548 t->cpu_id = cpu_id; in init_counter()
5550 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE; in init_counter()
5552 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE; in init_counter()
5555 c->core_id = core_id; in init_counter()
5556 p->package_id = pkg_id; in init_counter()
5572 err(-1, "calloc output buffer"); in allocate_output_buffer()
5578 err(-1, "calloc fd_percpu"); in allocate_fd_percpu()
5584 err(-1, "calloc %d", topo.num_cpus); in allocate_irq_buffers()
5588 err(-1, "calloc %d", topo.max_cpu_num + 1); in allocate_irq_buffers()
5605 err(-ENODEV, "No valid cpus found"); in set_base_cpu()
5651 /* clear affinity side-effect of get_counters() */ in fork_it()
5663 if (child_pid == -1) in fork_it()
5668 if (waitpid(child_pid, &status, 0) == -1) in fork_it()
5676 * because re-starting is problematic when forking in fork_it()
5716 " - Len Brown <lenb@kernel.org>\n"); in print_version()
5731 msrp->msr_num = msr_num; in add_counter()
5732 strncpy(msrp->name, name, NAME_BYTES - 1); in add_counter()
5734 strncpy(msrp->path, path, PATH_BYTES - 1); in add_counter()
5735 msrp->width = width; in add_counter()
5736 msrp->type = type; in add_counter()
5737 msrp->format = format; in add_counter()
5738 msrp->flags = flags; in add_counter()
5743 msrp->next = sys.tp; in add_counter()
5749 exit(-1); in add_counter()
5754 msrp->next = sys.cp; in add_counter()
5760 exit(-1); in add_counter()
5765 msrp->next = sys.pp; in add_counter()
5771 exit(-1); in add_counter()
5863 fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter ) required\n"); in parse_add_command()
5905 for (state = 10; state >= 0; --state) { in probe_sysfs()
5915 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
5916 sp = strchr(name_buf, '-'); in probe_sysfs()
5935 for (state = 10; state >= 0; --state) { in probe_sysfs()
5944 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
5945 sp = strchr(name_buf, '-'); in probe_sysfs()
5967 * 1,2,4..6,8-10 and set bits in cpu_subset
6000 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_command()
6017 if (*next == '-') { in parse_cpu_command()
6046 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
6048 exit(-1); in parse_cpu_command()
6065 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help in cmdline()
6080 long_options, &option_index)) != -1) { in cmdline()
6092 /* --enable specified counter */ in cmdline()
6101 * --hide: do not show those specified in cmdline()
6121 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000; in cmdline()
6122 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; in cmdline()
6150 * --show: show only those specified in cmdline()
6201 if (argc - optind) in main()