Pull turbostat fixes from Len Brown: - Fix a memory allocation issue that could corrupt output values or SEGV - Fix a perf initilization issue that could exit on some HW + kernels - Minor fixes * tag 'turbostat-fixes-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: tools/power turbostat: Allow execution to continue after perf_l2_init() failure tools/power turbostat: Fix delimiter bug in print functions tools/power turbostat: Fix --show/--hide for individual cpuidle counters tools/power turbostat: Fix incorrect format variable tools/power turbostat: Consistently use print_float_value() tools/power/turbostat: Fix microcode patch level output for AMD/Hygon tools/power turbostat: Eliminate unnecessary data structure allocation tools/power turbostat: Fix swidle header vs data display tools/power turbostat: Fix illegal memory access when SMT is present and disabled
Unified · Split
| @@ -2409,7 +2409,7 @@ struct topo_params { · 2408 unmodified lines | |||
| 2409 | int max_l3_id; | 2409 | int max_l3_id; |
| 2410 | int max_node_num; | 2410 | int max_node_num; |
| 2411 | int nodes_per_pkg; | 2411 | int nodes_per_pkg; |
| 2412 | int cores_per_node; | 2412 | int cores_per_pkg; |
| 2413 | int threads_per_core; | 2413 | int threads_per_core; |
| 2414 | } topo; | 2414 | } topo; |
| 2415 | 2415 | ||
| @@ -2837,30 +2837,29 @@ static inline int print_name(int width, int *printed, char *delim, char *name, e · 421 unmodified lines | |||
| 2837 | UNUSED(type); | 2837 | UNUSED(type); |
| 2838 | 2838 | ||
| 2839 | if (format == FORMAT_RAW && width >= 64) | 2839 | if (format == FORMAT_RAW && width >= 64) |
| 2840 | return (sprintf(outp, "%s%-8s", (*printed++ ? delim : ""), name)); | 2840 | return (sprintf(outp, "%s%-8s", ((*printed)++ ? delim : ""), name)); |
| 2841 | else | 2841 | else |
| 2842 | return (sprintf(outp, "%s%s", (*printed++ ? delim : ""), name)); | 2842 | return (sprintf(outp, "%s%s", ((*printed)++ ? delim : ""), name)); |
| 2843 | } | 2843 | } |
| 2844 | 2844 | ||
| 2845 | static inline int print_hex_value(int width, int *printed, char *delim, unsigned long long value) | 2845 | static inline int print_hex_value(int width, int *printed, char *delim, unsigned long long value) |
| 2846 | { | 2846 | { |
| 2847 | if (width <= 32) | 2847 | if (width <= 32) |
| 2848 | return (sprintf(outp, "%s%08x", (*printed++ ? delim : ""), (unsigned int)value)); | 2848 | return (sprintf(outp, "%s%08x", ((*printed)++ ? delim : ""), (unsigned int)value)); |
| 2849 | else | 2849 | else |
| 2850 | return (sprintf(outp, "%s%016llx", (*printed++ ? delim : ""), value)); | 2850 | return (sprintf(outp, "%s%016llx", ((*printed)++ ? delim : ""), value)); |
| 2851 | } | 2851 | } |
| 2852 | 2852 | ||
| 2853 | static inline int print_decimal_value(int width, int *printed, char *delim, unsigned long long value) | 2853 | static inline int print_decimal_value(int width, int *printed, char *delim, unsigned long long value) |
| 2854 | { | 2854 | { |
| 2855 | if (width <= 32) | 2855 | UNUSED(width); |
| 2856 | return (sprintf(outp, "%s%d", (*printed++ ? delim : ""), (unsigned int)value)); | 2856 | |
| 2857 | else | 2857 | return (sprintf(outp, "%s%lld", ((*printed)++ ? delim : ""), value)); |
| 2858 | return (sprintf(outp, "%s%-8lld", (*printed++ ? delim : ""), value)); | ||
| 2859 | } | 2858 | } |
| 2860 | 2859 | ||
| 2861 | static inline int print_float_value(int *printed, char *delim, double value) | 2860 | static inline int print_float_value(int *printed, char *delim, double value) |
| 2862 | { | 2861 | { |
| 2863 | return (sprintf(outp, "%s%0.2f", (*printed++ ? delim : ""), value)); | 2862 | return (sprintf(outp, "%s%0.2f", ((*printed)++ ? delim : ""), value)); |
| 2864 | } | 2863 | } |
| 2865 | 2864 | ||
| 2866 | void print_header(char *delim) | 2865 | void print_header(char *delim) |
| @@ -3469,7 +3468,7 @@ int format_counters(PER_THREAD_PARAMS) · 602 unmodified lines | |||
| 3469 | for (i = 0, pp = sys.perf_tp; pp; ++i, pp = pp->next) { | 3468 | for (i = 0, pp = sys.perf_tp; pp; ++i, pp = pp->next) { |
| 3470 | if (pp->format == FORMAT_RAW) | 3469 | if (pp->format == FORMAT_RAW) |
| 3471 | outp += print_hex_value(pp->width, &printed, delim, t->perf_counter[i]); | 3470 | outp += print_hex_value(pp->width, &printed, delim, t->perf_counter[i]); |
| 3472 | else if (pp->format == FORMAT_DELTA || mp->format == FORMAT_AVERAGE) | 3471 | else if (pp->format == FORMAT_DELTA || pp->format == FORMAT_AVERAGE) |
| 3473 | outp += print_decimal_value(pp->width, &printed, delim, t->perf_counter[i]); | 3472 | outp += print_decimal_value(pp->width, &printed, delim, t->perf_counter[i]); |
| 3474 | else if (pp->format == FORMAT_PERCENT) { | 3473 | else if (pp->format == FORMAT_PERCENT) { |
| 3475 | if (pp->type == COUNTER_USEC) | 3474 | if (pp->type == COUNTER_USEC) |
| @@ -3490,12 +3489,12 @@ int format_counters(PER_THREAD_PARAMS) · 14 unmodified lines | |||
| 3490 | 3489 | ||
| 3491 | case PMT_TYPE_XTAL_TIME: | 3490 | case PMT_TYPE_XTAL_TIME: |
| 3492 | value_converted = pct(value_raw / crystal_hz, interval_float); | 3491 | value_converted = pct(value_raw / crystal_hz, interval_float); |
| 3493 | outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted); | 3492 | outp += print_float_value(&printed, delim, value_converted); |
| 3494 | break; | 3493 | break; |
| 3495 | 3494 | ||
| 3496 | case PMT_TYPE_TCORE_CLOCK: | 3495 | case PMT_TYPE_TCORE_CLOCK: |
| 3497 | value_converted = pct(value_raw / tcore_clock_freq_hz, interval_float); | 3496 | value_converted = pct(value_raw / tcore_clock_freq_hz, interval_float); |
| 3498 | outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted); | 3497 | outp += print_float_value(&printed, delim, value_converted); |
| 3499 | } | 3498 | } |
| 3500 | } | 3499 | } |
| 3501 | 3500 | ||
| @@ -3539,7 +3538,7 @@ int format_counters(PER_THREAD_PARAMS) · 37 unmodified lines | |||
| 3539 | for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { | 3538 | for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) { |
| 3540 | if (pp->format == FORMAT_RAW) | 3539 | if (pp->format == FORMAT_RAW) |
| 3541 | outp += print_hex_value(pp->width, &printed, delim, c->perf_counter[i]); | 3540 | outp += print_hex_value(pp->width, &printed, delim, c->perf_counter[i]); |
| 3542 | else if (pp->format == FORMAT_DELTA || mp->format == FORMAT_AVERAGE) | 3541 | else if (pp->format == FORMAT_DELTA || pp->format == FORMAT_AVERAGE) |
| 3543 | outp += print_decimal_value(pp->width, &printed, delim, c->perf_counter[i]); | 3542 | outp += print_decimal_value(pp->width, &printed, delim, c->perf_counter[i]); |
| 3544 | else if (pp->format == FORMAT_PERCENT) | 3543 | else if (pp->format == FORMAT_PERCENT) |
| 3545 | outp += print_float_value(&printed, delim, pct(c->perf_counter[i], tsc)); | 3544 | outp += print_float_value(&printed, delim, pct(c->perf_counter[i], tsc)); |
| @@ -3695,7 +3694,7 @@ int format_counters(PER_THREAD_PARAMS) · 149 unmodified lines | |||
| 3695 | outp += print_hex_value(pp->width, &printed, delim, p->perf_counter[i]); | 3694 | outp += print_hex_value(pp->width, &printed, delim, p->perf_counter[i]); |
| 3696 | else if (pp->type == COUNTER_K2M) | 3695 | else if (pp->type == COUNTER_K2M) |
| 3697 | outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), (unsigned int)p->perf_counter[i] / 1000); | 3696 | outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), (unsigned int)p->perf_counter[i] / 1000); |
| 3698 | else if (pp->format == FORMAT_DELTA || mp->format == FORMAT_AVERAGE) | 3697 | else if (pp->format == FORMAT_DELTA || pp->format == FORMAT_AVERAGE) |
| 3699 | outp += print_decimal_value(pp->width, &printed, delim, p->perf_counter[i]); | 3698 | outp += print_decimal_value(pp->width, &printed, delim, p->perf_counter[i]); |
| 3700 | else if (pp->format == FORMAT_PERCENT) | 3699 | else if (pp->format == FORMAT_PERCENT) |
| 3701 | outp += print_float_value(&printed, delim, pct(p->perf_counter[i], tsc)); | 3700 | outp += print_float_value(&printed, delim, pct(p->perf_counter[i], tsc)); |
| @@ -9122,10 +9121,13 @@ void process_cpuid() · 5420 unmodified lines | |||
| 9122 | cpuid_has_hv = ecx_flags & (1 << 31); | 9121 | cpuid_has_hv = ecx_flags & (1 << 31); |
| 9123 | 9122 | ||
| 9124 | if (!no_msr) { | 9123 | if (!no_msr) { |
| 9125 | if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) | 9124 | if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) { |
| 9126 | warnx("get_msr(UCODE)"); | 9125 | warnx("get_msr(UCODE)"); |
| 9127 | else | 9126 | } else { |
| 9128 | ucode_patch_valid = true; | 9127 | ucode_patch_valid = true; |
| 9128 | if (!authentic_amd && !hygon_genuine) | ||
| 9129 | ucode_patch >>= 32; | ||
| 9130 | } | ||
| 9129 | } | 9131 | } |
| 9130 | 9132 | ||
| 9131 | /* | 9133 | /* |
| @@ -9139,7 +9141,7 @@ void process_cpuid() · 7 unmodified lines | |||
| 9139 | if (!quiet) { | 9141 | if (!quiet) { |
| 9140 | fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)", family, model, stepping, family, model, stepping); | 9142 | fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)", family, model, stepping, family, model, stepping); |
| 9141 | if (ucode_patch_valid) | 9143 | if (ucode_patch_valid) |
| 9142 | fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF)); | 9144 | fprintf(outf, " microcode 0x%x", (unsigned int)ucode_patch); |
| 9143 | fputc('\n', outf); | 9145 | fputc('\n', outf); |
| 9144 | 9146 | ||
| 9145 | fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level); | 9147 | fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level); |
| @@ -9403,13 +9405,13 @@ void perf_l2_init(void) · 257 unmodified lines | |||
| 9403 | if (!is_hybrid) { | 9405 | if (!is_hybrid) { |
| 9404 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.uniform, perf_model_support->first.refs, -1, PERF_FORMAT_GROUP); | 9406 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.uniform, perf_model_support->first.refs, -1, PERF_FORMAT_GROUP); |
| 9405 | if (fd_l2_percpu[cpu] == -1) { | 9407 | if (fd_l2_percpu[cpu] == -1) { |
| 9406 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.uniform, perf_model_support->first.refs); | 9408 | warnx("%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.uniform, perf_model_support->first.refs); |
| 9407 | free_fd_l2_percpu(); | 9409 | free_fd_l2_percpu(); |
| 9408 | return; | 9410 | return; |
| 9409 | } | 9411 | } |
| 9410 | retval = open_perf_counter(cpu, perf_pmu_types.uniform, perf_model_support->first.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); | 9412 | retval = open_perf_counter(cpu, perf_pmu_types.uniform, perf_model_support->first.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); |
| 9411 | if (retval == -1) { | 9413 | if (retval == -1) { |
| 9412 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.uniform, perf_model_support->first.hits); | 9414 | warnx("%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.uniform, perf_model_support->first.hits); |
| 9413 | free_fd_l2_percpu(); | 9415 | free_fd_l2_percpu(); |
| 9414 | return; | 9416 | return; |
| 9415 | } | 9417 | } |
| @@ -9418,39 +9420,39 @@ void perf_l2_init(void) · 2 unmodified lines | |||
| 9418 | if (perf_pcore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_pcore_set)) { | 9420 | if (perf_pcore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_pcore_set)) { |
| 9419 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.pcore, perf_model_support->first.refs, -1, PERF_FORMAT_GROUP); | 9421 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.pcore, perf_model_support->first.refs, -1, PERF_FORMAT_GROUP); |
| 9420 | if (fd_l2_percpu[cpu] == -1) { | 9422 | if (fd_l2_percpu[cpu] == -1) { |
| 9421 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->first.refs); | 9423 | warnx("%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->first.refs); |
| 9422 | free_fd_l2_percpu(); | 9424 | free_fd_l2_percpu(); |
| 9423 | return; | 9425 | return; |
| 9424 | } | 9426 | } |
| 9425 | retval = open_perf_counter(cpu, perf_pmu_types.pcore, perf_model_support->first.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); | 9427 | retval = open_perf_counter(cpu, perf_pmu_types.pcore, perf_model_support->first.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); |
| 9426 | if (retval == -1) { | 9428 | if (retval == -1) { |
| 9427 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->first.hits); | 9429 | warnx("%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->first.hits); |
| 9428 | free_fd_l2_percpu(); | 9430 | free_fd_l2_percpu(); |
| 9429 | return; | 9431 | return; |
| 9430 | } | 9432 | } |
| 9431 | } else if (perf_ecore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_ecore_set)) { | 9433 | } else if (perf_ecore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_ecore_set)) { |
| 9432 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.ecore, perf_model_support->second.refs, -1, PERF_FORMAT_GROUP); | 9434 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.ecore, perf_model_support->second.refs, -1, PERF_FORMAT_GROUP); |
| 9433 | if (fd_l2_percpu[cpu] == -1) { | 9435 | if (fd_l2_percpu[cpu] == -1) { |
| 9434 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->second.refs); | 9436 | warnx("%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.ecore, perf_model_support->second.refs); |
| 9435 | free_fd_l2_percpu(); | 9437 | free_fd_l2_percpu(); |
| 9436 | return; | 9438 | return; |
| 9437 | } | 9439 | } |
| 9438 | retval = open_perf_counter(cpu, perf_pmu_types.ecore, perf_model_support->second.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); | 9440 | retval = open_perf_counter(cpu, perf_pmu_types.ecore, perf_model_support->second.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); |
| 9439 | if (retval == -1) { | 9441 | if (retval == -1) { |
| 9440 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->second.hits); | 9442 | warnx("%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.ecore, perf_model_support->second.hits); |
| 9441 | free_fd_l2_percpu(); | 9443 | free_fd_l2_percpu(); |
| 9442 | return; | 9444 | return; |
| 9443 | } | 9445 | } |
| 9444 | } else if (perf_lcore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_lcore_set)) { | 9446 | } else if (perf_lcore_set && CPU_ISSET_S(cpu, cpu_possible_setsize, perf_lcore_set)) { |
| 9445 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.lcore, perf_model_support->third.refs, -1, PERF_FORMAT_GROUP); | 9447 | fd_l2_percpu[cpu] = open_perf_counter(cpu, perf_pmu_types.lcore, perf_model_support->third.refs, -1, PERF_FORMAT_GROUP); |
| 9446 | if (fd_l2_percpu[cpu] == -1) { | 9448 | if (fd_l2_percpu[cpu] == -1) { |
| 9447 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->third.refs); | 9449 | warnx("%s(cpu%d, 0x%x, 0x%llx) REFS", __func__, cpu, perf_pmu_types.lcore, perf_model_support->third.refs); |
| 9448 | free_fd_l2_percpu(); | 9450 | free_fd_l2_percpu(); |
| 9449 | return; | 9451 | return; |
| 9450 | } | 9452 | } |
| 9451 | retval = open_perf_counter(cpu, perf_pmu_types.lcore, perf_model_support->third.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); | 9453 | retval = open_perf_counter(cpu, perf_pmu_types.lcore, perf_model_support->third.hits, fd_l2_percpu[cpu], PERF_FORMAT_GROUP); |
| 9452 | if (retval == -1) { | 9454 | if (retval == -1) { |
| 9453 | err(-1, "%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.pcore, perf_model_support->third.hits); | 9455 | warnx("%s(cpu%d, 0x%x, 0x%llx) HITS", __func__, cpu, perf_pmu_types.lcore, perf_model_support->third.hits); |
| 9454 | free_fd_l2_percpu(); | 9456 | free_fd_l2_percpu(); |
| 9455 | return; | 9457 | return; |
| 9456 | } | 9458 | } |
| @@ -9634,9 +9636,9 @@ void topology_probe(bool startup) · 177 unmodified lines | |||
| 9634 | topo.max_core_id = max_core_id; /* within a package */ | 9636 | topo.max_core_id = max_core_id; /* within a package */ |
| 9635 | topo.max_package_id = max_package_id; | 9637 | topo.max_package_id = max_package_id; |
| 9636 | 9638 | ||
| 9637 | topo.cores_per_node = max_core_id + 1; | 9639 | topo.cores_per_pkg = max_core_id + 1; |
| 9638 | if (debug > 1) | 9640 | if (debug > 1) |
| 9639 | fprintf(outf, "max_core_id %d, sizing for %d cores per package\n", max_core_id, topo.cores_per_node); | 9641 | fprintf(outf, "max_core_id %d, sizing for %d cores per package\n", max_core_id, topo.cores_per_pkg); |
| 9640 | if (!summary_only) | 9642 | if (!summary_only) |
| 9641 | BIC_PRESENT(BIC_Core); | 9643 | BIC_PRESENT(BIC_Core); |
| 9642 | 9644 | ||
| @@ -9701,14 +9703,13 @@ error: · 58 unmodified lines | |||
| 9701 | void allocate_counters(struct counters *counters) | 9703 | void allocate_counters(struct counters *counters) |
| 9702 | { | 9704 | { |
| 9703 | int i; | 9705 | int i; |
| 9704 | int num_cores = topo.cores_per_node * topo.nodes_per_pkg * topo.num_packages; | 9706 | int num_cores = topo.cores_per_pkg * topo.num_packages; |
| 9705 | int num_threads = topo.threads_per_core * num_cores; | ||
| 9706 | 9707 | ||
| 9707 | counters->threads = calloc(num_threads, sizeof(struct thread_data)); | 9708 | counters->threads = calloc(topo.max_cpu_num + 1, sizeof(struct thread_data)); |
| 9708 | if (counters->threads == NULL) | 9709 | if (counters->threads == NULL) |
| 9709 | goto error; | 9710 | goto error; |
| 9710 | 9711 | ||
| 9711 | for (i = 0; i < num_threads; i++) | 9712 | for (i = 0; i < topo.max_cpu_num + 1; i++) |
| 9712 | (counters->threads)[i].cpu_id = -1; | 9713 | (counters->threads)[i].cpu_id = -1; |
| 9713 | 9714 | ||
| 9714 | counters->cores = calloc(num_cores, sizeof(struct core_data)); | 9715 | counters->cores = calloc(num_cores, sizeof(struct core_data)); |
| @@ -11284,6 +11285,14 @@ void probe_cpuidle_residency(void) · 1569 unmodified lines | |||
| 11284 | } | 11285 | } |
| 11285 | } | 11286 | } |
| 11286 | 11287 | ||
| 11288 | static bool cpuidle_counter_wanted(char *name) | ||
| 11289 | { | ||
| 11290 | if (is_deferred_skip(name)) | ||
| 11291 | return false; | ||
| 11292 | |||
| 11293 | return DO_BIC(BIC_cpuidle) || is_deferred_add(name); | ||
| 11294 | } | ||
| 11295 | |||
| 11287 | void probe_cpuidle_counts(void) | 11296 | void probe_cpuidle_counts(void) |
| 11288 | { | 11297 | { |
| 11289 | char path[64]; | 11298 | char path[64]; |
| @@ -11293,7 +11302,7 @@ void probe_cpuidle_counts(void) · 3 unmodified lines | |||
| 11293 | int min_state = 1024, max_state = 0; | 11302 | int min_state = 1024, max_state = 0; |
| 11294 | char *sp; | 11303 | char *sp; |
| 11295 | 11304 | ||
| 11296 | if (!DO_BIC(BIC_cpuidle)) | 11305 | if (!DO_BIC(BIC_cpuidle) && !deferred_add_index) |
| 11297 | return; | 11306 | return; |
| 11298 | 11307 | ||
| 11299 | for (state = 10; state >= 0; --state) { | 11308 | for (state = 10; state >= 0; --state) { |
| @@ -11308,12 +11317,6 @@ void probe_cpuidle_counts(void) · 8 unmodified lines | |||
| 11308 | 11317 | ||
| 11309 | remove_underbar(name_buf); | 11318 | remove_underbar(name_buf); |
| 11310 | 11319 | ||
| 11311 | if (!DO_BIC(BIC_cpuidle) && !is_deferred_add(name_buf)) | ||
| 11312 | continue; | ||
| 11313 | |||
| 11314 | if (is_deferred_skip(name_buf)) | ||
| 11315 | continue; | ||
| 11316 | |||
| 11317 | /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ | 11320 | /* truncate "C1-HSW\n" to "C1", or truncate "C1\n" to "C1" */ |
| 11318 | sp = strchr(name_buf, '-'); | 11321 | sp = strchr(name_buf, '-'); |
| 11319 | if (!sp) | 11322 | if (!sp) |
| @@ -11328,16 +11331,19 @@ void probe_cpuidle_counts(void) · 8 unmodified lines | |||
| 11328 | * Add 'C1+' for C1, and so on. The 'below' sysfs file always contains 0 for | 11331 | * Add 'C1+' for C1, and so on. The 'below' sysfs file always contains 0 for |
| 11329 | * the last state, so do not add it. | 11332 | * the last state, so do not add it. |
| 11330 | */ | 11333 | */ |
| 11331 | |||
| 11332 | *sp = '+'; | 11334 | *sp = '+'; |
| 11333 | *(sp + 1) = '\0'; | 11335 | *(sp + 1) = '\0'; |
| 11334 | sprintf(path, "cpuidle/state%d/below", state); | 11336 | if (cpuidle_counter_wanted(name_buf)) { |
| 11335 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | 11337 | sprintf(path, "cpuidle/state%d/below", state); |
| 11338 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | ||
| 11339 | } | ||
| 11336 | } | 11340 | } |
| 11337 | 11341 | ||
| 11338 | *sp = '\0'; | 11342 | *sp = '\0'; |
| 11339 | sprintf(path, "cpuidle/state%d/usage", state); | 11343 | if (cpuidle_counter_wanted(name_buf)) { |
| 11340 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | 11344 | sprintf(path, "cpuidle/state%d/usage", state); |
| 11345 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | ||
| 11346 | } | ||
| 11341 | 11347 | ||
| 11342 | /* | 11348 | /* |
| 11343 | * The 'above' sysfs file always contains 0 for the shallowest state (smallest | 11349 | * The 'above' sysfs file always contains 0 for the shallowest state (smallest |
| @@ -11346,8 +11352,10 @@ void probe_cpuidle_counts(void) · 2 unmodified lines | |||
| 11346 | if (state != min_state) { | 11352 | if (state != min_state) { |
| 11347 | *sp = '-'; | 11353 | *sp = '-'; |
| 11348 | *(sp + 1) = '\0'; | 11354 | *(sp + 1) = '\0'; |
| 11349 | sprintf(path, "cpuidle/state%d/above", state); | 11355 | if (cpuidle_counter_wanted(name_buf)) { |
| 11350 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | 11356 | sprintf(path, "cpuidle/state%d/above", state); |
| 11357 | add_counter(0, path, name_buf, 64, SCOPE_CPU, COUNTER_ITEMS, FORMAT_DELTA, SYSFS_PERCPU, 0); | ||
| 11358 | } | ||
| 11351 | } | 11359 | } |
| 11352 | } | 11360 | } |
| 11353 | } | 11361 | } |