Lines Matching full:msr

400 int get_msr(int cpu, off_t offset, unsigned long long *msr);
456 unsigned long long msr = 3; in slm_bclk() local
460 if (get_msr(base_cpu, MSR_FSB_FREQ, &msr)) in slm_bclk()
463 i = msr & 0xf; in slm_bclk()
1162 unsigned long long msr[NUM_RAPL_COUNTERS]; member
1180 unsigned long long msr; member
1183 …double *platform_rapl_msr_scale; /* Scale applied to values read by MSR (platform dependent, fille…
1195 .msr = MSR_PKG_ENERGY_STATUS,
1208 .msr = MSR_PKG_ENERGY_STAT,
1221 .msr = MSR_PP0_ENERGY_STATUS,
1234 .msr = MSR_DRAM_ENERGY_STATUS,
1247 .msr = MSR_PP1_ENERGY_STATUS,
1260 .msr = MSR_PKG_PERF_STATUS,
1273 .msr = MSR_DRAM_PERF_STATUS,
1286 .msr = MSR_CORE_ENERGY_STAT,
1299 .msr = MSR_PLATFORM_ENERGY_STATUS,
1335 unsigned long long msr[NUM_CSTATE_COUNTERS]; member
1351 unsigned long long msr; member
1363 .msr = MSR_CORE_C1_RES,
1373 .msr = MSR_CORE_C3_RESIDENCY,
1383 .msr = MSR_CORE_C6_RESIDENCY,
1393 .msr = MSR_CORE_C7_RESIDENCY,
1403 .msr = MSR_PKG_C2_RESIDENCY,
1413 .msr = MSR_PKG_C3_RESIDENCY,
1423 .msr = MSR_PKG_C6_RESIDENCY,
1433 .msr = MSR_PKG_C7_RESIDENCY,
1443 .msr = MSR_PKG_C8_RESIDENCY,
1453 .msr = MSR_PKG_C9_RESIDENCY,
1463 .msr = MSR_PKG_C10_RESIDENCY,
1482 unsigned long long msr[NUM_MSR_COUNTERS]; member
1493 unsigned long long msr; member
1508 .perf_subsys = "msr",
1510 .msr = MSR_IA32_APERF,
1516 .perf_subsys = "msr",
1518 .msr = MSR_IA32_MPERF,
1524 .perf_subsys = "msr",
1526 .msr = MSR_SMI_COUNT,
1824 * The accumulated sum of MSR is defined as a monotonic
1825 * increasing MSR, it will be accumulated periodically,
1839 int get_msr_sum(int cpu, off_t offset, unsigned long long *msr);
1844 /*The accumulated MSR value is updated by the timer */
1846 /*The MSR footprint recorded in last timer */
1851 /* The percpu MSR sum array.*/
1945 /* MSR added counters */
1990 * Free all added counters accessed via msr.
2140 sprintf(pathname, "/dev/cpu/%d/msr", cpu); in get_msr_fd()
2143 err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, " in get_msr_fd()
2144 "or run with --no-msr, or run as root", pathname); in get_msr_fd()
2200 int get_msr(int cpu, off_t offset, unsigned long long *msr) in get_msr() argument
2206 retval = pread(get_msr_fd(cpu), msr, sizeof(*msr), offset); in get_msr()
2208 if (retval != sizeof *msr) in get_msr()
2209 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
2227 /* If an Energy Status Counter MSR returns 0, the probe fails */ in probe_rapl_msr()
2305 " -M, --no-msr\n" in help()
2306 " disable all uses of the MSR driver\n" in help()
3571 * Some models have a dedicated C1 residency MSR, in delta_thread()
4121 unsigned long long msr; in get_epb() local
4143 get_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, &msr); in get_epb()
4145 return msr & 0xf; in get_epb()
4445 fprintf(stderr, "Reading rapl counter via msr at %u\n", i); in get_rapl_counters()
4449 if (get_msr_sum(cpu, rci->msr[i], &rci->data[i])) in get_rapl_counters()
4452 if (get_msr(cpu, rci->msr[i], &rci->data[i])) in get_rapl_counters()
4583 if (get_msr(cpu, cci->msr[i], &cci->data[i])) in get_cstate_counters()
4587 fprintf(stderr, "cstate via %s0x%llx %u: %llu\n", "msr", cci->msr[i], i, cci->data[i]); in get_cstate_counters()
4673 fprintf(stderr, "Reading msr counter via perf at %u: %llu\n", i, perf_data[pi]); in get_smi_aperf_mperf()
4683 if (get_msr(cpu, mci->msr[i], &mci->data[i])) in get_smi_aperf_mperf()
4689 fprintf(stderr, "Reading msr counter via msr at %u: %llu\n", i, mci->data[i]); in get_smi_aperf_mperf()
4763 unsigned long long msr; in get_counters() local
4830 if (get_msr(cpu, MSR_IA32_THERM_STATUS, &msr)) in get_counters()
4832 c->core_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
4882 if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_STATUS, &msr)) in get_counters()
4884 p->pkg_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
4986 unsigned long long msr; in probe_cst_limit() local
5024 get_msr(base_cpu, MSR_PKG_CST_CONFIG_CONTROL, &msr); in probe_cst_limit()
5025 pkg_cstate_limit = pkg_cstate_limits[msr & 0xF]; in probe_cst_limit()
5030 unsigned long long msr; in dump_platform_info() local
5036 get_msr(base_cpu, MSR_PLATFORM_INFO, &msr); in dump_platform_info()
5038 fprintf(outf, "cpu%d: MSR_PLATFORM_INFO: 0x%08llx\n", base_cpu, msr); in dump_platform_info()
5040 ratio = (msr >> 40) & 0xFF; in dump_platform_info()
5043 ratio = (msr >> 8) & 0xFF; in dump_platform_info()
5049 unsigned long long msr; in dump_power_ctl() local
5054 get_msr(base_cpu, MSR_IA32_POWER_CTL, &msr); in dump_power_ctl()
5056 base_cpu, msr, msr & 0x2 ? "EN" : "DIS"); in dump_power_ctl()
5060 fprintf(outf, "C-state Pre-wake: %sabled\n", msr & 0x40000000 ? "DIS" : "EN"); in dump_power_ctl()
5067 unsigned long long msr; in dump_turbo_ratio_limit2() local
5070 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT2, &msr); in dump_turbo_ratio_limit2()
5072 fprintf(outf, "cpu%d: MSR_TURBO_RATIO_LIMIT2: 0x%08llx\n", base_cpu, msr); in dump_turbo_ratio_limit2()
5074 ratio = (msr >> 8) & 0xFF; in dump_turbo_ratio_limit2()
5078 ratio = (msr >> 0) & 0xFF; in dump_turbo_ratio_limit2()
5086 unsigned long long msr; in dump_turbo_ratio_limit1() local
5089 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT1, &msr); in dump_turbo_ratio_limit1()
5091 fprintf(outf, "cpu%d: MSR_TURBO_RATIO_LIMIT1: 0x%08llx\n", base_cpu, msr); in dump_turbo_ratio_limit1()
5093 ratio = (msr >> 56) & 0xFF; in dump_turbo_ratio_limit1()
5097 ratio = (msr >> 48) & 0xFF; in dump_turbo_ratio_limit1()
5101 ratio = (msr >> 40) & 0xFF; in dump_turbo_ratio_limit1()
5105 ratio = (msr >> 32) & 0xFF; in dump_turbo_ratio_limit1()
5109 ratio = (msr >> 24) & 0xFF; in dump_turbo_ratio_limit1()
5113 ratio = (msr >> 16) & 0xFF; in dump_turbo_ratio_limit1()
5117 ratio = (msr >> 8) & 0xFF; in dump_turbo_ratio_limit1()
5121 ratio = (msr >> 0) & 0xFF; in dump_turbo_ratio_limit1()
5129 unsigned long long msr, core_counts; in dump_turbo_ratio_limits() local
5132 get_msr(base_cpu, trl_msr_offset, &msr); in dump_turbo_ratio_limits()
5134 base_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY_" : "", msr); in dump_turbo_ratio_limits()
5146 ratio = (msr >> shift) & 0xFF; in dump_turbo_ratio_limits()
5158 unsigned long long msr; in dump_atom_turbo_ratio_limits() local
5161 get_msr(base_cpu, MSR_ATOM_CORE_RATIOS, &msr); in dump_atom_turbo_ratio_limits()
5162 fprintf(outf, "cpu%d: MSR_ATOM_CORE_RATIOS: 0x%08llx\n", base_cpu, msr & 0xFFFFFFFF); in dump_atom_turbo_ratio_limits()
5164 ratio = (msr >> 0) & 0x3F; in dump_atom_turbo_ratio_limits()
5168 ratio = (msr >> 8) & 0x3F; in dump_atom_turbo_ratio_limits()
5172 ratio = (msr >> 16) & 0x3F; in dump_atom_turbo_ratio_limits()
5176 get_msr(base_cpu, MSR_ATOM_CORE_TURBO_RATIOS, &msr); in dump_atom_turbo_ratio_limits()
5177 fprintf(outf, "cpu%d: MSR_ATOM_CORE_TURBO_RATIOS: 0x%08llx\n", base_cpu, msr & 0xFFFFFFFF); in dump_atom_turbo_ratio_limits()
5179 ratio = (msr >> 24) & 0x3F; in dump_atom_turbo_ratio_limits()
5183 ratio = (msr >> 16) & 0x3F; in dump_atom_turbo_ratio_limits()
5187 ratio = (msr >> 8) & 0x3F; in dump_atom_turbo_ratio_limits()
5191 ratio = (msr >> 0) & 0x3F; in dump_atom_turbo_ratio_limits()
5200 unsigned long long msr; in dump_knl_turbo_ratio_limits() local
5206 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT, &msr); in dump_knl_turbo_ratio_limits()
5208 fprintf(outf, "cpu%d: MSR_TURBO_RATIO_LIMIT: 0x%08llx\n", base_cpu, msr); in dump_knl_turbo_ratio_limits()
5234 cores[b_nr] = (msr & 0xFF) >> 1; in dump_knl_turbo_ratio_limits()
5235 ratio[b_nr] = (msr >> 8) & 0xFF; in dump_knl_turbo_ratio_limits()
5238 delta_cores = (msr >> i) & 0x1F; in dump_knl_turbo_ratio_limits()
5239 delta_ratio = (msr >> (i + 5)) & 0x7; in dump_knl_turbo_ratio_limits()
5255 unsigned long long msr; in dump_cst_cfg() local
5260 get_msr(base_cpu, MSR_PKG_CST_CONFIG_CONTROL, &msr); in dump_cst_cfg()
5262 fprintf(outf, "cpu%d: MSR_PKG_CST_CONFIG_CONTROL: 0x%08llx", base_cpu, msr); in dump_cst_cfg()
5265 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", in dump_cst_cfg()
5266 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", in dump_cst_cfg()
5267 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", in dump_cst_cfg()
5268 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", in dump_cst_cfg()
5269 …(msr & (1 << 15)) ? "" : "UN", (unsigned int)msr & 0xF, pkg_cstate_limit_strings[pkg_cstate_limit]… in dump_cst_cfg()
5273 …fprintf(outf, ", automatic c-state conversion=%s", (msr & AUTOMATIC_CSTATE_CONVERSION) ? "on" : "o… in dump_cst_cfg()
5283 unsigned long long msr; in dump_config_tdp() local
5285 get_msr(base_cpu, MSR_CONFIG_TDP_NOMINAL, &msr); in dump_config_tdp()
5286 fprintf(outf, "cpu%d: MSR_CONFIG_TDP_NOMINAL: 0x%08llx", base_cpu, msr); in dump_config_tdp()
5287 fprintf(outf, " (base_ratio=%d)\n", (unsigned int)msr & 0xFF); in dump_config_tdp()
5289 get_msr(base_cpu, MSR_CONFIG_TDP_LEVEL_1, &msr); in dump_config_tdp()
5290 fprintf(outf, "cpu%d: MSR_CONFIG_TDP_LEVEL_1: 0x%08llx (", base_cpu, msr); in dump_config_tdp()
5291 if (msr) { in dump_config_tdp()
5292 fprintf(outf, "PKG_MIN_PWR_LVL1=%d ", (unsigned int)(msr >> 48) & 0x7FFF); in dump_config_tdp()
5293 fprintf(outf, "PKG_MAX_PWR_LVL1=%d ", (unsigned int)(msr >> 32) & 0x7FFF); in dump_config_tdp()
5294 fprintf(outf, "LVL1_RATIO=%d ", (unsigned int)(msr >> 16) & 0xFF); in dump_config_tdp()
5295 fprintf(outf, "PKG_TDP_LVL1=%d", (unsigned int)(msr) & 0x7FFF); in dump_config_tdp()
5299 get_msr(base_cpu, MSR_CONFIG_TDP_LEVEL_2, &msr); in dump_config_tdp()
5300 fprintf(outf, "cpu%d: MSR_CONFIG_TDP_LEVEL_2: 0x%08llx (", base_cpu, msr); in dump_config_tdp()
5301 if (msr) { in dump_config_tdp()
5302 fprintf(outf, "PKG_MIN_PWR_LVL2=%d ", (unsigned int)(msr >> 48) & 0x7FFF); in dump_config_tdp()
5303 fprintf(outf, "PKG_MAX_PWR_LVL2=%d ", (unsigned int)(msr >> 32) & 0x7FFF); in dump_config_tdp()
5304 fprintf(outf, "LVL2_RATIO=%d ", (unsigned int)(msr >> 16) & 0xFF); in dump_config_tdp()
5305 fprintf(outf, "PKG_TDP_LVL2=%d", (unsigned int)(msr) & 0x7FFF); in dump_config_tdp()
5309 get_msr(base_cpu, MSR_CONFIG_TDP_CONTROL, &msr); in dump_config_tdp()
5310 fprintf(outf, "cpu%d: MSR_CONFIG_TDP_CONTROL: 0x%08llx (", base_cpu, msr); in dump_config_tdp()
5311 if ((msr) & 0x3) in dump_config_tdp()
5312 fprintf(outf, "TDP_LEVEL=%d ", (unsigned int)(msr) & 0x3); in dump_config_tdp()
5313 fprintf(outf, " lock=%d", (unsigned int)(msr >> 31) & 1); in dump_config_tdp()
5316 get_msr(base_cpu, MSR_TURBO_ACTIVATION_RATIO, &msr); in dump_config_tdp()
5317 fprintf(outf, "cpu%d: MSR_TURBO_ACTIVATION_RATIO: 0x%08llx (", base_cpu, msr); in dump_config_tdp()
5318 fprintf(outf, "MAX_NON_TURBO_RATIO=%d", (unsigned int)(msr) & 0xFF); in dump_config_tdp()
5319 fprintf(outf, " lock=%d", (unsigned int)(msr >> 31) & 1); in dump_config_tdp()
5327 unsigned long long msr; in print_irtl() local
5333 get_msr(base_cpu, MSR_PKGC3_IRTL, &msr); in print_irtl()
5334 fprintf(outf, "cpu%d: MSR_PKGC3_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5335 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5336 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
5340 get_msr(base_cpu, MSR_PKGC6_IRTL, &msr); in print_irtl()
5341 fprintf(outf, "cpu%d: MSR_PKGC6_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5342 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5343 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
5347 get_msr(base_cpu, MSR_PKGC7_IRTL, &msr); in print_irtl()
5348 fprintf(outf, "cpu%d: MSR_PKGC7_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5349 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5350 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
5354 get_msr(base_cpu, MSR_PKGC8_IRTL, &msr); in print_irtl()
5355 fprintf(outf, "cpu%d: MSR_PKGC8_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5356 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5357 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
5361 get_msr(base_cpu, MSR_PKGC9_IRTL, &msr); in print_irtl()
5362 fprintf(outf, "cpu%d: MSR_PKGC9_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5363 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5364 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
5368 get_msr(base_cpu, MSR_PKGC10_IRTL, &msr); in print_irtl()
5369 fprintf(outf, "cpu%d: MSR_PKGC10_IRTL: 0x%08llx (", base_cpu, msr); in print_irtl()
5370 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT", in print_irtl()
5371 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]); in print_irtl()
6222 int get_msr_sum(int cpu, off_t offset, unsigned long long *msr) in get_msr_sum() argument
6241 *msr = msr_last + per_cpu_msr_sum[cpu].entries[idx].sum; in get_msr_sum()
6270 fprintf(outf, "Can not update msr(0x%llx)\n", (unsigned long long)offset); in update_msr_sum()
6297 fprintf(outf, "Can not allocate memory for long time MSR.\n"); in msr_sum_record()
6466 sprintf(pathname, "/dev/cpu/%d/msr", base_cpu); in check_dev_msr()
6468 if (system("/sbin/modprobe msr > /dev/null 2>&1")) in check_dev_msr()
6516 sprintf(pathname, "/dev/cpu/%d/msr", base_cpu); in check_msr_permission()
6523 … "\tRun as root to enable them or use %s to disable the access explicitly", pathname, "--no-msr"); in check_msr_permission()
6530 unsigned long long msr; in probe_bclk() local
6545 get_msr(base_cpu, MSR_PLATFORM_INFO, &msr); in probe_bclk()
6546 base_ratio = (msr >> 8) & 0xFF; in probe_bclk()
6961 * Decode the ENERGY_PERF_BIAS MSR
7014 unsigned long long msr; in print_hwp() local
7037 if (get_msr(cpu, MSR_PM_ENABLE, &msr)) in print_hwp()
7040 fprintf(outf, "cpu%d: MSR_PM_ENABLE: 0x%08llx (%sHWP)\n", cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
7043 if ((msr & (1 << 0)) == 0) in print_hwp()
7046 if (get_msr(cpu, MSR_HWP_CAPABILITIES, &msr)) in print_hwp()
7051 cpu, msr, in print_hwp()
7052 (unsigned int)HWP_HIGHEST_PERF(msr), in print_hwp()
7053 (unsigned int)HWP_GUARANTEED_PERF(msr), in print_hwp()
7054 (unsigned int)HWP_MOSTEFFICIENT_PERF(msr), (unsigned int)HWP_LOWEST_PERF(msr)); in print_hwp()
7056 if (get_msr(cpu, MSR_HWP_REQUEST, &msr)) in print_hwp()
7061 cpu, msr, in print_hwp()
7062 (unsigned int)(((msr) >> 0) & 0xff), in print_hwp()
7063 (unsigned int)(((msr) >> 8) & 0xff), in print_hwp()
7064 (unsigned int)(((msr) >> 16) & 0xff), in print_hwp()
7065 (unsigned int)(((msr) >> 24) & 0xff), in print_hwp()
7066 (unsigned int)(((msr) >> 32) & 0xff3), (unsigned int)(((msr) >> 42) & 0x1)); in print_hwp()
7069 if (get_msr(cpu, MSR_HWP_REQUEST_PKG, &msr)) in print_hwp()
7074 cpu, msr, in print_hwp()
7075 (unsigned int)(((msr) >> 0) & 0xff), in print_hwp()
7076 (unsigned int)(((msr) >> 8) & 0xff), in print_hwp()
7077 (unsigned int)(((msr) >> 16) & 0xff), in print_hwp()
7078 (unsigned int)(((msr) >> 24) & 0xff), (unsigned int)(((msr) >> 32) & 0xff3)); in print_hwp()
7081 if (get_msr(cpu, MSR_HWP_INTERRUPT, &msr)) in print_hwp()
7086 cpu, msr, ((msr) & 0x1) ? "EN" : "Dis", ((msr) & 0x2) ? "EN" : "Dis"); in print_hwp()
7088 if (get_msr(cpu, MSR_HWP_STATUS, &msr)) in print_hwp()
7093 cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x4) ? "" : "No-"); in print_hwp()
7103 unsigned long long msr; in print_perf_limit() local
7124 get_msr(cpu, MSR_CORE_PERF_LIMIT_REASONS, &msr); in print_perf_limit()
7125 fprintf(outf, "cpu%d: MSR_CORE_PERF_LIMIT_REASONS, 0x%08llx", cpu, msr); in print_perf_limit()
7127 (msr & 1 << 15) ? "bit15, " : "", in print_perf_limit()
7128 (msr & 1 << 14) ? "bit14, " : "", in print_perf_limit()
7129 (msr & 1 << 13) ? "Transitions, " : "", in print_perf_limit()
7130 (msr & 1 << 12) ? "MultiCoreTurbo, " : "", in print_perf_limit()
7131 (msr & 1 << 11) ? "PkgPwrL2, " : "", in print_perf_limit()
7132 (msr & 1 << 10) ? "PkgPwrL1, " : "", in print_perf_limit()
7133 (msr & 1 << 9) ? "CorePwr, " : "", in print_perf_limit()
7134 (msr & 1 << 8) ? "Amps, " : "", in print_perf_limit()
7135 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7136 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
7137 (msr & 1 << 4) ? "Graphics, " : "", in print_perf_limit()
7138 (msr & 1 << 2) ? "bit2, " : "", in print_perf_limit()
7139 (msr & 1 << 1) ? "ThermStatus, " : "", (msr & 1 << 0) ? "PROCHOT, " : ""); in print_perf_limit()
7141 (msr & 1 << 31) ? "bit31, " : "", in print_perf_limit()
7142 (msr & 1 << 30) ? "bit30, " : "", in print_perf_limit()
7143 (msr & 1 << 29) ? "Transitions, " : "", in print_perf_limit()
7144 (msr & 1 << 28) ? "MultiCoreTurbo, " : "", in print_perf_limit()
7145 (msr & 1 << 27) ? "PkgPwrL2, " : "", in print_perf_limit()
7146 (msr & 1 << 26) ? "PkgPwrL1, " : "", in print_perf_limit()
7147 (msr & 1 << 25) ? "CorePwr, " : "", in print_perf_limit()
7148 (msr & 1 << 24) ? "Amps, " : "", in print_perf_limit()
7149 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7150 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
7151 (msr & 1 << 20) ? "Graphics, " : "", in print_perf_limit()
7152 (msr & 1 << 18) ? "bit18, " : "", in print_perf_limit()
7153 (msr & 1 << 17) ? "ThermStatus, " : "", (msr & 1 << 16) ? "PROCHOT, " : ""); in print_perf_limit()
7157 get_msr(cpu, MSR_GFX_PERF_LIMIT_REASONS, &msr); in print_perf_limit()
7158 fprintf(outf, "cpu%d: MSR_GFX_PERF_LIMIT_REASONS, 0x%08llx", cpu, msr); in print_perf_limit()
7160 (msr & 1 << 0) ? "PROCHOT, " : "", in print_perf_limit()
7161 (msr & 1 << 1) ? "ThermStatus, " : "", in print_perf_limit()
7162 (msr & 1 << 4) ? "Graphics, " : "", in print_perf_limit()
7163 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7164 (msr & 1 << 8) ? "Amps, " : "", in print_perf_limit()
7165 (msr & 1 << 9) ? "GFXPwr, " : "", in print_perf_limit()
7166 (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : ""); in print_perf_limit()
7168 (msr & 1 << 16) ? "PROCHOT, " : "", in print_perf_limit()
7169 (msr & 1 << 17) ? "ThermStatus, " : "", in print_perf_limit()
7170 (msr & 1 << 20) ? "Graphics, " : "", in print_perf_limit()
7171 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7172 (msr & 1 << 24) ? "Amps, " : "", in print_perf_limit()
7173 (msr & 1 << 25) ? "GFXPwr, " : "", in print_perf_limit()
7174 (msr & 1 << 26) ? "PkgPwrL1, " : "", (msr & 1 << 27) ? "PkgPwrL2, " : ""); in print_perf_limit()
7177 get_msr(cpu, MSR_RING_PERF_LIMIT_REASONS, &msr); in print_perf_limit()
7178 fprintf(outf, "cpu%d: MSR_RING_PERF_LIMIT_REASONS, 0x%08llx", cpu, msr); in print_perf_limit()
7180 (msr & 1 << 0) ? "PROCHOT, " : "", in print_perf_limit()
7181 (msr & 1 << 1) ? "ThermStatus, " : "", in print_perf_limit()
7182 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7183 (msr & 1 << 8) ? "Amps, " : "", in print_perf_limit()
7184 (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : ""); in print_perf_limit()
7186 (msr & 1 << 16) ? "PROCHOT, " : "", in print_perf_limit()
7187 (msr & 1 << 17) ? "ThermStatus, " : "", in print_perf_limit()
7188 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7189 (msr & 1 << 24) ? "Amps, " : "", in print_perf_limit()
7190 (msr & 1 << 26) ? "PkgPwrL1, " : "", (msr & 1 << 27) ? "PkgPwrL2, " : ""); in print_perf_limit()
7208 unsigned long long msr; in get_tdp_intel() local
7211 if (!get_msr(base_cpu, MSR_PKG_POWER_INFO, &msr)) in get_tdp_intel()
7212 return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; in get_tdp_intel()
7223 unsigned long long msr; in rapl_probe_intel() local
7240 if (get_msr(base_cpu, MSR_RAPL_POWER_UNIT, &msr)) in rapl_probe_intel()
7243 rapl_power_units = 1.0 / (1 << (msr & 0xF)); in rapl_probe_intel()
7245 rapl_energy_units = 1.0 * (1 << (msr >> 8 & 0x1F)) / 1000000; in rapl_probe_intel()
7247 rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); in rapl_probe_intel()
7259 time_unit = msr >> 16 & 0xF; in rapl_probe_intel()
7274 unsigned long long msr; in rapl_probe_amd() local
7284 if (get_msr(base_cpu, MSR_RAPL_PWR_UNIT, &msr)) in rapl_probe_amd()
7287 rapl_time_units = ldexp(1.0, -(msr >> 16 & 0xf)); in rapl_probe_amd()
7288 rapl_energy_units = ldexp(1.0, -(msr >> 8 & 0x1f)); in rapl_probe_amd()
7289 rapl_power_units = ldexp(1.0, -(msr & 0xf)); in rapl_probe_amd()
7298 void print_power_limit_msr(int cpu, unsigned long long msr, char *label) in print_power_limit_msr() argument
7302 ((msr >> 15) & 1) ? "EN" : "DIS", in print_power_limit_msr()
7303 ((msr >> 0) & 0x7FFF) * rapl_power_units, in print_power_limit_msr()
7304 (1.0 + (((msr >> 22) & 0x3) / 4.0)) * (1 << ((msr >> 17) & 0x1F)) * rapl_time_units, in print_power_limit_msr()
7305 (((msr >> 16) & 1) ? "EN" : "DIS")); in print_power_limit_msr()
7312 unsigned long long msr; in print_rapl() local
7334 if (get_msr(cpu, MSR_RAPL_PWR_UNIT, &msr)) in print_rapl()
7338 if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) in print_rapl()
7342 fprintf(outf, "cpu%d: %s: 0x%08llx (%f Watts, %f Joules, %f sec.)\n", cpu, msr_name, msr, in print_rapl()
7347 if (get_msr(cpu, MSR_PKG_POWER_INFO, &msr)) in print_rapl()
7351 cpu, msr, in print_rapl()
7352 ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7353 ((msr >> 16) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7354 ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7355 ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); in print_rapl()
7360 if (get_msr(cpu, MSR_PKG_POWER_LIMIT, &msr)) in print_rapl()
7364 cpu, msr, (msr >> 63) & 1 ? "" : "UN"); in print_rapl()
7366 print_power_limit_msr(cpu, msr, "PKG Limit #1"); in print_rapl()
7369 ((msr >> 47) & 1) ? "EN" : "DIS", in print_rapl()
7370 ((msr >> 32) & 0x7FFF) * rapl_power_units, in print_rapl()
7371 (1.0 + (((msr >> 54) & 0x3) / 4.0)) * (1 << ((msr >> 49) & 0x1F)) * rapl_time_units, in print_rapl()
7372 ((msr >> 48) & 1) ? "EN" : "DIS"); in print_rapl()
7374 if (get_msr(cpu, MSR_VR_CURRENT_CONFIG, &msr)) in print_rapl()
7377 fprintf(outf, "cpu%d: MSR_VR_CURRENT_CONFIG: 0x%08llx\n", cpu, msr); in print_rapl()
7379 cpu, ((msr >> 0) & 0x1FFF) * rapl_power_units, (msr >> 31) & 1 ? "" : "UN"); in print_rapl()
7383 if (get_msr(cpu, MSR_DRAM_POWER_INFO, &msr)) in print_rapl()
7387 cpu, msr, in print_rapl()
7388 ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7389 ((msr >> 16) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7390 ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, in print_rapl()
7391 ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); in print_rapl()
7394 if (get_msr(cpu, MSR_DRAM_POWER_LIMIT, &msr)) in print_rapl()
7397 cpu, msr, (msr >> 31) & 1 ? "" : "UN"); in print_rapl()
7399 print_power_limit_msr(cpu, msr, "DRAM Limit"); in print_rapl()
7402 if (get_msr(cpu, MSR_PP0_POLICY, &msr)) in print_rapl()
7405 fprintf(outf, "cpu%d: MSR_PP0_POLICY: %lld\n", cpu, msr & 0xF); in print_rapl()
7408 if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) in print_rapl()
7411 cpu, msr, (msr >> 31) & 1 ? "" : "UN"); in print_rapl()
7412 print_power_limit_msr(cpu, msr, "Cores Limit"); in print_rapl()
7415 if (get_msr(cpu, MSR_PP1_POLICY, &msr)) in print_rapl()
7418 fprintf(outf, "cpu%d: MSR_PP1_POLICY: %lld\n", cpu, msr & 0xF); in print_rapl()
7420 if (get_msr(cpu, MSR_PP1_POWER_LIMIT, &msr)) in print_rapl()
7423 cpu, msr, (msr >> 31) & 1 ? "" : "UN"); in print_rapl()
7424 print_power_limit_msr(cpu, msr, "GFX Limit"); in print_rapl()
7455 * Older processors do not have this MSR, so there we guess,
7458 * Several MSR temperature values are in units of degrees-C
7464 unsigned long long msr; in set_temperature_target() local
7491 /* Temperature Target MSR is Nehalem and newer only */ in set_temperature_target()
7495 if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr)) in set_temperature_target()
7498 tcc_default = (msr >> 16) & 0xFF; in set_temperature_target()
7508 tcc_offset = (msr >> 24) & GENMASK(bits - 1, 0); in set_temperature_target()
7510 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
7512 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", cpu, msr, tcc_default); in set_temperature_target()
7532 unsigned long long msr; in print_thermal() local
7557 if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_STATUS, &msr)) in print_thermal()
7560 dts = (msr >> 16) & 0x7F; in print_thermal()
7561 fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_STATUS: 0x%08llx (%d C)\n", cpu, msr, tj_max - dts); in print_thermal()
7563 if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, &msr)) in print_thermal()
7566 dts = (msr >> 16) & 0x7F; in print_thermal()
7567 dts2 = (msr >> 8) & 0x7F; in print_thermal()
7569 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
7575 if (get_msr(cpu, MSR_IA32_THERM_STATUS, &msr)) in print_thermal()
7578 dts = (msr >> 16) & 0x7F; in print_thermal()
7579 resolution = (msr >> 27) & 0xF; in print_thermal()
7581 cpu, msr, tj_max - dts, resolution); in print_thermal()
7583 if (get_msr(cpu, MSR_IA32_THERM_INTERRUPT, &msr)) in print_thermal()
7586 dts = (msr >> 16) & 0x7F; in print_thermal()
7587 dts2 = (msr >> 8) & 0x7F; in print_thermal()
7589 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
7637 unsigned long long msr; in decode_feature_control_msr() local
7642 if (!get_msr(base_cpu, MSR_IA32_FEAT_CTL, &msr)) in decode_feature_control_msr()
7644 base_cpu, msr, msr & FEAT_CTL_LOCKED ? "" : "UN-", msr & (1 << 18) ? "SGX" : ""); in decode_feature_control_msr()
7649 unsigned long long msr; in decode_misc_enable_msr() local
7657 if (!get_msr(base_cpu, MSR_IA32_MISC_ENABLE, &msr)) in decode_misc_enable_msr()
7659 base_cpu, msr, in decode_misc_enable_msr()
7660 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", in decode_misc_enable_msr()
7661 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", in decode_misc_enable_msr()
7662 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-", in decode_misc_enable_msr()
7663 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", in decode_misc_enable_msr()
7664 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); in decode_misc_enable_msr()
7669 unsigned long long msr; in decode_misc_feature_control() local
7677 if (!get_msr(base_cpu, MSR_MISC_FEATURE_CONTROL, &msr)) in decode_misc_feature_control()
7680 base_cpu, msr, msr & (0 << 0) ? "No-" : "", msr & (1 << 0) ? "No-" : "", in decode_misc_feature_control()
7681 msr & (2 << 0) ? "No-" : "", msr & (3 << 0) ? "No-" : ""); in decode_misc_feature_control()
7693 unsigned long long msr; in decode_misc_pwr_mgmt_msr() local
7701 if (!get_msr(base_cpu, MSR_MISC_PWR_MGMT, &msr)) in decode_misc_pwr_mgmt_msr()
7703 base_cpu, msr, in decode_misc_pwr_mgmt_msr()
7704 msr & (1 << 0) ? "DIS" : "EN", msr & (1 << 1) ? "EN" : "DIS", msr & (1 << 8) ? "EN" : "DIS"); in decode_misc_pwr_mgmt_msr()
7715 unsigned long long msr; in decode_c6_demotion_policy_msr() local
7723 if (!get_msr(base_cpu, MSR_CC6_DEMOTION_POLICY_CONFIG, &msr)) in decode_c6_demotion_policy_msr()
7725 base_cpu, msr, msr & (1 << 0) ? "EN" : "DIS"); in decode_c6_demotion_policy_msr()
7727 if (!get_msr(base_cpu, MSR_MC6_DEMOTION_POLICY_CONFIG, &msr)) in decode_c6_demotion_policy_msr()
7729 base_cpu, msr, msr & (1 << 0) ? "EN" : "DIS"); in decode_c6_demotion_policy_msr()
7864 * If can't get it via perf, fallback to MSR in rapl_perf_init()
7908 /* Use MSR for this counter */ in rapl_perf_init()
7909 } else if (!no_msr && cai->msr && probe_rapl_msr(cpu, cai->msr, cai->rci_index) == 0) { in rapl_perf_init()
7911 rci->msr[cai->rci_index] = cai->msr; in rapl_perf_init()
8046 /* User MSR for this counter */ in msr_perf_init_()
8047 } else if (!no_msr && cai->msr && probe_rapl_msr(cpu, cai->msr, cai->rci_index) == 0) { in msr_perf_init_()
8049 cci->msr[cai->rci_index] = cai->msr; in msr_perf_init_()
8058 /* Initialize data for reading perf counters from the MSR group. */
8159 /* User MSR for this counter */ in cstate_perf_init_()
8160 } else if (!no_msr && cai->msr && pkg_cstate_limit >= cai->pkg_cstate_limit in cstate_perf_init_()
8161 && probe_rapl_msr(cpu, cai->msr, cai->rci_index) == 0) { in cstate_perf_init_()
8163 cci->msr[cai->rci_index] = cai->msr; in cstate_perf_init_()
8186 * If we don't have a C1 residency MSR, we calculate it "in software", in cstate_perf_init()
8323 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
8331 errx(1, "CPUID: no MSR"); in process_cpuid()
8458 if (platform->has_msr_knl_core_c6_residency && cai->msr == MSR_CORE_C6_RESIDENCY) in counter_info_init()
8459 cai->msr = MSR_KNL_CORE_C6_RESIDENCY; in counter_info_init()
8461 if (!platform->has_msr_core_c1_res && cai->msr == MSR_CORE_C1_RES) in counter_info_init()
8462 cai->msr = 0; in counter_info_init()
8464 if (platform->has_msr_atom_pkg_c6_residency && cai->msr == MSR_PKG_C6_RESIDENCY) in counter_info_init()
8465 cai->msr = MSR_ATOM_PKG_C6_RESIDENCY; in counter_info_init()
9618 errx(1, "Requested MSR counter 0x%x, but in --no-msr mode", msr_num); in add_counter()
9621 fprintf(stderr, "%s(msr%d, %s, %s, width%d, scope%d, type%d, format%d, flags%x, id%d)\n", in add_counter()
9823 if (sscanf(add_command, "msr%d", &msr_num) == 1) in parse_add_command_msr()
10381 { "no-msr", no_argument, 0, 'M' }, in cmdline()
10394 * like adding the MSR counter with --add and at the same time using --no-msr. in cmdline()