Lines Matching +full:crystal +full:- +full:26 +full:m +full:- +full:en

1 // SPDX-License-Identifier: GPL-2.0-only
3 * turbostat -- show CPU frequency and C-state residency
44 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
46 * matching on them for --show and --hide.
51 * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters
159 #define BIC_Pkgpc9 (1ULL << 26)
316 /* Indicates cores energy collection is per-core,
317 * not per-package. */
325 /* MSRs that are not yet in the kernel-provided header. */
367 unsigned long long mc6_us; /* duplicate as per-core for now, even though per module */
441 /* get_msr_sum() = sum + (get_msr() - last) */
480 offset = -1; in idx_to_offset()
510 idx = -1; in offset_to_idx()
555 int logical_node_id; /* 0-based count within the package */
591 * skip non-present cpus
609 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus()
629 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) in cpu_migrate()
630 return -1; in cpu_migrate()
648 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root", pathname); in get_msr_fd()
671 fd = perf_event_open(&pea, -1, cpu_num, -1, 0); in perf_instr_count_open()
672 if (fd == -1) { in perf_instr_count_open()
697 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
709 * HIDE_LIST - hide this list of counters, show the rest [default]
710 * SHOW_LIST - show this list of counters, hide the rest
717 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" in help()
721 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" in help()
723 " -a, --add add a counter\n" in help()
724 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" in help()
725 " -c, --cpu cpu-set limit output to summary plus cpu-set:\n" in help()
726 " {core | package | j,k,l..m,n-p }\n" in help()
727 " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n" in help()
728 " -D, --Dump displays the raw counter values\n" in help()
729 " -e, --enable [all | column]\n" in help()
731 " -H, --hide [column|column,column,...]\n" in help()
733 " -i, --interval sec.subsec\n" in help()
734 " Override default 5-second measurement interval\n" in help()
735 " -J, --Joules displays energy in Joules instead of Watts\n" in help()
736 " -l, --list list column headers only\n" in help()
737 " -n, --num_iterations num\n" in help()
739 " -N, --header_iterations num\n" in help()
741 " -o, --out file\n" in help()
743 " -q, --quiet skip decoding system configuration header\n" in help()
744 " -s, --show [column|column,column,...]\n" in help()
746 " -S, --Summary\n" in help()
747 " limits output to 1-line system summary per interval\n" in help()
748 " -T, --TCC temperature\n" in help()
751 " -h, --help print this help message\n" in help()
752 " -v, --version print version information\n" "\n" "For more help, run \"man turbostat\"\n"); in help()
803 fprintf(stderr, "More than max %d un-recognized --add options '%s'\n", in bic_lookup()
813 fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", in bic_lookup()
874 for (mp = sys.tp; mp; mp = mp->next) { in print_header()
876 if (mp->format == FORMAT_RAW) { in print_header()
877 if (mp->width == 64) in print_header()
878 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name); in print_header()
880 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name); in print_header()
882 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
883 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name); in print_header()
885 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name); in print_header()
915 for (mp = sys.cp; mp; mp = mp->next) { in print_header()
916 if (mp->format == FORMAT_RAW) { in print_header()
917 if (mp->width == 64) in print_header()
918 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
920 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
922 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
923 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
925 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
999 for (mp = sys.pp; mp; mp = mp->next) { in print_header()
1000 if (mp->format == FORMAT_RAW) { in print_header()
1001 if (mp->width == 64) in print_header()
1002 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
1004 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
1006 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
1007 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
1009 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
1024 outp += sprintf(outp, "CPU: %d flags 0x%x\n", t->cpu_id, t->flags); in dump_counters()
1025 outp += sprintf(outp, "TSC: %016llX\n", t->tsc); in dump_counters()
1026 outp += sprintf(outp, "aperf: %016llX\n", t->aperf); in dump_counters()
1027 outp += sprintf(outp, "mperf: %016llX\n", t->mperf); in dump_counters()
1028 outp += sprintf(outp, "c1: %016llX\n", t->c1); in dump_counters()
1031 outp += sprintf(outp, "IPC: %lld\n", t->instr_count); in dump_counters()
1034 outp += sprintf(outp, "IRQ: %lld\n", t->irq_count); in dump_counters()
1036 outp += sprintf(outp, "SMI: %d\n", t->smi_count); in dump_counters()
1038 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in dump_counters()
1039 outp += sprintf(outp, "tADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, t->counter[i]); in dump_counters()
1044 outp += sprintf(outp, "core: %d\n", c->core_id); in dump_counters()
1045 outp += sprintf(outp, "c3: %016llX\n", c->c3); in dump_counters()
1046 outp += sprintf(outp, "c6: %016llX\n", c->c6); in dump_counters()
1047 outp += sprintf(outp, "c7: %016llX\n", c->c7); in dump_counters()
1048 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); in dump_counters()
1049 outp += sprintf(outp, "cpu_throt_count: %016llX\n", c->core_throt_cnt); in dump_counters()
1050 outp += sprintf(outp, "Joules: %0X\n", c->core_energy); in dump_counters()
1052 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in dump_counters()
1053 outp += sprintf(outp, "cADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, c->counter[i]); in dump_counters()
1055 outp += sprintf(outp, "mc6_us: %016llX\n", c->mc6_us); in dump_counters()
1059 outp += sprintf(outp, "package: %d\n", p->package_id); in dump_counters()
1061 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); in dump_counters()
1062 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); in dump_counters()
1063 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); in dump_counters()
1064 outp += sprintf(outp, "CPU + GFX: %016llX\n", p->pkg_both_core_gfxe_c0); in dump_counters()
1066 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); in dump_counters()
1068 outp += sprintf(outp, "pc3: %016llX\n", p->pc3); in dump_counters()
1070 outp += sprintf(outp, "pc6: %016llX\n", p->pc6); in dump_counters()
1072 outp += sprintf(outp, "pc7: %016llX\n", p->pc7); in dump_counters()
1073 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); in dump_counters()
1074 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); in dump_counters()
1075 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); in dump_counters()
1076 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi); in dump_counters()
1077 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi); in dump_counters()
1078 outp += sprintf(outp, "Joules PKG: %0llX\n", p->energy_pkg); in dump_counters()
1079 outp += sprintf(outp, "Joules COR: %0llX\n", p->energy_cores); in dump_counters()
1080 outp += sprintf(outp, "Joules GFX: %0llX\n", p->energy_gfx); in dump_counters()
1081 outp += sprintf(outp, "Joules RAM: %0llX\n", p->energy_dram); in dump_counters()
1082 outp += sprintf(outp, "Throttle PKG: %0llX\n", p->rapl_pkg_perf_status); in dump_counters()
1083 outp += sprintf(outp, "Throttle RAM: %0llX\n", p->rapl_dram_perf_status); in dump_counters()
1084 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c); in dump_counters()
1086 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in dump_counters()
1087 outp += sprintf(outp, "pADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, p->counter[i]); in dump_counters()
1109 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1113 if (show_pkg_only && !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1116 /*if not summary line and --cpu is used */ in format_counters()
1117 …if ((t != &average.threads) && (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset)… in format_counters()
1124 timersub(&t->tv_end, &t->tv_begin, &tv); in format_counters()
1130 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec); in format_counters()
1132 interval_float = t->tv_delta.tv_sec + t->tv_delta.tv_usec / 1000000.0; in format_counters()
1134 tsc = t->tsc * tsc_tweak; in format_counters()
1139 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1141 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1143 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1145 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1147 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1149 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1151 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1155 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); in format_counters()
1157 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1161 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].die_id); in format_counters()
1163 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1168 (printed++ ? delim : ""), cpus[t->cpu_id].physical_node_id); in format_counters()
1170 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1174 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); in format_counters()
1176 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1179 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); in format_counters()
1181 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id); in format_counters()
1183 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id); in format_counters()
1187 …outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 / units * t->aperf / interval_float); in format_counters()
1190 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->mperf / tsc); in format_counters()
1195 sprintf(outp, "%s%.0f", (printed++ ? delim : ""), base_hz / units * t->aperf / t->mperf); in format_counters()
1198 tsc / units * t->aperf / t->mperf / interval_float); in format_counters()
1202 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 * t->tsc / units / interval_float); in format_counters()
1205 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 1.0 * t->instr_count / t->aperf); in format_counters()
1210 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1212 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1217 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->smi_count); in format_counters()
1220 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in format_counters()
1221 if (mp->format == FORMAT_RAW) { in format_counters()
1222 if (mp->width == 32) in format_counters()
1224 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)t->counter[i]); in format_counters()
1226 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1227 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1228 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1229 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1231 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1232 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1233 if (mp->type == COUNTER_USEC) in format_counters()
1236 t->counter[i] / interval_float / 10000); in format_counters()
1238 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->counter[i] / tsc); in format_counters()
1244 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->c1 / tsc); in format_counters()
1246 /* print per-core data only for 1st thread in core */ in format_counters()
1247 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1251 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3 / tsc); in format_counters()
1253 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6 / tsc); in format_counters()
1255 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c7 / tsc); in format_counters()
1259 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->mc6_us / tsc); in format_counters()
1262 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); in format_counters()
1266 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->core_throt_cnt); in format_counters()
1268 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in format_counters()
1269 if (mp->format == FORMAT_RAW) { in format_counters()
1270 if (mp->width == 32) in format_counters()
1272 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)c->counter[i]); in format_counters()
1274 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1275 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1276 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1277 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1279 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1280 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1281 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->counter[i] / tsc); in format_counters()
1289 …sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units / interval_float); in format_counters()
1291 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units); in format_counters()
1293 /* print per-package data only for 1st core in package */ in format_counters()
1294 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1299 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->pkg_temp_c); in format_counters()
1303 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
1307 p->gfx_rc6_ms / 10.0 / interval_float); in format_counters()
1313 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz); in format_counters()
1317 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_act_mhz); in format_counters()
1321 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0 / tsc); in format_counters()
1323 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0 / tsc); in format_counters()
1325 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0 / tsc); in format_counters()
1327 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0 / tsc); in format_counters()
1330 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2 / tsc); in format_counters()
1332 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc3 / tsc); in format_counters()
1334 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc6 / tsc); in format_counters()
1336 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc7 / tsc); in format_counters()
1338 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc8 / tsc); in format_counters()
1340 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc9 / tsc); in format_counters()
1342 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10 / tsc); in format_counters()
1346 …sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->cpu_lpi / 1000000.0 / interval_float); in format_counters()
1349 …sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->sys_lpi / 1000000.0 / interval_float); in format_counters()
1353 … sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units / interval_float); in format_counters()
1357 …sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units / interval_float… in format_counters()
1360 … sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units / interval_float); in format_counters()
1364 p->energy_dram * rapl_dram_energy_units / interval_float); in format_counters()
1366 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units); in format_counters()
1368 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units); in format_counters()
1370 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units); in format_counters()
1372 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units); in format_counters()
1376 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float); in format_counters()
1380 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float); in format_counters()
1383 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->uncore_mhz); in format_counters()
1385 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in format_counters()
1386 if (mp->format == FORMAT_RAW) { in format_counters()
1387 if (mp->width == 32) in format_counters()
1389 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)p->counter[i]); in format_counters()
1391 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1392 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1393 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1394 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1396 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1397 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1398 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->counter[i] / tsc); in format_counters()
1403 if (*(outp - 1) != '\n') in format_counters()
1449 old = ((((unsigned long long)new << 32) - ((unsigned long long)old << 32)) >> 32);
1457 old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0; in delta_package()
1459 old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0; in delta_package()
1461 old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0; in delta_package()
1463 old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0; in delta_package()
1465 old->pc2 = new->pc2 - old->pc2; in delta_package()
1467 old->pc3 = new->pc3 - old->pc3; in delta_package()
1469 old->pc6 = new->pc6 - old->pc6; in delta_package()
1471 old->pc7 = new->pc7 - old->pc7; in delta_package()
1472 old->pc8 = new->pc8 - old->pc8; in delta_package()
1473 old->pc9 = new->pc9 - old->pc9; in delta_package()
1474 old->pc10 = new->pc10 - old->pc10; in delta_package()
1475 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi; in delta_package()
1476 old->sys_lpi = new->sys_lpi - old->sys_lpi; in delta_package()
1477 old->pkg_temp_c = new->pkg_temp_c; in delta_package()
1480 if (old->gfx_rc6_ms > new->gfx_rc6_ms) in delta_package()
1481 old->gfx_rc6_ms = -1; in delta_package()
1483 old->gfx_rc6_ms = new->gfx_rc6_ms - old->gfx_rc6_ms; in delta_package()
1485 old->uncore_mhz = new->uncore_mhz; in delta_package()
1486 old->gfx_mhz = new->gfx_mhz; in delta_package()
1487 old->gfx_act_mhz = new->gfx_act_mhz; in delta_package()
1489 old->energy_pkg = new->energy_pkg - old->energy_pkg; in delta_package()
1490 old->energy_cores = new->energy_cores - old->energy_cores; in delta_package()
1491 old->energy_gfx = new->energy_gfx - old->energy_gfx; in delta_package()
1492 old->energy_dram = new->energy_dram - old->energy_dram; in delta_package()
1493 old->rapl_pkg_perf_status = new->rapl_pkg_perf_status - old->rapl_pkg_perf_status; in delta_package()
1494 old->rapl_dram_perf_status = new->rapl_dram_perf_status - old->rapl_dram_perf_status; in delta_package()
1496 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in delta_package()
1497 if (mp->format == FORMAT_RAW) in delta_package()
1498 old->counter[i] = new->counter[i]; in delta_package()
1500 old->counter[i] = new->counter[i] - old->counter[i]; in delta_package()
1511 old->c3 = new->c3 - old->c3; in delta_core()
1512 old->c6 = new->c6 - old->c6; in delta_core()
1513 old->c7 = new->c7 - old->c7; in delta_core()
1514 old->core_temp_c = new->core_temp_c; in delta_core()
1515 old->core_throt_cnt = new->core_throt_cnt; in delta_core()
1516 old->mc6_us = new->mc6_us - old->mc6_us; in delta_core()
1518 DELTA_WRAP32(new->core_energy, old->core_energy); in delta_core()
1520 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in delta_core()
1521 if (mp->format == FORMAT_RAW) in delta_core()
1522 old->counter[i] = new->counter[i]; in delta_core()
1524 old->counter[i] = new->counter[i] - old->counter[i]; in delta_core()
1537 * old = new - old
1546 new->apic_id = old->apic_id; in delta_thread()
1548 new->x2apic_id = old->x2apic_id; in delta_thread()
1553 * over-write old w/ new so we can print end of interval values in delta_thread()
1556 timersub(&new->tv_begin, &old->tv_begin, &old->tv_delta); in delta_thread()
1557 old->tv_begin = new->tv_begin; in delta_thread()
1558 old->tv_end = new->tv_end; in delta_thread()
1560 old->tsc = new->tsc - old->tsc; in delta_thread()
1563 if (old->tsc < (1000 * 1000)) in delta_thread()
1564 errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n" in delta_thread()
1565 "You can disable all c-states by booting with \"idle=poll\"\n" in delta_thread()
1568 old->c1 = new->c1 - old->c1; in delta_thread()
1571 if ((new->aperf > old->aperf) && (new->mperf > old->mperf)) { in delta_thread()
1572 old->aperf = new->aperf - old->aperf; in delta_thread()
1573 old->mperf = new->mperf - old->mperf; in delta_thread()
1575 return -1; in delta_thread()
1587 * it is possible for mperf's non-halted cycles + idle states in delta_thread()
1590 if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) in delta_thread()
1591 old->c1 = 0; in delta_thread()
1594 old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 in delta_thread()
1595 - core_delta->c6 - core_delta->c7; in delta_thread()
1599 if (old->mperf == 0) { in delta_thread()
1601 fprintf(outf, "cpu%d MPERF 0!\n", old->cpu_id); in delta_thread()
1602 old->mperf = 1; /* divide by 0 protection */ in delta_thread()
1606 old->instr_count = new->instr_count - old->instr_count; in delta_thread()
1609 old->irq_count = new->irq_count - old->irq_count; in delta_thread()
1612 old->smi_count = new->smi_count - old->smi_count; in delta_thread()
1614 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in delta_thread()
1615 if (mp->format == FORMAT_RAW) in delta_thread()
1616 old->counter[i] = new->counter[i]; in delta_thread()
1618 old->counter[i] = new->counter[i] - old->counter[i]; in delta_thread()
1629 if (t->flags & CPU_IS_FIRST_THREAD_IN_CORE) in delta_cpu()
1638 if (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE) in delta_cpu()
1649 t->tv_begin.tv_sec = 0; in clear_counters()
1650 t->tv_begin.tv_usec = 0; in clear_counters()
1651 t->tv_end.tv_sec = 0; in clear_counters()
1652 t->tv_end.tv_usec = 0; in clear_counters()
1653 t->tv_delta.tv_sec = 0; in clear_counters()
1654 t->tv_delta.tv_usec = 0; in clear_counters()
1656 t->tsc = 0; in clear_counters()
1657 t->aperf = 0; in clear_counters()
1658 t->mperf = 0; in clear_counters()
1659 t->c1 = 0; in clear_counters()
1661 t->instr_count = 0; in clear_counters()
1663 t->irq_count = 0; in clear_counters()
1664 t->smi_count = 0; in clear_counters()
1667 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE; in clear_counters()
1669 c->c3 = 0; in clear_counters()
1670 c->c6 = 0; in clear_counters()
1671 c->c7 = 0; in clear_counters()
1672 c->mc6_us = 0; in clear_counters()
1673 c->core_temp_c = 0; in clear_counters()
1674 c->core_energy = 0; in clear_counters()
1675 c->core_throt_cnt = 0; in clear_counters()
1677 p->pkg_wtd_core_c0 = 0; in clear_counters()
1678 p->pkg_any_core_c0 = 0; in clear_counters()
1679 p->pkg_any_gfxe_c0 = 0; in clear_counters()
1680 p->pkg_both_core_gfxe_c0 = 0; in clear_counters()
1682 p->pc2 = 0; in clear_counters()
1684 p->pc3 = 0; in clear_counters()
1686 p->pc6 = 0; in clear_counters()
1688 p->pc7 = 0; in clear_counters()
1689 p->pc8 = 0; in clear_counters()
1690 p->pc9 = 0; in clear_counters()
1691 p->pc10 = 0; in clear_counters()
1692 p->cpu_lpi = 0; in clear_counters()
1693 p->sys_lpi = 0; in clear_counters()
1695 p->energy_pkg = 0; in clear_counters()
1696 p->energy_dram = 0; in clear_counters()
1697 p->energy_cores = 0; in clear_counters()
1698 p->energy_gfx = 0; in clear_counters()
1699 p->rapl_pkg_perf_status = 0; in clear_counters()
1700 p->rapl_dram_perf_status = 0; in clear_counters()
1701 p->pkg_temp_c = 0; in clear_counters()
1703 p->gfx_rc6_ms = 0; in clear_counters()
1704 p->uncore_mhz = 0; in clear_counters()
1705 p->gfx_mhz = 0; in clear_counters()
1706 p->gfx_act_mhz = 0; in clear_counters()
1707 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) in clear_counters()
1708 t->counter[i] = 0; in clear_counters()
1710 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) in clear_counters()
1711 c->counter[i] = 0; in clear_counters()
1713 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) in clear_counters()
1714 p->counter[i] = 0; in clear_counters()
1722 /* copy un-changing apic_id's */ in sum_counters()
1724 average.threads.apic_id = t->apic_id; in sum_counters()
1726 average.threads.x2apic_id = t->x2apic_id; in sum_counters()
1730 average.threads.tv_begin = t->tv_begin; in sum_counters()
1733 average.threads.tv_end = t->tv_end; in sum_counters()
1735 average.threads.tsc += t->tsc; in sum_counters()
1736 average.threads.aperf += t->aperf; in sum_counters()
1737 average.threads.mperf += t->mperf; in sum_counters()
1738 average.threads.c1 += t->c1; in sum_counters()
1740 average.threads.instr_count += t->instr_count; in sum_counters()
1742 average.threads.irq_count += t->irq_count; in sum_counters()
1743 average.threads.smi_count += t->smi_count; in sum_counters()
1745 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in sum_counters()
1746 if (mp->format == FORMAT_RAW) in sum_counters()
1748 average.threads.counter[i] += t->counter[i]; in sum_counters()
1751 /* sum per-core values only for 1st thread in core */ in sum_counters()
1752 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in sum_counters()
1755 average.cores.c3 += c->c3; in sum_counters()
1756 average.cores.c6 += c->c6; in sum_counters()
1757 average.cores.c7 += c->c7; in sum_counters()
1758 average.cores.mc6_us += c->mc6_us; in sum_counters()
1760 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); in sum_counters()
1761 average.cores.core_throt_cnt = MAX(average.cores.core_throt_cnt, c->core_throt_cnt); in sum_counters()
1763 average.cores.core_energy += c->core_energy; in sum_counters()
1765 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in sum_counters()
1766 if (mp->format == FORMAT_RAW) in sum_counters()
1768 average.cores.counter[i] += c->counter[i]; in sum_counters()
1771 /* sum per-pkg values only for 1st core in pkg */ in sum_counters()
1772 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in sum_counters()
1776 average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0; in sum_counters()
1778 average.packages.pkg_any_core_c0 += p->pkg_any_core_c0; in sum_counters()
1780 average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0; in sum_counters()
1782 average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0; in sum_counters()
1784 average.packages.pc2 += p->pc2; in sum_counters()
1786 average.packages.pc3 += p->pc3; in sum_counters()
1788 average.packages.pc6 += p->pc6; in sum_counters()
1790 average.packages.pc7 += p->pc7; in sum_counters()
1791 average.packages.pc8 += p->pc8; in sum_counters()
1792 average.packages.pc9 += p->pc9; in sum_counters()
1793 average.packages.pc10 += p->pc10; in sum_counters()
1795 average.packages.cpu_lpi = p->cpu_lpi; in sum_counters()
1796 average.packages.sys_lpi = p->sys_lpi; in sum_counters()
1798 average.packages.energy_pkg += p->energy_pkg; in sum_counters()
1799 average.packages.energy_dram += p->energy_dram; in sum_counters()
1800 average.packages.energy_cores += p->energy_cores; in sum_counters()
1801 average.packages.energy_gfx += p->energy_gfx; in sum_counters()
1803 average.packages.gfx_rc6_ms = p->gfx_rc6_ms; in sum_counters()
1804 average.packages.uncore_mhz = p->uncore_mhz; in sum_counters()
1805 average.packages.gfx_mhz = p->gfx_mhz; in sum_counters()
1806 average.packages.gfx_act_mhz = p->gfx_act_mhz; in sum_counters()
1808 average.packages.pkg_temp_c = MAX(average.packages.pkg_temp_c, p->pkg_temp_c); in sum_counters()
1810 average.packages.rapl_pkg_perf_status += p->rapl_pkg_perf_status; in sum_counters()
1811 average.packages.rapl_dram_perf_status += p->rapl_dram_perf_status; in sum_counters()
1813 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in sum_counters()
1814 if (mp->format == FORMAT_RAW) in sum_counters()
1816 average.packages.counter[i] += p->counter[i]; in sum_counters()
1872 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in compute_average()
1873 if (mp->format == FORMAT_RAW) in compute_average()
1875 if (mp->type == COUNTER_ITEMS) { in compute_average()
1882 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in compute_average()
1883 if (mp->format == FORMAT_RAW) in compute_average()
1885 if (mp->type == COUNTER_ITEMS) { in compute_average()
1891 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in compute_average()
1892 if (mp->format == FORMAT_RAW) in compute_average()
1894 if (mp->type == COUNTER_ITEMS) { in compute_average()
1947 if (mp->msr_num != 0) { in get_mp()
1948 if (get_msr(cpu, mp->msr_num, counterp)) in get_mp()
1949 return -1; in get_mp()
1953 if (mp->flags & SYSFS_PERCPU) { in get_mp()
1954 sprintf(path, "/sys/devices/system/cpu/cpu%d/%s", cpu, mp->path); in get_mp()
1958 *counterp = snapshot_sysfs_counter(mp->path); in get_mp()
1979 int ret, epb = -1; in get_epb()
2010 t->apic_id = (ebx >> 24) & 0xff; in get_apic_id()
2032 t->x2apic_id = eax; in get_apic_id()
2044 t->x2apic_id = edx; in get_apic_id()
2046 if (debug && (t->apic_id != (t->x2apic_id & 0xff))) in get_apic_id()
2047 fprintf(outf, "cpu%d: BIOS BUG: apic 0x%x x2apic 0x%x\n", t->cpu_id, t->apic_id, t->x2apic_id); in get_apic_id()
2060 return -1; in get_core_throt_cnt()
2064 return -1; in get_core_throt_cnt()
2077 int cpu = t->cpu_id; in get_counters()
2085 return -1; in get_counters()
2088 gettimeofday(&t->tv_begin, (struct timezone *)NULL); in get_counters()
2093 t->tsc = rdtsc(); /* we are running on local CPU of interest */ in get_counters()
2105 * varies by a large amount, we re-read them. in get_counters()
2113 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
2114 return -3; in get_counters()
2116 t->tsc = rdtsc(); /* re-read close to APERF */ in get_counters()
2118 tsc_before = t->tsc; in get_counters()
2120 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
2121 return -3; in get_counters()
2125 if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) in get_counters()
2126 return -4; in get_counters()
2130 aperf_time = tsc_between - tsc_before; in get_counters()
2131 mperf_time = tsc_after - tsc_between; in get_counters()
2146 t->aperf = t->aperf * aperf_mperf_multiplier; in get_counters()
2147 t->mperf = t->mperf * aperf_mperf_multiplier; in get_counters()
2151 if (read(get_instr_count_fd(cpu), &t->instr_count, sizeof(long long)) != sizeof(long long)) in get_counters()
2152 return -4; in get_counters()
2155 t->irq_count = irqs_per_cpu[cpu]; in get_counters()
2158 return -5; in get_counters()
2159 t->smi_count = msr & 0xFFFFFFFF; in get_counters()
2162 if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) in get_counters()
2163 return -6; in get_counters()
2166 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in get_counters()
2167 if (get_mp(cpu, mp, &t->counter[i])) in get_counters()
2168 return -10; in get_counters()
2172 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in get_counters()
2176 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) in get_counters()
2177 return -6; in get_counters()
2181 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
2182 return -7; in get_counters()
2184 if (get_msr(cpu, MSR_KNL_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
2185 return -7; in get_counters()
2189 if (get_msr(cpu, MSR_CORE_C7_RESIDENCY, &c->c7)) in get_counters()
2190 return -8; in get_counters()
2191 else if (t->is_atom) { in get_counters()
2198 c->c6 -= c->c7; in get_counters()
2203 if (get_msr(cpu, MSR_MODULE_C6_RES_MS, &c->mc6_us)) in get_counters()
2204 return -8; in get_counters()
2208 return -9; in get_counters()
2209 c->core_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
2213 get_core_throt_cnt(cpu, &c->core_throt_cnt); in get_counters()
2217 return -14; in get_counters()
2218 c->core_energy = msr & 0xFFFFFFFF; in get_counters()
2221 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in get_counters()
2222 if (get_mp(cpu, mp, &c->counter[i])) in get_counters()
2223 return -10; in get_counters()
2227 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in get_counters()
2231 if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) in get_counters()
2232 return -10; in get_counters()
2235 if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0)) in get_counters()
2236 return -11; in get_counters()
2239 if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0)) in get_counters()
2240 return -12; in get_counters()
2243 if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0)) in get_counters()
2244 return -13; in get_counters()
2247 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) in get_counters()
2248 return -9; in get_counters()
2251 if (get_msr(cpu, MSR_ATOM_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2252 return -10; in get_counters()
2254 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2255 return -10; in get_counters()
2260 if (get_msr(cpu, MSR_PKG_C2_RESIDENCY, &p->pc2)) in get_counters()
2261 return -11; in get_counters()
2263 if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) in get_counters()
2264 return -12; in get_counters()
2266 if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) in get_counters()
2267 return -13; in get_counters()
2269 if (get_msr(cpu, MSR_PKG_C9_RESIDENCY, &p->pc9)) in get_counters()
2270 return -13; in get_counters()
2272 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) in get_counters()
2273 return -13; in get_counters()
2276 p->cpu_lpi = cpuidle_cur_cpu_lpi_us; in get_counters()
2278 p->sys_lpi = cpuidle_cur_sys_lpi_us; in get_counters()
2282 return -13; in get_counters()
2283 p->energy_pkg = msr; in get_counters()
2287 return -14; in get_counters()
2288 p->energy_cores = msr; in get_counters()
2292 return -15; in get_counters()
2293 p->energy_dram = msr; in get_counters()
2297 return -16; in get_counters()
2298 p->energy_gfx = msr; in get_counters()
2302 return -16; in get_counters()
2303 p->rapl_pkg_perf_status = msr; in get_counters()
2307 return -16; in get_counters()
2308 p->rapl_dram_perf_status = msr; in get_counters()
2312 return -13; in get_counters()
2313 p->energy_pkg = msr; in get_counters()
2317 return -17; in get_counters()
2318 p->pkg_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
2322 p->gfx_rc6_ms = gfx_cur_rc6_ms; in get_counters()
2326 p->uncore_mhz = get_uncore_mhz(p->package_id, 0); in get_counters()
2329 p->gfx_mhz = gfx_cur_mhz; in get_counters()
2332 p->gfx_act_mhz = gfx_act_mhz; in get_counters()
2334 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in get_counters()
2335 if (get_mp(cpu, mp, &p->counter[i])) in get_counters()
2336 return -10; in get_counters()
2339 gettimeofday(&t->tv_end, (struct timezone *)NULL); in get_counters()
2440 fprintf(outf, "cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", in dump_nhm_platform_info()
2441 base_cpu, msr, msr & 0x2 ? "EN" : "DIS"); in dump_nhm_platform_info()
2443 /* C-state Pre-wake Disable (CSTATE_PREWAKE_DISABLE) */ in dump_nhm_platform_info()
2445 fprintf(outf, "C-state Pre-wake: %sabled\n", msr & 0x40000000 ? "DIS" : "EN"); in dump_nhm_platform_info()
2550 for (shift = 56; shift >= 0; shift -= 8) { in dump_turbo_ratio_limits()
2619 * [0] -- Reserved in dump_knl_turbo_ratio_limits()
2620 * [7:1] -- Base value of number of active cores of bucket 1. in dump_knl_turbo_ratio_limits()
2621 * [15:8] -- Base value of freq ratio of bucket 1. in dump_knl_turbo_ratio_limits()
2622 * [20:16] -- +ve delta of number of active cores of bucket 2. in dump_knl_turbo_ratio_limits()
2625 * [23:21] -- Negative delta of freq ratio of bucket 2. in dump_knl_turbo_ratio_limits()
2627 * freq ratio of bucket 1 - delta in dump_knl_turbo_ratio_limits()
2628 * [28:24]-- +ve delta of number of active cores of bucket 3. in dump_knl_turbo_ratio_limits()
2629 * [31:29]-- -ve delta of freq ratio of bucket 3. in dump_knl_turbo_ratio_limits()
2630 * [36:32]-- +ve delta of number of active cores of bucket 4. in dump_knl_turbo_ratio_limits()
2631 * [39:37]-- -ve delta of freq ratio of bucket 4. in dump_knl_turbo_ratio_limits()
2632 * [44:40]-- +ve delta of number of active cores of bucket 5. in dump_knl_turbo_ratio_limits()
2633 * [47:45]-- -ve delta of freq ratio of bucket 5. in dump_knl_turbo_ratio_limits()
2634 * [52:48]-- +ve delta of number of active cores of bucket 6. in dump_knl_turbo_ratio_limits()
2635 * [55:53]-- -ve delta of freq ratio of bucket 6. in dump_knl_turbo_ratio_limits()
2636 * [60:56]-- +ve delta of number of active cores of bucket 7. in dump_knl_turbo_ratio_limits()
2637 * [63:61]-- -ve delta of freq ratio of bucket 7. in dump_knl_turbo_ratio_limits()
2649 ratio[b_nr + 1] = ratio[b_nr] - delta_ratio; in dump_knl_turbo_ratio_limits()
2653 for (i = buckets_no - 1; i >= 0; i--) in dump_knl_turbo_ratio_limits()
2654 if (i > 0 ? ratio[i] != ratio[i - 1] : 1) in dump_knl_turbo_ratio_limits()
2668 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)", in dump_nhm_cst_cfg()
2669 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", in dump_nhm_cst_cfg()
2670 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", in dump_nhm_cst_cfg()
2671 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", in dump_nhm_cst_cfg()
2672 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", in dump_nhm_cst_cfg()
2677 …fprintf(outf, ", automatic c-state conversion=%s", (msr & AUTOMATIC_CSTATE_CONVERSION) ? "on" : "o… in dump_nhm_cst_cfg()
2879 cpus[cpu].logical_node_id = -1; in set_node_data()
2888 if (cpus[cpu].logical_node_id != -1) in set_node_data()
2917 int cpu = thiscpu->logical_cpu_id; in get_physical_node_id()
2927 return -1; in get_physical_node_id()
2936 int cpu = thiscpu->logical_cpu_id; in get_thread_siblings()
2941 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); in get_thread_siblings()
2942 if (thiscpu->thread_id < 0) in get_thread_siblings()
2943 thiscpu->thread_id = thread_id++; in get_thread_siblings()
2944 if (!thiscpu->put_ids) in get_thread_siblings()
2945 return -1; in get_thread_siblings()
2948 CPU_ZERO_S(size, thiscpu->put_ids); in get_thread_siblings()
2955 return -1; in get_thread_siblings()
2958 offset -= BITMASK_SIZE; in get_thread_siblings()
2965 if (sib_core == thiscpu->physical_core_id) { in get_thread_siblings()
2966 CPU_SET_S(so, size, thiscpu->put_ids); in get_thread_siblings()
2975 return CPU_COUNT_S(size, thiscpu->put_ids); in get_thread_siblings()
2980 * skip non-present cpus
3001 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus_2()
3057 fprintf(outf, "turbostat: re-initialized with num_cpus %d\n", topo.num_cpus); in re_initialize()
3077 topo.max_cpu_num--; /* 0 based */ in set_max_cpu_num()
3100 cpus[cpu].thread_id = -1; in init_thread_id()
3263 return -1; in snapshot_cpu_lpi_us()
3288 return -1; in snapshot_sys_lpi_us()
3403 /* get_msr_sum() = sum + (get_msr() - last) */ in get_msr_sum()
3420 int cpu = t->cpu_id; in update_msr_sum()
3474 if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) { in msr_sum_record()
3490 if (timer_settime(timerid, 0, &its, NULL) == -1) { in msr_sum_record()
3506 * if non-root, do this:
3516 if (errno && (original_priority == -1)) in set_my_sched_priority()
3542 set_my_sched_priority(-20); in turbostat_loop()
3550 if (retval < -1) { in turbostat_loop()
3552 } else if (retval == -1) { in turbostat_loop()
3572 if (retval < -1) { in turbostat_loop()
3574 } else if (retval == -1) { in turbostat_loop()
3595 if (retval < -1) { in turbostat_loop()
3597 } else if (retval == -1) { in turbostat_loop()
3625 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); in check_dev_msr()
3640 err(-6, "cap_get_proc\n"); in check_for_cap_sys_rawio()
3643 err(-6, "cap_get\n"); in check_for_cap_sys_rawio()
3650 if (cap_free(caps) == -1) in check_for_cap_sys_rawio()
3651 err(-6, "cap_free\n"); in check_for_cap_sys_rawio()
3677 exit(-6); in check_permissions()
3714 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in probe_nhm_msrs()
3715 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in probe_nhm_msrs()
3923 /* Nehalem compatible, but do not include turbo-ratio limit support */ in has_turbo_ratio_limit()
3924 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in has_turbo_ratio_limit()
3925 case INTEL_FAM6_XEON_PHI_KNL: /* PHI - Knights Landing (different MSR definition) */ in has_turbo_ratio_limit()
4125 int retval = -1; in read_sysfs_int()
4131 return (-1); in read_sysfs_int()
4185 fprintf(outf, "Uncore Frequency pkg%d die%d: %d - %d MHz ", i, j, k / 1000, l / 1000); in intel_uncore_frequency_probe()
4195 fprintf(outf, "(%d - %d MHz)\n", k / 1000, l / 1000); in intel_uncore_frequency_probe()
4227 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in dump_sysfs_cstate_config()
4228 sp = strchr(name_buf, '-'); in dump_sysfs_cstate_config()
4313 cpu = t->cpu_id; in print_epb()
4315 /* EPB is per-package */ in print_epb()
4316 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_epb()
4321 return -1; in print_epb()
4362 cpu = t->cpu_id; in print_hwp()
4364 /* MSR_HWP_CAPABILITIES is per-package */ in print_hwp()
4365 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_hwp()
4370 return -1; in print_hwp()
4376 fprintf(outf, "cpu%d: MSR_PM_ENABLE: 0x%08llx (%sHWP)\n", cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
4422 cpu, msr, ((msr) & 0x1) ? "EN" : "Dis", ((msr) & 0x2) ? "EN" : "Dis"); in print_hwp()
4429 cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x2) ? "" : "No-"); in print_hwp()
4445 cpu = t->cpu_id; in print_perf_limit()
4447 /* per-package */ in print_perf_limit()
4448 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_perf_limit()
4453 return -1; in print_perf_limit()
4468 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4469 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
4479 (msr & 1 << 26) ? "PkgPwrL1, " : "", in print_perf_limit()
4482 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4483 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
4496 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4504 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4507 (msr & 1 << 26) ? "PkgPwrL1, " : "", (msr & 1 << 27) ? "PkgPwrL2, " : ""); in print_perf_limit()
4515 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4521 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4523 (msr & 1 << 26) ? "PkgPwrL1, " : "", (msr & 1 << 27) ? "PkgPwrL2, " : ""); in print_perf_limit()
4558 * Energy units are either hard-coded, or come from RAPL Energy Unit MSR.
4777 rapl_time_units = ldexp(1.0, -(msr >> 16 & 0xf)); in rapl_probe_amd()
4778 rapl_energy_units = ldexp(1.0, -(msr >> 8 & 0x1f)); in rapl_probe_amd()
4779 rapl_power_units = ldexp(1.0, -(msr & 0xf)); in rapl_probe_amd()
4853 cpu = t->cpu_id; in print_thermal()
4855 /* DTS is per-core, no need to print for each thread */ in print_thermal()
4856 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in print_thermal()
4861 return -1; in print_thermal()
4864 if (do_ptm && (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) { in print_thermal()
4869 fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_STATUS: 0x%08llx (%d C)\n", cpu, msr, tj_max - dts); in print_thermal()
4877 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
4888 fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", in print_thermal()
4889 cpu, msr, tj_max - dts, resolution); in print_thermal()
4897 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
4907 ((msr >> 15) & 1) ? "EN" : "DIS", in print_power_limit_msr()
4910 (((msr >> 16) & 1) ? "EN" : "DIS")); in print_power_limit_msr()
4928 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_rapl()
4931 cpu = t->cpu_id; in print_rapl()
4934 return -1; in print_rapl()
4940 return -1; in print_rapl()
4944 return -1; in print_rapl()
4953 return -5; in print_rapl()
4955 fprintf(outf, "cpu%d: MSR_PKG_POWER_INFO: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4966 return -9; in print_rapl()
4974 ((msr >> 47) & 1) ? "EN" : "DIS", in print_rapl()
4977 ((msr >> 48) & 1) ? "EN" : "DIS"); in print_rapl()
4980 return -9; in print_rapl()
4989 return -6; in print_rapl()
4991 fprintf(outf, "cpu%d: MSR_DRAM_POWER_INFO,: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
5000 return -9; in print_rapl()
5008 return -7; in print_rapl()
5014 return -9; in print_rapl()
5021 return -8; in print_rapl()
5026 return -9; in print_rapl()
5233 if (cpu_migrate(t->cpu_id)) { in get_cpu_type()
5234 fprintf(outf, "Could not migrate to CPU %d\n", t->cpu_id); in get_cpu_type()
5235 return -1; in get_cpu_type()
5244 t->is_atom = true; in get_cpu_type()
5254 * but also allow cmdline over-ride with -T.
5256 * Several MSR temperature values are in units of degrees-C
5273 /* this is a per-package concept */ in set_temperature_target()
5274 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in set_temperature_target()
5277 cpu = t->cpu_id; in set_temperature_target()
5280 return -1; in set_temperature_target()
5302 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in set_temperature_target()
5303 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
5307 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in set_temperature_target()
5308 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
5325 fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n", cpu, tj_max); in set_temperature_target()
5336 base_cpu, msr, msr & FEAT_CTL_LOCKED ? "" : "UN-", msr & (1 << 18) ? "SGX" : ""); in decode_feature_control_msr()
5349 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", in decode_misc_enable_msr()
5350 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", in decode_misc_enable_msr()
5351 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-", in decode_misc_enable_msr()
5352 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", in decode_misc_enable_msr()
5353 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); in decode_misc_enable_msr()
5365 …"cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1-IP in decode_misc_feature_control()
5366 base_cpu, msr, msr & (0 << 0) ? "No-" : "", msr & (1 << 0) ? "No-" : "", in decode_misc_feature_control()
5367 msr & (2 << 0) ? "No-" : "", msr & (3 << 0) ? "No-" : ""); in decode_misc_feature_control()
5388 …fprintf(outf, "cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)… in decode_misc_pwr_mgmt_msr()
5390 msr & (1 << 0) ? "DIS" : "EN", msr & (1 << 1) ? "EN" : "DIS", msr & (1 << 8) ? "EN" : "DIS"); in decode_misc_pwr_mgmt_msr()
5404 fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", in decode_c6_demotion_policy_msr()
5405 base_cpu, msr, msr & (1 << 0) ? "EN" : "DIS"); in decode_c6_demotion_policy_msr()
5408 fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", in decode_c6_demotion_policy_msr()
5409 base_cpu, msr, msr & (1 << 0) ? "EN" : "DIS"); in decode_c6_demotion_policy_msr()
5419 case INTEL_FAM6_NEHALEM_EP: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */ in intel_model_duplicates()
5420 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in intel_model_duplicates()
5421 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ in intel_model_duplicates()
5422 case INTEL_FAM6_WESTMERE: /* Westmere Client - Clarkdale, Arrandale */ in intel_model_duplicates()
5423 case INTEL_FAM6_WESTMERE_EP: /* Westmere EP - Gulftown */ in intel_model_duplicates()
5426 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in intel_model_duplicates()
5427 case INTEL_FAM6_WESTMERE_EX: /* Westmere-EX Xeon - Eagleton */ in intel_model_duplicates()
5434 case INTEL_FAM6_BROADWELL_D: /* BDX-DE */ in intel_model_duplicates()
5495 * Linux-perf manages the HW instructions-retired counter
5508 err(-1, "calloc fd_instr_count_percpu"); in linux_perf_init()
5562 ecx_flags & (1 << 0) ? "SSE3" : "-", in process_cpuid()
5563 ecx_flags & (1 << 3) ? "MONITOR" : "-", in process_cpuid()
5564 ecx_flags & (1 << 6) ? "SMX" : "-", in process_cpuid()
5565 ecx_flags & (1 << 7) ? "EIST" : "-", in process_cpuid()
5566 ecx_flags & (1 << 8) ? "TM2" : "-", in process_cpuid()
5567 edx_flags & (1 << 4) ? "TSC" : "-", in process_cpuid()
5568 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
5569 edx_flags & (1 << 22) ? "ACPI-TM" : "-", in process_cpuid()
5570 edx_flags & (1 << 28) ? "HT" : "-", edx_flags & (1 << 29) ? "TM" : "-"); in process_cpuid()
5583 * Non-Stop TSC is advertised by CPUID.EAX=0x80000007: EDX.bit8 in process_cpuid()
5619 has_aperf ? "" : "No-", in process_cpuid()
5620 has_turbo ? "" : "No-", in process_cpuid()
5621 do_dts ? "" : "No-", in process_cpuid()
5622 do_ptm ? "" : "No-", in process_cpuid()
5623 has_hwp ? "" : "No-", in process_cpuid()
5624 has_hwp_notify ? "" : "No-", in process_cpuid()
5625 has_hwp_activity_window ? "" : "No-", in process_cpuid()
5626 has_hwp_epp ? "" : "No-", has_hwp_pkg ? "" : "No-", has_epb ? "" : "No-"); in process_cpuid()
5642 fprintf(outf, "CPUID(7): %sSGX %sHybrid\n", has_sgx ? "" : "No-", is_hybrid ? "" : "No-"); in process_cpuid()
5653 * CPUID 15H TSC/Crystal ratio, possibly Crystal Hz in process_cpuid()
5852 if (isdigit(dirp->d_name[0])) in dir_filter()
6006 (*t)[i].cpu_id = -1; in allocate_counters()
6013 (*c)[i].core_id = -1; in allocate_counters()
6042 /* Workaround for systems where physical_node_id==-1 in init_counter()
6043 * and logical_node_id==(-1 - topo.num_cpus) in init_counter()
6052 t->cpu_id = cpu_id; in init_counter()
6054 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE; in init_counter()
6056 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE; in init_counter()
6059 c->core_id = core_id; in init_counter()
6060 p->package_id = pkg_id; in init_counter()
6075 err(-1, "calloc output buffer"); in allocate_output_buffer()
6082 err(-1, "calloc fd_percpu"); in allocate_fd_percpu()
6089 err(-1, "calloc %d", topo.num_cpus); in allocate_irq_buffers()
6093 err(-1, "calloc %d", topo.max_cpu_num + 1); in allocate_irq_buffers()
6111 err(-ENODEV, "No valid cpus found"); in set_base_cpu()
6163 /* clear affinity side-effect of get_counters() */ in fork_it()
6175 if (child_pid == -1) in fork_it()
6180 if (waitpid(child_pid, &status, 0) == -1) in fork_it()
6188 * because re-starting is problematic when forking in fork_it()
6228 fprintf(outf, "turbostat version 2022.10.04 - Len Brown <lenb@kernel.org>\n"); in print_version()
6244 ret = fread(bootcmd, sizeof(char), COMMAND_LINE_SIZE - 1, fp); in print_bootcmd()
6266 msrp->msr_num = msr_num; in add_counter()
6267 strncpy(msrp->name, name, NAME_BYTES - 1); in add_counter()
6269 strncpy(msrp->path, path, PATH_BYTES - 1); in add_counter()
6270 msrp->width = width; in add_counter()
6271 msrp->type = type; in add_counter()
6272 msrp->format = format; in add_counter()
6273 msrp->flags = flags; in add_counter()
6278 msrp->next = sys.tp; in add_counter()
6283 exit(-1); in add_counter()
6288 msrp->next = sys.cp; in add_counter()
6293 exit(-1); in add_counter()
6298 msrp->next = sys.pp; in add_counter()
6303 exit(-1); in add_counter()
6395 fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter ) required\n"); in parse_add_command()
6444 for (state = 10; state >= 0; --state) { in probe_sysfs()
6453 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
6454 sp = strchr(name_buf, '-'); in probe_sysfs()
6475 for (state = 10; state >= 0; --state) { in probe_sysfs()
6483 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
6484 sp = strchr(name_buf, '-'); in probe_sysfs()
6507 * 1,2,4..6,8-10 and set bits in cpu_subset
6540 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_command()
6557 if (*next == '-') { in parse_cpu_command()
6586 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
6588 exit(-1); in parse_cpu_command()
6606 { "hide", required_argument, 0, 'H' }, // meh, -h taken by --help in cmdline()
6620 …opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qST:v", long_options, &option_index)) != -1) { in cmdline()
6632 /* --enable specified counter */ in cmdline()
6641 * --hide: do not show those specified in cmdline()
6660 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000; in cmdline()
6661 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; in cmdline()
6696 * --show: show only those specified in cmdline()
6750 if (argc - optind) in main()