MINOR: cpu-topo: write thread-cpu bindings into trash buffer

Write thread-cpu bindings and cluster summary into provided trash buffer.
Like this we can call this function in any place, when this info is needed.
This commit is contained in:
Valentine Krasnobaeva 2025-07-17 18:18:20 +02:00 committed by Willy Tarreau
parent 2405283230
commit 9e11c852fe
3 changed files with 10 additions and 10 deletions

View File

@ -61,7 +61,7 @@ void cpu_topo_debug(const struct ha_cpu_topo *topo);
/* Dump the summary of CPU topology <topo>, i.e. clusters info and thread-cpu
* bindings.
*/
void cpu_topo_dump_summary(const struct ha_cpu_topo *topo);
void cpu_topo_dump_summary(const struct ha_cpu_topo *topo, struct buffer *trash);
/* re-order a CPU topology array by locality to help form groups. */
void cpu_reorder_by_locality(struct ha_cpu_topo *topo, int entries);

View File

@ -269,21 +269,21 @@ void cpu_topo_debug(const struct ha_cpu_topo *topo)
/* Dump the summary of CPU topology <topo>: clusters info and thread-cpu
* bindings.
*/
void cpu_topo_dump_summary(const struct ha_cpu_topo *topo)
void cpu_topo_dump_summary(const struct ha_cpu_topo *topo, struct buffer *trash)
{
int cpu, grp, thr;
printf("CPU clusters:\n");
chunk_appendf(trash, "CPU clusters:\n");
for (cpu = 0; cpu < cpu_topo_maxcpus; cpu++) {
if (!ha_cpu_clusters[cpu].nb_cpu)
continue;
printf(" %3u cpus=%3u cores=%3u capa=%u\n",
cpu, ha_cpu_clusters[cpu].nb_cpu,
ha_cpu_clusters[cpu].nb_cores,
ha_cpu_clusters[cpu].capa);
chunk_appendf(trash, " %3u cpus=%3u cores=%3u capa=%u\n",
cpu, ha_cpu_clusters[cpu].nb_cpu,
ha_cpu_clusters[cpu].nb_cores,
ha_cpu_clusters[cpu].capa);
}
printf("Thread CPU Bindings:\n Tgrp/Thr Tid CPU set\n");
chunk_appendf(trash, "Thread CPU Bindings:\n Tgrp/Thr Tid CPU set\n");
for (grp = 0; grp < global.nbtgroups; grp++) {
int first, last;
int min, max;
@ -338,7 +338,7 @@ void cpu_topo_dump_summary(const struct ha_cpu_topo *topo)
else if (len2 == 0)
snprintf(str + len, sizeof(str) - len, "<all>");
printf(" %s\n", str);
chunk_appendf(trash, " %s\n", str);
min = max = -1;
}
}

View File

@ -1481,7 +1481,7 @@ int thread_map_to_groups()
cpu_reorder_by_index(ha_cpu_topo, cpu_topo_maxcpus);
cpu_topo_debug(ha_cpu_topo);
chunk_reset(&trash);
cpu_topo_dump_summary(ha_cpu_topo);
cpu_topo_dump_summary(ha_cpu_topo, &trash);
printf("%s\n", trash.area);
}
#endif