Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/power turbostat: Unify even/odd/average counter referencing

Update the syntax of accesses to the even and odd counters
to match the average counters.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>

Len Brown a8546849 3cecd4a6

+41 -41
+41 -41
tools/power/x86/turbostat/turbostat.c
··· 2133 2133 unsigned long long counter[MAX_ADDED_THREAD_COUNTERS]; 2134 2134 unsigned long long perf_counter[MAX_ADDED_THREAD_COUNTERS]; 2135 2135 unsigned long long pmt_counter[PMT_MAX_ADDED_THREAD_COUNTERS]; 2136 - } *thread_even, *thread_odd; 2136 + }; 2137 2137 2138 2138 struct core_data { 2139 2139 int first_cpu; ··· 2147 2147 unsigned long long counter[MAX_ADDED_CORE_COUNTERS]; 2148 2148 unsigned long long perf_counter[MAX_ADDED_CORE_COUNTERS]; 2149 2149 unsigned long long pmt_counter[PMT_MAX_ADDED_CORE_COUNTERS]; 2150 - } *core_even, *core_odd; 2150 + }; 2151 2151 2152 2152 struct pkg_data { 2153 2153 int first_cpu; ··· 2182 2182 unsigned long long counter[MAX_ADDED_PACKAGE_COUNTERS]; 2183 2183 unsigned long long perf_counter[MAX_ADDED_PACKAGE_COUNTERS]; 2184 2184 unsigned long long pmt_counter[PMT_MAX_ADDED_PACKAGE_COUNTERS]; 2185 - } *package_even, *package_odd; 2185 + }; 2186 2186 2187 - #define ODD_COUNTERS thread_odd, core_odd, package_odd 2188 - #define EVEN_COUNTERS thread_even, core_even, package_even 2187 + #define ODD_COUNTERS odd.threads, odd.cores, odd.packages 2188 + #define EVEN_COUNTERS even.threads, even.cores, even.packages 2189 2189 2190 2190 #define GET_THREAD(thread_base, thread_no, core_no, node_no, pkg_no) \ 2191 2191 ((thread_base) + \ ··· 2382 2382 sys.added_package_counters -= free_msr_counters_(&sys.pp); 2383 2383 } 2384 2384 2385 - struct system_summary { 2385 + struct counters { 2386 2386 struct thread_data *threads; 2387 2387 struct core_data *cores; 2388 2388 struct pkg_data *packages; 2389 - } average; 2389 + } average, even, odd; 2390 2390 2391 2391 struct platform_counters { 2392 2392 struct rapl_counter energy_psys; /* MSR_PLATFORM_ENERGY_STATUS */ ··· 3142 3142 { 3143 3143 int i; 3144 3144 struct msr_counter *mp; 3145 - struct platform_counters *pplat_cnt = p == package_odd ? &platform_counters_odd : &platform_counters_even; 3145 + struct platform_counters *pplat_cnt = p == odd.packages ? &platform_counters_odd : &platform_counters_even; 3146 3146 3147 3147 outp += sprintf(outp, "t %p, c %p, p %p\n", t, c, p); 3148 3148 ··· 4800 4800 4801 4801 int get_rapl_counters(int cpu, unsigned int domain, struct core_data *c, struct pkg_data *p) 4802 4802 { 4803 - struct platform_counters *pplat_cnt = p == package_odd ? &platform_counters_odd : &platform_counters_even; 4803 + struct platform_counters *pplat_cnt = p == odd.packages ? &platform_counters_odd : &platform_counters_even; 4804 4804 unsigned long long perf_data[NUM_RAPL_COUNTERS + 1]; 4805 4805 struct rapl_counter_info_t *rci; 4806 4806 ··· 5973 5973 perf_lcore_set = NULL; 5974 5974 } 5975 5975 5976 - free(thread_even); 5977 - free(core_even); 5978 - free(package_even); 5976 + free(even.threads); 5977 + free(even.cores); 5978 + free(even.packages); 5979 5979 5980 - thread_even = NULL; 5981 - core_even = NULL; 5982 - package_even = NULL; 5980 + even.threads = NULL; 5981 + even.cores = NULL; 5982 + even.packages = NULL; 5983 5983 5984 - free(thread_odd); 5985 - free(core_odd); 5986 - free(package_odd); 5984 + free(odd.threads); 5985 + free(odd.cores); 5986 + free(odd.packages); 5987 5987 5988 - thread_odd = NULL; 5989 - core_odd = NULL; 5990 - package_odd = NULL; 5988 + odd.threads = NULL; 5989 + odd.cores = NULL; 5990 + odd.packages = NULL; 5991 5991 5992 5992 free(output_buffer); 5993 5993 output_buffer = NULL; ··· 9687 9687 9688 9688 } 9689 9689 9690 - void allocate_counters_1(struct thread_data **t, struct core_data **c, struct pkg_data **p) 9690 + void allocate_counters_1(struct counters *counters) 9691 9691 { 9692 - *t = calloc(1, sizeof(struct thread_data)); 9693 - if (*t == NULL) 9692 + counters->threads = calloc(1, sizeof(struct thread_data)); 9693 + if (counters->threads == NULL) 9694 9694 goto error; 9695 9695 9696 - *c = calloc(1, sizeof(struct core_data)); 9697 - if (*c == NULL) 9696 + counters->cores = calloc(1, sizeof(struct core_data)); 9697 + if (counters->cores == NULL) 9698 9698 goto error; 9699 9699 9700 - *p = calloc(1, sizeof(struct pkg_data)); 9701 - if (*p == NULL) 9700 + counters->packages = calloc(1, sizeof(struct pkg_data)); 9701 + if (counters->packages == NULL) 9702 9702 goto error; 9703 9703 9704 9704 return; 9705 9705 error: 9706 9706 err(1, "calloc counters_1"); 9707 9707 } 9708 - void allocate_counters(struct thread_data **t, struct core_data **c, struct pkg_data **p) 9708 + void allocate_counters(struct counters *counters) 9709 9709 { 9710 9710 int i; 9711 9711 int num_cores = topo.cores_per_node * topo.nodes_per_pkg * topo.num_packages; 9712 9712 int num_threads = topo.threads_per_core * num_cores; 9713 9713 9714 - *t = calloc(num_threads, sizeof(struct thread_data)); 9715 - if (*t == NULL) 9714 + counters->threads = calloc(num_threads, sizeof(struct thread_data)); 9715 + if (counters->threads == NULL) 9716 9716 goto error; 9717 9717 9718 9718 for (i = 0; i < num_threads; i++) 9719 - (*t)[i].cpu_id = -1; 9719 + (counters->threads)[i].cpu_id = -1; 9720 9720 9721 - *c = calloc(num_cores, sizeof(struct core_data)); 9722 - if (*c == NULL) 9721 + counters->cores = calloc(num_cores, sizeof(struct core_data)); 9722 + if (counters->cores == NULL) 9723 9723 goto error; 9724 9724 9725 9725 for (i = 0; i < num_cores; i++) 9726 - (*c)[i].first_cpu = -1; 9726 + (counters->cores)[i].first_cpu = -1; 9727 9727 9728 - *p = calloc(topo.num_packages, sizeof(struct pkg_data)); 9729 - if (*p == NULL) 9728 + counters->packages = calloc(topo.num_packages, sizeof(struct pkg_data)); 9729 + if (counters->packages == NULL) 9730 9730 goto error; 9731 9731 9732 9732 for (i = 0; i < topo.num_packages; i++) 9733 - (*p)[i].first_cpu = -1; 9733 + (counters->packages)[i].first_cpu = -1; 9734 9734 9735 9735 return; 9736 9736 error: ··· 9831 9831 topology_probe(startup); 9832 9832 allocate_irq_buffers(); 9833 9833 allocate_fd_percpu(); 9834 - allocate_counters_1(&average.threads, &average.cores, &average.packages); 9835 - allocate_counters(&thread_even, &core_even, &package_even); 9836 - allocate_counters(&thread_odd, &core_odd, &package_odd); 9834 + allocate_counters_1(&average); 9835 + allocate_counters(&even); 9836 + allocate_counters(&odd); 9837 9837 allocate_output_buffer(); 9838 9838 for_all_proc_cpus(initialize_counters); 9839 9839 topology_update();