Skip to content

Commit 5e16064

Browse files
committed
tools/power turbostat: Rename physical_core_id to core_id
The Linux Kernel topology sysfs is flawed. core_id is not globally unique, but is per-package. Turbostat works around this when it needs to, with rapl_core_id = cpus[cpu].core_id; rapl_core_id += cpus[cpu].package_id * nr_cores_per_package Otherwise, turbostat handles core_id as subservient to each package. As there is only one core_id namespace, rename physical_core_id to simply be core_id. No functional change. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 4aaf7d0 commit 5e16064

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,13 +2394,13 @@ struct platform_counters {
23942394
} platform_counters_odd, platform_counters_even;
23952395

23962396
struct cpu_topology {
2397+
int core_id;
23972398
int package_id;
23982399
int die_id;
23992400
int l3_id;
24002401
int logical_cpu_id;
24012402
int physical_node_id;
24022403
int logical_node_id; /* 0-based count within the package */
2403-
int physical_core_id;
24042404
int thread_id;
24052405
int type;
24062406
cpu_set_t *put_ids; /* Processing Unit/Thread IDs */
@@ -2658,7 +2658,7 @@ unsigned int cpu_to_domain(const struct perf_counter_info *pc, int cpu)
26582658
return cpu;
26592659

26602660
case SCOPE_CORE:
2661-
return cpus[cpu].physical_core_id;
2661+
return cpus[cpu].core_id;
26622662

26632663
case SCOPE_PACKAGE:
26642664
return cpus[cpu].package_id;
@@ -5180,7 +5180,7 @@ static inline int get_rapl_domain_id(int cpu)
51805180
return cpus[cpu].package_id;
51815181

51825182
/* Compute the system-wide unique core-id for @cpu */
5183-
rapl_core_id = cpus[cpu].physical_core_id;
5183+
rapl_core_id = cpus[cpu].core_id;
51845184
rapl_core_id += cpus[cpu].package_id * nr_cores_per_package;
51855185

51865186
return rapl_core_id;
@@ -6216,7 +6216,7 @@ int get_thread_siblings(struct cpu_topology *thiscpu)
62166216
if ((map >> shift) & 0x1) {
62176217
so = shift + offset;
62186218
sib_core = get_core_id(so);
6219-
if (sib_core == thiscpu->physical_core_id) {
6219+
if (sib_core == thiscpu->core_id) {
62206220
CPU_SET_S(so, size, thiscpu->put_ids);
62216221
if ((so != cpu) && (cpus[so].thread_id < 0))
62226222
cpus[so].thread_id = thread_id++;
@@ -8948,7 +8948,7 @@ void cstate_perf_init_(bool soft_c1)
89488948
if (cpu_is_not_allowed(cpu))
89498949
continue;
89508950

8951-
const int core_id = cpus[cpu].physical_core_id;
8951+
const int core_id = cpus[cpu].core_id;
89528952
const int pkg_id = cpus[cpu].package_id;
89538953

89548954
assert(core_id < cores_visited_elems);
@@ -9629,9 +9629,9 @@ void topology_probe(bool startup)
96299629
topo.max_node_num = cpus[i].physical_node_id;
96309630

96319631
/* get core information */
9632-
cpus[i].physical_core_id = get_core_id(i);
9633-
if (cpus[i].physical_core_id > max_core_id)
9634-
max_core_id = cpus[i].physical_core_id;
9632+
cpus[i].core_id = get_core_id(i);
9633+
if (cpus[i].core_id > max_core_id)
9634+
max_core_id = cpus[i].core_id;
96359635

96369636
/* get thread information */
96379637
siblings = get_thread_siblings(&cpus[i]);
@@ -9683,7 +9683,7 @@ void topology_probe(bool startup)
96839683
fprintf(outf,
96849684
"cpu %d pkg %d die %d l3 %d node %d lnode %d core %d thread %d\n",
96859685
i, cpus[i].package_id, cpus[i].die_id, cpus[i].l3_id,
9686-
cpus[i].physical_node_id, cpus[i].logical_node_id, cpus[i].physical_core_id, cpus[i].thread_id);
9686+
cpus[i].physical_node_id, cpus[i].logical_node_id, cpus[i].core_id, cpus[i].thread_id);
96879687
}
96889688

96899689
}
@@ -9731,7 +9731,7 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
97319731
{
97329732
int pkg_id = cpus[cpu_id].package_id;
97339733
int node_id = cpus[cpu_id].logical_node_id;
9734-
int core_id = cpus[cpu_id].physical_core_id;
9734+
int core_id = cpus[cpu_id].core_id;
97359735
int thread_id = cpus[cpu_id].thread_id;
97369736
struct thread_data *t;
97379737
struct core_data *c;

0 commit comments

Comments
 (0)