@@ -2393,7 +2393,7 @@ struct platform_counters {
23932393} platform_counters_odd , platform_counters_even ;
23942394
23952395struct cpu_topology {
2396- int core_id ;
2396+ int core_id ; /* unique within a package */
23972397 int package_id ;
23982398 int die_id ;
23992399 int l3_id ;
@@ -2409,12 +2409,12 @@ struct topo_params {
24092409 int num_packages ;
24102410 int num_die ;
24112411 int num_cpus ;
2412- int num_cores ;
2412+ int num_cores ; /* system wide */
24132413 int allowed_packages ;
24142414 int allowed_cpus ;
24152415 int allowed_cores ;
24162416 int max_cpu_num ;
2417- int max_core_id ;
2417+ int max_core_id ; /* within a package */
24182418 int max_package_id ;
24192419 int max_die_id ;
24202420 int max_l3_id ;
@@ -2446,6 +2446,7 @@ int cpu_is_not_allowed(int cpu)
24462446 return !CPU_ISSET_S (cpu , cpu_allowed_setsize , cpu_allowed_set );
24472447}
24482448
2449+ #define GLOBAL_CORE_ID (core_id , pkg_id ) (core_id + pkg_id * (topo.max_core_id + 1))
24492450/*
24502451 * run func(thread, core, package) in topology order
24512452 * skip non-present cpus
@@ -5157,32 +5158,18 @@ unsigned long pmt_read_counter(struct pmt_counter *ppmt, unsigned int domain_id)
51575158/* Rapl domain enumeration helpers */
51585159static inline int get_rapl_num_domains (void )
51595160{
5160- int num_packages = topo .max_package_id + 1 ;
5161- int num_cores_per_package ;
5162- int num_cores ;
5163-
51645161 if (!platform -> has_per_core_rapl )
5165- return num_packages ;
5166-
5167- num_cores_per_package = topo .max_core_id + 1 ;
5168- num_cores = num_cores_per_package * num_packages ;
5162+ return topo .num_packages ;
51695163
5170- return num_cores ;
5164+ return topo . num_cores ;
51715165}
51725166
51735167static inline int get_rapl_domain_id (int cpu )
51745168{
5175- int nr_cores_per_package = topo .max_core_id + 1 ;
5176- int rapl_core_id ;
5177-
51785169 if (!platform -> has_per_core_rapl )
51795170 return cpus [cpu ].package_id ;
51805171
5181- /* Compute the system-wide unique core-id for @cpu */
5182- rapl_core_id = cpus [cpu ].core_id ;
5183- rapl_core_id += cpus [cpu ].package_id * nr_cores_per_package ;
5184-
5185- return rapl_core_id ;
5172+ return GLOBAL_CORE_ID (cpu , cpus [cpu ].package_id );
51865173}
51875174
51885175/*
0 commit comments