]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpu-topo: split cpu_dump_topology() to show its summary in show dev
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 17 Jul 2025 10:05:33 +0000 (12:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Jul 2025 17:07:46 +0000 (19:07 +0200)
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().

include/haproxy/cpu_topo.h
src/cpu_topo.c
src/thread.c

index 959d89b9955ff222d8f6cfda24a99d3a5eb77afd..20dabe02c823292f48c6a9e419af4b55f7427ea2 100644 (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);
index 7422046c3b4ae7391db8ff7d044e0538a75cd4e2..6ffb6e54fb82ac1cc4fce4a907e1d49f6ef7226c 100644 (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++) {
index 266c1562bdfff4827e273d0c97ae2a5f51228fa1..0feee87e496e8218c9f641f9181d00ce81298739 100644 (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;