From 377e37a80fcdf7c83e5b672ed1500327ce0a698e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 24 Jun 2022 15:18:49 +0200 Subject: [PATCH] MINOR: tinfo: add the mask of enabled threads in each group In order to replace the global "all_threads_mask" we'll need to have an equivalent per group. Take this opportunity for calling it threads_enabled and make sure which ones are counted there (in case in the future we allow to stop some). --- include/haproxy/tinfo-t.h | 1 + src/haproxy.c | 1 + src/thread.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h index 5f0d794260..f7a7494b69 100644 --- a/include/haproxy/tinfo-t.h +++ b/include/haproxy/tinfo-t.h @@ -52,6 +52,7 @@ enum { * at 1 so tgroup[0] describes thread group 1. */ struct tgroup_info { + ulong threads_enabled; /* mask of threads enabled in this group */ uint base; /* first thread in this group */ uint count; /* number of threads in this group */ ulong tgid_bit; /* bit corresponding to the tgroup ID */ diff --git a/src/haproxy.c b/src/haproxy.c index 1df98d6159..79d40ab1b7 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2973,6 +2973,7 @@ static void *run_thread_poll_loop(void *data) ptff->fct(); #ifdef USE_THREAD + _HA_ATOMIC_AND(&ha_tgroup_info[ti->tgid].threads_enabled, ~ti->ltid_bit); _HA_ATOMIC_AND(&all_threads_mask, ~tid_bit); if (tid > 0) pthread_exit(NULL); diff --git a/src/thread.c b/src/thread.c index dedde13b4c..d895bbcdab 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1082,6 +1082,11 @@ int thread_map_to_groups() ha_thread_info[t].ltid_bit = 1UL << ha_thread_info[t].ltid; } + for (g = 0; g < global.nbtgroups; g++) { + ha_tgroup_info[g].threads_enabled = nbits(ha_tgroup_info[g].count); + + } + return 0; } -- 2.39.5