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: Simplify global core_id calculation

Standardize the generation of globally unique core_id's
in a macro, and simplify the related code.

No functional change.

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

Len Brown ddf60e38 a8546849

+7 -20
+7 -20
tools/power/x86/turbostat/turbostat.c
··· 2393 2393 } platform_counters_odd, platform_counters_even; 2394 2394 2395 2395 struct cpu_topology { 2396 - int core_id; 2396 + int core_id; /* unique within a package */ 2397 2397 int package_id; 2398 2398 int die_id; 2399 2399 int l3_id; ··· 2409 2409 int num_packages; 2410 2410 int num_die; 2411 2411 int num_cpus; 2412 - int num_cores; 2412 + int num_cores; /* system wide */ 2413 2413 int allowed_packages; 2414 2414 int allowed_cpus; 2415 2415 int allowed_cores; 2416 2416 int max_cpu_num; 2417 - int max_core_id; 2417 + int max_core_id; /* within a package */ 2418 2418 int max_package_id; 2419 2419 int max_die_id; 2420 2420 int max_l3_id; ··· 2446 2446 return !CPU_ISSET_S(cpu, cpu_allowed_setsize, cpu_allowed_set); 2447 2447 } 2448 2448 2449 + #define GLOBAL_CORE_ID(core_id, pkg_id) (core_id + pkg_id * (topo.max_core_id + 1)) 2449 2450 /* 2450 2451 * run func(thread, core, package) in topology order 2451 2452 * skip non-present cpus ··· 5158 5157 /* Rapl domain enumeration helpers */ 5159 5158 static inline int get_rapl_num_domains(void) 5160 5159 { 5161 - int num_packages = topo.max_package_id + 1; 5162 - int num_cores_per_package; 5163 - int num_cores; 5164 - 5165 5160 if (!platform->has_per_core_rapl) 5166 - return num_packages; 5161 + return topo.num_packages; 5167 5162 5168 - num_cores_per_package = topo.max_core_id + 1; 5169 - num_cores = num_cores_per_package * num_packages; 5170 - 5171 - return num_cores; 5163 + return topo.num_cores; 5172 5164 } 5173 5165 5174 5166 static inline int get_rapl_domain_id(int cpu) 5175 5167 { 5176 - int nr_cores_per_package = topo.max_core_id + 1; 5177 - int rapl_core_id; 5178 - 5179 5168 if (!platform->has_per_core_rapl) 5180 5169 return cpus[cpu].package_id; 5181 5170 5182 - /* Compute the system-wide unique core-id for @cpu */ 5183 - rapl_core_id = cpus[cpu].core_id; 5184 - rapl_core_id += cpus[cpu].package_id * nr_cores_per_package; 5185 - 5186 - return rapl_core_id; 5171 + return GLOBAL_CORE_ID(cpu, cpus[cpu].package_id); 5187 5172 } 5188 5173 5189 5174 /*