From 617df441d60b55e4a908fb8ba6a958a4db850b00 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 28 May 2026 17:15:57 +0200 Subject: [PATCH] BUG/MINOR: threads: set at least grp_max when mtpg is too small When starting, say, 128 threads with max-threads-per-group set to 2 and MAX_TGROUPS set to the default 32, instead of setting the resulting number of groups to 32 and threads to 64, they're set to 1 and 32 respectively because the condition to raise grp_min is not satisfied. Let's cut the condition in two parts to also permit to raise it at least to grp_max. This should be backported to 3.2. --- src/thread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/thread.c b/src/thread.c index 3aa477782..a3e362d52 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1713,9 +1713,12 @@ void thread_detect_count(void) thr_max > global.maxthrpertgroup * grp_max) thr_max = global.maxthrpertgroup * grp_max; - if (grp_min < (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup && - grp_max >= (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup) - grp_min = (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup; + if (grp_min < (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup) { + if (grp_max >= (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup) + grp_min = (thr_min + global.maxthrpertgroup - 1) / global.maxthrpertgroup; + else + grp_min = grp_max; + } if (grp_max > thr_max && grp_min <= thr_max) grp_max = thr_max;