From: Valentine Krasnobaeva Date: Thu, 17 Jul 2025 16:18:20 +0000 (+0200) Subject: MINOR: cpu-topo: write thread-cpu bindings into trash buffer X-Git-Tag: v3.3-dev4~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e11c852feb681173da288fe3472e80362390b68;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/cpu_topo.h b/include/haproxy/cpu_topo.h index 20dabe02c..767d01c38 100644 --- a/include/haproxy/cpu_topo.h +++ b/include/haproxy/cpu_topo.h @@ -61,7 +61,7 @@ void cpu_topo_debug(const struct ha_cpu_topo *topo); /* Dump the summary of CPU topology , 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); diff --git a/src/cpu_topo.c b/src/cpu_topo.c index 6ffb6e54f..b5840e507 100644 --- a/src/cpu_topo.c +++ b/src/cpu_topo.c @@ -269,21 +269,21 @@ void cpu_topo_debug(const struct ha_cpu_topo *topo) /* Dump the summary of CPU topology : 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, ""); - printf(" %s\n", str); + chunk_appendf(trash, " %s\n", str); min = max = -1; } } diff --git a/src/thread.c b/src/thread.c index 0feee87e4..16d087b83 100644 --- a/src/thread.c +++ b/src/thread.c @@ -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