mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 22:58:29 +00:00
tools/power turbostat: Fix logical node enumeration to allow for non-sequential physical nodes
turbostat fails on some multi-package topologies because the logical node enumeration assumes that the nodes are sequentially numbered, which causes the logical numa nodes to not be enumerated, or enumerated incorrectly. Use a more robust enumeration algorithm which allows for non-seqential physical nodes. Signed-off-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
cfce494db3
commit
2ffbb22406
1 changed files with 48 additions and 54 deletions
|
@ -2471,55 +2471,43 @@ int get_core_id(int cpu)
|
||||||
|
|
||||||
void set_node_data(void)
|
void set_node_data(void)
|
||||||
{
|
{
|
||||||
char path[80];
|
int pkg, node, lnode, cpu, cpux;
|
||||||
FILE *filep;
|
int cpu_count;
|
||||||
int pkg, node, cpu;
|
|
||||||
|
|
||||||
struct pkg_node_info {
|
/* initialize logical_node_id */
|
||||||
int count;
|
for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu)
|
||||||
int min;
|
cpus[cpu].logical_node_id = -1;
|
||||||
} *pni;
|
|
||||||
|
|
||||||
pni = calloc(topo.num_packages, sizeof(struct pkg_node_info));
|
cpu_count = 0;
|
||||||
if (!pni)
|
for (pkg = 0; pkg < topo.num_packages; pkg++) {
|
||||||
err(1, "calloc pkg_node_count");
|
lnode = 0;
|
||||||
|
for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu) {
|
||||||
for (pkg = 0; pkg < topo.num_packages; pkg++)
|
if (cpus[cpu].physical_package_id != pkg)
|
||||||
pni[pkg].min = topo.num_cpus;
|
continue;
|
||||||
|
/* find a cpu with an unset logical_node_id */
|
||||||
for (node = 0; node <= topo.max_node_num; node++) {
|
if (cpus[cpu].logical_node_id != -1)
|
||||||
/* find the "first" cpu in the node */
|
continue;
|
||||||
sprintf(path, "/sys/bus/node/devices/node%d/cpulist", node);
|
cpus[cpu].logical_node_id = lnode;
|
||||||
filep = fopen(path, "r");
|
node = cpus[cpu].physical_node_id;
|
||||||
if (!filep)
|
cpu_count++;
|
||||||
continue;
|
/*
|
||||||
fscanf(filep, "%d", &cpu);
|
* find all matching cpus on this pkg and set
|
||||||
fclose(filep);
|
* the logical_node_id
|
||||||
|
*/
|
||||||
pkg = cpus[cpu].physical_package_id;
|
for (cpux = cpu; cpux <= topo.max_cpu_num; cpux++) {
|
||||||
pni[pkg].count++;
|
if ((cpus[cpux].physical_package_id == pkg) &&
|
||||||
|
(cpus[cpux].physical_node_id == node)) {
|
||||||
if (node < pni[pkg].min)
|
cpus[cpux].logical_node_id = lnode;
|
||||||
pni[pkg].min = node;
|
cpu_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lnode++;
|
||||||
|
if (lnode > topo.nodes_per_pkg)
|
||||||
|
topo.nodes_per_pkg = lnode;
|
||||||
|
}
|
||||||
|
if (cpu_count >= topo.max_cpu_num)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pkg = 0; pkg < topo.num_packages; pkg++)
|
|
||||||
if (pni[pkg].count > topo.nodes_per_pkg)
|
|
||||||
topo.nodes_per_pkg = pni[0].count;
|
|
||||||
|
|
||||||
/* Fake 1 node per pkg for machines that don't
|
|
||||||
* expose nodes and thus avoid -nan results
|
|
||||||
*/
|
|
||||||
if (topo.nodes_per_pkg == 0)
|
|
||||||
topo.nodes_per_pkg = 1;
|
|
||||||
|
|
||||||
for (cpu = 0; cpu < topo.num_cpus; cpu++) {
|
|
||||||
pkg = cpus[cpu].physical_package_id;
|
|
||||||
node = cpus[cpu].physical_node_id;
|
|
||||||
cpus[cpu].logical_node_id = node - pni[pkg].min;
|
|
||||||
}
|
|
||||||
free(pni);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_physical_node_id(struct cpu_topology *thiscpu)
|
int get_physical_node_id(struct cpu_topology *thiscpu)
|
||||||
|
@ -4840,14 +4828,6 @@ void topology_probe()
|
||||||
max_siblings = siblings;
|
max_siblings = siblings;
|
||||||
if (cpus[i].thread_id == 0)
|
if (cpus[i].thread_id == 0)
|
||||||
topo.num_cores++;
|
topo.num_cores++;
|
||||||
|
|
||||||
if (debug > 1)
|
|
||||||
fprintf(outf,
|
|
||||||
"cpu %d pkg %d node %d core %d thread %d\n",
|
|
||||||
i, cpus[i].physical_package_id,
|
|
||||||
cpus[i].physical_node_id,
|
|
||||||
cpus[i].physical_core_id,
|
|
||||||
cpus[i].thread_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
topo.cores_per_node = max_core_id + 1;
|
topo.cores_per_node = max_core_id + 1;
|
||||||
|
@ -4873,6 +4853,20 @@ void topology_probe()
|
||||||
topo.threads_per_core = max_siblings;
|
topo.threads_per_core = max_siblings;
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
fprintf(outf, "max_siblings %d\n", max_siblings);
|
fprintf(outf, "max_siblings %d\n", max_siblings);
|
||||||
|
|
||||||
|
if (debug < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i <= topo.max_cpu_num; ++i) {
|
||||||
|
fprintf(outf,
|
||||||
|
"cpu %d pkg %d node %d lnode %d core %d thread %d\n",
|
||||||
|
i, cpus[i].physical_package_id,
|
||||||
|
cpus[i].physical_node_id,
|
||||||
|
cpus[i].logical_node_id,
|
||||||
|
cpus[i].physical_core_id,
|
||||||
|
cpus[i].thread_id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue