Lines Matching +full:operating +full:- +full:range +full:- +full:celsius
1 // SPDX-License-Identifier: GPL-2.0-only
3 * turbostat -- show CPU frequency and C-state residency
146 /* Indicates cores energy collection is per-core,
147 * not per-package. */
155 /* MSRs that are not yet in the kernel-provided header. */
164 * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters
204 unsigned long long mc6_us; /* duplicate as per-core for now, even though per module */
294 /* get_msr_sum() = sum + (get_msr() - last) */
333 offset = -1; in idx_to_offset()
363 idx = -1; in offset_to_idx()
408 int logical_node_id; /* 0-based count within the package */
444 * skip non-present cpus
462 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus()
482 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) in cpu_migrate()
483 return -1; in cpu_migrate()
501 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root", pathname); in get_msr_fd()
524 fd = perf_event_open(&pea, -1, cpu_num, -1, 0); in perf_instr_count_open()
525 if (fd == -1) in perf_instr_count_open()
526 err(-1, "cpu%d: perf instruction counter\n", cpu_num); in perf_instr_count_open()
548 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
555 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
557 * matching on them for --show and --hide.
693 * HIDE_LIST - hide this list of counters, show the rest [default]
694 * SHOW_LIST - show this list of counters, hide the rest
701 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" in help()
705 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" in help()
707 " -a, --add add a counter\n" in help()
708 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" in help()
709 " -c, --cpu cpu-set limit output to summary plus cpu-set:\n" in help()
710 " {core | package | j,k,l..m,n-p }\n" in help()
711 " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n" in help()
712 " -D, --Dump displays the raw counter values\n" in help()
713 " -e, --enable [all | column]\n" in help()
715 " -H, --hide [column|column,column,...]\n" in help()
717 " -i, --interval sec.subsec\n" in help()
718 " Override default 5-second measurement interval\n" in help()
719 " -J, --Joules displays energy in Joules instead of Watts\n" in help()
720 " -l, --list list column headers only\n" in help()
721 " -n, --num_iterations num\n" in help()
723 " -o, --out file\n" in help()
725 " -q, --quiet skip decoding system configuration header\n" in help()
726 " -s, --show [column|column,column,...]\n" in help()
728 " -S, --Summary\n" in help()
729 " limits output to 1-line system summary per interval\n" in help()
730 " -T, --TCC temperature\n" in help()
732 " degrees Celsius\n" in help()
733 " -h, --help print this help message\n" in help()
734 " -v, --version print version information\n" "\n" "For more help, run \"man turbostat\"\n"); in help()
779 exit(-1); in bic_lookup()
785 fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", in bic_lookup()
845 for (mp = sys.tp; mp; mp = mp->next) { in print_header()
847 if (mp->format == FORMAT_RAW) { in print_header()
848 if (mp->width == 64) in print_header()
849 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name); in print_header()
851 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name); in print_header()
853 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
854 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name); in print_header()
856 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name); in print_header()
883 for (mp = sys.cp; mp; mp = mp->next) { in print_header()
884 if (mp->format == FORMAT_RAW) { in print_header()
885 if (mp->width == 64) in print_header()
886 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
888 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
890 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
891 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
893 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
964 for (mp = sys.pp; mp; mp = mp->next) { in print_header()
965 if (mp->format == FORMAT_RAW) { in print_header()
966 if (mp->width == 64) in print_header()
967 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
969 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
971 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
972 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
974 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
989 outp += sprintf(outp, "CPU: %d flags 0x%x\n", t->cpu_id, t->flags); in dump_counters()
990 outp += sprintf(outp, "TSC: %016llX\n", t->tsc); in dump_counters()
991 outp += sprintf(outp, "aperf: %016llX\n", t->aperf); in dump_counters()
992 outp += sprintf(outp, "mperf: %016llX\n", t->mperf); in dump_counters()
993 outp += sprintf(outp, "c1: %016llX\n", t->c1); in dump_counters()
996 outp += sprintf(outp, "IPC: %lld\n", t->instr_count); in dump_counters()
999 outp += sprintf(outp, "IRQ: %lld\n", t->irq_count); in dump_counters()
1001 outp += sprintf(outp, "SMI: %d\n", t->smi_count); in dump_counters()
1003 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in dump_counters()
1004 outp += sprintf(outp, "tADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, t->counter[i]); in dump_counters()
1009 outp += sprintf(outp, "core: %d\n", c->core_id); in dump_counters()
1010 outp += sprintf(outp, "c3: %016llX\n", c->c3); in dump_counters()
1011 outp += sprintf(outp, "c6: %016llX\n", c->c6); in dump_counters()
1012 outp += sprintf(outp, "c7: %016llX\n", c->c7); in dump_counters()
1013 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); in dump_counters()
1014 outp += sprintf(outp, "Joules: %0X\n", c->core_energy); in dump_counters()
1016 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in dump_counters()
1017 outp += sprintf(outp, "cADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, c->counter[i]); in dump_counters()
1019 outp += sprintf(outp, "mc6_us: %016llX\n", c->mc6_us); in dump_counters()
1023 outp += sprintf(outp, "package: %d\n", p->package_id); in dump_counters()
1025 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); in dump_counters()
1026 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); in dump_counters()
1027 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); in dump_counters()
1028 outp += sprintf(outp, "CPU + GFX: %016llX\n", p->pkg_both_core_gfxe_c0); in dump_counters()
1030 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); in dump_counters()
1032 outp += sprintf(outp, "pc3: %016llX\n", p->pc3); in dump_counters()
1034 outp += sprintf(outp, "pc6: %016llX\n", p->pc6); in dump_counters()
1036 outp += sprintf(outp, "pc7: %016llX\n", p->pc7); in dump_counters()
1037 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); in dump_counters()
1038 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); in dump_counters()
1039 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); in dump_counters()
1040 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi); in dump_counters()
1041 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi); in dump_counters()
1042 outp += sprintf(outp, "Joules PKG: %0llX\n", p->energy_pkg); in dump_counters()
1043 outp += sprintf(outp, "Joules COR: %0llX\n", p->energy_cores); in dump_counters()
1044 outp += sprintf(outp, "Joules GFX: %0llX\n", p->energy_gfx); in dump_counters()
1045 outp += sprintf(outp, "Joules RAM: %0llX\n", p->energy_dram); in dump_counters()
1046 outp += sprintf(outp, "Throttle PKG: %0llX\n", p->rapl_pkg_perf_status); in dump_counters()
1047 outp += sprintf(outp, "Throttle RAM: %0llX\n", p->rapl_dram_perf_status); in dump_counters()
1048 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c); in dump_counters()
1050 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in dump_counters()
1051 outp += sprintf(outp, "pADDED [%d] msr0x%x: %08llX\n", i, mp->msr_num, p->counter[i]); in dump_counters()
1073 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1077 if (show_pkg_only && !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1080 /*if not summary line and --cpu is used */ in format_counters()
1081 …if ((t != &average.threads) && (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset)… in format_counters()
1088 timersub(&t->tv_end, &t->tv_begin, &tv); in format_counters()
1094 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec); in format_counters()
1096 interval_float = t->tv_delta.tv_sec + t->tv_delta.tv_usec / 1000000.0; in format_counters()
1098 tsc = t->tsc * tsc_tweak; in format_counters()
1103 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1105 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1107 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1109 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1111 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1113 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1115 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1119 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); in format_counters()
1121 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1125 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].die_id); in format_counters()
1127 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1132 (printed++ ? delim : ""), cpus[t->cpu_id].physical_node_id); in format_counters()
1134 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1138 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); in format_counters()
1140 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1143 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); in format_counters()
1145 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id); in format_counters()
1147 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id); in format_counters()
1151 …outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 / units * t->aperf / interval_float); in format_counters()
1154 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->mperf / tsc); in format_counters()
1159 sprintf(outp, "%s%.0f", (printed++ ? delim : ""), base_hz / units * t->aperf / t->mperf); in format_counters()
1162 tsc / units * t->aperf / t->mperf / interval_float); in format_counters()
1166 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 * t->tsc / units / interval_float); in format_counters()
1169 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 1.0 * t->instr_count / t->aperf); in format_counters()
1174 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1176 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1181 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->smi_count); in format_counters()
1184 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in format_counters()
1185 if (mp->format == FORMAT_RAW) { in format_counters()
1186 if (mp->width == 32) in format_counters()
1188 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)t->counter[i]); in format_counters()
1190 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1191 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1192 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1193 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1195 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1196 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1197 if (mp->type == COUNTER_USEC) in format_counters()
1200 t->counter[i] / interval_float / 10000); in format_counters()
1202 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->counter[i] / tsc); in format_counters()
1208 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->c1 / tsc); in format_counters()
1210 /* print per-core data only for 1st thread in core */ in format_counters()
1211 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1215 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3 / tsc); in format_counters()
1217 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6 / tsc); in format_counters()
1219 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c7 / tsc); in format_counters()
1223 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->mc6_us / tsc); in format_counters()
1226 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); in format_counters()
1228 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in format_counters()
1229 if (mp->format == FORMAT_RAW) { in format_counters()
1230 if (mp->width == 32) in format_counters()
1232 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)c->counter[i]); in format_counters()
1234 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1235 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1236 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1237 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1239 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1240 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1241 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->counter[i] / tsc); in format_counters()
1249 …sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units / interval_float); in format_counters()
1251 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units); in format_counters()
1253 /* print per-package data only for 1st core in package */ in format_counters()
1254 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1259 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->pkg_temp_c); in format_counters()
1263 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
1267 p->gfx_rc6_ms / 10.0 / interval_float); in format_counters()
1273 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz); in format_counters()
1277 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_act_mhz); in format_counters()
1281 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0 / tsc); in format_counters()
1283 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0 / tsc); in format_counters()
1285 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0 / tsc); in format_counters()
1287 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0 / tsc); in format_counters()
1290 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2 / tsc); in format_counters()
1292 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc3 / tsc); in format_counters()
1294 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc6 / tsc); in format_counters()
1296 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc7 / tsc); in format_counters()
1298 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc8 / tsc); in format_counters()
1300 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc9 / tsc); in format_counters()
1302 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10 / tsc); in format_counters()
1306 …sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->cpu_lpi / 1000000.0 / interval_float); in format_counters()
1309 …sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->sys_lpi / 1000000.0 / interval_float); in format_counters()
1313 … sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units / interval_float); in format_counters()
1316 …sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units / interval_float… in format_counters()
1319 … sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units / interval_float); in format_counters()
1323 p->energy_dram * rapl_dram_energy_units / interval_float); in format_counters()
1325 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units); in format_counters()
1327 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units); in format_counters()
1329 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units); in format_counters()
1331 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units); in format_counters()
1335 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float); in format_counters()
1339 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float); in format_counters()
1341 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in format_counters()
1342 if (mp->format == FORMAT_RAW) { in format_counters()
1343 if (mp->width == 32) in format_counters()
1345 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)p->counter[i]); in format_counters()
1347 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1348 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1349 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1350 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1352 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1353 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1354 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->counter[i] / tsc); in format_counters()
1359 if (*(outp - 1) != '\n') in format_counters()
1405 old = ((((unsigned long long)new << 32) - ((unsigned long long)old << 32)) >> 32);
1413 old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0; in delta_package()
1415 old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0; in delta_package()
1417 old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0; in delta_package()
1419 old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0; in delta_package()
1421 old->pc2 = new->pc2 - old->pc2; in delta_package()
1423 old->pc3 = new->pc3 - old->pc3; in delta_package()
1425 old->pc6 = new->pc6 - old->pc6; in delta_package()
1427 old->pc7 = new->pc7 - old->pc7; in delta_package()
1428 old->pc8 = new->pc8 - old->pc8; in delta_package()
1429 old->pc9 = new->pc9 - old->pc9; in delta_package()
1430 old->pc10 = new->pc10 - old->pc10; in delta_package()
1431 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi; in delta_package()
1432 old->sys_lpi = new->sys_lpi - old->sys_lpi; in delta_package()
1433 old->pkg_temp_c = new->pkg_temp_c; in delta_package()
1436 if (old->gfx_rc6_ms > new->gfx_rc6_ms) in delta_package()
1437 old->gfx_rc6_ms = -1; in delta_package()
1439 old->gfx_rc6_ms = new->gfx_rc6_ms - old->gfx_rc6_ms; in delta_package()
1441 old->gfx_mhz = new->gfx_mhz; in delta_package()
1442 old->gfx_act_mhz = new->gfx_act_mhz; in delta_package()
1444 old->energy_pkg = new->energy_pkg - old->energy_pkg; in delta_package()
1445 old->energy_cores = new->energy_cores - old->energy_cores; in delta_package()
1446 old->energy_gfx = new->energy_gfx - old->energy_gfx; in delta_package()
1447 old->energy_dram = new->energy_dram - old->energy_dram; in delta_package()
1448 old->rapl_pkg_perf_status = new->rapl_pkg_perf_status - old->rapl_pkg_perf_status; in delta_package()
1449 old->rapl_dram_perf_status = new->rapl_dram_perf_status - old->rapl_dram_perf_status; in delta_package()
1451 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in delta_package()
1452 if (mp->format == FORMAT_RAW) in delta_package()
1453 old->counter[i] = new->counter[i]; in delta_package()
1455 old->counter[i] = new->counter[i] - old->counter[i]; in delta_package()
1466 old->c3 = new->c3 - old->c3; in delta_core()
1467 old->c6 = new->c6 - old->c6; in delta_core()
1468 old->c7 = new->c7 - old->c7; in delta_core()
1469 old->core_temp_c = new->core_temp_c; in delta_core()
1470 old->mc6_us = new->mc6_us - old->mc6_us; in delta_core()
1472 DELTA_WRAP32(new->core_energy, old->core_energy); in delta_core()
1474 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in delta_core()
1475 if (mp->format == FORMAT_RAW) in delta_core()
1476 old->counter[i] = new->counter[i]; in delta_core()
1478 old->counter[i] = new->counter[i] - old->counter[i]; in delta_core()
1491 * old = new - old
1500 new->apic_id = old->apic_id; in delta_thread()
1502 new->x2apic_id = old->x2apic_id; in delta_thread()
1507 * over-write old w/ new so we can print end of interval values in delta_thread()
1510 timersub(&new->tv_begin, &old->tv_begin, &old->tv_delta); in delta_thread()
1511 old->tv_begin = new->tv_begin; in delta_thread()
1512 old->tv_end = new->tv_end; in delta_thread()
1514 old->tsc = new->tsc - old->tsc; in delta_thread()
1517 if (old->tsc < (1000 * 1000)) in delta_thread()
1518 errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n" in delta_thread()
1519 "You can disable all c-states by booting with \"idle=poll\"\n" in delta_thread()
1522 old->c1 = new->c1 - old->c1; in delta_thread()
1525 if ((new->aperf > old->aperf) && (new->mperf > old->mperf)) { in delta_thread()
1526 old->aperf = new->aperf - old->aperf; in delta_thread()
1527 old->mperf = new->mperf - old->mperf; in delta_thread()
1529 return -1; in delta_thread()
1541 * it is possible for mperf's non-halted cycles + idle states in delta_thread()
1544 if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) in delta_thread()
1545 old->c1 = 0; in delta_thread()
1548 old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 in delta_thread()
1549 - core_delta->c6 - core_delta->c7; in delta_thread()
1553 if (old->mperf == 0) { in delta_thread()
1555 fprintf(outf, "cpu%d MPERF 0!\n", old->cpu_id); in delta_thread()
1556 old->mperf = 1; /* divide by 0 protection */ in delta_thread()
1560 old->instr_count = new->instr_count - old->instr_count; in delta_thread()
1563 old->irq_count = new->irq_count - old->irq_count; in delta_thread()
1566 old->smi_count = new->smi_count - old->smi_count; in delta_thread()
1568 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in delta_thread()
1569 if (mp->format == FORMAT_RAW) in delta_thread()
1570 old->counter[i] = new->counter[i]; in delta_thread()
1572 old->counter[i] = new->counter[i] - old->counter[i]; in delta_thread()
1583 if (t->flags & CPU_IS_FIRST_THREAD_IN_CORE) in delta_cpu()
1592 if (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE) in delta_cpu()
1603 t->tv_begin.tv_sec = 0; in clear_counters()
1604 t->tv_begin.tv_usec = 0; in clear_counters()
1605 t->tv_end.tv_sec = 0; in clear_counters()
1606 t->tv_end.tv_usec = 0; in clear_counters()
1607 t->tv_delta.tv_sec = 0; in clear_counters()
1608 t->tv_delta.tv_usec = 0; in clear_counters()
1610 t->tsc = 0; in clear_counters()
1611 t->aperf = 0; in clear_counters()
1612 t->mperf = 0; in clear_counters()
1613 t->c1 = 0; in clear_counters()
1615 t->instr_count = 0; in clear_counters()
1617 t->irq_count = 0; in clear_counters()
1618 t->smi_count = 0; in clear_counters()
1621 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE; in clear_counters()
1623 c->c3 = 0; in clear_counters()
1624 c->c6 = 0; in clear_counters()
1625 c->c7 = 0; in clear_counters()
1626 c->mc6_us = 0; in clear_counters()
1627 c->core_temp_c = 0; in clear_counters()
1628 c->core_energy = 0; in clear_counters()
1630 p->pkg_wtd_core_c0 = 0; in clear_counters()
1631 p->pkg_any_core_c0 = 0; in clear_counters()
1632 p->pkg_any_gfxe_c0 = 0; in clear_counters()
1633 p->pkg_both_core_gfxe_c0 = 0; in clear_counters()
1635 p->pc2 = 0; in clear_counters()
1637 p->pc3 = 0; in clear_counters()
1639 p->pc6 = 0; in clear_counters()
1641 p->pc7 = 0; in clear_counters()
1642 p->pc8 = 0; in clear_counters()
1643 p->pc9 = 0; in clear_counters()
1644 p->pc10 = 0; in clear_counters()
1645 p->cpu_lpi = 0; in clear_counters()
1646 p->sys_lpi = 0; in clear_counters()
1648 p->energy_pkg = 0; in clear_counters()
1649 p->energy_dram = 0; in clear_counters()
1650 p->energy_cores = 0; in clear_counters()
1651 p->energy_gfx = 0; in clear_counters()
1652 p->rapl_pkg_perf_status = 0; in clear_counters()
1653 p->rapl_dram_perf_status = 0; in clear_counters()
1654 p->pkg_temp_c = 0; in clear_counters()
1656 p->gfx_rc6_ms = 0; in clear_counters()
1657 p->gfx_mhz = 0; in clear_counters()
1658 p->gfx_act_mhz = 0; in clear_counters()
1659 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) in clear_counters()
1660 t->counter[i] = 0; in clear_counters()
1662 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) in clear_counters()
1663 c->counter[i] = 0; in clear_counters()
1665 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) in clear_counters()
1666 p->counter[i] = 0; in clear_counters()
1674 /* copy un-changing apic_id's */ in sum_counters()
1676 average.threads.apic_id = t->apic_id; in sum_counters()
1678 average.threads.x2apic_id = t->x2apic_id; in sum_counters()
1682 average.threads.tv_begin = t->tv_begin; in sum_counters()
1685 average.threads.tv_end = t->tv_end; in sum_counters()
1687 average.threads.tsc += t->tsc; in sum_counters()
1688 average.threads.aperf += t->aperf; in sum_counters()
1689 average.threads.mperf += t->mperf; in sum_counters()
1690 average.threads.c1 += t->c1; in sum_counters()
1692 average.threads.instr_count += t->instr_count; in sum_counters()
1694 average.threads.irq_count += t->irq_count; in sum_counters()
1695 average.threads.smi_count += t->smi_count; in sum_counters()
1697 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in sum_counters()
1698 if (mp->format == FORMAT_RAW) in sum_counters()
1700 average.threads.counter[i] += t->counter[i]; in sum_counters()
1703 /* sum per-core values only for 1st thread in core */ in sum_counters()
1704 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in sum_counters()
1707 average.cores.c3 += c->c3; in sum_counters()
1708 average.cores.c6 += c->c6; in sum_counters()
1709 average.cores.c7 += c->c7; in sum_counters()
1710 average.cores.mc6_us += c->mc6_us; in sum_counters()
1712 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); in sum_counters()
1714 average.cores.core_energy += c->core_energy; in sum_counters()
1716 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in sum_counters()
1717 if (mp->format == FORMAT_RAW) in sum_counters()
1719 average.cores.counter[i] += c->counter[i]; in sum_counters()
1722 /* sum per-pkg values only for 1st core in pkg */ in sum_counters()
1723 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in sum_counters()
1727 average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0; in sum_counters()
1729 average.packages.pkg_any_core_c0 += p->pkg_any_core_c0; in sum_counters()
1731 average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0; in sum_counters()
1733 average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0; in sum_counters()
1735 average.packages.pc2 += p->pc2; in sum_counters()
1737 average.packages.pc3 += p->pc3; in sum_counters()
1739 average.packages.pc6 += p->pc6; in sum_counters()
1741 average.packages.pc7 += p->pc7; in sum_counters()
1742 average.packages.pc8 += p->pc8; in sum_counters()
1743 average.packages.pc9 += p->pc9; in sum_counters()
1744 average.packages.pc10 += p->pc10; in sum_counters()
1746 average.packages.cpu_lpi = p->cpu_lpi; in sum_counters()
1747 average.packages.sys_lpi = p->sys_lpi; in sum_counters()
1749 average.packages.energy_pkg += p->energy_pkg; in sum_counters()
1750 average.packages.energy_dram += p->energy_dram; in sum_counters()
1751 average.packages.energy_cores += p->energy_cores; in sum_counters()
1752 average.packages.energy_gfx += p->energy_gfx; in sum_counters()
1754 average.packages.gfx_rc6_ms = p->gfx_rc6_ms; in sum_counters()
1755 average.packages.gfx_mhz = p->gfx_mhz; in sum_counters()
1756 average.packages.gfx_act_mhz = p->gfx_act_mhz; in sum_counters()
1758 average.packages.pkg_temp_c = MAX(average.packages.pkg_temp_c, p->pkg_temp_c); in sum_counters()
1760 average.packages.rapl_pkg_perf_status += p->rapl_pkg_perf_status; in sum_counters()
1761 average.packages.rapl_dram_perf_status += p->rapl_dram_perf_status; in sum_counters()
1763 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in sum_counters()
1764 if (mp->format == FORMAT_RAW) in sum_counters()
1766 average.packages.counter[i] += p->counter[i]; in sum_counters()
1822 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in compute_average()
1823 if (mp->format == FORMAT_RAW) in compute_average()
1825 if (mp->type == COUNTER_ITEMS) { in compute_average()
1832 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in compute_average()
1833 if (mp->format == FORMAT_RAW) in compute_average()
1835 if (mp->type == COUNTER_ITEMS) { in compute_average()
1841 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in compute_average()
1842 if (mp->format == FORMAT_RAW) in compute_average()
1844 if (mp->type == COUNTER_ITEMS) { in compute_average()
1897 if (mp->msr_num != 0) { in get_mp()
1898 if (get_msr(cpu, mp->msr_num, counterp)) in get_mp()
1899 return -1; in get_mp()
1903 if (mp->flags & SYSFS_PERCPU) { in get_mp()
1904 sprintf(path, "/sys/devices/system/cpu/cpu%d/%s", cpu, mp->path); in get_mp()
1908 *counterp = snapshot_sysfs_counter(mp->path); in get_mp()
1919 int ret, epb = -1; in get_epb()
1950 t->apic_id = (ebx >> 24) & 0xff; in get_apic_id()
1972 t->x2apic_id = eax; in get_apic_id()
1984 t->x2apic_id = edx; in get_apic_id()
1986 if (debug && (t->apic_id != (t->x2apic_id & 0xff))) in get_apic_id()
1987 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()
1997 int cpu = t->cpu_id; in get_counters()
2005 return -1; in get_counters()
2008 gettimeofday(&t->tv_begin, (struct timezone *)NULL); in get_counters()
2013 t->tsc = rdtsc(); /* we are running on local CPU of interest */ in get_counters()
2025 * varies by a large amount, we re-read them. in get_counters()
2033 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
2034 return -3; in get_counters()
2036 t->tsc = rdtsc(); /* re-read close to APERF */ in get_counters()
2038 tsc_before = t->tsc; in get_counters()
2040 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
2041 return -3; in get_counters()
2045 if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) in get_counters()
2046 return -4; in get_counters()
2050 aperf_time = tsc_between - tsc_before; in get_counters()
2051 mperf_time = tsc_after - tsc_between; in get_counters()
2066 t->aperf = t->aperf * aperf_mperf_multiplier; in get_counters()
2067 t->mperf = t->mperf * aperf_mperf_multiplier; in get_counters()
2071 if (read(get_instr_count_fd(cpu), &t->instr_count, sizeof(long long)) != sizeof(long long)) in get_counters()
2072 return -4; in get_counters()
2075 t->irq_count = irqs_per_cpu[cpu]; in get_counters()
2078 return -5; in get_counters()
2079 t->smi_count = msr & 0xFFFFFFFF; in get_counters()
2082 if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) in get_counters()
2083 return -6; in get_counters()
2086 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in get_counters()
2087 if (get_mp(cpu, mp, &t->counter[i])) in get_counters()
2088 return -10; in get_counters()
2092 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in get_counters()
2096 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) in get_counters()
2097 return -6; in get_counters()
2101 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
2102 return -7; in get_counters()
2104 if (get_msr(cpu, MSR_KNL_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
2105 return -7; in get_counters()
2109 if (get_msr(cpu, MSR_CORE_C7_RESIDENCY, &c->c7)) in get_counters()
2110 return -8; in get_counters()
2111 else if (t->is_atom) { in get_counters()
2118 c->c6 -= c->c7; in get_counters()
2123 if (get_msr(cpu, MSR_MODULE_C6_RES_MS, &c->mc6_us)) in get_counters()
2124 return -8; in get_counters()
2128 return -9; in get_counters()
2129 c->core_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
2134 return -14; in get_counters()
2135 c->core_energy = msr & 0xFFFFFFFF; in get_counters()
2138 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in get_counters()
2139 if (get_mp(cpu, mp, &c->counter[i])) in get_counters()
2140 return -10; in get_counters()
2144 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in get_counters()
2148 if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) in get_counters()
2149 return -10; in get_counters()
2152 if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0)) in get_counters()
2153 return -11; in get_counters()
2156 if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0)) in get_counters()
2157 return -12; in get_counters()
2160 if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0)) in get_counters()
2161 return -13; in get_counters()
2164 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) in get_counters()
2165 return -9; in get_counters()
2168 if (get_msr(cpu, MSR_ATOM_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2169 return -10; in get_counters()
2171 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2172 return -10; in get_counters()
2177 if (get_msr(cpu, MSR_PKG_C2_RESIDENCY, &p->pc2)) in get_counters()
2178 return -11; in get_counters()
2180 if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) in get_counters()
2181 return -12; in get_counters()
2183 if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) in get_counters()
2184 return -13; in get_counters()
2186 if (get_msr(cpu, MSR_PKG_C9_RESIDENCY, &p->pc9)) in get_counters()
2187 return -13; in get_counters()
2189 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) in get_counters()
2190 return -13; in get_counters()
2193 p->cpu_lpi = cpuidle_cur_cpu_lpi_us; in get_counters()
2195 p->sys_lpi = cpuidle_cur_sys_lpi_us; in get_counters()
2199 return -13; in get_counters()
2200 p->energy_pkg = msr; in get_counters()
2204 return -14; in get_counters()
2205 p->energy_cores = msr; in get_counters()
2209 return -15; in get_counters()
2210 p->energy_dram = msr; in get_counters()
2214 return -16; in get_counters()
2215 p->energy_gfx = msr; in get_counters()
2219 return -16; in get_counters()
2220 p->rapl_pkg_perf_status = msr; in get_counters()
2224 return -16; in get_counters()
2225 p->rapl_dram_perf_status = msr; in get_counters()
2229 return -13; in get_counters()
2230 p->energy_pkg = msr; in get_counters()
2234 return -17; in get_counters()
2235 p->pkg_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
2239 p->gfx_rc6_ms = gfx_cur_rc6_ms; in get_counters()
2242 p->gfx_mhz = gfx_cur_mhz; in get_counters()
2245 p->gfx_act_mhz = gfx_act_mhz; in get_counters()
2247 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in get_counters()
2248 if (get_mp(cpu, mp, &p->counter[i])) in get_counters()
2249 return -10; in get_counters()
2252 gettimeofday(&t->tv_end, (struct timezone *)NULL); in get_counters()
2353 fprintf(outf, "cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", in dump_nhm_platform_info()
2356 /* C-state Pre-wake Disable (CSTATE_PREWAKE_DISABLE) */ in dump_nhm_platform_info()
2358 fprintf(outf, "C-state Pre-wake: %sabled\n", msr & 0x40000000 ? "DIS" : "EN"); in dump_nhm_platform_info()
2517 fprintf(outf, "%d * %.1f = %.1f MHz minimum operating frequency\n", ratio, bclk, ratio * bclk); in dump_atom_turbo_ratio_limits()
2563 * [0] -- Reserved in dump_knl_turbo_ratio_limits()
2564 * [7:1] -- Base value of number of active cores of bucket 1. in dump_knl_turbo_ratio_limits()
2565 * [15:8] -- Base value of freq ratio of bucket 1. in dump_knl_turbo_ratio_limits()
2566 * [20:16] -- +ve delta of number of active cores of bucket 2. in dump_knl_turbo_ratio_limits()
2569 * [23:21] -- Negative delta of freq ratio of bucket 2. in dump_knl_turbo_ratio_limits()
2571 * freq ratio of bucket 1 - delta in dump_knl_turbo_ratio_limits()
2572 * [28:24]-- +ve delta of number of active cores of bucket 3. in dump_knl_turbo_ratio_limits()
2573 * [31:29]-- -ve delta of freq ratio of bucket 3. in dump_knl_turbo_ratio_limits()
2574 * [36:32]-- +ve delta of number of active cores of bucket 4. in dump_knl_turbo_ratio_limits()
2575 * [39:37]-- -ve delta of freq ratio of bucket 4. in dump_knl_turbo_ratio_limits()
2576 * [44:40]-- +ve delta of number of active cores of bucket 5. in dump_knl_turbo_ratio_limits()
2577 * [47:45]-- -ve delta of freq ratio of bucket 5. in dump_knl_turbo_ratio_limits()
2578 * [52:48]-- +ve delta of number of active cores of bucket 6. in dump_knl_turbo_ratio_limits()
2579 * [55:53]-- -ve delta of freq ratio of bucket 6. in dump_knl_turbo_ratio_limits()
2580 * [60:56]-- +ve delta of number of active cores of bucket 7. in dump_knl_turbo_ratio_limits()
2581 * [63:61]-- -ve delta of freq ratio of bucket 7. in dump_knl_turbo_ratio_limits()
2593 ratio[b_nr + 1] = ratio[b_nr] - delta_ratio; in dump_knl_turbo_ratio_limits()
2597 for (i = buckets_no - 1; i >= 0; i--) in dump_knl_turbo_ratio_limits()
2598 if (i > 0 ? ratio[i] != ratio[i - 1] : 1) in dump_knl_turbo_ratio_limits()
2612 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)", in dump_nhm_cst_cfg()
2613 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", in dump_nhm_cst_cfg()
2614 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", in dump_nhm_cst_cfg()
2615 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", in dump_nhm_cst_cfg()
2616 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", in dump_nhm_cst_cfg()
2621 …fprintf(outf, ", automatic c-state conversion=%s", (msr & AUTOMATIC_CSTATE_CONVERSION) ? "on" : "o… in dump_nhm_cst_cfg()
2823 cpus[cpu].logical_node_id = -1; in set_node_data()
2832 if (cpus[cpu].logical_node_id != -1) in set_node_data()
2861 int cpu = thiscpu->logical_cpu_id; in get_physical_node_id()
2871 return -1; in get_physical_node_id()
2880 int cpu = thiscpu->logical_cpu_id; in get_thread_siblings()
2885 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); in get_thread_siblings()
2886 if (thiscpu->thread_id < 0) in get_thread_siblings()
2887 thiscpu->thread_id = thread_id++; in get_thread_siblings()
2888 if (!thiscpu->put_ids) in get_thread_siblings()
2889 return -1; in get_thread_siblings()
2892 CPU_ZERO_S(size, thiscpu->put_ids); in get_thread_siblings()
2899 return -1; in get_thread_siblings()
2902 offset -= BITMASK_SIZE; in get_thread_siblings()
2909 if (sib_core == thiscpu->physical_core_id) { in get_thread_siblings()
2910 CPU_SET_S(so, size, thiscpu->put_ids); in get_thread_siblings()
2919 return CPU_COUNT_S(size, thiscpu->put_ids); in get_thread_siblings()
2924 * skip non-present cpus
2945 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus_2()
3001 fprintf(outf, "turbostat: re-initialized with num_cpus %d\n", topo.num_cpus); in re_initialize()
3021 topo.max_cpu_num--; /* 0 based */ in set_max_cpu_num()
3042 cpus[cpu].thread_id = -1; in init_thread_id()
3205 return -1; in snapshot_cpu_lpi_us()
3230 return -1; in snapshot_sys_lpi_us()
3345 /* get_msr_sum() = sum + (get_msr() - last) */ in get_msr_sum()
3362 int cpu = t->cpu_id; in update_msr_sum()
3411 if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) { in msr_sum_record()
3427 if (timer_settime(timerid, 0, &its, NULL) == -1) { in msr_sum_record()
3450 if (errno && (original_priority == -1)) in set_my_sched_priority()
3460 err(-1, "getpriority(%d) != setpriority(%d)", retval, priority); in set_my_sched_priority()
3476 set_my_sched_priority(-20); in turbostat_loop()
3484 if (retval < -1) { in turbostat_loop()
3486 } else if (retval == -1) { in turbostat_loop()
3506 if (retval < -1) { in turbostat_loop()
3508 } else if (retval == -1) { in turbostat_loop()
3529 if (retval < -1) { in turbostat_loop()
3531 } else if (retval == -1) { in turbostat_loop()
3559 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); in check_dev_msr()
3574 err(-6, "cap_get_proc\n"); in check_for_cap_sys_rawio()
3577 err(-6, "cap_get\n"); in check_for_cap_sys_rawio()
3584 if (cap_free(caps) == -1) in check_for_cap_sys_rawio()
3585 err(-6, "cap_free\n"); in check_for_cap_sys_rawio()
3611 exit(-6); in check_permissions()
3648 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in probe_nhm_msrs()
3649 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in probe_nhm_msrs()
3815 /* Nehalem compatible, but do not include turbo-ratio limit support */ in has_turbo_ratio_limit()
3816 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in has_turbo_ratio_limit()
3817 case INTEL_FAM6_XEON_PHI_KNL: /* PHI - Knights Landing (different MSR definition) */ in has_turbo_ratio_limit()
4048 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in dump_sysfs_cstate_config()
4049 sp = strchr(name_buf, '-'); in dump_sysfs_cstate_config()
4131 cpu = t->cpu_id; in print_epb()
4133 /* EPB is per-package */ in print_epb()
4134 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_epb()
4139 return -1; in print_epb()
4177 cpu = t->cpu_id; in print_hwp()
4179 /* MSR_HWP_CAPABILITIES is per-package */ in print_hwp()
4180 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_hwp()
4185 return -1; in print_hwp()
4191 fprintf(outf, "cpu%d: MSR_PM_ENABLE: 0x%08llx (%sHWP)\n", cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
4244 cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x2) ? "" : "No-"); in print_hwp()
4257 cpu = t->cpu_id; in print_perf_limit()
4259 /* per-package */ in print_perf_limit()
4260 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_perf_limit()
4265 return -1; in print_perf_limit()
4280 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4281 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
4294 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4295 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
4308 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4316 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4327 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4333 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4368 * Energy units are either hard-coded, or come from RAPL Energy Unit MSR.
4552 …fprintf(outf, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, td… in rapl_probe_intel()
4583 rapl_time_units = ldexp(1.0, -(msr >> 16 & 0xf)); in rapl_probe_amd()
4584 rapl_energy_units = ldexp(1.0, -(msr >> 8 & 0x1f)); in rapl_probe_amd()
4585 rapl_power_units = ldexp(1.0, -(msr & 0xf)); in rapl_probe_amd()
4591 …fprintf(outf, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, td… in rapl_probe_amd()
4649 cpu = t->cpu_id; in print_thermal()
4651 /* DTS is per-core, no need to print for each thread */ in print_thermal()
4652 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in print_thermal()
4657 return -1; in print_thermal()
4660 if (do_ptm && (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) { in print_thermal()
4665 fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_STATUS: 0x%08llx (%d C)\n", cpu, msr, tj_max - dts); in print_thermal()
4673 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
4684 fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", in print_thermal()
4685 cpu, msr, tj_max - dts, resolution); in print_thermal()
4693 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
4721 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_rapl()
4724 cpu = t->cpu_id; in print_rapl()
4727 return -1; in print_rapl()
4733 return -1; in print_rapl()
4737 return -1; in print_rapl()
4746 return -5; in print_rapl()
4748 fprintf(outf, "cpu%d: MSR_PKG_POWER_INFO: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4759 return -9; in print_rapl()
4775 return -6; in print_rapl()
4777 fprintf(outf, "cpu%d: MSR_DRAM_POWER_INFO,: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4786 return -9; in print_rapl()
4794 return -7; in print_rapl()
4800 return -9; in print_rapl()
4807 return -8; in print_rapl()
4812 return -9; in print_rapl()
4995 if (cpu_migrate(t->cpu_id)) { in get_cpu_type()
4996 fprintf(outf, "Could not migrate to CPU %d\n", t->cpu_id); in get_cpu_type()
4997 return -1; in get_cpu_type()
5006 t->is_atom = true; in get_cpu_type()
5016 * but also allow cmdline over-ride with -T.
5018 * Several MSR temperature values are in units of degrees-C
5032 /* this is a per-package concept */ in set_temperature_target()
5033 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in set_temperature_target()
5036 cpu = t->cpu_id; in set_temperature_target()
5039 return -1; in set_temperature_target()
5061 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in set_temperature_target()
5062 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
5066 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in set_temperature_target()
5067 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
5084 fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n", cpu, tj_max); in set_temperature_target()
5095 base_cpu, msr, msr & FEAT_CTL_LOCKED ? "" : "UN-", msr & (1 << 18) ? "SGX" : ""); in decode_feature_control_msr()
5108 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", in decode_misc_enable_msr()
5109 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", in decode_misc_enable_msr()
5110 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-", in decode_misc_enable_msr()
5111 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", in decode_misc_enable_msr()
5112 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); in decode_misc_enable_msr()
5124 …"cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1-IP… in decode_misc_feature_control()
5125 base_cpu, msr, msr & (0 << 0) ? "No-" : "", msr & (1 << 0) ? "No-" : "", in decode_misc_feature_control()
5126 msr & (2 << 0) ? "No-" : "", msr & (3 << 0) ? "No-" : ""); in decode_misc_feature_control()
5147 …fprintf(outf, "cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)… in decode_misc_pwr_mgmt_msr()
5163 fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", in decode_c6_demotion_policy_msr()
5167 fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", in decode_c6_demotion_policy_msr()
5178 case INTEL_FAM6_NEHALEM_EP: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */ in intel_model_duplicates()
5179 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in intel_model_duplicates()
5180 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ in intel_model_duplicates()
5181 case INTEL_FAM6_WESTMERE: /* Westmere Client - Clarkdale, Arrandale */ in intel_model_duplicates()
5182 case INTEL_FAM6_WESTMERE_EP: /* Westmere EP - Gulftown */ in intel_model_duplicates()
5185 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in intel_model_duplicates()
5186 case INTEL_FAM6_WESTMERE_EX: /* Westmere-EX Xeon - Eagleton */ in intel_model_duplicates()
5193 case INTEL_FAM6_BROADWELL_D: /* BDX-DE */ in intel_model_duplicates()
5249 * Linux-perf manages the the HW instructions-retired counter
5262 err(-1, "calloc fd_instr_count_percpu"); in linux_perf_init()
5317 ecx_flags & (1 << 0) ? "SSE3" : "-", in process_cpuid()
5318 ecx_flags & (1 << 3) ? "MONITOR" : "-", in process_cpuid()
5319 ecx_flags & (1 << 6) ? "SMX" : "-", in process_cpuid()
5320 ecx_flags & (1 << 7) ? "EIST" : "-", in process_cpuid()
5321 ecx_flags & (1 << 8) ? "TM2" : "-", in process_cpuid()
5322 edx_flags & (1 << 4) ? "TSC" : "-", in process_cpuid()
5323 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
5324 edx_flags & (1 << 22) ? "ACPI-TM" : "-", in process_cpuid()
5325 edx_flags & (1 << 28) ? "HT" : "-", edx_flags & (1 << 29) ? "TM" : "-"); in process_cpuid()
5338 * Non-Stop TSC is advertised by CPUID.EAX=0x80000007: EDX.bit8 in process_cpuid()
5374 has_aperf ? "" : "No-", in process_cpuid()
5375 has_turbo ? "" : "No-", in process_cpuid()
5376 do_dts ? "" : "No-", in process_cpuid()
5377 do_ptm ? "" : "No-", in process_cpuid()
5378 has_hwp ? "" : "No-", in process_cpuid()
5379 has_hwp_notify ? "" : "No-", in process_cpuid()
5380 has_hwp_activity_window ? "" : "No-", in process_cpuid()
5381 has_hwp_epp ? "" : "No-", has_hwp_pkg ? "" : "No-", has_epb ? "" : "No-"); in process_cpuid()
5394 fprintf(outf, "CPUID(7): %sSGX\n", has_sgx ? "" : "No-"); in process_cpuid()
5598 if (isdigit(dirp->d_name[0])) in dir_filter()
5757 (*t)[i].cpu_id = -1; in allocate_counters()
5764 (*c)[i].core_id = -1; in allocate_counters()
5793 /* Workaround for systems where physical_node_id==-1 in init_counter()
5794 * and logical_node_id==(-1 - topo.num_cpus) in init_counter()
5803 t->cpu_id = cpu_id; in init_counter()
5805 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE; in init_counter()
5807 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE; in init_counter()
5810 c->core_id = core_id; in init_counter()
5811 p->package_id = pkg_id; in init_counter()
5826 err(-1, "calloc output buffer"); in allocate_output_buffer()
5833 err(-1, "calloc fd_percpu"); in allocate_fd_percpu()
5840 err(-1, "calloc %d", topo.num_cpus); in allocate_irq_buffers()
5844 err(-1, "calloc %d", topo.max_cpu_num + 1); in allocate_irq_buffers()
5862 err(-ENODEV, "No valid cpus found"); in set_base_cpu()
5911 /* clear affinity side-effect of get_counters() */ in fork_it()
5923 if (child_pid == -1) in fork_it()
5928 if (waitpid(child_pid, &status, 0) == -1) in fork_it()
5936 * because re-starting is problematic when forking in fork_it()
5976 fprintf(outf, "turbostat version 21.05.04" " - Len Brown <lenb@kernel.org>\n"); in print_version()
5991 msrp->msr_num = msr_num; in add_counter()
5992 strncpy(msrp->name, name, NAME_BYTES - 1); in add_counter()
5994 strncpy(msrp->path, path, PATH_BYTES - 1); in add_counter()
5995 msrp->width = width; in add_counter()
5996 msrp->type = type; in add_counter()
5997 msrp->format = format; in add_counter()
5998 msrp->flags = flags; in add_counter()
6003 msrp->next = sys.tp; in add_counter()
6008 exit(-1); in add_counter()
6013 msrp->next = sys.cp; in add_counter()
6018 exit(-1); in add_counter()
6023 msrp->next = sys.pp; in add_counter()
6028 exit(-1); in add_counter()
6120 fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter ) required\n"); in parse_add_command()
6162 for (state = 10; state >= 0; --state) { in probe_sysfs()
6171 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
6172 sp = strchr(name_buf, '-'); in probe_sysfs()
6190 for (state = 10; state >= 0; --state) { in probe_sysfs()
6198 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
6199 sp = strchr(name_buf, '-'); in probe_sysfs()
6219 * 1,2,4..6,8-10 and set bits in cpu_subset
6252 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_command()
6269 if (*next == '-') { in parse_cpu_command()
6270 next += 1; /* start range */ in parse_cpu_command()
6274 next += 1; /* start range */ in parse_cpu_command()
6298 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
6300 exit(-1); in parse_cpu_command()
6317 { "hide", required_argument, 0, 'H' }, // meh, -h taken by --help in cmdline()
6331 …opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qST:v", long_options, &option_index)) != -1) { in cmdline()
6343 /* --enable specified counter */ in cmdline()
6352 * --hide: do not show those specified in cmdline()
6371 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000; in cmdline()
6372 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; in cmdline()
6399 * --show: show only those specified in cmdline()
6450 if (argc - optind) in main()