Lines Matching +full:ecx +full:- +full:1000
1 // SPDX-License-Identifier: GPL-2.0-only
3 * turbostat -- show CPU frequency and C-state residency
19 #define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT)
20 #define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT)
21 #define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT)
75 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
77 * matching on them for --show and --hide.
82 * Usually truncated to 7 characters, but also handles 18 columns for raw 64-bit counters
98 #define ROUND_UP_TO_PAGE_SIZE(n) (((n) + 0x1000UL-1UL) & ~(0x1000UL-1UL))
429 …bool has_per_core_rapl; /* Indicates cores energy collection is per-core, not per-package. AMD spe…
1076 unsigned int eax, ebx, ecx, edx; in probe_platform_features() local
1078 __cpuid(0x80000007, eax, ebx, ecx, edx); in probe_platform_features()
1114 /* MSRs that are not yet in the kernel-provided header. */
1194 .perf_name = "energy-pkg",
1207 .perf_name = "energy-pkg",
1220 .perf_name = "energy-cores",
1233 .perf_name = "energy-ram",
1246 .perf_name = "energy-gpu",
1298 .perf_name = "energy-psys",
1362 .perf_name = "c1-residency",
1372 .perf_name = "c3-residency",
1382 .perf_name = "c6-residency",
1392 .perf_name = "c7-residency",
1402 .perf_name = "c2-residency",
1412 .perf_name = "c3-residency",
1422 .perf_name = "c6-residency",
1432 .perf_name = "c7-residency",
1442 .perf_name = "c8-residency",
1452 .perf_name = "c9-residency",
1462 .perf_name = "c10-residency",
1598 /* BIC-like metadata */
1620 return sscanf(e->d_name, "telem%u", &dummy); in pmt_telemdir_filter()
1627 sscanf((*a)->d_name, "telem%u", &aidx); in pmt_telemdir_sort()
1628 sscanf((*b)->d_name, "telem%u", &bidx); in pmt_telemdir_sort()
1637 if (!iter->dir) in pmt_diriter_next()
1640 if (iter->current_name_idx >= iter->num_names) in pmt_diriter_next()
1643 ret = iter->namelist[iter->current_name_idx]; in pmt_diriter_next()
1644 ++iter->current_name_idx; in pmt_diriter_next()
1651 int num_names = iter->num_names; in pmt_diriter_begin()
1653 if (!iter->dir) { in pmt_diriter_begin()
1654 iter->dir = opendir(pmt_root_path); in pmt_diriter_begin()
1655 if (iter->dir == NULL) in pmt_diriter_begin()
1658 num_names = scandir(pmt_root_path, &iter->namelist, pmt_telemdir_filter, pmt_telemdir_sort); in pmt_diriter_begin()
1659 if (num_names == -1) in pmt_diriter_begin()
1663 iter->current_name_idx = 0; in pmt_diriter_begin()
1664 iter->num_names = num_names; in pmt_diriter_begin()
1676 if (iter->namelist) { in pmt_diriter_remove()
1677 for (unsigned int i = 0; i < iter->num_names; i++) { in pmt_diriter_remove()
1678 free(iter->namelist[i]); in pmt_diriter_remove()
1679 iter->namelist[i] = NULL; in pmt_diriter_remove()
1683 free(iter->namelist); in pmt_diriter_remove()
1684 iter->namelist = NULL; in pmt_diriter_remove()
1685 iter->num_names = 0; in pmt_diriter_remove()
1686 iter->current_name_idx = 0; in pmt_diriter_remove()
1688 closedir(iter->dir); in pmt_diriter_remove()
1689 iter->dir = NULL; in pmt_diriter_remove()
1694 return (p->msb - p->lsb) + 1; in pmt_counter_get_width()
1701 …new_mem = (struct pmt_domain_info *)reallocarray(pcounter->domains, new_size, sizeof(*pcounter->do… in pmt_counter_resize_()
1708 const size_t num_new_domains = new_size - pcounter->num_domains; in pmt_counter_resize_()
1710 memset(&new_mem[pcounter->num_domains], 0, num_new_domains * sizeof(*pcounter->domains)); in pmt_counter_resize_()
1712 pcounter->num_domains = new_size; in pmt_counter_resize_()
1713 pcounter->domains = new_mem; in pmt_counter_resize_()
1726 new_size = MAX(new_size, pcounter->num_domains * 2); in pmt_counter_resize()
1758 unsigned long long mc6_us; /* duplicate as per-core for now, even though per module */
1842 /* get_msr_sum() = sum + (get_msr() - last) */
1860 if (platform->rapl_msrs & RAPL_AMD_F17H) in idx_to_offset()
1884 offset = -1; in idx_to_offset()
1917 idx = -1; in offset_to_idx()
1926 return platform->rapl_msrs & (RAPL_PKG | RAPL_AMD_F17H); in idx_valid()
1928 return platform->rapl_msrs & RAPL_DRAM; in idx_valid()
1930 return platform->rapl_msrs & RAPL_CORE_ENERGY_STATUS; in idx_valid()
1932 return platform->rapl_msrs & RAPL_GFX; in idx_valid()
1934 return platform->rapl_msrs & RAPL_PKG_PERF_STATUS; in idx_valid()
1936 return platform->rapl_msrs & RAPL_DRAM_PERF_STATUS; in idx_valid()
1938 return platform->rapl_msrs & RAPL_PSYS; in idx_valid()
1974 if (p->msr_num != 0) { in free_msr_counters_()
1975 *pp = p->next; in free_msr_counters_()
1983 pp = &p->next; in free_msr_counters_()
1995 sys.added_thread_counters -= free_msr_counters_(&sys.tp); in free_sys_msr_counters()
1998 sys.added_core_counters -= free_msr_counters_(&sys.cp); in free_sys_msr_counters()
2001 sys.added_package_counters -= free_msr_counters_(&sys.pp); in free_sys_msr_counters()
2019 int logical_node_id; /* 0-based count within the package */
2068 * skip non-present cpus
2087 if (cpu_is_not_allowed(t->cpu_id)) in for_all_cpus()
2105 return ((int)t->cpu_id == c->base_cpu || c->base_cpu < 0); in is_cpu_first_thread_in_core()
2112 return ((int)t->cpu_id == p->base_cpu || p->base_cpu < 0); in is_cpu_first_core_in_package()
2124 if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) in cpu_migrate()
2125 return -1; in cpu_migrate()
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()
2171 const pid_t pid = -1; in open_perf_counter()
2195 …_count_percpu[cpu] = open_perf_counter(cpu, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, -1, 0); in get_instr_count_fd()
2209 err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset); in get_msr()
2245 switch (pc->scope) { in cpu_to_domain()
2266 * HIDE_LIST - hide this list of counters, show the rest [default]
2267 * SHOW_LIST - show this list of counters, hide the rest
2274 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" in help()
2278 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" in help()
2280 " -a, --add counter\n" in help()
2282 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" in help()
2283 " eg. --add perf/cstate_pkg/c2-residency,package,delta,percent,perfPC2\n" in help()
2284 " eg. --add pmt,name=XTAL,type=raw,domain=package0,offset=0,lsb=0,msb=63,guid=0x1a067102\n" in help()
2285 " -c, --cpu cpu-set\n" in help()
2286 " limit output to summary plus cpu-set:\n" in help()
2287 " {core | package | j,k,l..m,n-p }\n" in help()
2288 " -d, --debug\n" in help()
2291 " -D, --Dump\n" in help()
2293 " -e, --enable [all | column]\n" in help()
2295 " -f, --force\n" in help()
2297 " -H, --hide [column | column,column,...]\n" in help()
2299 " -i, --interval sec.subsec\n" in help()
2300 " override default 5-second measurement interval\n" in help()
2301 " -J, --Joules\n" in help()
2303 " -l, --list\n" in help()
2305 " -M, --no-msr\n" in help()
2307 " -P, --no-perf\n" in help()
2309 " -n, --num_iterations num\n" in help()
2311 " -N, --header_iterations num\n" in help()
2313 " -o, --out file\n" in help()
2315 " -q, --quiet\n" in help()
2317 " -s, --show [column | column,column,...]\n" in help()
2319 " -S, --Summary\n" in help()
2320 " limits output to 1-line system summary per interval\n" in help()
2321 " -T, --TCC temperature\n" in help()
2324 " -h, --help\n" in help()
2326 " -v, --version\n" in help()
2378 fprintf(stderr, "More than max %d un-recognized --add options '%s'\n", in bic_lookup()
2388 fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n", in bic_lookup()
2457 for (mp = sys.tp; mp; mp = mp->next) { in print_header()
2459 if (mp->format == FORMAT_RAW) { in print_header()
2460 if (mp->width == 64) in print_header()
2461 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name); in print_header()
2463 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), mp->name); in print_header()
2465 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2466 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), mp->name); in print_header()
2468 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), mp->name); in print_header()
2472 for (pp = sys.perf_tp; pp; pp = pp->next) { in print_header()
2474 if (pp->format == FORMAT_RAW) { in print_header()
2475 if (pp->width == 64) in print_header()
2476 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), pp->name); in print_header()
2478 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), pp->name); in print_header()
2480 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2481 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), pp->name); in print_header()
2483 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), pp->name); in print_header()
2489 switch (ppmt->type) { in print_header()
2492 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), ppmt->name); in print_header()
2494 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), ppmt->name); in print_header()
2500 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name); in print_header()
2504 ppmt = ppmt->next; in print_header()
2525 if (platform->rapl_msrs && !rapl_joules) { in print_header()
2526 if (DO_BIC(BIC_CorWatt) && platform->has_per_core_rapl) in print_header()
2528 } else if (platform->rapl_msrs && rapl_joules) { in print_header()
2529 if (DO_BIC(BIC_Cor_J) && platform->has_per_core_rapl) in print_header()
2533 for (mp = sys.cp; mp; mp = mp->next) { in print_header()
2534 if (mp->format == FORMAT_RAW) { in print_header()
2535 if (mp->width == 64) in print_header()
2536 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
2538 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
2540 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2541 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
2543 outp += sprintf(outp, "%s%s", delim, mp->name); in print_header()
2547 for (pp = sys.perf_cp; pp; pp = pp->next) { in print_header()
2549 if (pp->format == FORMAT_RAW) { in print_header()
2550 if (pp->width == 64) in print_header()
2551 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), pp->name); in print_header()
2553 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), pp->name); in print_header()
2555 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2556 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), pp->name); in print_header()
2558 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), pp->name); in print_header()
2564 switch (ppmt->type) { in print_header()
2567 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), ppmt->name); in print_header()
2569 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), ppmt->name); in print_header()
2575 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name); in print_header()
2579 ppmt = ppmt->next; in print_header()
2633 if (platform->rapl_msrs && !rapl_joules) { in print_header()
2636 if (DO_BIC(BIC_CorWatt) && !platform->has_per_core_rapl) in print_header()
2646 } else if (platform->rapl_msrs && rapl_joules) { in print_header()
2649 if (DO_BIC(BIC_Cor_J) && !platform->has_per_core_rapl) in print_header()
2663 for (mp = sys.pp; mp; mp = mp->next) { in print_header()
2664 if (mp->format == FORMAT_RAW) { in print_header()
2665 if (mp->width == 64) in print_header()
2666 outp += sprintf(outp, "%s%18.18s", delim, mp->name); in print_header()
2667 else if (mp->width == 32) in print_header()
2668 outp += sprintf(outp, "%s%10.10s", delim, mp->name); in print_header()
2670 outp += sprintf(outp, "%s%7.7s", delim, mp->name); in print_header()
2672 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2673 outp += sprintf(outp, "%s%8s", delim, mp->name); in print_header()
2675 outp += sprintf(outp, "%s%7.7s", delim, mp->name); in print_header()
2679 for (pp = sys.perf_pp; pp; pp = pp->next) { in print_header()
2681 if (pp->format == FORMAT_RAW) { in print_header()
2682 if (pp->width == 64) in print_header()
2683 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), pp->name); in print_header()
2685 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), pp->name); in print_header()
2687 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in print_header()
2688 outp += sprintf(outp, "%s%8s", (printed++ ? delim : ""), pp->name); in print_header()
2690 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), pp->name); in print_header()
2696 switch (ppmt->type) { in print_header()
2699 outp += sprintf(outp, "%s%10.10s", (printed++ ? delim : ""), ppmt->name); in print_header()
2701 outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), ppmt->name); in print_header()
2707 outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name); in print_header()
2711 ppmt = ppmt->next; in print_header()
2731 outp += sprintf(outp, "CPU: %d flags 0x%x\n", t->cpu_id, t->flags); in dump_counters()
2732 outp += sprintf(outp, "TSC: %016llX\n", t->tsc); in dump_counters()
2733 outp += sprintf(outp, "aperf: %016llX\n", t->aperf); in dump_counters()
2734 outp += sprintf(outp, "mperf: %016llX\n", t->mperf); in dump_counters()
2735 outp += sprintf(outp, "c1: %016llX\n", t->c1); in dump_counters()
2738 outp += sprintf(outp, "IPC: %lld\n", t->instr_count); in dump_counters()
2741 outp += sprintf(outp, "IRQ: %lld\n", t->irq_count); in dump_counters()
2743 outp += sprintf(outp, "IRQ: %lld\n", t->nmi_count); in dump_counters()
2745 outp += sprintf(outp, "SMI: %d\n", t->smi_count); in dump_counters()
2747 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in dump_counters()
2749 sprintf(outp, "tADDED [%d] %8s msr0x%x: %08llX %s\n", i, mp->name, mp->msr_num, in dump_counters()
2750 t->counter[i], mp->sp->path); in dump_counters()
2755 outp += sprintf(outp, "core: %d\n", c->core_id); in dump_counters()
2756 outp += sprintf(outp, "c3: %016llX\n", c->c3); in dump_counters()
2757 outp += sprintf(outp, "c6: %016llX\n", c->c6); in dump_counters()
2758 outp += sprintf(outp, "c7: %016llX\n", c->c7); in dump_counters()
2759 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); in dump_counters()
2760 outp += sprintf(outp, "cpu_throt_count: %016llX\n", c->core_throt_cnt); in dump_counters()
2762 const unsigned long long energy_value = c->core_energy.raw_value * c->core_energy.scale; in dump_counters()
2763 const double energy_scale = c->core_energy.scale; in dump_counters()
2765 if (c->core_energy.unit == RAPL_UNIT_JOULES) in dump_counters()
2768 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in dump_counters()
2770 sprintf(outp, "cADDED [%d] %8s msr0x%x: %08llX %s\n", i, mp->name, mp->msr_num, in dump_counters()
2771 c->counter[i], mp->sp->path); in dump_counters()
2773 outp += sprintf(outp, "mc6_us: %016llX\n", c->mc6_us); in dump_counters()
2777 outp += sprintf(outp, "package: %d\n", p->package_id); in dump_counters()
2779 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); in dump_counters()
2780 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); in dump_counters()
2781 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); in dump_counters()
2782 outp += sprintf(outp, "CPU + GFX: %016llX\n", p->pkg_both_core_gfxe_c0); in dump_counters()
2784 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); in dump_counters()
2786 outp += sprintf(outp, "pc3: %016llX\n", p->pc3); in dump_counters()
2788 outp += sprintf(outp, "pc6: %016llX\n", p->pc6); in dump_counters()
2790 outp += sprintf(outp, "pc7: %016llX\n", p->pc7); in dump_counters()
2791 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); in dump_counters()
2792 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); in dump_counters()
2793 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); in dump_counters()
2794 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi); in dump_counters()
2795 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi); in dump_counters()
2796 outp += sprintf(outp, "Joules PKG: %0llX\n", p->energy_pkg.raw_value); in dump_counters()
2797 outp += sprintf(outp, "Joules COR: %0llX\n", p->energy_cores.raw_value); in dump_counters()
2798 outp += sprintf(outp, "Joules GFX: %0llX\n", p->energy_gfx.raw_value); in dump_counters()
2799 outp += sprintf(outp, "Joules RAM: %0llX\n", p->energy_dram.raw_value); in dump_counters()
2800 outp += sprintf(outp, "Joules PSYS: %0llX\n", pplat_cnt->energy_psys.raw_value); in dump_counters()
2801 outp += sprintf(outp, "Throttle PKG: %0llX\n", p->rapl_pkg_perf_status.raw_value); in dump_counters()
2802 outp += sprintf(outp, "Throttle RAM: %0llX\n", p->rapl_dram_perf_status.raw_value); in dump_counters()
2803 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c); in dump_counters()
2805 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in dump_counters()
2807 sprintf(outp, "pADDED [%d] %8s msr0x%x: %08llX %s\n", i, mp->name, mp->msr_num, in dump_counters()
2808 p->counter[i], mp->sp->path); in dump_counters()
2825 assert(c->unit == RAPL_UNIT_JOULES); in rapl_counter_get_value()
2827 const double scaled = c->raw_value * c->scale; in rapl_counter_get_value()
2864 /*if not summary line and --cpu is used */ in format_counters()
2865 …if ((t != &average.threads) && (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset)… in format_counters()
2872 timersub(&t->tv_end, &t->tv_begin, &tv); in format_counters()
2878 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec); in format_counters()
2880 interval_float = t->tv_delta.tv_sec + t->tv_delta.tv_usec / 1000000.0; in format_counters()
2882 tsc = t->tsc * tsc_tweak; in format_counters()
2887 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2889 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2891 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2893 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2895 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2897 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2899 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2903 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); in format_counters()
2905 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2909 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].die_id); in format_counters()
2911 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2916 (printed++ ? delim : ""), cpus[t->cpu_id].physical_node_id); in format_counters()
2918 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2922 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); in format_counters()
2924 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); in format_counters()
2927 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); in format_counters()
2929 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id); in format_counters()
2931 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id); in format_counters()
2935 …outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 / units * t->aperf / interval_float); in format_counters()
2938 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->mperf / tsc); in format_counters()
2943 sprintf(outp, "%s%.0f", (printed++ ? delim : ""), base_hz / units * t->aperf / t->mperf); in format_counters()
2946 tsc / units * t->aperf / t->mperf / interval_float); in format_counters()
2950 outp += sprintf(outp, "%s%.0f", (printed++ ? delim : ""), 1.0 * t->tsc / units / interval_float); in format_counters()
2953 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 1.0 * t->instr_count / t->aperf); in format_counters()
2958 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
2960 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->irq_count); in format_counters()
2966 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->nmi_count); in format_counters()
2968 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->nmi_count); in format_counters()
2973 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->smi_count); in format_counters()
2976 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in format_counters()
2977 if (mp->format == FORMAT_RAW) { in format_counters()
2978 if (mp->width == 32) in format_counters()
2980 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)t->counter[i]); in format_counters()
2982 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); in format_counters()
2983 } else if (mp->format == FORMAT_DELTA) { in format_counters()
2984 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
2985 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
2987 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->counter[i]); in format_counters()
2988 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
2989 if (mp->type == COUNTER_USEC) in format_counters()
2992 t->counter[i] / interval_float / 10000); in format_counters()
2994 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->counter[i] / tsc); in format_counters()
2999 for (i = 0, pp = sys.perf_tp; pp; ++i, pp = pp->next) { in format_counters()
3000 if (pp->format == FORMAT_RAW) { in format_counters()
3001 if (pp->width == 32) in format_counters()
3004 (unsigned int)t->perf_counter[i]); in format_counters()
3006 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->perf_counter[i]); in format_counters()
3007 } else if (pp->format == FORMAT_DELTA) { in format_counters()
3008 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
3009 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), t->perf_counter[i]); in format_counters()
3011 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), t->perf_counter[i]); in format_counters()
3012 } else if (pp->format == FORMAT_PERCENT) { in format_counters()
3013 if (pp->type == COUNTER_USEC) in format_counters()
3016 t->perf_counter[i] / interval_float / 10000); in format_counters()
3019 sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->perf_counter[i] / tsc); in format_counters()
3023 for (i = 0, ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) { in format_counters()
3024 const unsigned long value_raw = t->pmt_counter[i]; in format_counters()
3026 switch (ppmt->type) { in format_counters()
3030 (unsigned int)t->pmt_counter[i]); in format_counters()
3032 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->pmt_counter[i]); in format_counters()
3049 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * t->c1 / tsc); in format_counters()
3051 /* print per-core data only for 1st thread in core */ in format_counters()
3056 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3 / tsc); in format_counters()
3058 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6 / tsc); in format_counters()
3060 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c7 / tsc); in format_counters()
3064 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->mc6_us / tsc); in format_counters()
3067 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_temp_c); in format_counters()
3071 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->core_throt_cnt); in format_counters()
3073 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in format_counters()
3074 if (mp->format == FORMAT_RAW) { in format_counters()
3075 if (mp->width == 32) in format_counters()
3077 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)c->counter[i]); in format_counters()
3079 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); in format_counters()
3080 } else if (mp->format == FORMAT_DELTA) { in format_counters()
3081 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
3082 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
3084 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->counter[i]); in format_counters()
3085 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
3086 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->counter[i] / tsc); in format_counters()
3090 for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { in format_counters()
3091 if (pp->format == FORMAT_RAW) { in format_counters()
3092 if (pp->width == 32) in format_counters()
3095 (unsigned int)c->perf_counter[i]); in format_counters()
3097 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->perf_counter[i]); in format_counters()
3098 } else if (pp->format == FORMAT_DELTA) { in format_counters()
3099 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
3100 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), c->perf_counter[i]); in format_counters()
3102 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->perf_counter[i]); in format_counters()
3103 } else if (pp->format == FORMAT_PERCENT) { in format_counters()
3104 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->perf_counter[i] / tsc); in format_counters()
3108 for (i = 0, ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) { in format_counters()
3109 const unsigned long value_raw = c->pmt_counter[i]; in format_counters()
3111 switch (ppmt->type) { in format_counters()
3115 (unsigned int)c->pmt_counter[i]); in format_counters()
3117 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->pmt_counter[i]); in format_counters()
3134 if (DO_BIC(BIC_CorWatt) && platform->has_per_core_rapl) in format_counters()
3137 rapl_counter_get_value(&c->core_energy, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3138 if (DO_BIC(BIC_Cor_J) && platform->has_per_core_rapl) in format_counters()
3140 rapl_counter_get_value(&c->core_energy, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3142 /* print per-package data only for 1st core in package */ in format_counters()
3148 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->pkg_temp_c); in format_counters()
3152 if (p->gfx_rc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
3156 p->gfx_rc6_ms / 10.0 / interval_float); in format_counters()
3162 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_mhz); in format_counters()
3166 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->gfx_act_mhz); in format_counters()
3170 if (p->sam_mc6_ms == -1) { /* detect GFX counter reset */ in format_counters()
3174 p->sam_mc6_ms / 10.0 / interval_float); in format_counters()
3180 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->sam_mhz); in format_counters()
3184 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->sam_act_mhz); in format_counters()
3188 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_wtd_core_c0 / tsc); in format_counters()
3190 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_core_c0 / tsc); in format_counters()
3192 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_any_gfxe_c0 / tsc); in format_counters()
3194 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pkg_both_core_gfxe_c0 / tsc); in format_counters()
3197 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc2 / tsc); in format_counters()
3199 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc3 / tsc); in format_counters()
3201 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc6 / tsc); in format_counters()
3203 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc7 / tsc); in format_counters()
3205 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc8 / tsc); in format_counters()
3207 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc9 / tsc); in format_counters()
3209 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10 / tsc); in format_counters()
3213 …sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->die_c6 / crystal_hz / interval_float); in format_counters()
3216 if (p->cpu_lpi >= 0) in format_counters()
3219 100.0 * p->cpu_lpi / 1000000.0 / interval_float); in format_counters()
3224 if (p->sys_lpi >= 0) in format_counters()
3227 100.0 * p->sys_lpi / 1000000.0 / interval_float); in format_counters()
3235 rapl_counter_get_value(&p->energy_pkg, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3236 if (DO_BIC(BIC_CorWatt) && !platform->has_per_core_rapl) in format_counters()
3239 rapl_counter_get_value(&p->energy_cores, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3243 rapl_counter_get_value(&p->energy_gfx, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3247 rapl_counter_get_value(&p->energy_dram, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3250 rapl_counter_get_value(&p->energy_pkg, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3251 if (DO_BIC(BIC_Cor_J) && !platform->has_per_core_rapl) in format_counters()
3253 rapl_counter_get_value(&p->energy_cores, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3256 rapl_counter_get_value(&p->energy_gfx, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3259 rapl_counter_get_value(&p->energy_dram, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3263 rapl_counter_get_value(&p->rapl_pkg_perf_status, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3267 rapl_counter_get_value(&p->rapl_dram_perf_status, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3270 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->uncore_mhz); in format_counters()
3272 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in format_counters()
3273 if (mp->format == FORMAT_RAW) { in format_counters()
3274 if (mp->width == 32) in format_counters()
3276 sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)p->counter[i]); in format_counters()
3278 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); in format_counters()
3279 } else if (mp->format == FORMAT_DELTA) { in format_counters()
3280 if ((mp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
3281 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
3283 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->counter[i]); in format_counters()
3284 } else if (mp->format == FORMAT_PERCENT) { in format_counters()
3285 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->counter[i] / tsc); in format_counters()
3286 } else if (mp->type == COUNTER_K2M) in format_counters()
3287 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), (unsigned int)p->counter[i] / 1000); in format_counters()
3290 for (i = 0, pp = sys.perf_pp; pp; i++, pp = pp->next) { in format_counters()
3291 if (pp->format == FORMAT_RAW) { in format_counters()
3292 if (pp->width == 32) in format_counters()
3295 (unsigned int)p->perf_counter[i]); in format_counters()
3297 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->perf_counter[i]); in format_counters()
3298 } else if (pp->format == FORMAT_DELTA) { in format_counters()
3299 if ((pp->type == COUNTER_ITEMS) && sums_need_wide_columns) in format_counters()
3300 outp += sprintf(outp, "%s%8lld", (printed++ ? delim : ""), p->perf_counter[i]); in format_counters()
3302 outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), p->perf_counter[i]); in format_counters()
3303 } else if (pp->format == FORMAT_PERCENT) { in format_counters()
3304 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->perf_counter[i] / tsc); in format_counters()
3305 } else if (pp->type == COUNTER_K2M) { in format_counters()
3307 sprintf(outp, "%s%d", (printed++ ? delim : ""), (unsigned int)p->perf_counter[i] / 1000); in format_counters()
3311 for (i = 0, ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) { in format_counters()
3312 const unsigned long value_raw = p->pmt_counter[i]; in format_counters()
3314 switch (ppmt->type) { in format_counters()
3318 (unsigned int)p->pmt_counter[i]); in format_counters()
3320 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->pmt_counter[i]); in format_counters()
3337 rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_WATTS, interval_float)); in format_counters()
3340 rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_JOULES, interval_float)); in format_counters()
3343 if (*(outp - 1) != '\n') in format_counters()
3389 old = ((((unsigned long long)new << 32) - ((unsigned long long)old << 32)) >> 32);
3399 old->pkg_wtd_core_c0 = new->pkg_wtd_core_c0 - old->pkg_wtd_core_c0; in delta_package()
3401 old->pkg_any_core_c0 = new->pkg_any_core_c0 - old->pkg_any_core_c0; in delta_package()
3403 old->pkg_any_gfxe_c0 = new->pkg_any_gfxe_c0 - old->pkg_any_gfxe_c0; in delta_package()
3405 old->pkg_both_core_gfxe_c0 = new->pkg_both_core_gfxe_c0 - old->pkg_both_core_gfxe_c0; in delta_package()
3407 old->pc2 = new->pc2 - old->pc2; in delta_package()
3409 old->pc3 = new->pc3 - old->pc3; in delta_package()
3411 old->pc6 = new->pc6 - old->pc6; in delta_package()
3413 old->pc7 = new->pc7 - old->pc7; in delta_package()
3414 old->pc8 = new->pc8 - old->pc8; in delta_package()
3415 old->pc9 = new->pc9 - old->pc9; in delta_package()
3416 old->pc10 = new->pc10 - old->pc10; in delta_package()
3417 old->die_c6 = new->die_c6 - old->die_c6; in delta_package()
3418 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi; in delta_package()
3419 old->sys_lpi = new->sys_lpi - old->sys_lpi; in delta_package()
3420 old->pkg_temp_c = new->pkg_temp_c; in delta_package()
3423 if (old->gfx_rc6_ms > new->gfx_rc6_ms) in delta_package()
3424 old->gfx_rc6_ms = -1; in delta_package()
3426 old->gfx_rc6_ms = new->gfx_rc6_ms - old->gfx_rc6_ms; in delta_package()
3428 old->uncore_mhz = new->uncore_mhz; in delta_package()
3429 old->gfx_mhz = new->gfx_mhz; in delta_package()
3430 old->gfx_act_mhz = new->gfx_act_mhz; in delta_package()
3433 if (old->sam_mc6_ms > new->sam_mc6_ms) in delta_package()
3434 old->sam_mc6_ms = -1; in delta_package()
3436 old->sam_mc6_ms = new->sam_mc6_ms - old->sam_mc6_ms; in delta_package()
3438 old->sam_mhz = new->sam_mhz; in delta_package()
3439 old->sam_act_mhz = new->sam_act_mhz; in delta_package()
3441 old->energy_pkg.raw_value = new->energy_pkg.raw_value - old->energy_pkg.raw_value; in delta_package()
3442 old->energy_cores.raw_value = new->energy_cores.raw_value - old->energy_cores.raw_value; in delta_package()
3443 old->energy_gfx.raw_value = new->energy_gfx.raw_value - old->energy_gfx.raw_value; in delta_package()
3444 old->energy_dram.raw_value = new->energy_dram.raw_value - old->energy_dram.raw_value; in delta_package()
3445 …old->rapl_pkg_perf_status.raw_value = new->rapl_pkg_perf_status.raw_value - old->rapl_pkg_perf_sta… in delta_package()
3446 old->rapl_dram_perf_status.raw_value = in delta_package()
3447 new->rapl_dram_perf_status.raw_value - old->rapl_dram_perf_status.raw_value; in delta_package()
3449 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in delta_package()
3450 if (mp->format == FORMAT_RAW) in delta_package()
3451 old->counter[i] = new->counter[i]; in delta_package()
3452 else if (mp->format == FORMAT_AVERAGE) in delta_package()
3453 old->counter[i] = new->counter[i]; in delta_package()
3455 old->counter[i] = new->counter[i] - old->counter[i]; in delta_package()
3458 for (i = 0, pp = sys.perf_pp; pp; i++, pp = pp->next) { in delta_package()
3459 if (pp->format == FORMAT_RAW) in delta_package()
3460 old->perf_counter[i] = new->perf_counter[i]; in delta_package()
3461 else if (pp->format == FORMAT_AVERAGE) in delta_package()
3462 old->perf_counter[i] = new->perf_counter[i]; in delta_package()
3464 old->perf_counter[i] = new->perf_counter[i] - old->perf_counter[i]; in delta_package()
3467 for (i = 0, ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) { in delta_package()
3468 if (ppmt->format == FORMAT_RAW) in delta_package()
3469 old->pmt_counter[i] = new->pmt_counter[i]; in delta_package()
3471 old->pmt_counter[i] = new->pmt_counter[i] - old->pmt_counter[i]; in delta_package()
3484 old->c3 = new->c3 - old->c3; in delta_core()
3485 old->c6 = new->c6 - old->c6; in delta_core()
3486 old->c7 = new->c7 - old->c7; in delta_core()
3487 old->core_temp_c = new->core_temp_c; in delta_core()
3488 old->core_throt_cnt = new->core_throt_cnt - old->core_throt_cnt; in delta_core()
3489 old->mc6_us = new->mc6_us - old->mc6_us; in delta_core()
3491 DELTA_WRAP32(new->core_energy.raw_value, old->core_energy.raw_value); in delta_core()
3493 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in delta_core()
3494 if (mp->format == FORMAT_RAW) in delta_core()
3495 old->counter[i] = new->counter[i]; in delta_core()
3497 old->counter[i] = new->counter[i] - old->counter[i]; in delta_core()
3500 for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { in delta_core()
3501 if (pp->format == FORMAT_RAW) in delta_core()
3502 old->perf_counter[i] = new->perf_counter[i]; in delta_core()
3504 old->perf_counter[i] = new->perf_counter[i] - old->perf_counter[i]; in delta_core()
3507 for (i = 0, ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) { in delta_core()
3508 if (ppmt->format == FORMAT_RAW) in delta_core()
3509 old->pmt_counter[i] = new->pmt_counter[i]; in delta_core()
3511 old->pmt_counter[i] = new->pmt_counter[i] - old->pmt_counter[i]; in delta_core()
3517 if (!DO_BIC(BIC_CPU_c1) || platform->has_msr_core_c1_res) in soft_c1_residency_display()
3524 * old = new - old
3535 new->apic_id = old->apic_id; in delta_thread()
3537 new->x2apic_id = old->x2apic_id; in delta_thread()
3542 * over-write old w/ new so we can print end of interval values in delta_thread()
3545 timersub(&new->tv_begin, &old->tv_begin, &old->tv_delta); in delta_thread()
3546 old->tv_begin = new->tv_begin; in delta_thread()
3547 old->tv_end = new->tv_end; in delta_thread()
3549 old->tsc = new->tsc - old->tsc; in delta_thread()
3552 if (old->tsc < (1000 * 1000)) in delta_thread()
3553 errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n" in delta_thread()
3554 "You can disable all c-states by booting with \"idle=poll\"\n" in delta_thread()
3557 old->c1 = new->c1 - old->c1; in delta_thread()
3561 if ((new->aperf > old->aperf) && (new->mperf > old->mperf)) { in delta_thread()
3562 old->aperf = new->aperf - old->aperf; in delta_thread()
3563 old->mperf = new->mperf - old->mperf; in delta_thread()
3565 return -1; in delta_thread()
3569 if (platform->has_msr_core_c1_res) { in delta_thread()
3577 * it is possible for mperf's non-halted cycles + idle states in delta_thread()
3580 if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) in delta_thread()
3581 old->c1 = 0; in delta_thread()
3584 old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 in delta_thread()
3585 - core_delta->c6 - core_delta->c7; in delta_thread()
3589 if (old->mperf == 0) { in delta_thread()
3591 fprintf(outf, "cpu%d MPERF 0!\n", old->cpu_id); in delta_thread()
3592 old->mperf = 1; /* divide by 0 protection */ in delta_thread()
3596 old->instr_count = new->instr_count - old->instr_count; in delta_thread()
3599 old->irq_count = new->irq_count - old->irq_count; in delta_thread()
3602 old->nmi_count = new->nmi_count - old->nmi_count; in delta_thread()
3605 old->smi_count = new->smi_count - old->smi_count; in delta_thread()
3607 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in delta_thread()
3608 if (mp->format == FORMAT_RAW) in delta_thread()
3609 old->counter[i] = new->counter[i]; in delta_thread()
3611 old->counter[i] = new->counter[i] - old->counter[i]; in delta_thread()
3614 for (i = 0, pp = sys.perf_tp; pp; i++, pp = pp->next) { in delta_thread()
3615 if (pp->format == FORMAT_RAW) in delta_thread()
3616 old->perf_counter[i] = new->perf_counter[i]; in delta_thread()
3618 old->perf_counter[i] = new->perf_counter[i] - old->perf_counter[i]; in delta_thread()
3621 for (i = 0, ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) { in delta_thread()
3622 if (ppmt->format == FORMAT_RAW) in delta_thread()
3623 old->pmt_counter[i] = new->pmt_counter[i]; in delta_thread()
3625 old->pmt_counter[i] = new->pmt_counter[i] - old->pmt_counter[i]; in delta_thread()
3652 old->energy_psys.raw_value = new->energy_psys.raw_value - old->energy_psys.raw_value; in delta_platform()
3657 c->raw_value = 0; in rapl_counter_clear()
3658 c->scale = 0.0; in rapl_counter_clear()
3659 c->unit = RAPL_UNIT_INVALID; in rapl_counter_clear()
3667 t->tv_begin.tv_sec = 0; in clear_counters()
3668 t->tv_begin.tv_usec = 0; in clear_counters()
3669 t->tv_end.tv_sec = 0; in clear_counters()
3670 t->tv_end.tv_usec = 0; in clear_counters()
3671 t->tv_delta.tv_sec = 0; in clear_counters()
3672 t->tv_delta.tv_usec = 0; in clear_counters()
3674 t->tsc = 0; in clear_counters()
3675 t->aperf = 0; in clear_counters()
3676 t->mperf = 0; in clear_counters()
3677 t->c1 = 0; in clear_counters()
3679 t->instr_count = 0; in clear_counters()
3681 t->irq_count = 0; in clear_counters()
3682 t->nmi_count = 0; in clear_counters()
3683 t->smi_count = 0; in clear_counters()
3685 c->c3 = 0; in clear_counters()
3686 c->c6 = 0; in clear_counters()
3687 c->c7 = 0; in clear_counters()
3688 c->mc6_us = 0; in clear_counters()
3689 c->core_temp_c = 0; in clear_counters()
3690 rapl_counter_clear(&c->core_energy); in clear_counters()
3691 c->core_throt_cnt = 0; in clear_counters()
3693 p->pkg_wtd_core_c0 = 0; in clear_counters()
3694 p->pkg_any_core_c0 = 0; in clear_counters()
3695 p->pkg_any_gfxe_c0 = 0; in clear_counters()
3696 p->pkg_both_core_gfxe_c0 = 0; in clear_counters()
3698 p->pc2 = 0; in clear_counters()
3700 p->pc3 = 0; in clear_counters()
3702 p->pc6 = 0; in clear_counters()
3704 p->pc7 = 0; in clear_counters()
3705 p->pc8 = 0; in clear_counters()
3706 p->pc9 = 0; in clear_counters()
3707 p->pc10 = 0; in clear_counters()
3708 p->die_c6 = 0; in clear_counters()
3709 p->cpu_lpi = 0; in clear_counters()
3710 p->sys_lpi = 0; in clear_counters()
3712 rapl_counter_clear(&p->energy_pkg); in clear_counters()
3713 rapl_counter_clear(&p->energy_dram); in clear_counters()
3714 rapl_counter_clear(&p->energy_cores); in clear_counters()
3715 rapl_counter_clear(&p->energy_gfx); in clear_counters()
3716 rapl_counter_clear(&p->rapl_pkg_perf_status); in clear_counters()
3717 rapl_counter_clear(&p->rapl_dram_perf_status); in clear_counters()
3718 p->pkg_temp_c = 0; in clear_counters()
3720 p->gfx_rc6_ms = 0; in clear_counters()
3721 p->uncore_mhz = 0; in clear_counters()
3722 p->gfx_mhz = 0; in clear_counters()
3723 p->gfx_act_mhz = 0; in clear_counters()
3724 p->sam_mc6_ms = 0; in clear_counters()
3725 p->sam_mhz = 0; in clear_counters()
3726 p->sam_act_mhz = 0; in clear_counters()
3727 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) in clear_counters()
3728 t->counter[i] = 0; in clear_counters()
3730 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) in clear_counters()
3731 c->counter[i] = 0; in clear_counters()
3733 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) in clear_counters()
3734 p->counter[i] = 0; in clear_counters()
3736 memset(&t->perf_counter[0], 0, sizeof(t->perf_counter)); in clear_counters()
3737 memset(&c->perf_counter[0], 0, sizeof(c->perf_counter)); in clear_counters()
3738 memset(&p->perf_counter[0], 0, sizeof(p->perf_counter)); in clear_counters()
3740 memset(&t->pmt_counter[0], 0, ARRAY_SIZE(t->pmt_counter)); in clear_counters()
3741 memset(&c->pmt_counter[0], 0, ARRAY_SIZE(c->pmt_counter)); in clear_counters()
3742 memset(&p->pmt_counter[0], 0, ARRAY_SIZE(p->pmt_counter)); in clear_counters()
3748 if (dst->unit == RAPL_UNIT_INVALID) { in rapl_counter_accumulate()
3749 dst->unit = src->unit; in rapl_counter_accumulate()
3750 dst->scale = src->scale; in rapl_counter_accumulate()
3753 assert(dst->unit == src->unit); in rapl_counter_accumulate()
3754 assert(dst->scale == src->scale); in rapl_counter_accumulate()
3756 dst->raw_value += src->raw_value; in rapl_counter_accumulate()
3766 /* copy un-changing apic_id's */ in sum_counters()
3768 average.threads.apic_id = t->apic_id; in sum_counters()
3770 average.threads.x2apic_id = t->x2apic_id; in sum_counters()
3777 average.threads.tv_end = t->tv_end; in sum_counters()
3779 average.threads.tsc += t->tsc; in sum_counters()
3780 average.threads.aperf += t->aperf; in sum_counters()
3781 average.threads.mperf += t->mperf; in sum_counters()
3782 average.threads.c1 += t->c1; in sum_counters()
3784 average.threads.instr_count += t->instr_count; in sum_counters()
3786 average.threads.irq_count += t->irq_count; in sum_counters()
3787 average.threads.nmi_count += t->nmi_count; in sum_counters()
3788 average.threads.smi_count += t->smi_count; in sum_counters()
3790 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in sum_counters()
3791 if (mp->format == FORMAT_RAW) in sum_counters()
3793 average.threads.counter[i] += t->counter[i]; in sum_counters()
3796 for (i = 0, pp = sys.perf_tp; pp; i++, pp = pp->next) { in sum_counters()
3797 if (pp->format == FORMAT_RAW) in sum_counters()
3799 average.threads.perf_counter[i] += t->perf_counter[i]; in sum_counters()
3802 for (i = 0, ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) { in sum_counters()
3803 average.threads.pmt_counter[i] += t->pmt_counter[i]; in sum_counters()
3806 /* sum per-core values only for 1st thread in core */ in sum_counters()
3810 average.cores.c3 += c->c3; in sum_counters()
3811 average.cores.c6 += c->c6; in sum_counters()
3812 average.cores.c7 += c->c7; in sum_counters()
3813 average.cores.mc6_us += c->mc6_us; in sum_counters()
3815 average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); in sum_counters()
3816 average.cores.core_throt_cnt = MAX(average.cores.core_throt_cnt, c->core_throt_cnt); in sum_counters()
3818 rapl_counter_accumulate(&average.cores.core_energy, &c->core_energy); in sum_counters()
3820 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in sum_counters()
3821 if (mp->format == FORMAT_RAW) in sum_counters()
3823 average.cores.counter[i] += c->counter[i]; in sum_counters()
3826 for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { in sum_counters()
3827 if (pp->format == FORMAT_RAW) in sum_counters()
3829 average.cores.perf_counter[i] += c->perf_counter[i]; in sum_counters()
3832 for (i = 0, ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) { in sum_counters()
3833 average.cores.pmt_counter[i] += c->pmt_counter[i]; in sum_counters()
3836 /* sum per-pkg values only for 1st core in pkg */ in sum_counters()
3841 average.packages.pkg_wtd_core_c0 += p->pkg_wtd_core_c0; in sum_counters()
3843 average.packages.pkg_any_core_c0 += p->pkg_any_core_c0; in sum_counters()
3845 average.packages.pkg_any_gfxe_c0 += p->pkg_any_gfxe_c0; in sum_counters()
3847 average.packages.pkg_both_core_gfxe_c0 += p->pkg_both_core_gfxe_c0; in sum_counters()
3849 average.packages.pc2 += p->pc2; in sum_counters()
3851 average.packages.pc3 += p->pc3; in sum_counters()
3853 average.packages.pc6 += p->pc6; in sum_counters()
3855 average.packages.pc7 += p->pc7; in sum_counters()
3856 average.packages.pc8 += p->pc8; in sum_counters()
3857 average.packages.pc9 += p->pc9; in sum_counters()
3858 average.packages.pc10 += p->pc10; in sum_counters()
3859 average.packages.die_c6 += p->die_c6; in sum_counters()
3861 average.packages.cpu_lpi = p->cpu_lpi; in sum_counters()
3862 average.packages.sys_lpi = p->sys_lpi; in sum_counters()
3864 rapl_counter_accumulate(&average.packages.energy_pkg, &p->energy_pkg); in sum_counters()
3865 rapl_counter_accumulate(&average.packages.energy_dram, &p->energy_dram); in sum_counters()
3866 rapl_counter_accumulate(&average.packages.energy_cores, &p->energy_cores); in sum_counters()
3867 rapl_counter_accumulate(&average.packages.energy_gfx, &p->energy_gfx); in sum_counters()
3869 average.packages.gfx_rc6_ms = p->gfx_rc6_ms; in sum_counters()
3870 average.packages.uncore_mhz = p->uncore_mhz; in sum_counters()
3871 average.packages.gfx_mhz = p->gfx_mhz; in sum_counters()
3872 average.packages.gfx_act_mhz = p->gfx_act_mhz; in sum_counters()
3873 average.packages.sam_mc6_ms = p->sam_mc6_ms; in sum_counters()
3874 average.packages.sam_mhz = p->sam_mhz; in sum_counters()
3875 average.packages.sam_act_mhz = p->sam_act_mhz; in sum_counters()
3877 average.packages.pkg_temp_c = MAX(average.packages.pkg_temp_c, p->pkg_temp_c); in sum_counters()
3879 rapl_counter_accumulate(&average.packages.rapl_pkg_perf_status, &p->rapl_pkg_perf_status); in sum_counters()
3880 rapl_counter_accumulate(&average.packages.rapl_dram_perf_status, &p->rapl_dram_perf_status); in sum_counters()
3882 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in sum_counters()
3883 if ((mp->format == FORMAT_RAW) && (topo.num_packages == 0)) in sum_counters()
3884 average.packages.counter[i] = p->counter[i]; in sum_counters()
3886 average.packages.counter[i] += p->counter[i]; in sum_counters()
3889 for (i = 0, pp = sys.perf_pp; pp; i++, pp = pp->next) { in sum_counters()
3890 if ((pp->format == FORMAT_RAW) && (topo.num_packages == 0)) in sum_counters()
3891 average.packages.perf_counter[i] = p->perf_counter[i]; in sum_counters()
3893 average.packages.perf_counter[i] += p->perf_counter[i]; in sum_counters()
3896 for (i = 0, ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) { in sum_counters()
3897 average.packages.pmt_counter[i] += p->pmt_counter[i]; in sum_counters()
3960 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in compute_average()
3961 if (mp->format == FORMAT_RAW) in compute_average()
3963 if (mp->type == COUNTER_ITEMS) { in compute_average()
3970 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in compute_average()
3971 if (mp->format == FORMAT_RAW) in compute_average()
3973 if (mp->type == COUNTER_ITEMS) { in compute_average()
3979 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in compute_average()
3980 if (mp->format == FORMAT_RAW) in compute_average()
3982 if (mp->type == COUNTER_ITEMS) { in compute_average()
3989 for (i = 0, pp = sys.perf_tp; pp; i++, pp = pp->next) { in compute_average()
3990 if (pp->format == FORMAT_RAW) in compute_average()
3992 if (pp->type == COUNTER_ITEMS) { in compute_average()
3999 for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { in compute_average()
4000 if (pp->format == FORMAT_RAW) in compute_average()
4002 if (pp->type == COUNTER_ITEMS) { in compute_average()
4008 for (i = 0, pp = sys.perf_pp; pp; i++, pp = pp->next) { in compute_average()
4009 if (pp->format == FORMAT_RAW) in compute_average()
4011 if (pp->type == COUNTER_ITEMS) { in compute_average()
4018 for (i = 0, ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) { in compute_average()
4021 for (i = 0, ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) { in compute_average()
4024 for (i = 0, ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) { in compute_average()
4074 if (mp->msr_num != 0) { in get_mp()
4076 if (get_msr(cpu, mp->msr_num, counterp)) in get_mp()
4077 return -1; in get_mp()
4081 if (mp->flags & SYSFS_PERCPU) { in get_mp()
4082 sprintf(path, "/sys/devices/system/cpu/cpu%d/%s", cpu, mp->sp->path); in get_mp()
4108 return (snapshot_sysfs_counter(path) / 1000); in get_legacy_uncore_mhz()
4122 int ret, epb = -1; in get_epb()
4141 return -1; in get_epb()
4150 unsigned int eax, ebx, ecx, edx; in get_apic_id() local
4153 eax = ebx = ecx = edx = 0; in get_apic_id()
4154 __cpuid(1, eax, ebx, ecx, edx); in get_apic_id()
4156 t->apic_id = (ebx >> 24) & 0xff; in get_apic_id()
4168 eax = ebx = ecx = edx = 0; in get_apic_id()
4169 __cpuid(0x80000001, eax, ebx, ecx, edx); in get_apic_id()
4170 topology_extensions = ecx & (1 << 22); in get_apic_id()
4175 eax = ebx = ecx = edx = 0; in get_apic_id()
4176 __cpuid(0x8000001e, eax, ebx, ecx, edx); in get_apic_id()
4178 t->x2apic_id = eax; in get_apic_id()
4188 ecx = 0; in get_apic_id()
4189 __cpuid(0xb, eax, ebx, ecx, edx); in get_apic_id()
4190 t->x2apic_id = edx; in get_apic_id()
4192 if (debug && (t->apic_id != (t->x2apic_id & 0xff))) in get_apic_id()
4193 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()
4206 return -1; in get_core_throt_cnt()
4210 return -1; in get_core_throt_cnt()
4226 int ret = -1; in read_perf_counter_info()
4229 if (fdmt == -1) { in read_perf_counter_info()
4232 ret = -1; in read_perf_counter_info()
4236 bytes_read = read(fdmt, buf, sizeof(buf) - 1); in read_perf_counter_info()
4240 ret = -1; in read_perf_counter_info()
4249 ret = -1; in read_perf_counter_info()
4267 v = -1; in read_perf_counter_info_n()
4293 unsigned int ret = -1; in read_perf_config()
4299 return -1; in read_perf_config()
4370 if (rci->source[i] == COUNTER_SOURCE_PERF) in rapl_counter_info_count_perf()
4381 if (cci->source[i] == COUNTER_SOURCE_PERF) in cstate_counter_info_count_perf()
4389 if (rci->source[idx] == COUNTER_SOURCE_NONE) in write_rapl_counter()
4392 rc->raw_value = rci->data[idx]; in write_rapl_counter()
4393 rc->unit = rci->unit[idx]; in write_rapl_counter()
4394 rc->scale = rci->scale[idx]; in write_rapl_counter()
4414 if (rci->fd_perf != -1) { in get_rapl_counters()
4417 const ssize_t actual_read_size = read(rci->fd_perf, &perf_data[0], sizeof(perf_data)); in get_rapl_counters()
4420 err(-1, "%s: failed to read perf_data (%zu %zu)", __func__, expected_read_size, in get_rapl_counters()
4425 switch (rci->source[i]) { in get_rapl_counters()
4427 rci->data[i] = 0; in get_rapl_counters()
4432 assert(rci->fd_perf != -1); in get_rapl_counters()
4436 i, perf_data[pi], rci->scale[i], perf_data[pi] * rci->scale[i]); in get_rapl_counters()
4438 rci->data[i] = perf_data[pi]; in get_rapl_counters()
4448 if (rci->flags[i] & RAPL_COUNTER_FLAG_USE_MSR_SUM) { in get_rapl_counters()
4449 if (get_msr_sum(cpu, rci->msr[i], &rci->data[i])) in get_rapl_counters()
4450 return -13 - i; in get_rapl_counters()
4452 if (get_msr(cpu, rci->msr[i], &rci->data[i])) in get_rapl_counters()
4453 return -13 - i; in get_rapl_counters()
4456 rci->data[i] &= rci->msr_mask[i]; in get_rapl_counters()
4457 if (rci->msr_shift[i] >= 0) in get_rapl_counters()
4458 rci->data[i] >>= abs(rci->msr_shift[i]); in get_rapl_counters()
4460 rci->data[i] <<= abs(rci->msr_shift[i]); in get_rapl_counters()
4467 write_rapl_counter(&p->energy_pkg, rci, RAPL_RCI_INDEX_ENERGY_PKG); in get_rapl_counters()
4468 write_rapl_counter(&p->energy_cores, rci, RAPL_RCI_INDEX_ENERGY_CORES); in get_rapl_counters()
4469 write_rapl_counter(&p->energy_dram, rci, RAPL_RCI_INDEX_DRAM); in get_rapl_counters()
4470 write_rapl_counter(&p->energy_gfx, rci, RAPL_RCI_INDEX_GFX); in get_rapl_counters()
4471 write_rapl_counter(&p->rapl_pkg_perf_status, rci, RAPL_RCI_INDEX_PKG_PERF_STATUS); in get_rapl_counters()
4472 write_rapl_counter(&p->rapl_dram_perf_status, rci, RAPL_RCI_INDEX_DRAM_PERF_STATUS); in get_rapl_counters()
4473 write_rapl_counter(&c->core_energy, rci, RAPL_RCI_INDEX_CORE_ENERGY); in get_rapl_counters()
4474 write_rapl_counter(&pplat_cnt->energy_psys, rci, RAPL_RCI_INDEX_ENERGY_PLATFORM); in get_rapl_counters()
4482 if (sp->id == id) in find_sysfs_path_by_id()
4483 return (sp->path); in find_sysfs_path_by_id()
4484 sp = sp->next; in find_sysfs_path_by_id()
4522 if (cci->fd_perf_core != -1) { in get_cstate_counters()
4526 actual_read_size_core = read(cci->fd_perf_core, &perf_data_core[0], sizeof(perf_data_core)); in get_cstate_counters()
4529 err(-1, "%s: read perf %s: %ld", __func__, "core", actual_read_size_core); in get_cstate_counters()
4532 if (cci->fd_perf_pkg != -1) { in get_cstate_counters()
4536 actual_read_size_pkg = read(cci->fd_perf_pkg, &perf_data_pkg[0], sizeof(perf_data_pkg)); in get_cstate_counters()
4539 err(-1, "%s: read perf %s: %ld", __func__, "pkg", actual_read_size_pkg); in get_cstate_counters()
4545 …err(-1, "%s: failed to read perf_data (%zu %zu)", __func__, expected_read_size, actual_read_size_t… in get_cstate_counters()
4565 switch (cci->source[i]) { in get_cstate_counters()
4571 assert(cci->fd_perf_core != -1 || cci->fd_perf_pkg != -1); in get_cstate_counters()
4576 cci->data[i] = perf_data[pi]; in get_cstate_counters()
4583 if (get_msr(cpu, cci->msr[i], &cci->data[i])) in get_cstate_counters()
4584 return -13 - 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()
4601 if (cci->source[index] != COUNTER_SOURCE_NONE) \ in get_cstate_counters()
4602 out_counter = cci->data[index]; \ in get_cstate_counters()
4607 PERF_COUNTER_WRITE_DATA(t->c1, CCSTATE_RCI_INDEX_C1_RESIDENCY); in get_cstate_counters()
4608 PERF_COUNTER_WRITE_DATA(c->c3, CCSTATE_RCI_INDEX_C3_RESIDENCY); in get_cstate_counters()
4609 PERF_COUNTER_WRITE_DATA(c->c6, CCSTATE_RCI_INDEX_C6_RESIDENCY); in get_cstate_counters()
4610 PERF_COUNTER_WRITE_DATA(c->c7, CCSTATE_RCI_INDEX_C7_RESIDENCY); in get_cstate_counters()
4612 PERF_COUNTER_WRITE_DATA(p->pc2, PCSTATE_RCI_INDEX_C2_RESIDENCY); in get_cstate_counters()
4613 PERF_COUNTER_WRITE_DATA(p->pc3, PCSTATE_RCI_INDEX_C3_RESIDENCY); in get_cstate_counters()
4614 PERF_COUNTER_WRITE_DATA(p->pc6, PCSTATE_RCI_INDEX_C6_RESIDENCY); in get_cstate_counters()
4615 PERF_COUNTER_WRITE_DATA(p->pc7, PCSTATE_RCI_INDEX_C7_RESIDENCY); in get_cstate_counters()
4616 PERF_COUNTER_WRITE_DATA(p->pc8, PCSTATE_RCI_INDEX_C8_RESIDENCY); in get_cstate_counters()
4617 PERF_COUNTER_WRITE_DATA(p->pc9, PCSTATE_RCI_INDEX_C9_RESIDENCY); in get_cstate_counters()
4618 PERF_COUNTER_WRITE_DATA(p->pc10, PCSTATE_RCI_INDEX_C10_RESIDENCY); in get_cstate_counters()
4630 if (mci->source[i] == COUNTER_SOURCE_PERF) in msr_counter_info_count_perf()
4651 ZERO_ARRAY(mci->data); in get_smi_aperf_mperf()
4653 if (mci->fd_perf != -1) { in get_smi_aperf_mperf()
4656 const ssize_t actual_read_size = read(mci->fd_perf, &perf_data[0], sizeof(perf_data)); in get_smi_aperf_mperf()
4659 err(-1, "%s: failed to read perf_data (%zu %zu)", __func__, expected_read_size, in get_smi_aperf_mperf()
4664 switch (mci->source[i]) { in get_smi_aperf_mperf()
4670 assert(mci->fd_perf != -1); in get_smi_aperf_mperf()
4675 mci->data[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()
4684 return -2 - i; in get_smi_aperf_mperf()
4686 mci->data[i] &= mci->msr_mask[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()
4696 t->aperf = mci->data[MSR_RCI_INDEX_APERF]; in get_smi_aperf_mperf()
4697 t->mperf = mci->data[MSR_RCI_INDEX_MPERF]; in get_smi_aperf_mperf()
4698 t->smi_count = mci->data[MSR_RCI_INDEX_SMI]; in get_smi_aperf_mperf()
4709 for (size_t i = 0; pp; ++i, pp = pp->next) { in perf_counter_info_read_values()
4711 assert(domain < pp->num_domains); in perf_counter_info_read_values()
4713 fd_counter = pp->fd_perf_per_domain[domain]; in perf_counter_info_read_values()
4715 if (fd_counter == -1) in perf_counter_info_read_values()
4722 out[i] = value * pp->scale; in perf_counter_info_read_values()
4735 mask = ((1 << (msb + 1)) - 1); in pmt_gen_value_mask()
4737 mask -= (1 << lsb) - 1; in pmt_gen_value_mask()
4744 if (domain_id >= ppmt->num_domains) in pmt_read_counter()
4747 const unsigned long *pmmio = ppmt->domains[domain_id].pcounter; in pmt_read_counter()
4749 const unsigned long value_mask = pmt_gen_value_mask(ppmt->lsb, ppmt->msb); in pmt_read_counter()
4750 const unsigned long value_shift = ppmt->lsb; in pmt_read_counter()
4762 int cpu = t->cpu_id; in get_counters()
4771 return -1; in get_counters()
4774 gettimeofday(&t->tv_begin, (struct timezone *)NULL); in get_counters()
4779 t->tsc = rdtsc(); /* we are running on local CPU of interest */ in get_counters()
4784 if (read(get_instr_count_fd(cpu), &t->instr_count, sizeof(long long)) != sizeof(long long)) in get_counters()
4785 return -4; in get_counters()
4788 t->irq_count = irqs_per_cpu[cpu]; in get_counters()
4790 t->nmi_count = nmi_per_cpu[cpu]; in get_counters()
4794 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { in get_counters()
4795 if (get_mp(cpu, mp, &t->counter[i], mp->sp->path)) in get_counters()
4796 return -10; in get_counters()
4799 if (perf_counter_info_read_values(sys.perf_tp, cpu, t->perf_counter, MAX_ADDED_THREAD_COUNTERS)) in get_counters()
4800 return -10; in get_counters()
4802 for (i = 0, pp = sys.pmt_tp; pp; i++, pp = pp->next) in get_counters()
4803 t->pmt_counter[i] = pmt_read_counter(pp, t->cpu_id); in get_counters()
4809 if (platform->has_per_core_rapl) { in get_counters()
4810 status = get_rapl_counters(cpu, c->core_id, c, p); in get_counters()
4815 if (DO_BIC(BIC_CPU_c7) && t->is_atom) { in get_counters()
4822 c->c6 -= c->c7; in get_counters()
4826 if (get_msr(cpu, MSR_MODULE_C6_RES_MS, &c->mc6_us)) in get_counters()
4827 return -8; in get_counters()
4831 return -9; in get_counters()
4832 c->core_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
4836 get_core_throt_cnt(cpu, &c->core_throt_cnt); in get_counters()
4838 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { in get_counters()
4839 if (get_mp(cpu, mp, &c->counter[i], mp->sp->path)) in get_counters()
4840 return -10; in get_counters()
4843 if (perf_counter_info_read_values(sys.perf_cp, cpu, c->perf_counter, MAX_ADDED_CORE_COUNTERS)) in get_counters()
4844 return -10; in get_counters()
4846 for (i = 0, pp = sys.pmt_cp; pp; i++, pp = pp->next) in get_counters()
4847 c->pmt_counter[i] = pmt_read_counter(pp, c->core_id); in get_counters()
4854 if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) in get_counters()
4855 return -10; in get_counters()
4858 if (get_msr(cpu, MSR_PKG_ANY_CORE_C0_RES, &p->pkg_any_core_c0)) in get_counters()
4859 return -11; in get_counters()
4862 if (get_msr(cpu, MSR_PKG_ANY_GFXE_C0_RES, &p->pkg_any_gfxe_c0)) in get_counters()
4863 return -12; in get_counters()
4866 if (get_msr(cpu, MSR_PKG_BOTH_CORE_GFXE_C0_RES, &p->pkg_both_core_gfxe_c0)) in get_counters()
4867 return -13; in get_counters()
4871 p->cpu_lpi = cpuidle_cur_cpu_lpi_us; in get_counters()
4873 p->sys_lpi = cpuidle_cur_sys_lpi_us; in get_counters()
4875 if (!platform->has_per_core_rapl) { in get_counters()
4876 status = get_rapl_counters(cpu, p->package_id, c, p); in get_counters()
4883 return -17; in get_counters()
4884 p->pkg_temp_c = tj_max - ((msr >> 16) & 0x7F); in get_counters()
4888 p->uncore_mhz = get_legacy_uncore_mhz(p->package_id); in get_counters()
4891 p->gfx_rc6_ms = gfx_info[GFX_rc6].val_ull; in get_counters()
4894 p->gfx_mhz = gfx_info[GFX_MHz].val; in get_counters()
4897 p->gfx_act_mhz = gfx_info[GFX_ACTMHz].val; in get_counters()
4900 p->sam_mc6_ms = gfx_info[SAM_mc6].val_ull; in get_counters()
4903 p->sam_mhz = gfx_info[SAM_MHz].val; in get_counters()
4906 p->sam_act_mhz = gfx_info[SAM_ACTMHz].val; in get_counters()
4908 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { in get_counters()
4911 if (mp->msr_num == 0) { in get_counters()
4912 path = find_sysfs_path_by_id(mp->sp, p->package_id); in get_counters()
4914 warnx("%s: package_id %d not found", __func__, p->package_id); in get_counters()
4915 return -10; in get_counters()
4918 if (get_mp(cpu, mp, &p->counter[i], path)) in get_counters()
4919 return -10; in get_counters()
4922 if (perf_counter_info_read_values(sys.perf_pp, cpu, p->perf_counter, MAX_ADDED_PACKAGE_COUNTERS)) in get_counters()
4923 return -10; in get_counters()
4925 for (i = 0, pp = sys.pmt_pp; pp; i++, pp = pp->next) in get_counters()
4926 p->pmt_counter[i] = pmt_read_counter(pp, p->package_id); in get_counters()
4929 gettimeofday(&t->tv_end, (struct timezone *)NULL); in get_counters()
4989 if (!platform->has_nhm_msrs || no_msr) in probe_cst_limit()
4992 switch (platform->cst_limit) { in probe_cst_limit()
5033 if (!platform->has_nhm_msrs || no_msr) in dump_platform_info()
5051 if (!platform->has_nhm_msrs || no_msr) in dump_power_ctl()
5055 fprintf(outf, "cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", in dump_power_ctl()
5058 /* C-state Pre-wake Disable (CSTATE_PREWAKE_DISABLE) */ in dump_power_ctl()
5059 if (platform->has_cst_prewake_bit) in dump_power_ctl()
5060 fprintf(outf, "C-state Pre-wake: %sabled\n", msr & 0x40000000 ? "DIS" : "EN"); in dump_power_ctl()
5136 if (platform->trl_msrs & TRL_CORECOUNT) { in dump_turbo_ratio_limits()
5143 for (shift = 56; shift >= 0; shift -= 8) { in dump_turbo_ratio_limits()
5212 * [0] -- Reserved in dump_knl_turbo_ratio_limits()
5213 * [7:1] -- Base value of number of active cores of bucket 1. in dump_knl_turbo_ratio_limits()
5214 * [15:8] -- Base value of freq ratio of bucket 1. in dump_knl_turbo_ratio_limits()
5215 * [20:16] -- +ve delta of number of active cores of bucket 2. in dump_knl_turbo_ratio_limits()
5218 * [23:21] -- Negative delta of freq ratio of bucket 2. in dump_knl_turbo_ratio_limits()
5220 * freq ratio of bucket 1 - delta in dump_knl_turbo_ratio_limits()
5221 * [28:24]-- +ve delta of number of active cores of bucket 3. in dump_knl_turbo_ratio_limits()
5222 * [31:29]-- -ve delta of freq ratio of bucket 3. in dump_knl_turbo_ratio_limits()
5223 * [36:32]-- +ve delta of number of active cores of bucket 4. in dump_knl_turbo_ratio_limits()
5224 * [39:37]-- -ve delta of freq ratio of bucket 4. in dump_knl_turbo_ratio_limits()
5225 * [44:40]-- +ve delta of number of active cores of bucket 5. in dump_knl_turbo_ratio_limits()
5226 * [47:45]-- -ve delta of freq ratio of bucket 5. in dump_knl_turbo_ratio_limits()
5227 * [52:48]-- +ve delta of number of active cores of bucket 6. in dump_knl_turbo_ratio_limits()
5228 * [55:53]-- -ve delta of freq ratio of bucket 6. in dump_knl_turbo_ratio_limits()
5229 * [60:56]-- +ve delta of number of active cores of bucket 7. in dump_knl_turbo_ratio_limits()
5230 * [63:61]-- -ve delta of freq ratio of bucket 7. in dump_knl_turbo_ratio_limits()
5242 ratio[b_nr + 1] = ratio[b_nr] - delta_ratio; in dump_knl_turbo_ratio_limits()
5246 for (i = buckets_no - 1; i >= 0; i--) in dump_knl_turbo_ratio_limits()
5247 if (i > 0 ? ratio[i] != ratio[i - 1] : 1) in dump_knl_turbo_ratio_limits()
5257 if (!platform->has_nhm_msrs || no_msr) in dump_cst_cfg()
5264 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)", 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()
5272 if (platform->has_cst_auto_convension) { in dump_cst_cfg()
5273 …fprintf(outf, ", automatic c-state conversion=%s", (msr & AUTOMATIC_CSTATE_CONVERSION) ? "on" : "o… in dump_cst_cfg()
5329 if (!platform->has_irtl_msrs || no_msr) in print_irtl()
5332 if (platform->supported_cstates & PC3) { in print_irtl()
5339 if (platform->supported_cstates & PC6) { in print_irtl()
5346 if (platform->supported_cstates & PC7) { in print_irtl()
5353 if (platform->supported_cstates & PC8) { in print_irtl()
5360 if (platform->supported_cstates & PC9) { in print_irtl()
5367 if (platform->supported_cstates & PC10) { in print_irtl()
5413 if (ccstate_counter_info[counter_id].fd_perf_core != -1) in free_fd_cstate()
5416 if (ccstate_counter_info[counter_id].fd_perf_pkg != -1) in free_fd_cstate()
5431 if (msr_counter_info[cpu].fd_perf != -1) in free_fd_msr()
5448 if (rapl_counter_info_perdomain[domain_id].fd_perf != -1) in free_fd_rapl_percpu()
5462 if (!pp->fd_perf_per_domain) in free_fd_added_perf_counters_()
5466 for (size_t domain = 0; domain < pp->num_domains; ++domain) { in free_fd_added_perf_counters_()
5467 if (pp->fd_perf_per_domain[domain] != -1) { in free_fd_added_perf_counters_()
5468 close(pp->fd_perf_per_domain[domain]); in free_fd_added_perf_counters_()
5469 pp->fd_perf_per_domain[domain] = -1; in free_fd_added_perf_counters_()
5473 free(pp->fd_perf_per_domain); in free_fd_added_perf_counters_()
5474 pp->fd_perf_per_domain = NULL; in free_fd_added_perf_counters_()
5476 pp = pp->next; in free_fd_added_perf_counters_()
5600 cpus[cpu].logical_node_id = -1; in set_node_data()
5609 if (cpus[cpu].logical_node_id != -1) in set_node_data()
5638 int cpu = thiscpu->logical_cpu_id; in get_physical_node_id()
5648 return -1; in get_physical_node_id()
5658 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_str()
5678 if (*next == '-') { in parse_cpu_str()
5713 int cpu = thiscpu->logical_cpu_id; in get_thread_siblings()
5718 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); in get_thread_siblings()
5719 if (thiscpu->thread_id < 0) in get_thread_siblings()
5720 thiscpu->thread_id = thread_id++; in get_thread_siblings()
5721 if (!thiscpu->put_ids) in get_thread_siblings()
5722 return -1; in get_thread_siblings()
5725 CPU_ZERO_S(size, thiscpu->put_ids); in get_thread_siblings()
5732 return -1; in get_thread_siblings()
5735 offset -= BITMASK_SIZE; in get_thread_siblings()
5742 if (sib_core == thiscpu->physical_core_id) { in get_thread_siblings()
5743 CPU_SET_S(so, size, thiscpu->put_ids); in get_thread_siblings()
5752 return CPU_COUNT_S(size, thiscpu->put_ids); in get_thread_siblings()
5757 * skip non-present cpus
5780 if (cpu_is_not_allowed(t->cpu_id)) in for_all_cpus_2()
5887 fprintf(outf, "turbostat: re-initialized with num_cpus %d, allowed_cpus %d\n", topo.num_cpus, in re_initialize()
5908 topo.max_cpu_num--; /* 0 based */ in set_max_cpu_num()
5931 cpus[cpu].thread_id = -1; in init_thread_id()
5937 unsigned int eax, ebx, ecx, edx; in set_my_cpu_type() local
5940 __cpuid(0, max_level, ebx, ecx, edx); in set_my_cpu_type()
5945 __cpuid(CPUID_LEAF_MODEL_ID, eax, ebx, ecx, edx); in set_my_cpu_type()
5953 return -1; in set_cpu_hybrid_type()
6060 return -EINVAL; in snapshot_graphics()
6082 return -1; in snapshot_cpu_lpi_us()
6107 return -1; in snapshot_sys_lpi_us()
6216 rest.tv_nsec = (tout.tv_usec % 1000000) * 1000; in do_sleep()
6235 /* get_msr_sum() = sum + (get_msr() - last) */ in get_msr_sum()
6252 int cpu = t->cpu_id; in update_msr_sum()
6308 if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) { in msr_sum_record()
6324 if (timer_settime(timerid, 0, &its, NULL) == -1) { in msr_sum_record()
6339 * return value < -20 on failure
6348 if (errno && (original_priority == -1)) in set_my_sched_priority()
6349 return -21; in set_my_sched_priority()
6353 return -21; in set_my_sched_priority()
6358 return -21; in set_my_sched_priority()
6374 * ignore on error - we probably don't have permission to set it, but in turbostat_loop()
6377 set_my_sched_priority(-20); in turbostat_loop()
6385 if (retval < -1) { in turbostat_loop()
6387 } else if (retval == -1) { in turbostat_loop()
6411 if (retval < -1) { in turbostat_loop()
6413 } else if (retval == -1) { in turbostat_loop()
6435 if (retval < -1) { in turbostat_loop()
6437 } else if (retval == -1) { in turbostat_loop()
6498 if (cap_free(caps) == -1) in check_for_cap_sys_rawio()
6499 err(-6, "cap_free\n"); in check_for_cap_sys_rawio()
6523 … "\tRun as root to enable them or use %s to disable the access explicitly", pathname, "--no-msr"); in check_msr_permission()
6533 if (!platform->has_nhm_msrs || no_msr) in probe_bclk()
6536 if (platform->bclk_freq == BCLK_100MHZ) in probe_bclk()
6538 else if (platform->bclk_freq == BCLK_133MHZ) in probe_bclk()
6540 else if (platform->bclk_freq == BCLK_SLV) in probe_bclk()
6551 if (platform->enable_tsc_tweak) in probe_bclk()
6573 if (!platform->has_nhm_msrs || no_msr) in dump_turbo_ratio_info()
6576 if (platform->trl_msrs & TRL_LIMIT2) in dump_turbo_ratio_info()
6579 if (platform->trl_msrs & TRL_LIMIT1) in dump_turbo_ratio_info()
6582 if (platform->trl_msrs & TRL_BASE) { in dump_turbo_ratio_info()
6589 if (platform->trl_msrs & TRL_ATOM) in dump_turbo_ratio_info()
6592 if (platform->trl_msrs & TRL_KNL) in dump_turbo_ratio_info()
6595 if (platform->has_config_tdp) in dump_turbo_ratio_info()
6602 int retval = -1; in read_sysfs_int()
6608 return (-1); in read_sysfs_int()
6660 fprintf(outf, "Uncore Frequency package%d die%d: %d - %d MHz ", i, j, k / 1000, l / 1000); in probe_intel_uncore_frequency_legacy()
6666 fprintf(outf, "(%d - %d MHz)", k / 1000, l / 1000); in probe_intel_uncore_frequency_legacy()
6670 fprintf(outf, " %d MHz\n", k / 1000); in probe_intel_uncore_frequency_legacy()
6690 uncore_max_id -= 1; in probe_intel_uncore_frequency_cluster()
6694 for (i = uncore_max_id; i >= 0; --i) { in probe_intel_uncore_frequency_cluster()
6725 …fprintf(outf, "Uncore Frequency package%d domain%d cluster%d: %d - %d MHz ", package_id, domain_id, in probe_intel_uncore_frequency_cluster()
6726 cluster_id, k / 1000, l / 1000); in probe_intel_uncore_frequency_cluster()
6732 fprintf(outf, "(%d - %d MHz)", k / 1000, l / 1000); in probe_intel_uncore_frequency_cluster()
6736 fprintf(outf, " %d MHz\n", k / 1000); in probe_intel_uncore_frequency_cluster()
6781 if (!strncmp(buf, "gt0-rc", strlen("gt0-rc"))) in probe_graphics()
6783 else if (!strncmp(buf, "gt0-mc", strlen("gt0-mc"))) in probe_graphics()
6888 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in dump_sysfs_cstate_config()
6889 sp = strchr(name_buf, '-'); in dump_sysfs_cstate_config()
6974 cpu = t->cpu_id; in print_epb()
6976 /* EPB is per-package */ in print_epb()
6982 return -1; in print_epb()
7026 cpu = t->cpu_id; in print_hwp()
7028 /* MSR_HWP_CAPABILITIES is per-package */ in print_hwp()
7034 return -1; in print_hwp()
7040 fprintf(outf, "cpu%d: MSR_PM_ENABLE: 0x%08llx (%sHWP)\n", cpu, msr, (msr & (1 << 0)) ? "" : "No-"); in print_hwp()
7093 cpu, msr, ((msr) & 0x1) ? "" : "No-", ((msr) & 0x4) ? "" : "No-"); in print_hwp()
7112 cpu = t->cpu_id; in print_perf_limit()
7114 /* per-package */ in print_perf_limit()
7120 return -1; in print_perf_limit()
7123 if (platform->plr_msrs & PLR_CORE) { in print_perf_limit()
7135 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7136 (msr & 1 << 5) ? "Auto-HWP, " : "", in print_perf_limit()
7149 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7150 (msr & 1 << 21) ? "Auto-HWP, " : "", in print_perf_limit()
7156 if (platform->plr_msrs & PLR_GFX) { in print_perf_limit()
7163 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7171 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7176 if (platform->plr_msrs & PLR_RING) { in print_perf_limit()
7182 (msr & 1 << 6) ? "VR-Therm, " : "", in print_perf_limit()
7188 (msr & 1 << 22) ? "VR-Therm, " : "", in print_perf_limit()
7200 if (platform->rapl_quirk_tdp) in get_quirk_tdp()
7201 return platform->rapl_quirk_tdp; in get_quirk_tdp()
7210 if (platform->rapl_msrs & RAPL_PKG_POWER_INFO) in get_tdp_intel()
7234 if (!(platform->rapl_msrs & RAPL_PKG_PERF_STATUS)) in rapl_probe_intel()
7236 if (!(platform->rapl_msrs & RAPL_DRAM_PERF_STATUS)) in rapl_probe_intel()
7244 if (platform->has_rapl_divisor) in rapl_probe_intel()
7249 if (platform->has_fixed_rapl_unit) in rapl_probe_intel()
7254 if (platform->has_fixed_rapl_psys_unit) in rapl_probe_intel()
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()
7319 if (!platform->rapl_msrs) in print_rapl()
7326 cpu = t->cpu_id; in print_rapl()
7329 return -1; in print_rapl()
7332 if (platform->rapl_msrs & RAPL_AMD_F17H) { in print_rapl()
7335 return -1; in print_rapl()
7339 return -1; in print_rapl()
7345 if (platform->rapl_msrs & RAPL_PKG_POWER_INFO) { in print_rapl()
7348 return -5; in print_rapl()
7350 fprintf(outf, "cpu%d: MSR_PKG_POWER_INFO: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
7358 if (platform->rapl_msrs & RAPL_PKG) { in print_rapl()
7361 return -9; in print_rapl()
7375 return -9; in print_rapl()
7382 if (platform->rapl_msrs & RAPL_DRAM_POWER_INFO) { in print_rapl()
7384 return -6; in print_rapl()
7386 fprintf(outf, "cpu%d: MSR_DRAM_POWER_INFO,: 0x%08llx (%.0f W TDP, RAPL %.0f - %.0f W, %f sec.)\n", in print_rapl()
7393 if (platform->rapl_msrs & RAPL_DRAM) { in print_rapl()
7395 return -9; in print_rapl()
7401 if (platform->rapl_msrs & RAPL_CORE_POLICY) { in print_rapl()
7403 return -7; in print_rapl()
7407 if (platform->rapl_msrs & RAPL_CORE_POWER_LIMIT) { in print_rapl()
7409 return -9; in print_rapl()
7414 if (platform->rapl_msrs & RAPL_GFX) { in print_rapl()
7416 return -8; in print_rapl()
7421 return -9; in print_rapl()
7436 if (!platform->rapl_msrs || no_msr) in probe_rapl()
7456 * but also allow cmdline over-ride with -T.
7458 * Several MSR temperature values are in units of degrees-C
7475 /* this is a per-package concept */ in set_temperature_target()
7479 cpu = t->cpu_id; in set_temperature_target()
7482 return -1; in set_temperature_target()
7492 if (!platform->has_nhm_msrs || no_msr) in set_temperature_target()
7501 int bits = platform->tcc_offset_bits; in set_temperature_target()
7508 tcc_offset = (msr >> 24) & GENMASK(bits - 1, 0); in set_temperature_target()
7509 fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n", in set_temperature_target()
7510 cpu, msr, tcc_default - tcc_offset, tcc_default, tcc_offset); in set_temperature_target()
7525 fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n", cpu, tj_max); in set_temperature_target()
7545 cpu = t->cpu_id; in print_thermal()
7547 /* DTS is per-core, no need to print for each thread */ in print_thermal()
7553 return -1; 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()
7569 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
7580 fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", in print_thermal()
7581 cpu, msr, tj_max - dts, resolution); in print_thermal()
7589 cpu, msr, tj_max - dts, tj_max - dts2); in print_thermal()
7612 unsigned int eax, ebx, ecx, edx; in get_cpu_type() local
7620 if (cpu_migrate(t->cpu_id)) { in get_cpu_type()
7621 fprintf(outf, "Could not migrate to CPU %d\n", t->cpu_id); in get_cpu_type()
7622 return -1; in get_cpu_type()
7628 __cpuid(0x1a, eax, ebx, ecx, edx); in get_cpu_type()
7631 t->is_atom = true; in get_cpu_type()
7644 base_cpu, msr, msr & FEAT_CTL_LOCKED ? "" : "UN-", msr & (1 << 18) ? "SGX" : ""); in decode_feature_control_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()
7674 if (!platform->has_msr_misc_feature_control) in decode_misc_feature_control()
7679 …"cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1-IP… 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()
7698 if (!platform->has_msr_misc_pwr_mgmt) in decode_misc_pwr_mgmt_msr()
7702 …fprintf(outf, "cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)… in decode_misc_pwr_mgmt_msr()
7720 if (!platform->has_msr_c6_demotion_policy_config) in decode_c6_demotion_policy_msr()
7724 fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", in decode_c6_demotion_policy_msr()
7728 fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", in decode_c6_demotion_policy_msr()
7765 fd = open_perf_counter(base_cpu, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, -1, 0); in has_instr_count_access()
7766 has_access = fd != -1; in has_instr_count_access()
7768 if (fd != -1) in has_instr_count_access()
7774 "instructions retired perf counter", "--no-perf"); in has_instr_count_access()
7783 return -1; in add_rapl_perf_counter_()
7785 const double scale = read_perf_scale(cai->perf_subsys, cai->perf_name); in add_rapl_perf_counter_()
7788 return -1; in add_rapl_perf_counter_()
7790 const enum rapl_unit unit = read_perf_rapl_unit(cai->perf_subsys, cai->perf_name); in add_rapl_perf_counter_()
7793 return -1; in add_rapl_perf_counter_()
7795 const unsigned int rapl_type = read_perf_type(cai->perf_subsys); in add_rapl_perf_counter_()
7796 const unsigned int rapl_energy_pkg_config = read_perf_config(cai->perf_subsys, cai->perf_name); in add_rapl_perf_counter_()
7799 open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP); in add_rapl_perf_counter_()
7800 if (fd_counter == -1) in add_rapl_perf_counter_()
7801 return -1; in add_rapl_perf_counter_()
7804 if (rci->fd_perf == -1) in add_rapl_perf_counter_()
7805 rci->fd_perf = fd_counter; in add_rapl_perf_counter_()
7824 * Linux-perf manages the HW instructions-retired counter
7835 err(-1, "calloc fd_instr_count_percpu"); in linux_perf_init()
7841 …const unsigned int num_domains = (platform->has_per_core_rapl ? topo.max_core_id : topo.max_packag… in rapl_perf_init()
7846 err(-1, "calloc rapl_counter_info_percpu"); in rapl_perf_init()
7855 rci->fd_perf = -1; in rapl_perf_init()
7857 rci->data[i] = 0; in rapl_perf_init()
7858 rci->source[i] = COUNTER_SOURCE_NONE; in rapl_perf_init()
7883 platform->has_per_core_rapl ? cpus[cpu].physical_core_id : cpus[cpu].physical_package_id; in rapl_perf_init()
7892 if ((cai->flags & RAPL_COUNTER_FLAG_PLATFORM_COUNTER) && (cpu != base_cpu)) in rapl_perf_init()
7898 if (BIC_IS_ENABLED(cai->bic) && (platform->rapl_msrs & cai->feature_mask)) { in rapl_perf_init()
7901 if (!no_perf && cai->perf_name in rapl_perf_init()
7902 && add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) { in rapl_perf_init()
7903 rci->source[cai->rci_index] = COUNTER_SOURCE_PERF; in rapl_perf_init()
7904 rci->scale[cai->rci_index] = scale * cai->compat_scale; in rapl_perf_init()
7905 rci->unit[cai->rci_index] = unit; in rapl_perf_init()
7906 rci->flags[cai->rci_index] = cai->flags; 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()
7910 rci->source[cai->rci_index] = COUNTER_SOURCE_MSR; in rapl_perf_init()
7911 rci->msr[cai->rci_index] = cai->msr; in rapl_perf_init()
7912 rci->msr_mask[cai->rci_index] = cai->msr_mask; in rapl_perf_init()
7913 rci->msr_shift[cai->rci_index] = cai->msr_shift; in rapl_perf_init()
7914 rci->unit[cai->rci_index] = RAPL_UNIT_JOULES; in rapl_perf_init()
7915 rci->scale[cai->rci_index] = *cai->platform_rapl_msr_scale * cai->compat_scale; in rapl_perf_init()
7916 rci->flags[cai->rci_index] = cai->flags; in rapl_perf_init()
7920 if (rci->source[cai->rci_index] != COUNTER_SOURCE_NONE) in rapl_perf_init()
7926 BIC_PRESENT(cai->bic); in rapl_perf_init()
7942 return &cci->fd_perf_core; in get_cstate_perf_group_fd()
7945 return &cci->fd_perf_pkg; in get_cstate_perf_group_fd()
7953 return -1; in add_cstate_perf_counter_()
7955 int *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys); in add_cstate_perf_counter_()
7958 return -1; in add_cstate_perf_counter_()
7960 const unsigned int type = read_perf_type(cai->perf_subsys); in add_cstate_perf_counter_()
7961 const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name); in add_cstate_perf_counter_()
7965 if (fd_counter == -1) in add_cstate_perf_counter_()
7966 return -1; in add_cstate_perf_counter_()
7969 if (*pfd_group == -1) in add_cstate_perf_counter_()
7988 return -1; in add_msr_perf_counter_()
7990 const unsigned int type = read_perf_type(cai->perf_subsys); in add_msr_perf_counter_()
7991 const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name); in add_msr_perf_counter_()
7993 const int fd_counter = open_perf_counter(cpu, type, config, cci->fd_perf, PERF_FORMAT_GROUP); in add_msr_perf_counter_()
7995 if (fd_counter == -1) in add_msr_perf_counter_()
7996 return -1; in add_msr_perf_counter_()
7999 if (cci->fd_perf == -1) in add_msr_perf_counter_()
8000 cci->fd_perf = fd_counter; in add_msr_perf_counter_()
8010 …fprintf(stderr, "%s: %s/%s: %d (cpu: %d)\n", __func__, cai->perf_subsys, cai->perf_name, ret, cpu); in add_msr_perf_counter()
8025 msr_counter_info[cpu].fd_perf = -1; in msr_perf_init_()
8031 cai->present = false; in msr_perf_init_()
8040 if (cai->needed) { in msr_perf_init_()
8042 if (!no_perf && cai->perf_name && add_msr_perf_counter(cpu, cci, cai) != -1) { in msr_perf_init_()
8043 cci->source[cai->rci_index] = COUNTER_SOURCE_PERF; in msr_perf_init_()
8044 cai->present = true; 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_()
8048 cci->source[cai->rci_index] = COUNTER_SOURCE_MSR; in msr_perf_init_()
8049 cci->msr[cai->rci_index] = cai->msr; in msr_perf_init_()
8050 cci->msr_mask[cai->rci_index] = cai->msr_mask; in msr_perf_init_()
8051 cai->present = true; in msr_perf_init_()
8062 const bool need_soft_c1 = (!platform->has_msr_core_c1_res) && (platform->supported_cstates & CC1); in msr_perf_init()
8116 ccstate_counter_info[cpu].fd_perf_core = -1; in cstate_perf_init_()
8117 ccstate_counter_info[cpu].fd_perf_pkg = -1; in cstate_perf_init_()
8140 const bool per_thread = cai->flags & CSTATE_COUNTER_FLAG_COLLECT_PER_THREAD; in cstate_perf_init_()
8141 const bool per_core = cai->flags & CSTATE_COUNTER_FLAG_COLLECT_PER_CORE; in cstate_perf_init_()
8149 const bool counter_needed = BIC_IS_ENABLED(cai->bic) || in cstate_perf_init_()
8150 (soft_c1 && (cai->flags & CSTATE_COUNTER_FLAG_SOFT_C1_DEPENDENCY)); in cstate_perf_init_()
8151 const bool counter_supported = (platform->supported_cstates & cai->feature_mask); in cstate_perf_init_()
8155 if (!no_perf && cai->perf_name && add_cstate_perf_counter(cpu, cci, cai) != -1) { in cstate_perf_init_()
8157 cci->source[cai->rci_index] = COUNTER_SOURCE_PERF; 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_()
8162 cci->source[cai->rci_index] = COUNTER_SOURCE_MSR; in cstate_perf_init_()
8163 cci->msr[cai->rci_index] = cai->msr; in cstate_perf_init_()
8167 if (cci->source[cai->rci_index] != COUNTER_SOURCE_NONE) { in cstate_perf_init_()
8176 BIC_PRESENT(cai->bic); in cstate_perf_init_()
8189 const bool soft_c1 = !platform->has_msr_core_c1_res && has_amperf_access() in cstate_perf_init()
8190 && platform->supported_cstates & CC1; in cstate_perf_init()
8202 if (platform->has_msr_module_c6_res_ms) in probe_cstates()
8205 if (platform->has_ext_cst_msrs && !no_msr) { in probe_cstates()
8262 unsigned int eax, ebx, ecx, edx; in process_cpuid() local
8267 eax = ebx = ecx = edx = 0; in process_cpuid()
8269 __cpuid(0, max_level, ebx, ecx, edx); in process_cpuid()
8271 if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) in process_cpuid()
8273 else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) in process_cpuid()
8275 else if (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e) in process_cpuid()
8280 (char *)&ebx, (char *)&edx, (char *)&ecx, max_level); in process_cpuid()
8282 __cpuid(1, fms, ebx, ecx, edx); in process_cpuid()
8290 ecx_flags = ecx; in process_cpuid()
8305 ebx = ecx = edx = 0; in process_cpuid()
8306 __cpuid(0x80000000, max_extended_level, ebx, ecx, edx); in process_cpuid()
8317 ecx_flags & (1 << 0) ? "SSE3" : "-", in process_cpuid()
8318 ecx_flags & (1 << 3) ? "MONITOR" : "-", in process_cpuid()
8319 ecx_flags & (1 << 6) ? "SMX" : "-", in process_cpuid()
8320 ecx_flags & (1 << 7) ? "EIST" : "-", in process_cpuid()
8321 ecx_flags & (1 << 8) ? "TM2" : "-", in process_cpuid()
8322 edx_flags & (1 << 4) ? "TSC" : "-", in process_cpuid()
8323 edx_flags & (1 << 5) ? "MSR" : "-", in process_cpuid()
8324 edx_flags & (1 << 22) ? "ACPI-TM" : "-", in process_cpuid()
8325 edx_flags & (1 << 28) ? "HT" : "-", edx_flags & (1 << 29) ? "TM" : "-"); in process_cpuid()
8336 * Non-Stop TSC is advertised by CPUID.EAX=0x80000007: EDX.bit8 in process_cpuid()
8339 __cpuid(0x80000007, eax, ebx, ecx, edx); in process_cpuid()
8344 * APERF/MPERF is advertised by CPUID.EAX=0x6: ECX.bit0 in process_cpuid()
8348 __cpuid(0x6, eax, ebx, ecx, edx); in process_cpuid()
8349 has_aperf = ecx & (1 << 0); in process_cpuid()
8362 has_epb = ecx & (1 << 3); in process_cpuid()
8367 has_aperf ? "" : "No-", in process_cpuid()
8368 has_turbo ? "" : "No-", in process_cpuid()
8369 do_dts ? "" : "No-", in process_cpuid()
8370 do_ptm ? "" : "No-", in process_cpuid()
8371 has_hwp ? "" : "No-", in process_cpuid()
8372 has_hwp_notify ? "" : "No-", in process_cpuid()
8373 has_hwp_activity_window ? "" : "No-", in process_cpuid()
8374 has_hwp_epp ? "" : "No-", has_hwp_pkg ? "" : "No-", has_epb ? "" : "No-"); in process_cpuid()
8382 ecx = 0; in process_cpuid()
8384 __cpuid_count(0x7, 0, eax, ebx, ecx, edx); in process_cpuid()
8390 fprintf(outf, "CPUID(7): %sSGX %sHybrid\n", has_sgx ? "" : "No-", is_hybrid ? "" : "No-"); in process_cpuid()
8412 crystal_hz = platform->crystal_freq; in process_cpuid()
8437 if (platform->enable_tsc_tweak) in process_cpuid()
8446 aperf_mperf_multiplier = platform->need_perf_multiplier ? 1024 : 1; 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()
8490 if (platform->has_nhm_msrs && !no_msr) in probe_pm_features()
8503 if (isdigit(dirp->d_name[0])) in dir_filter()
8519 return -1; in initialize_cpu_possible_set()
8533 return -1; in initialize_cpu_possible_set()
8631 err(-ENODEV, "No valid cpus found"); in topology_probe()
8745 (*t)[i].cpu_id = -1; in allocate_counters()
8752 (*c)[i].core_id = -1; in allocate_counters()
8753 (*c)[i].base_cpu = -1; in allocate_counters()
8762 (*p)[i].base_cpu = -1; in allocate_counters()
8785 /* Workaround for systems where physical_node_id==-1 in init_counter()
8786 * and logical_node_id==(-1 - topo.num_cpus) in init_counter()
8795 t->cpu_id = cpu_id; in init_counter()
8797 if (c->base_cpu < 0) in init_counter()
8798 c->base_cpu = t->cpu_id; in init_counter()
8799 if (p->base_cpu < 0) in init_counter()
8800 p->base_cpu = t->cpu_id; in init_counter()
8803 c->core_id = core_id; in init_counter()
8804 p->package_id = pkg_id; in init_counter()
8819 err(-1, "calloc output buffer"); in allocate_output_buffer()
8826 err(-1, "calloc fd_percpu"); in allocate_fd_percpu()
8833 err(-1, "calloc %d", topo.num_cpus); in allocate_irq_buffers()
8837 err(-1, "calloc %d IRQ", topo.max_cpu_num + 1); in allocate_irq_buffers()
8841 err(-1, "calloc %d NMI", topo.max_cpu_num + 1); in allocate_irq_buffers()
8847 if ((int)t->cpu_id == c->base_cpu) in update_topo()
8849 if ((int)t->cpu_id == p->base_cpu) in update_topo()
8887 err(-ENODEV, "No valid cpus found"); in set_base_cpu()
8920 * -1: doesn't have separate perf device for p and e core in perf_has_hybrid_devices()
8931 cached = -1; in perf_has_hybrid_devices()
8936 cached = -1; in perf_has_hybrid_devices()
8961 switch (pinfo->scope) { in added_perf_counters_init_()
8976 pinfo->fd_perf_per_domain = calloc(num_domains, sizeof(*pinfo->fd_perf_per_domain)); in added_perf_counters_init_()
8977 if (!pinfo->fd_perf_per_domain) in added_perf_counters_init_()
8981 pinfo->fd_perf_per_domain[i] = -1; in added_perf_counters_init_()
8983 pinfo->num_domains = num_domains; in added_perf_counters_init_()
8984 pinfo->scale = 1.0; in added_perf_counters_init_()
9010 const char *perf_device = pinfo->device; in added_perf_counters_init_()
9028 if (perf_type == (unsigned int)-1) { in added_perf_counters_init_()
9030 __func__, perf_device, pinfo->event, "type"); in added_perf_counters_init_()
9034 perf_config = read_perf_config(perf_device, pinfo->event); in added_perf_counters_init_()
9035 if (perf_config == (unsigned int)-1) { in added_perf_counters_init_()
9037 __func__, perf_device, pinfo->event, "config"); in added_perf_counters_init_()
9042 perf_scale = read_perf_scale(perf_device, pinfo->event); in added_perf_counters_init_()
9046 fd_perf = open_perf_counter(cpu, perf_type, perf_config, -1, 0); in added_perf_counters_init_()
9047 if (fd_perf == -1) { in added_perf_counters_init_()
9049 __func__, perf_device, pinfo->event, cpu); in added_perf_counters_init_()
9054 pinfo->fd_perf_per_domain[next_domain] = fd_perf; in added_perf_counters_init_()
9055 pinfo->scale = perf_scale; in added_perf_counters_init_()
9059 perf_device, pinfo->event, cpu, pinfo->fd_perf_per_domain[next_domain]); in added_perf_counters_init_()
9062 pinfo = pinfo->next; in added_perf_counters_init_()
9089 if (fd_telem_info == -1) in parse_telem_info_file()
9090 return -1; in parse_telem_info_file()
9095 return -1; in parse_telem_info_file()
9100 return -1; in parse_telem_info_file()
9122 if (stat(SYSFS_TELEM_PATH, &st) == -1) in pmt_mmio_open()
9133 if (fstatat(dirfd(pmt_iter.dir), entry->d_name, &st, 0) == -1) in pmt_mmio_open()
9139 fd_telem_dir = openat(dirfd(pmt_iter.dir), entry->d_name, O_RDONLY); in pmt_mmio_open()
9140 if (fd_telem_dir == -1) in pmt_mmio_open()
9166 if (fd_pmt == -1) in pmt_mmio_open()
9188 new_pmt->guid = guid; in pmt_mmio_open()
9189 new_pmt->mmio_base = mmio; in pmt_mmio_open()
9190 new_pmt->pmt_offset = offset; in pmt_mmio_open()
9191 new_pmt->size = size; in pmt_mmio_open()
9192 new_pmt->next = pmt_mmios; in pmt_mmio_open()
9195 last->next = new_pmt; in pmt_mmio_open()
9224 if (pmmio->guid == guid) in pmt_mmio_find()
9227 pmmio = pmmio->next; in pmt_mmio_find()
9238 ret = (char *)pmmio->mmio_base; in pmt_get_counter_pointer()
9243 * - we might have to apply the offset first. in pmt_get_counter_pointer()
9245 ret += pmmio->pmt_offset; in pmt_get_counter_pointer()
9262 ret = ret->next; in pmt_add_guid()
9263 --seq; in pmt_add_guid()
9277 if (strcmp(pcounter->name, name) == 0) in pmt_find_counter()
9280 pcounter = pcounter->next; in pmt_find_counter()
9303 if (domain_id >= pcounter->num_domains) in pmt_counter_add_domain()
9306 assert(pcounter->domains); in pmt_counter_add_domain()
9307 assert(domain_id < pcounter->num_domains); in pmt_counter_add_domain()
9309 pcounter->domains[domain_id].pcounter = pmmio; in pmt_counter_add_domain()
9342 if (offset >= mmio->size) { in pmt_add_counter()
9344 fprintf(stderr, "%s: offset %u outside of PMT MMIO size %u\n", __func__, offset, mmio->size); in pmt_add_counter()
9358 strncpy(pcounter->name, name, ARRAY_SIZE(pcounter->name) - 1); in pmt_add_counter()
9359 pcounter->type = type; in pmt_add_counter()
9360 pcounter->scope = scope; in pmt_add_counter()
9361 pcounter->lsb = lsb; in pmt_add_counter()
9362 pcounter->msb = msb; in pmt_add_counter()
9363 pcounter->format = format; in pmt_add_counter()
9365 conflict += pcounter->type != type; in pmt_add_counter()
9366 conflict += pcounter->scope != scope; in pmt_add_counter()
9367 conflict += pcounter->lsb != lsb; in pmt_add_counter()
9368 conflict += pcounter->msb != msb; in pmt_add_counter()
9369 conflict += pcounter->format != format; in pmt_add_counter()
9381 pcounter->next = *pmt_root; in pmt_add_counter()
9474 if (BIC_IS_ENABLED(BIC_IPC) && has_aperf_access && get_instr_count_fd(base_cpu) != -1) in turbostat_init()
9481 if (platform->enable_tsc_tweak && !has_base_hz) { in turbostat_init()
9520 if (child_pid == -1) in fork_it()
9525 if (waitpid(child_pid, &status, 0) == -1) in fork_it()
9533 * because re-starting is problematic when forking in fork_it()
9572 fprintf(outf, "turbostat version 2025.02.02 - Len Brown <[email protected]>\n"); in print_version()
9588 ret = fread(bootcmd, sizeof(char), COMMAND_LINE_SIZE - 1, fp); in print_bootcmd()
9602 for (mp = head; mp; mp = mp->next) { in find_msrp_by_name()
9604 fprintf(stderr, "%s: %s %s\n", __func__, name, mp->name); in find_msrp_by_name()
9605 if (!strncmp(name, mp->name, strlen(mp->name))) in find_msrp_by_name()
9618 errx(1, "Requested MSR counter 0x%x, but in --no-msr mode", msr_num); in add_counter()
9635 return -1; in add_counter()
9647 return -1; in add_counter()
9659 return -1; in add_counter()
9664 return -1; in add_counter()
9670 err(-1, "calloc msr_counter"); in add_counter()
9672 msrp->msr_num = msr_num; in add_counter()
9673 strncpy(msrp->name, name, NAME_BYTES - 1); in add_counter()
9674 msrp->width = width; in add_counter()
9675 msrp->type = type; in add_counter()
9676 msrp->format = format; in add_counter()
9677 msrp->flags = flags; in add_counter()
9681 msrp->next = sys.tp; in add_counter()
9685 msrp->next = sys.cp; in add_counter()
9689 msrp->next = sys.pp; in add_counter()
9703 strncpy(sp->path, path, PATH_BYTES - 1); in add_counter()
9704 sp->id = id; in add_counter()
9705 sp->next = msrp->sp; in add_counter()
9706 msrp->sp = sp; in add_counter()
9732 strncpy(pinfo->device, perf_device, ARRAY_SIZE(pinfo->device) - 1); in make_perf_counter_info()
9733 strncpy(pinfo->event, perf_event, ARRAY_SIZE(pinfo->event) - 1); in make_perf_counter_info()
9735 strncpy(pinfo->name, name, ARRAY_SIZE(pinfo->name) - 1); in make_perf_counter_info()
9736 pinfo->width = width; in make_perf_counter_info()
9737 pinfo->scope = scope; in make_perf_counter_info()
9738 pinfo->type = type; in make_perf_counter_info()
9739 pinfo->format = format; in make_perf_counter_info()
9753 return -1; in add_perf_counter()
9760 return -1; in add_perf_counter()
9767 return -1; in add_perf_counter()
9775 return -1; in add_perf_counter()
9779 pinfo->next = sys.perf_tp; in add_perf_counter()
9785 pinfo->next = sys.perf_cp; in add_perf_counter()
9791 pinfo->next = sys.perf_pp; in add_perf_counter()
9800 __func__, pinfo->device, pinfo->event, pinfo->name, pinfo->scope); in add_perf_counter()
9897 fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter | perf/device/event) required\n"); in parse_add_command_msr()
9901 /* Test for non-empty perf_device and perf_event */ in parse_add_command_msr()
9940 int fd_telem_dir = -1; in pmt_parse_from_path()
9944 int ret = -1; in pmt_parse_from_path()
9947 if (fd_target_dir == -1) { in pmt_parse_from_path()
9948 return -1; in pmt_parse_from_path()
9951 if (fstat(fd_target_dir, &target_stat) == -1) { in pmt_parse_from_path()
9968 fd_telem_dir = openat(dirfd(pmt_iter.dir), dirname->d_name, O_RDONLY | O_DIRECTORY); in pmt_parse_from_path()
9969 if (fd_telem_dir == -1) in pmt_parse_from_path()
9977 if (fstat(fd_telem_dir, &stat) == -1) { in pmt_parse_from_path()
9979 dirname->d_name, strerror(errno)); in pmt_parse_from_path()
10001 fd_telem_dir = -1; in pmt_parse_from_path()
10006 if (fd_telem_dir != -1) in pmt_parse_from_path()
10260 for (state = 10; state >= 0; --state) { in probe_sysfs()
10269 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
10270 sp = strchr(name_buf, '-'); in probe_sysfs()
10291 for (state = 10; state >= 0; --state) { in probe_sysfs()
10299 /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ in probe_sysfs()
10300 sp = strchr(name_buf, '-'); in probe_sysfs()
10323 * 1,2,4..6,8-10 and set bits in cpu_subset
10355 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
10357 exit(-1); in parse_cpu_command()
10376 { "hide", required_argument, 0, 'H' }, // meh, -h taken by --help in cmdline()
10381 { "no-msr", no_argument, 0, 'M' }, in cmdline()
10382 { "no-perf", no_argument, 0, 'P' }, in cmdline()
10394 * like adding the MSR counter with --add and at the same time using --no-msr. in cmdline()
10396 while ((opt = getopt_long_only(argc, argv, "+MPn:", long_options, &option_index)) != -1) { in cmdline()
10410 …pt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qMST:v", long_options, &option_index)) != -1) { in cmdline()
10428 /* --enable specified counter */ in cmdline()
10440 * --hide: do not show those specified in cmdline()
10459 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000; in cmdline()
10460 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; in cmdline()
10499 * --show: show only those specified in cmdline()
10548 if (ret == -1) in main()
10586 if (argc - optind) in main()