MINOR: cpu-topo: split cpu_dump_topology() to show its summary in show dev

cpu_dump_topology() prints details about each enabled CPU and a summary with
clusters info and thread-cpu bindings. The latter is often usefull for
debugging and we want to add it in the 'show dev' output.

So, let's split cpu_dump_topology() in two parts: cpu_topo_debug() to print the
details about each enabled CPU; and cpu_topo_dump_summary() to print only the
summary.

In the next commit we will modify cpu_topo_dump_summary() to write into local
trash buffer and it could be easily called from debug_parse_cli_show_dev().
This commit is contained in:
Valentine Krasnobaeva 2025-07-17 12:05:33 +02:00 committed by Willy Tarreau
parent 254e4d59f7
commit 2405283230
3 changed files with 20 additions and 4 deletions

View file

@ -2,6 +2,7 @@
#define _HAPROXY_CPU_TOPO_H
#include <haproxy/api.h>
#include <haproxy/chunk.h>
#include <haproxy/cpuset-t.h>
#include <haproxy/cpu_topo-t.h>
@ -55,7 +56,12 @@ int cpu_map_configured(void);
/* Dump the CPU topology <topo> for up to cpu_topo_maxcpus CPUs for
* debugging purposes. Offline CPUs are skipped.
*/
void cpu_dump_topology(const struct ha_cpu_topo *topo);
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);
/* 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

@ -218,11 +218,10 @@ int cpu_map_configured(void)
/* Dump the CPU topology <topo> for up to cpu_topo_maxcpus CPUs for
* debugging purposes. Offline CPUs are skipped.
*/
void cpu_dump_topology(const struct ha_cpu_topo *topo)
void cpu_topo_debug(const struct ha_cpu_topo *topo)
{
int has_smt = 0;
int cpu, lvl;
int grp, thr;
for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++) {
if (ha_cpu_topo[cpu].th_cnt > 1) {
@ -265,6 +264,14 @@ void cpu_dump_topology(const struct ha_cpu_topo *topo)
}
putchar('\n');
}
}
/* Dump the summary of CPU topology <topo>: clusters info and thread-cpu
* bindings.
*/
void cpu_topo_dump_summary(const struct ha_cpu_topo *topo)
{
int cpu, grp, thr;
printf("CPU clusters:\n");
for (cpu = 0; cpu < cpu_topo_maxcpus; cpu++) {

View file

@ -1479,7 +1479,10 @@ int thread_map_to_groups()
#if defined(USE_THREAD) && defined(USE_CPU_AFFINITY)
if (global.tune.debug & GDBG_CPU_AFFINITY) {
cpu_reorder_by_index(ha_cpu_topo, cpu_topo_maxcpus);
cpu_dump_topology(ha_cpu_topo);
cpu_topo_debug(ha_cpu_topo);
chunk_reset(&trash);
cpu_topo_dump_summary(ha_cpu_topo);
printf("%s\n", trash.area);
}
#endif
return 0;