Skip to content

Commit 99b38fa

Browse files
zhang-ruilenb
authored andcommitted
tools/power turbostat: Eliminate unnecessary data structure allocation
Linux core_id's are a per-package namespace, not a per-node namespace. Rename topo.cores_per_node to topo.cores_per_pkg to reflect this. Eliminate topo.nodes_per_pkg from the sizing for core data structures, since it has no role except to unnecessarily bloat the allocation. Validated on multiple Intel platforms (ICX/SPR/SRF/EMR/GNR/CWF) with various CPU online/offline configurations and SMT enabled/disabled scenarios. No functional changes. [lenb: commit message] Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent b8ead30 commit 99b38fa

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,7 +2409,7 @@ struct topo_params {
24092409
int max_l3_id;
24102410
int max_node_num;
24112411
int nodes_per_pkg;
2412-
int cores_per_node;
2412+
int cores_per_pkg;
24132413
int threads_per_core;
24142414
} topo;
24152415

@@ -9633,9 +9633,9 @@ void topology_probe(bool startup)
96339633
topo.max_core_id = max_core_id; /* within a package */
96349634
topo.max_package_id = max_package_id;
96359635

9636-
topo.cores_per_node = max_core_id + 1;
9636+
topo.cores_per_pkg = max_core_id + 1;
96379637
if (debug > 1)
9638-
fprintf(outf, "max_core_id %d, sizing for %d cores per package\n", max_core_id, topo.cores_per_node);
9638+
fprintf(outf, "max_core_id %d, sizing for %d cores per package\n", max_core_id, topo.cores_per_pkg);
96399639
if (!summary_only)
96409640
BIC_PRESENT(BIC_Core);
96419641

@@ -9700,7 +9700,7 @@ void allocate_counters_1(struct counters *counters)
97009700
void allocate_counters(struct counters *counters)
97019701
{
97029702
int i;
9703-
int num_cores = topo.cores_per_node * topo.nodes_per_pkg * topo.num_packages;
9703+
int num_cores = topo.cores_per_pkg * topo.num_packages;
97049704

97059705
counters->threads = calloc(topo.max_cpu_num + 1, sizeof(struct thread_data));
97069706
if (counters->threads == NULL)

0 commit comments

Comments
 (0)