Lines Matching +full:ecx +full:- +full:1000
1 // SPDX-License-Identifier: GPL-2.0-only
3 * turbostat -- show CPU frequency and C-state residency
135 /* Indicates cores energy collection is per-core,
136 * not per-package. */
144 /* MSRs that are not yet in the kernel-provided header. */
153 * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters
191 unsigned long long mc6_us; /* duplicate as per-core for now, even though per module */
282 /* get_msr_sum() = sum + (get_msr() - last) */
321 offset = -1; in idx_to_offset()
351 idx = -1; in offset_to_idx()
395 int logical_node_id; /* 0-based count within the package */
430 * skip non-present cpus
451 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus()
472 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) in cpu_migrate()
473 return -1; in cpu_migrate()
490 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root", pathname); in get_msr_fd()
504 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
511 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
513 * matching on them for --show and --hide.
641 * HIDE_LIST - hide this list of counters, show the rest [default]
642 * SHOW_LIST - show this list of counters, hide the rest
649 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" in help()
653 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" in help()
655 " -a, --add add a counter\n" in help()
656 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" in help()
657 " -c, --cpu cpu-set limit output to summary plus cpu-set:\n" in help()
658 " {core | package | j,k,l..m,n-p }\n" in help()
659 " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n" in help()
660 " -D, --Dump displays the raw counter values\n" in help()
661 " -e, --enable [all | column]\n" in help()
663 " -H, --hide [column|column,column,...]\n" in help()
665 " -i, --interval sec.subsec\n" in help()
666 " Override default 5-second measurement interval\n" in help()
667 " -J, --Joules displays energy in Joules instead of Watts\n" in help()
668 " -l, --list list column headers only\n" in help()
669 " -n, --num_iterations num\n" in help()
671 " -o, --out file\n" in help()
673 " -q, --quiet skip decoding system configuration header\n" in help()
674 " -s, --show [column|column,column,...]\n" in help()
676 " -S, --Summary\n" in help()
677 " limits output to 1-line system summary per interval\n" in help()
678 " -T, --TCC temperature\n" in help()
681 " -h, --help print this help message\n" in help()
682 " -v, --version print version information\n" in help()
717 exit(-1); in bic_lookup()
723 fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", in bic_lookup()
781 for (mp = sys.tp; mp; mp = mp->next) { in print_header()
783 if (mp->format == FORMAT_RAW) { in print_header()
784 if (mp->width == 64) in print_header()
785 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name); in print_header()
787 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name); in print_header()
789 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
790 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name); in print_header()
792 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name); in print_header()
819 for (mp = sys.cp; mp; mp = mp->next) { in print_header()
820 if (mp->format == FORMAT_RAW) { in print_header()
821 if (mp->width == 64) in print_header()
822 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
824 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
826 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
827 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
829 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
900 for (mp = sys.pp; mp; mp = mp->next) { in print_header()
901 if (mp->format == FORMAT_RAW) { in print_header()
902 if (mp->width == 64) in print_header()
903 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
905 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
907 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
908 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
910 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
927 t->cpu_id, t->flags); in dump_counters()
928 outp += sprintf(outp, "TSC: %016llX\n", t->tsc); in dump_counters()
929 outp += sprintf(outp, "aperf: %016llX\n", t->aperf); in dump_counters()
930 outp += sprintf(outp, "mperf: %016llX\n", t->mperf); in dump_counters()
931 outp += sprintf(outp, "c1: %016llX\n", t->c1); in dump_counters()
934 outp += sprintf(outp, "IRQ: %lld\n", t->irq_count); in dump_counters()
936 outp += sprintf(outp, "SMI: %d\n", t->smi_count); in dump_counters()
938 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in dump_counters()
940 i, mp->msr_num, t->counter[i]); in dump_counters()
945 outp += sprintf(outp, "core: %d\n", c->core_id); in dump_counters()
946 outp += sprintf(outp, "c3: %016llX\n", c->c3); in dump_counters()
947 outp += sprintf(outp, "c6: %016llX\n", c->c6); in dump_counters()
948 outp += sprintf(outp, "c7: %016llX\n", c->c7); in dump_counters()
949 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); in dump_counters()
950 outp += sprintf(outp, "Joules: %0X\n", c->core_energy); in dump_counters()
952 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in dump_counters()
954 i, mp->msr_num, c->counter[i]); in dump_counters()
956 outp += sprintf(outp, "mc6_us: %016llX\n", c->mc6_us); in dump_counters()
960 outp += sprintf(outp, "package: %d\n", p->package_id); in dump_counters()
962 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); in dump_counters()
963 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); in dump_counters()
964 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); in dump_counters()
965 outp += sprintf(outp, "CPU + GFX: %016llX\n", p->pkg_both_core_gfxe_c0); in dump_counters()
967 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); in dump_counters()
969 outp += sprintf(outp, "pc3: %016llX\n", p->pc3); in dump_counters()
971 outp += sprintf(outp, "pc6: %016llX\n", p->pc6); in dump_counters()
973 outp += sprintf(outp, "pc7: %016llX\n", p->pc7); in dump_counters()
974 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); in dump_counters()
975 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); in dump_counters()
976 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); in dump_counters()
977 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi); in dump_counters()
978 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi); in dump_counters()
979 outp += sprintf(outp, "Joules PKG: %0llX\n", p->energy_pkg); in dump_counters()
980 outp += sprintf(outp, "Joules COR: %0llX\n", p->energy_cores); in dump_counters()
981 outp += sprintf(outp, "Joules GFX: %0llX\n", p->energy_gfx); in dump_counters()
982 outp += sprintf(outp, "Joules RAM: %0llX\n", p->energy_dram); in dump_counters()
984 p->rapl_pkg_perf_status); in dump_counters()
986 p->rapl_dram_perf_status); in dump_counters()
987 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c); in dump_counters()
989 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in dump_counters()
991 i, mp->msr_num, p->counter[i]); in dump_counters()
1014 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1018 if (show_pkg_only && !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1021 /*if not summary line and --cpu is used */ in format_counters()
1023 (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) in format_counters()
1030 timersub(&t->tv_end, &t->tv_begin, &tv); in format_counters()
1036 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec); in format_counters()
1038 interval_float = t->tv_delta.tv_sec + t->tv_delta.tv_usec/1000000.0; in format_counters()
1040 tsc = t->tsc * tsc_tweak; in format_counters()
1045 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1047 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1049 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1051 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1053 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1055 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1057 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1061 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); in format_counters()
1063 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1067 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].die_id); in format_counters()
1069 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1075 cpus[t->cpu_id].physical_node_id); in format_counters()
1077 outp += sprintf(outp, "%s-", in format_counters()
1082 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); in format_counters()
1084 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
1087 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); in format_counters()
1089 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id); in format_counters()
1091 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id); in format_counters()
1096 1.0 / units * t->aperf / interval_float); in format_counters()
1099 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->mperf/tsc); in format_counters()
1103 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), base_hz / units * t->aperf / t->mperf); in format_counters()
1106 tsc / units * t->aperf / t->mperf / interval_float); in format_counters()
1110 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 * t->tsc/units/interval_float); in format_counters()
1115 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1117 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
1122 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->smi_count); in format_counters()
1125 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in format_counters()
1126 if (mp->format == FORMAT_RAW) { in format_counters()
1127 if (mp->width == 32) in format_counters()
1128 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) t->counter[i]); in format_counters()
1130 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1131 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1132 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1133 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1135 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
1136 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1137 if (mp->type == COUNTER_USEC) in format_counters()
1138 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), t->counter[i]/interval_float/10000); in format_counters()
1140 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->counter[i]/tsc); in format_counters()
1146 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->c1/tsc); in format_counters()
1149 /* print per-core data only for 1st thread in core */ in format_counters()
1150 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in format_counters()
1154 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3/tsc); in format_counters()
1156 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6/tsc); in format_counters()
1158 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c7/tsc); in format_counters()
1162 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->mc6_us / tsc); in format_counters()
1165 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); in format_counters()
1167 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in format_counters()
1168 if (mp->format == FORMAT_RAW) { in format_counters()
1169 if (mp->width == 32) in format_counters()
1170 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) c->counter[i]); in format_counters()
1172 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1173 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1174 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1175 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1177 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
1178 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1179 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->counter[i]/tsc); in format_counters()
1186 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units / interva… in format_counters()
1188 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), c->core_energy * rapl_energy_units); in format_counters()
1190 /* print per-package data only for 1st core in package */ in format_counters()
1191 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in format_counters()
1196 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->pkg_temp_c); in format_counters()
1200 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
1204 p->gfx_rc6_ms / 10.0 / interval_float); in format_counters()
1210 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz); in format_counters()
1214 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_act_mhz); in format_counters()
1218 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0/tsc); in format_counters()
1220 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0/tsc); in format_counters()
1222 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0/tsc); in format_counters()
1224 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0/tsc); in format_counters()
1227 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2/tsc); in format_counters()
1229 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc3/tsc); in format_counters()
1231 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc6/tsc); in format_counters()
1233 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc7/tsc); in format_counters()
1235 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc8/tsc); in format_counters()
1237 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc9/tsc); in format_counters()
1239 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10/tsc); in format_counters()
1242 …outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->cpu_lpi / 1000000.0 / interva… in format_counters()
1244 …outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->sys_lpi / 1000000.0 / interva… in format_counters()
1247 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units / interval… in format_counters()
1249 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units / interv… in format_counters()
1251 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units / interval… in format_counters()
1253 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units / in… in format_counters()
1255 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_pkg * rapl_energy_units); in format_counters()
1257 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_cores * rapl_energy_units); in format_counters()
1259 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_gfx * rapl_energy_units); in format_counters()
1261 outp += sprintf(outp, fmt8, (printed++ ? delim : ""), p->energy_dram * rapl_dram_energy_units); in format_counters()
1263 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), 100.0 * p->rapl_pkg_perf_status * rapl_time_… in format_counters()
1265 …outp += sprintf(outp, fmt8, (printed++ ? delim : ""), 100.0 * p->rapl_dram_perf_status * rapl_time… in format_counters()
1267 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in format_counters()
1268 if (mp->format == FORMAT_RAW) { in format_counters()
1269 if (mp->width == 32) in format_counters()
1270 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) p->counter[i]); in format_counters()
1272 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1273 } else if (mp->format == FORMAT_DELTA) { in format_counters()
1274 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
1275 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1277 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
1278 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
1279 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->counter[i]/tsc); in format_counters()
1284 if (*(outp - 1) != '\n') in format_counters()
1328 old = ((((unsigned long long)new << 32) - ((unsigned long long)old << 32)) >> 32);
1338 old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0; in delta_package()
1340 old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0; in delta_package()
1342 old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0; in delta_package()
1344 old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0; in delta_package()
1346 old->pc2 = new->pc2 - old->pc2; in delta_package()
1348 old->pc3 = new->pc3 - old->pc3; in delta_package()
1350 old->pc6 = new->pc6 - old->pc6; in delta_package()
1352 old->pc7 = new->pc7 - old->pc7; in delta_package()
1353 old->pc8 = new->pc8 - old->pc8; in delta_package()
1354 old->pc9 = new->pc9 - old->pc9; in delta_package()
1355 old->pc10 = new->pc10 - old->pc10; in delta_package()
1356 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi; in delta_package()
1357 old->sys_lpi = new->sys_lpi - old->sys_lpi; in delta_package()
1358 old->pkg_temp_c = new->pkg_temp_c; in delta_package()
1361 if (old->gfx_rc6_ms > new->gfx_rc6_ms) in delta_package()
1362 old->gfx_rc6_ms = -1; in delta_package()
1364 old->gfx_rc6_ms = new->gfx_rc6_ms - old->gfx_rc6_ms; in delta_package()
1366 old->gfx_mhz = new->gfx_mhz; in delta_package()
1367 old->gfx_act_mhz = new->gfx_act_mhz; in delta_package()
1369 old->energy_pkg = new->energy_pkg - old->energy_pkg; in delta_package()
1370 old->energy_cores = new->energy_cores - old->energy_cores; in delta_package()
1371 old->energy_gfx = new->energy_gfx - old->energy_gfx; in delta_package()
1372 old->energy_dram = new->energy_dram - old->energy_dram; in delta_package()
1373 old->rapl_pkg_perf_status = new->rapl_pkg_perf_status - old->rapl_pkg_perf_status; in delta_package()
1374 old->rapl_dram_perf_status = new->rapl_dram_perf_status - old->rapl_dram_perf_status; in delta_package()
1376 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in delta_package()
1377 if (mp->format == FORMAT_RAW) in delta_package()
1378 old->counter[i] = new->counter[i]; in delta_package()
1380 old->counter[i] = new->counter[i] - old->counter[i]; in delta_package()
1392 old->c3 = new->c3 - old->c3; in delta_core()
1393 old->c6 = new->c6 - old->c6; in delta_core()
1394 old->c7 = new->c7 - old->c7; in delta_core()
1395 old->core_temp_c = new->core_temp_c; in delta_core()
1396 old->mc6_us = new->mc6_us - old->mc6_us; in delta_core()
1398 DELTA_WRAP32(new->core_energy, old->core_energy); in delta_core()
1400 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in delta_core()
1401 if (mp->format == FORMAT_RAW) in delta_core()
1402 old->counter[i] = new->counter[i]; in delta_core()
1404 old->counter[i] = new->counter[i] - old->counter[i]; in delta_core()
1417 * old = new - old
1428 new->apic_id = old->apic_id; in delta_thread()
1430 new->x2apic_id = old->x2apic_id; in delta_thread()
1435 * over-write old w/ new so we can print end of interval values in delta_thread()
1438 timersub(&new->tv_begin, &old->tv_begin, &old->tv_delta); in delta_thread()
1439 old->tv_begin = new->tv_begin; in delta_thread()
1440 old->tv_end = new->tv_end; in delta_thread()
1442 old->tsc = new->tsc - old->tsc; in delta_thread()
1445 if (old->tsc < (1000 * 1000)) in delta_thread()
1446 errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n" in delta_thread()
1447 "You can disable all c-states by booting with \"idle=poll\"\n" in delta_thread()
1450 old->c1 = new->c1 - old->c1; in delta_thread()
1454 if ((new->aperf > old->aperf) && (new->mperf > old->mperf)) { in delta_thread()
1455 old->aperf = new->aperf - old->aperf; in delta_thread()
1456 old->mperf = new->mperf - old->mperf; in delta_thread()
1458 return -1; in delta_thread()
1471 * it is possible for mperf's non-halted cycles + idle states in delta_thread()
1474 if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) in delta_thread()
1475 old->c1 = 0; in delta_thread()
1478 old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 in delta_thread()
1479 - core_delta->c6 - core_delta->c7; in delta_thread()
1483 if (old->mperf == 0) { in delta_thread()
1485 fprintf(outf, "cpu%d MPERF 0!\n", old->cpu_id); in delta_thread()
1486 old->mperf = 1; /* divide by 0 protection */ in delta_thread()
1490 old->irq_count = new->irq_count - old->irq_count; in delta_thread()
1493 old->smi_count = new->smi_count - old->smi_count; in delta_thread()
1495 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in delta_thread()
1496 if (mp->format == FORMAT_RAW) in delta_thread()
1497 old->counter[i] = new->counter[i]; in delta_thread()
1499 old->counter[i] = new->counter[i] - old->counter[i]; in delta_thread()
1511 if (t->flags & CPU_IS_FIRST_THREAD_IN_CORE) in delta_cpu()
1520 if (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE) in delta_cpu()
1531 t->tv_begin.tv_sec = 0; in clear_counters()
1532 t->tv_begin.tv_usec = 0; in clear_counters()
1533 t->tv_end.tv_sec = 0; in clear_counters()
1534 t->tv_end.tv_usec = 0; in clear_counters()
1535 t->tv_delta.tv_sec = 0; in clear_counters()
1536 t->tv_delta.tv_usec = 0; in clear_counters()
1538 t->tsc = 0; in clear_counters()
1539 t->aperf = 0; in clear_counters()
1540 t->mperf = 0; in clear_counters()
1541 t->c1 = 0; in clear_counters()
1543 t->irq_count = 0; in clear_counters()
1544 t->smi_count = 0; in clear_counters()
1547 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE; in clear_counters()
1549 c->c3 = 0; in clear_counters()
1550 c->c6 = 0; in clear_counters()
1551 c->c7 = 0; in clear_counters()
1552 c->mc6_us = 0; in clear_counters()
1553 c->core_temp_c = 0; in clear_counters()
1554 c->core_energy = 0; in clear_counters()
1556 p->pkg_wtd_core_c0 = 0; in clear_counters()
1557 p->pkg_any_core_c0 = 0; in clear_counters()
1558 p->pkg_any_gfxe_c0 = 0; in clear_counters()
1559 p->pkg_both_core_gfxe_c0 = 0; in clear_counters()
1561 p->pc2 = 0; in clear_counters()
1563 p->pc3 = 0; in clear_counters()
1565 p->pc6 = 0; in clear_counters()
1567 p->pc7 = 0; in clear_counters()
1568 p->pc8 = 0; in clear_counters()
1569 p->pc9 = 0; in clear_counters()
1570 p->pc10 = 0; in clear_counters()
1571 p->cpu_lpi = 0; in clear_counters()
1572 p->sys_lpi = 0; in clear_counters()
1574 p->energy_pkg = 0; in clear_counters()
1575 p->energy_dram = 0; in clear_counters()
1576 p->energy_cores = 0; in clear_counters()
1577 p->energy_gfx = 0; in clear_counters()
1578 p->rapl_pkg_perf_status = 0; in clear_counters()
1579 p->rapl_dram_perf_status = 0; in clear_counters()
1580 p->pkg_temp_c = 0; in clear_counters()
1582 p->gfx_rc6_ms = 0; in clear_counters()
1583 p->gfx_mhz = 0; in clear_counters()
1584 p->gfx_act_mhz = 0; in clear_counters()
1585 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) in clear_counters()
1586 t->counter[i] = 0; in clear_counters()
1588 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) in clear_counters()
1589 c->counter[i] = 0; in clear_counters()
1591 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) in clear_counters()
1592 p->counter[i] = 0; in clear_counters()
1600 /* copy un-changing apic_id's */ in sum_counters()
1602 average.threads.apic_id = t->apic_id; in sum_counters()
1604 average.threads.x2apic_id = t->x2apic_id; in sum_counters()
1608 average.threads.tv_begin = t->tv_begin; in sum_counters()
1611 average.threads.tv_end = t->tv_end; in sum_counters()
1613 average.threads.tsc += t->tsc; in sum_counters()
1614 average.threads.aperf += t->aperf; in sum_counters()
1615 average.threads.mperf += t->mperf; in sum_counters()
1616 average.threads.c1 += t->c1; in sum_counters()
1618 average.threads.irq_count += t->irq_count; in sum_counters()
1619 average.threads.smi_count += t->smi_count; in sum_counters()
1621 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in sum_counters()
1622 if (mp->format == FORMAT_RAW) in sum_counters()
1624 average.threads.counter[i] += t->counter[i]; in sum_counters()
1627 /* sum per-core values only for 1st thread in core */ in sum_counters()
1628 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in sum_counters()
1631 average.cores.c3 += c->c3; in sum_counters()
1632 average.cores.c6 += c->c6; in sum_counters()
1633 average.cores.c7 += c->c7; in sum_counters()
1634 average.cores.mc6_us += c->mc6_us; in sum_counters()
1636 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); in sum_counters()
1638 average.cores.core_energy += c->core_energy; in sum_counters()
1640 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in sum_counters()
1641 if (mp->format == FORMAT_RAW) in sum_counters()
1643 average.cores.counter[i] += c->counter[i]; in sum_counters()
1646 /* sum per-pkg values only for 1st core in pkg */ in sum_counters()
1647 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in sum_counters()
1651 average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0; in sum_counters()
1653 average.packages.pkg_any_core_c0 += p->pkg_any_core_c0; in sum_counters()
1655 average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0; in sum_counters()
1657 average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0; in sum_counters()
1659 average.packages.pc2 += p->pc2; in sum_counters()
1661 average.packages.pc3 += p->pc3; in sum_counters()
1663 average.packages.pc6 += p->pc6; in sum_counters()
1665 average.packages.pc7 += p->pc7; in sum_counters()
1666 average.packages.pc8 += p->pc8; in sum_counters()
1667 average.packages.pc9 += p->pc9; in sum_counters()
1668 average.packages.pc10 += p->pc10; in sum_counters()
1670 average.packages.cpu_lpi = p->cpu_lpi; in sum_counters()
1671 average.packages.sys_lpi = p->sys_lpi; in sum_counters()
1673 average.packages.energy_pkg += p->energy_pkg; in sum_counters()
1674 average.packages.energy_dram += p->energy_dram; in sum_counters()
1675 average.packages.energy_cores += p->energy_cores; in sum_counters()
1676 average.packages.energy_gfx += p->energy_gfx; in sum_counters()
1678 average.packages.gfx_rc6_ms = p->gfx_rc6_ms; in sum_counters()
1679 average.packages.gfx_mhz = p->gfx_mhz; in sum_counters()
1680 average.packages.gfx_act_mhz = p->gfx_act_mhz; in sum_counters()
1682 average.packages.pkg_temp_c = MAX(average.packages.pkg_temp_c, p->pkg_temp_c); in sum_counters()
1684 average.packages.rapl_pkg_perf_status += p->rapl_pkg_perf_status; in sum_counters()
1685 average.packages.rapl_dram_perf_status += p->rapl_dram_perf_status; in sum_counters()
1687 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in sum_counters()
1688 if (mp->format == FORMAT_RAW) in sum_counters()
1690 average.packages.counter[i] += p->counter[i]; in sum_counters()
1745 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in compute_average()
1746 if (mp->format == FORMAT_RAW) in compute_average()
1748 if (mp->type == COUNTER_ITEMS) { in compute_average()
1755 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in compute_average()
1756 if (mp->format == FORMAT_RAW) in compute_average()
1758 if (mp->type == COUNTER_ITEMS) { in compute_average()
1764 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in compute_average()
1765 if (mp->format == FORMAT_RAW) in compute_average()
1767 if (mp->type == COUNTER_ITEMS) { in compute_average()
1819 if (mp->msr_num != 0) { in get_mp()
1820 if (get_msr(cpu, mp->msr_num, counterp)) in get_mp()
1821 return -1; in get_mp()
1825 if (mp->flags & SYSFS_PERCPU) { in get_mp()
1827 cpu, mp->path); in get_mp()
1831 *counterp = snapshot_sysfs_counter(mp->path); in get_mp()
1840 unsigned int eax, ebx, ecx, edx; in get_apic_id() local
1843 eax = ebx = ecx = edx = 0; in get_apic_id()
1844 __cpuid(1, eax, ebx, ecx, edx); in get_apic_id()
1846 t->apic_id = (ebx >> 24) & 0xff; in get_apic_id()
1858 eax = ebx = ecx = edx = 0; in get_apic_id()
1859 __cpuid(0x80000001, eax, ebx, ecx, edx); in get_apic_id()
1860 topology_extensions = ecx & (1 << 22); in get_apic_id()
1865 eax = ebx = ecx = edx = 0; in get_apic_id()
1866 __cpuid(0x8000001e, eax, ebx, ecx, edx); in get_apic_id()
1868 t->x2apic_id = eax; in get_apic_id()
1878 ecx = 0; in get_apic_id()
1879 __cpuid(0xb, eax, ebx, ecx, edx); in get_apic_id()
1880 t->x2apic_id = edx; in get_apic_id()
1882 if (debug && (t->apic_id != (t->x2apic_id & 0xff))) in get_apic_id()
1884 t->cpu_id, t->apic_id, t->x2apic_id); in get_apic_id()
1894 int cpu = t->cpu_id; in get_counters()
1902 return -1; in get_counters()
1905 gettimeofday(&t->tv_begin, (struct timezone *)NULL); in get_counters()
1910 t->tsc = rdtsc(); /* we are running on local CPU of interest */ in get_counters()
1923 * varies by a large amount, we re-read them. in get_counters()
1931 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
1932 return -3; in get_counters()
1934 t->tsc = rdtsc(); /* re-read close to APERF */ in get_counters()
1936 tsc_before = t->tsc; in get_counters()
1938 if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) in get_counters()
1939 return -3; in get_counters()
1943 if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) in get_counters()
1944 return -4; in get_counters()
1948 aperf_time = tsc_between - tsc_before; in get_counters()
1949 mperf_time = tsc_after - tsc_between; in get_counters()
1965 t->aperf = t->aperf * aperf_mperf_multiplier; in get_counters()
1966 t->mperf = t->mperf * aperf_mperf_multiplier; in get_counters()
1970 t->irq_count = irqs_per_cpu[cpu]; in get_counters()
1973 return -5; in get_counters()
1974 t->smi_count = msr & 0xFFFFFFFF; in get_counters()
1977 if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) in get_counters()
1978 return -6; in get_counters()
1981 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in get_counters()
1982 if (get_mp(cpu, mp, &t->counter[i])) in get_counters()
1983 return -10; in get_counters()
1987 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in get_counters()
1991 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) in get_counters()
1992 return -6; in get_counters()
1996 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
1997 return -7; in get_counters()
1999 if (get_msr(cpu, MSR_KNL_CORE_C6_RESIDENCY, &c->c6)) in get_counters()
2000 return -7; in get_counters()
2004 if (get_msr(cpu, MSR_CORE_C7_RESIDENCY, &c->c7)) in get_counters()
2005 return -8; in get_counters()
2008 if (get_msr(cpu, MSR_MODULE_C6_RES_MS, &c->mc6_us)) in get_counters()
2009 return -8; in get_counters()
2013 return -9; in get_counters()
2014 c->core_temp_c = tcc_activation_temp - ((msr >> 16) & 0x7F); in get_counters()
2019 return -14; in get_counters()
2020 c->core_energy = msr & 0xFFFFFFFF; in get_counters()
2023 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in get_counters()
2024 if (get_mp(cpu, mp, &c->counter[i])) in get_counters()
2025 return -10; in get_counters()
2029 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in get_counters()
2033 if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) in get_counters()
2034 return -10; in get_counters()
2037 if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0)) in get_counters()
2038 return -11; in get_counters()
2041 if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0)) in get_counters()
2042 return -12; in get_counters()
2045 if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0)) in get_counters()
2046 return -13; in get_counters()
2049 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) in get_counters()
2050 return -9; in get_counters()
2053 if (get_msr(cpu, MSR_ATOM_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2054 return -10; in get_counters()
2056 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) in get_counters()
2057 return -10; in get_counters()
2062 if (get_msr(cpu, MSR_PKG_C2_RESIDENCY, &p->pc2)) in get_counters()
2063 return -11; in get_counters()
2065 if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) in get_counters()
2066 return -12; in get_counters()
2068 if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) in get_counters()
2069 return -13; in get_counters()
2071 if (get_msr(cpu, MSR_PKG_C9_RESIDENCY, &p->pc9)) in get_counters()
2072 return -13; in get_counters()
2074 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) in get_counters()
2075 return -13; in get_counters()
2078 p->cpu_lpi = cpuidle_cur_cpu_lpi_us; in get_counters()
2080 p->sys_lpi = cpuidle_cur_sys_lpi_us; in get_counters()
2084 return -13; in get_counters()
2085 p->energy_pkg = msr; in get_counters()
2089 return -14; in get_counters()
2090 p->energy_cores = msr; in get_counters()
2094 return -15; in get_counters()
2095 p->energy_dram = msr; in get_counters()
2099 return -16; in get_counters()
2100 p->energy_gfx = msr; in get_counters()
2104 return -16; in get_counters()
2105 p->rapl_pkg_perf_status = msr; in get_counters()
2109 return -16; in get_counters()
2110 p->rapl_dram_perf_status = msr; in get_counters()
2114 return -13; in get_counters()
2115 p->energy_pkg = msr; in get_counters()
2119 return -17; in get_counters()
2120 p->pkg_temp_c = tcc_activation_temp - ((msr >> 16) & 0x7F); in get_counters()
2124 p->gfx_rc6_ms = gfx_cur_rc6_ms; in get_counters()
2127 p->gfx_mhz = gfx_cur_mhz; in get_counters()
2130 p->gfx_act_mhz = gfx_act_mhz; in get_counters()
2132 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in get_counters()
2133 if (get_mp(cpu, mp, &p->counter[i])) in get_counters()
2134 return -10; in get_counters()
2137 gettimeofday(&t->tv_end, (struct timezone *)NULL); in get_counters()
2204 fprintf(outf, "cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", in dump_nhm_platform_info()
2431 * [0] -- Reserved in dump_knl_turbo_ratio_limits()
2432 * [7:1] -- Base value of number of active cores of bucket 1. in dump_knl_turbo_ratio_limits()
2433 * [15:8] -- Base value of freq ratio of bucket 1. in dump_knl_turbo_ratio_limits()
2434 * [20:16] -- +ve delta of number of active cores of bucket 2. in dump_knl_turbo_ratio_limits()
2437 * [23:21] -- Negative delta of freq ratio of bucket 2. in dump_knl_turbo_ratio_limits()
2439 * freq ratio of bucket 1 - delta in dump_knl_turbo_ratio_limits()
2440 * [28:24]-- +ve delta of number of active cores of bucket 3. in dump_knl_turbo_ratio_limits()
2441 * [31:29]-- -ve delta of freq ratio of bucket 3. in dump_knl_turbo_ratio_limits()
2442 * [36:32]-- +ve delta of number of active cores of bucket 4. in dump_knl_turbo_ratio_limits()
2443 * [39:37]-- -ve delta of freq ratio of bucket 4. in dump_knl_turbo_ratio_limits()
2444 * [44:40]-- +ve delta of number of active cores of bucket 5. in dump_knl_turbo_ratio_limits()
2445 * [47:45]-- -ve delta of freq ratio of bucket 5. in dump_knl_turbo_ratio_limits()
2446 * [52:48]-- +ve delta of number of active cores of bucket 6. in dump_knl_turbo_ratio_limits()
2447 * [55:53]-- -ve delta of freq ratio of bucket 6. in dump_knl_turbo_ratio_limits()
2448 * [60:56]-- +ve delta of number of active cores of bucket 7. in dump_knl_turbo_ratio_limits()
2449 * [63:61]-- -ve delta of freq ratio of bucket 7. in dump_knl_turbo_ratio_limits()
2461 ratio[b_nr + 1] = ratio[b_nr] - delta_ratio; in dump_knl_turbo_ratio_limits()
2465 for (i = buckets_no - 1; i >= 0; i--) in dump_knl_turbo_ratio_limits()
2466 if (i > 0 ? ratio[i] != ratio[i - 1] : 1) in dump_knl_turbo_ratio_limits()
2481 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)", in dump_nhm_cst_cfg()
2482 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", in dump_nhm_cst_cfg()
2483 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", in dump_nhm_cst_cfg()
2484 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", in dump_nhm_cst_cfg()
2485 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", in dump_nhm_cst_cfg()
2492 fprintf(outf, ", automatic c-state conversion=%s", in dump_nhm_cst_cfg()
2696 cpus[cpu].logical_node_id = -1; in set_node_data()
2705 if (cpus[cpu].logical_node_id != -1) in set_node_data()
2735 int cpu = thiscpu->logical_cpu_id; in get_physical_node_id()
2746 return -1; in get_physical_node_id()
2755 int cpu = thiscpu->logical_cpu_id; in get_thread_siblings()
2760 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); in get_thread_siblings()
2761 if (thiscpu->thread_id < 0) in get_thread_siblings()
2762 thiscpu->thread_id = thread_id++; in get_thread_siblings()
2763 if (!thiscpu->put_ids) in get_thread_siblings()
2764 return -1; in get_thread_siblings()
2767 CPU_ZERO_S(size, thiscpu->put_ids); in get_thread_siblings()
2775 return -1; in get_thread_siblings()
2778 offset -= BITMASK_SIZE; in get_thread_siblings()
2785 if (sib_core == thiscpu->physical_core_id) { in get_thread_siblings()
2786 CPU_SET_S(so, size, thiscpu->put_ids); in get_thread_siblings()
2797 return CPU_COUNT_S(size, thiscpu->put_ids); in get_thread_siblings()
2802 * skip non-present cpus
2828 if (cpu_is_not_present(t->cpu_id)) in for_all_cpus_2()
2889 fprintf(outf, "turbostat: re-initialized with num_cpus %d\n", topo.num_cpus); in re_initialize()
2911 topo.max_cpu_num--; /* 0 based */ in set_max_cpu_num()
2931 cpus[cpu].thread_id = -1; in init_thread_id()
3093 return -1; in snapshot_cpu_lpi_us()
3117 return -1; in snapshot_sys_lpi_us()
3214 rest.tv_nsec = (tout.tv_usec % 1000000) * 1000; in do_sleep()
3231 /* get_msr_sum() = sum + (get_msr() - last) */ in get_msr_sum()
3248 int cpu = t->cpu_id; in update_msr_sum()
3299 if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) { in msr_sum_record()
3315 if (timer_settime(timerid, 0, &its, NULL) == -1) { in msr_sum_record()
3341 if (retval < -1) { in turbostat_loop()
3343 } else if (retval == -1) { in turbostat_loop()
3363 if (retval < -1) { in turbostat_loop()
3365 } else if (retval == -1) { in turbostat_loop()
3386 if (retval < -1) { in turbostat_loop()
3388 } else if (retval == -1) { in turbostat_loop()
3416 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); in check_dev_msr()
3431 err(-6, "cap_get_proc\n"); in check_for_cap_sys_rawio()
3434 err(-6, "cap_get\n"); in check_for_cap_sys_rawio()
3442 if (cap_free(caps) == -1) in check_for_cap_sys_rawio()
3443 err(-6, "cap_free\n"); in check_for_cap_sys_rawio()
3468 exit(-6); in check_permissions()
3505 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in probe_nhm_msrs()
3506 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in probe_nhm_msrs()
3649 /* Nehalem compatible, but do not include turbo-ratio limit support */ in has_turbo_ratio_limit()
3650 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in has_turbo_ratio_limit()
3651 case INTEL_FAM6_XEON_PHI_KNL: /* PHI - Knights Landing (different MSR definition) */ in has_turbo_ratio_limit()
3844 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in dump_sysfs_cstate_config()
3845 sp = strchr(name_buf, '-'); in dump_sysfs_cstate_config()
3932 cpu = t->cpu_id; in print_epb()
3934 /* EPB is per-package */ in print_epb()
3935 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_epb()
3940 return -1; in print_epb()
3976 cpu = t->cpu_id; in print_hwp()
3978 /* MSR_HWP_CAPABILITIES is per-package */ in print_hwp()
3979 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_hwp()
3984 return -1; in print_hwp()
3991 cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
4050 ((msr) & 0x1) ? "" : "No-", in print_hwp()
4051 ((msr) & 0x2) ? "" : "No-"); in print_hwp()
4064 cpu = t->cpu_id; in print_perf_limit()
4066 /* per-package */ in print_perf_limit()
4067 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_perf_limit()
4072 return -1; in print_perf_limit()
4087 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4088 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
4102 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4103 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
4117 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4126 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4138 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
4145 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
4181 * Energy units are either hard-coded, or come from RAPL Energy Unit MSR.
4360 unsigned int eax, ebx, ecx, edx; in rapl_probe_amd() local
4365 __cpuid(0x80000007, eax, ebx, ecx, edx); in rapl_probe_amd()
4385 rapl_time_units = ldexp(1.0, -(msr >> 16 & 0xf)); in rapl_probe_amd()
4386 rapl_energy_units = ldexp(1.0, -(msr >> 8 & 0x1f)); in rapl_probe_amd()
4387 rapl_power_units = ldexp(1.0, -(msr & 0xf)); in rapl_probe_amd()
4445 cpu = t->cpu_id; in print_thermal()
4447 /* DTS is per-core, no need to print for each thread */ in print_thermal()
4448 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) in print_thermal()
4453 return -1; in print_thermal()
4456 if (do_ptm && (t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) { in print_thermal()
4462 cpu, msr, tcc_activation_temp - dts); in print_thermal()
4470 cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); in print_thermal()
4482 fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", in print_thermal()
4483 cpu, msr, tcc_activation_temp - dts, resolution); in print_thermal()
4491 cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); in print_thermal()
4519 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in print_rapl()
4522 cpu = t->cpu_id; in print_rapl()
4525 return -1; in print_rapl()
4531 return -1; in print_rapl()
4535 return -1; in print_rapl()
4544 return -5; in print_rapl()
4547 fprintf(outf, "cpu%d: MSR_PKG_POWER_INFO: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4558 return -9; in print_rapl()
4574 return -6; in print_rapl()
4576 fprintf(outf, "cpu%d: MSR_DRAM_POWER_INFO,: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
4585 return -9; in print_rapl()
4593 return -7; in print_rapl()
4599 return -9; in print_rapl()
4606 return -8; in print_rapl()
4611 return -9; in print_rapl()
4792 * but also allow cmdline over-ride with -T.
4794 * Several MSR temperature values are in units of degrees-C
4808 /* this is a per-package concept */ in set_temperature_target()
4809 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) in set_temperature_target()
4812 cpu = t->cpu_id; in set_temperature_target()
4815 return -1; in set_temperature_target()
4847 fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n", in set_temperature_target()
4860 msr & FEAT_CTL_LOCKED ? "" : "UN-", in decode_feature_control_msr()
4874 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", in decode_misc_enable_msr()
4875 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", in decode_misc_enable_msr()
4876 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-", in decode_misc_enable_msr()
4877 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", in decode_misc_enable_msr()
4878 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); in decode_misc_enable_msr()
4889 …f, "cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1… in decode_misc_feature_control()
4891 msr & (0 << 0) ? "No-" : "", in decode_misc_feature_control()
4892 msr & (1 << 0) ? "No-" : "", in decode_misc_feature_control()
4893 msr & (2 << 0) ? "No-" : "", in decode_misc_feature_control()
4894 msr & (3 << 0) ? "No-" : ""); in decode_misc_feature_control()
4914 …fprintf(outf, "cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)… in decode_misc_pwr_mgmt_msr()
4931 fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", in decode_c6_demotion_policy_msr()
4935 fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", in decode_c6_demotion_policy_msr()
4946 case INTEL_FAM6_NEHALEM_EP: /* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */ in intel_model_duplicates()
4947 case INTEL_FAM6_NEHALEM: /* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */ in intel_model_duplicates()
4948 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ in intel_model_duplicates()
4949 case INTEL_FAM6_WESTMERE: /* Westmere Client - Clarkdale, Arrandale */ in intel_model_duplicates()
4950 case INTEL_FAM6_WESTMERE_EP: /* Westmere EP - Gulftown */ in intel_model_duplicates()
4953 case INTEL_FAM6_NEHALEM_EX: /* Nehalem-EX Xeon - Beckton */ in intel_model_duplicates()
4954 case INTEL_FAM6_WESTMERE_EX: /* Westmere-EX Xeon - Eagleton */ in intel_model_duplicates()
4961 case INTEL_FAM6_BROADWELL_D: /* BDX-DE */ in intel_model_duplicates()
5018 unsigned int eax, ebx, ecx, edx; in process_cpuid() local
5022 eax = ebx = ecx = edx = 0; in process_cpuid()
5024 __cpuid(0, max_level, ebx, ecx, edx); in process_cpuid()
5026 if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) in process_cpuid()
5028 else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) in process_cpuid()
5030 else if (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e) in process_cpuid()
5035 (char *)&ebx, (char *)&edx, (char *)&ecx); in process_cpuid()
5037 __cpuid(1, fms, ebx, ecx, edx); in process_cpuid()
5045 ecx_flags = ecx; in process_cpuid()
5053 ebx = ecx = edx = 0; in process_cpuid()
5054 __cpuid(0x80000000, max_extended_level, ebx, ecx, edx); in process_cpuid()
5060 ecx_flags & (1 << 0) ? "SSE3" : "-", in process_cpuid()
5061 ecx_flags & (1 << 3) ? "MONITOR" : "-", in process_cpuid()
5062 ecx_flags & (1 << 6) ? "SMX" : "-", in process_cpuid()
5063 ecx_flags & (1 << 7) ? "EIST" : "-", in process_cpuid()
5064 ecx_flags & (1 << 8) ? "TM2" : "-", in process_cpuid()
5065 edx_flags & (1 << 4) ? "TSC" : "-", in process_cpuid()
5066 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
5067 edx_flags & (1 << 22) ? "ACPI-TM" : "-", in process_cpuid()
5068 edx_flags & (1 << 28) ? "HT" : "-", in process_cpuid()
5069 edx_flags & (1 << 29) ? "TM" : "-"); in process_cpuid()
5080 * Non-Stop TSC is advertised by CPUID.EAX=0x80000007: EDX.bit8 in process_cpuid()
5083 __cpuid(0x80000007, eax, ebx, ecx, edx); in process_cpuid()
5088 * APERF/MPERF is advertised by CPUID.EAX=0x6: ECX.bit0 in process_cpuid()
5092 __cpuid(0x6, eax, ebx, ecx, edx); in process_cpuid()
5093 has_aperf = ecx & (1 << 0); in process_cpuid()
5111 has_epb = ecx & (1 << 3); in process_cpuid()
5116 has_aperf ? "" : "No-", in process_cpuid()
5117 has_turbo ? "" : "No-", in process_cpuid()
5118 do_dts ? "" : "No-", in process_cpuid()
5119 do_ptm ? "" : "No-", in process_cpuid()
5120 has_hwp ? "" : "No-", in process_cpuid()
5121 has_hwp_notify ? "" : "No-", in process_cpuid()
5122 has_hwp_activity_window ? "" : "No-", in process_cpuid()
5123 has_hwp_epp ? "" : "No-", in process_cpuid()
5124 has_hwp_pkg ? "" : "No-", in process_cpuid()
5125 has_epb ? "" : "No-"); in process_cpuid()
5134 ecx = 0; in process_cpuid()
5136 __cpuid_count(0x7, 0, eax, ebx, ecx, edx); in process_cpuid()
5139 fprintf(outf, "CPUID(7): %sSGX\n", has_sgx ? "" : "No-"); in process_cpuid()
5342 if (isdigit(dirp->d_name[0])) in dir_filter()
5510 (*t)[i].cpu_id = -1; in allocate_counters()
5517 (*c)[i].core_id = -1; in allocate_counters()
5547 /* Workaround for systems where physical_node_id==-1 in init_counter()
5548 * and logical_node_id==(-1 - topo.num_cpus) in init_counter()
5557 t->cpu_id = cpu_id; in init_counter()
5559 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE; in init_counter()
5561 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE; in init_counter()
5564 c->core_id = core_id; in init_counter()
5565 p->package_id = pkg_id; in init_counter()
5581 err(-1, "calloc output buffer"); in allocate_output_buffer()
5587 err(-1, "calloc fd_percpu"); in allocate_fd_percpu()
5593 err(-1, "calloc %d", topo.num_cpus); in allocate_irq_buffers()
5597 err(-1, "calloc %d", topo.max_cpu_num + 1); in allocate_irq_buffers()
5614 err(-ENODEV, "No valid cpus found"); in set_base_cpu()
5660 /* clear affinity side-effect of get_counters() */ in fork_it()
5672 if (child_pid == -1) in fork_it()
5677 if (waitpid(child_pid, &status, 0) == -1) in fork_it()
5685 * because re-starting is problematic when forking in fork_it()
5725 " - Len Brown <lenb@kernel.org>\n"); in print_version()
5740 msrp->msr_num = msr_num; in add_counter()
5741 strncpy(msrp->name, name, NAME_BYTES - 1); in add_counter()
5743 strncpy(msrp->path, path, PATH_BYTES - 1); in add_counter()
5744 msrp->width = width; in add_counter()
5745 msrp->type = type; in add_counter()
5746 msrp->format = format; in add_counter()
5747 msrp->flags = flags; in add_counter()
5752 msrp->next = sys.tp; in add_counter()
5758 exit(-1); in add_counter()
5763 msrp->next = sys.cp; in add_counter()
5769 exit(-1); in add_counter()
5774 msrp->next = sys.pp; in add_counter()
5780 exit(-1); in add_counter()
5872 fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter ) required\n"); in parse_add_command()
5914 for (state = 10; state >= 0; --state) { in probe_sysfs()
5924 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
5925 sp = strchr(name_buf, '-'); in probe_sysfs()
5944 for (state = 10; state >= 0; --state) { in probe_sysfs()
5953 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
5954 sp = strchr(name_buf, '-'); in probe_sysfs()
5976 * 1,2,4..6,8-10 and set bits in cpu_subset
6009 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_command()
6026 if (*next == '-') { in parse_cpu_command()
6055 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
6057 exit(-1); in parse_cpu_command()
6074 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help in cmdline()
6089 long_options, &option_index)) != -1) { in cmdline()
6101 /* --enable specified counter */ in cmdline()
6110 * --hide: do not show those specified in cmdline()
6130 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000; in cmdline()
6131 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; in cmdline()
6159 * --show: show only those specified in cmdline()
6210 if (argc - optind) in main()