]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cpu-topo: use ha_diag_notice() to report thread creations
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2026 16:40:08 +0000 (18:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2026 16:49:57 +0000 (18:49 +0200)
Using ha_diag_warning() to report the number of threads created resulted
in warnings being counted and possibly an error being fired when combined
with -dW:

  $ printf "global\nstats socket /tmp/sock1\n" | ./haproxy -dD -dW -c -f /dev/stdin; echo $?
  [NOTICE]   (10406) : haproxy version is 3.5-dev0-5091ac-35
  [NOTICE]   (10406) : path to executable is ./haproxy
  [DIAG]     (10406) : Created 20 threads split into 2 groups
  [ALERT]    (10406) : Some warnings were found and 'zero-warning' is set. Aborting.
  1

Now that we have ha_diag_notice(), let's use it:

  $ printf "global\nstats socket /tmp/sock1\n" | ./haproxy -dD -dW -c -f /dev/stdin; echo $?
  [DIAG]     (10513) : Created 20 threads split into 2 groups
  0

It would make sense to backport this to 3.2 because it helps validate configs
against diag warnings without triggering a false positive. It depends on
this previous patch:

  MINOR: errors: add ha_diag_notice() to report diag-level notifications

src/cpu_topo.c

index b14e69fae049e91970a94cab8f60d061719d476e..fefefc9f09cc1c8ac7913f3cbad82f68172645f1 100644 (file)
@@ -1279,7 +1279,7 @@ static int cpu_policy_first_usable_node(int policy, int tmin, int tmax, int gmin
        if (tmin <= thr_count && thr_count < tmax)
                tmax = thr_count;
 
-       ha_diag_warning("Multi-socket cpu detected, automatically binding on active CPUs of '%d' (%u active cpu(s))\n", first_node_id, cpu_count);
+       ha_diag_notice("Multi-socket cpu detected, automatically binding on active CPUs of '%d' (%u active cpu(s))\n", first_node_id, cpu_count);
 
        if (!global.nbthread)
                global.nbthread = tmax;
@@ -1586,9 +1586,9 @@ static int cpu_policy_group_by_cluster(int policy, int tmin, int tmax, int gmin,
        }
 
        if (global.nbthread)
-               ha_diag_warning("Created %d threads split into %d groups\n", global.nbthread, global.nbtgroups);
+               ha_diag_notice("Created %d threads split into %d groups\n", global.nbthread, global.nbtgroups);
        else
-               ha_diag_warning("Could not determine any CPU cluster\n");
+               ha_diag_notice("Could not determine any CPU cluster\n");
 
        return 0;
 }
@@ -1684,9 +1684,9 @@ static int cpu_policy_group_by_ccx(int policy, int tmin, int tmax, int gmin, int
        }
 
        if (global.nbthread)
-               ha_diag_warning("Created %d threads split into %d groups\n", global.nbthread, global.nbtgroups);
+               ha_diag_notice("Created %d threads split into %d groups\n", global.nbthread, global.nbtgroups);
        else
-               ha_diag_warning("Could not determine any CPU cluster\n");
+               ha_diag_notice("Could not determine any CPU cluster\n");
 
        return 0;
 }