@@ -2133,7 +2133,7 @@ struct thread_data {
21332133 unsigned long long counter [MAX_ADDED_THREAD_COUNTERS ];
21342134 unsigned long long perf_counter [MAX_ADDED_THREAD_COUNTERS ];
21352135 unsigned long long pmt_counter [PMT_MAX_ADDED_THREAD_COUNTERS ];
2136- } * thread_even , * thread_odd ;
2136+ };
21372137
21382138struct core_data {
21392139 int first_cpu ;
@@ -2147,7 +2147,7 @@ struct core_data {
21472147 unsigned long long counter [MAX_ADDED_CORE_COUNTERS ];
21482148 unsigned long long perf_counter [MAX_ADDED_CORE_COUNTERS ];
21492149 unsigned long long pmt_counter [PMT_MAX_ADDED_CORE_COUNTERS ];
2150- } * core_even , * core_odd ;
2150+ };
21512151
21522152struct pkg_data {
21532153 int first_cpu ;
@@ -2182,10 +2182,10 @@ struct pkg_data {
21822182 unsigned long long counter [MAX_ADDED_PACKAGE_COUNTERS ];
21832183 unsigned long long perf_counter [MAX_ADDED_PACKAGE_COUNTERS ];
21842184 unsigned long long pmt_counter [PMT_MAX_ADDED_PACKAGE_COUNTERS ];
2185- } * package_even , * package_odd ;
2185+ };
21862186
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
21892189
21902190#define GET_THREAD (thread_base , thread_no , core_no , node_no , pkg_no ) \
21912191 ((thread_base) + \
@@ -2382,11 +2382,11 @@ static void free_sys_msr_counters(void)
23822382 sys .added_package_counters -= free_msr_counters_ (& sys .pp );
23832383}
23842384
2385- struct system_summary {
2385+ struct counters {
23862386 struct thread_data * threads ;
23872387 struct core_data * cores ;
23882388 struct pkg_data * packages ;
2389- } average ;
2389+ } average , even , odd ;
23902390
23912391struct platform_counters {
23922392 struct rapl_counter energy_psys ; /* MSR_PLATFORM_ENERGY_STATUS */
@@ -3142,7 +3142,7 @@ int dump_counters(PER_THREAD_PARAMS)
31423142{
31433143 int i ;
31443144 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 ;
31463146
31473147 outp += sprintf (outp , "t %p, c %p, p %p\n" , t , c , p );
31483148
@@ -4800,7 +4800,7 @@ void write_rapl_counter(struct rapl_counter *rc, struct rapl_counter_info_t *rci
48004800
48014801int get_rapl_counters (int cpu , unsigned int domain , struct core_data * c , struct pkg_data * p )
48024802{
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 ;
48044804 unsigned long long perf_data [NUM_RAPL_COUNTERS + 1 ];
48054805 struct rapl_counter_info_t * rci ;
48064806
@@ -5973,21 +5973,21 @@ void free_all_buffers(void)
59735973 perf_lcore_set = NULL ;
59745974 }
59755975
5976- free (thread_even );
5977- free (core_even );
5978- free (package_even );
5976+ free (even . threads );
5977+ free (even . cores );
5978+ free (even . packages );
59795979
5980- thread_even = NULL ;
5981- core_even = NULL ;
5982- package_even = NULL ;
5980+ even . threads = NULL ;
5981+ even . cores = NULL ;
5982+ even . packages = NULL ;
59835983
5984- free (thread_odd );
5985- free (core_odd );
5986- free (package_odd );
5984+ free (odd . threads );
5985+ free (odd . cores );
5986+ free (odd . packages );
59875987
5988- thread_odd = NULL ;
5989- core_odd = NULL ;
5990- package_odd = NULL ;
5988+ odd . threads = NULL ;
5989+ odd . cores = NULL ;
5990+ odd . packages = NULL ;
59915991
59925992 free (output_buffer );
59935993 output_buffer = NULL ;
@@ -9687,50 +9687,50 @@ void topology_probe(bool startup)
96879687
96889688}
96899689
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 )
96919691{
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 )
96949694 goto error ;
96959695
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 )
96989698 goto error ;
96999699
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 )
97029702 goto error ;
97039703
97049704 return ;
97059705error :
97069706 err (1 , "calloc counters_1" );
97079707}
9708- void allocate_counters (struct thread_data * * t , struct core_data * * c , struct pkg_data * * p )
9708+ void allocate_counters (struct counters * counters )
97099709{
97109710 int i ;
97119711 int num_cores = topo .cores_per_node * topo .nodes_per_pkg * topo .num_packages ;
97129712 int num_threads = topo .threads_per_core * num_cores ;
97139713
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 )
97169716 goto error ;
97179717
97189718 for (i = 0 ; i < num_threads ; i ++ )
9719- (* t )[i ].cpu_id = -1 ;
9719+ (counters -> threads )[i ].cpu_id = -1 ;
97209720
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 )
97239723 goto error ;
97249724
97259725 for (i = 0 ; i < num_cores ; i ++ )
9726- (* c )[i ].first_cpu = -1 ;
9726+ (counters -> cores )[i ].first_cpu = -1 ;
97279727
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 )
97309730 goto error ;
97319731
97329732 for (i = 0 ; i < topo .num_packages ; i ++ )
9733- (* p )[i ].first_cpu = -1 ;
9733+ (counters -> packages )[i ].first_cpu = -1 ;
97349734
97359735 return ;
97369736error :
@@ -9831,9 +9831,9 @@ void setup_all_buffers(bool startup)
98319831 topology_probe (startup );
98329832 allocate_irq_buffers ();
98339833 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 );
98379837 allocate_output_buffer ();
98389838 for_all_proc_cpus (initialize_counters );
98399839 topology_update ();
0 commit comments