From c6b596dccec61610508d3b9630159d426db12921 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 15 Jul 2022 17:28:11 +0200 Subject: [PATCH] CLEANUP: threads: remove the now unused all_threads_mask and tid_bit Since these are not used anymore, let's now remove them. Given the number of places where we're using ti->ldit_bit, maybe an equivalent might be useful though. --- include/haproxy/thread.h | 5 ----- src/cfgparse.c | 1 - src/haproxy.c | 6 ------ src/thread.c | 4 ---- 4 files changed, 16 deletions(-) diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h index 67aefc7a3..97502c0a6 100644 --- a/include/haproxy/thread.h +++ b/include/haproxy/thread.h @@ -55,7 +55,6 @@ extern int thread_cpus_enabled_at_boot; /* Only way found to replace variables with constants that are optimized away * at build time. */ -enum { all_threads_mask = 1UL }; enum { all_tgroups_mask = 1UL }; enum { tid_bit = 1UL }; enum { tid = 0 }; @@ -176,11 +175,9 @@ void wait_for_threads_completion(); void set_thread_cpu_affinity(); unsigned long long ha_get_pthread_id(unsigned int thr); -extern volatile unsigned long all_threads_mask; extern volatile unsigned long all_tgroups_mask; extern volatile unsigned int rdv_requests; extern volatile unsigned int isolated_thread; -extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */ extern THREAD_LOCAL unsigned int tid; /* The thread id */ extern THREAD_LOCAL unsigned int tgid; /* The thread group id (starts at 1) */ @@ -201,13 +198,11 @@ static inline void ha_set_thread(const struct thread_info *thr) tg = thr->tg; tid = thr->tid; tgid = thr->tgid; - tid_bit = 1UL << tid; /* FIXME: must become thr->ltid_bit */ th_ctx = &ha_thread_ctx[tid]; tg_ctx = &ha_tgroup_ctx[tgid-1]; } else { tgid = 1; tid = 0; - tid_bit = 1; ti = &ha_thread_info[0]; tg = &ha_tgroup_info[0]; th_ctx = &ha_thread_ctx[0]; diff --git a/src/cfgparse.c b/src/cfgparse.c index 2bd498ac7..a56052151 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2495,7 +2495,6 @@ int check_config_validity() global.nbthread = numa_cores ? numa_cores : thread_cpus_enabled_at_boot; } - all_threads_mask = nbits(global.nbthread); #endif } diff --git a/src/haproxy.c b/src/haproxy.c index e32707c97..a2a737673 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -835,11 +835,6 @@ static void mworker_loop() global.nbthread = 1; -#ifdef USE_THREAD - tid_bit = 1; - all_threads_mask = 1; -#endif - jobs++; /* this is the "master" job, we want to take care of the signals even if there is no listener so the poll loop don't leave */ @@ -2997,7 +2992,6 @@ static void *run_thread_poll_loop(void *data) _HA_ATOMIC_AND(&all_tgroups_mask, ~tg->tgid_bit); if (!_HA_ATOMIC_AND_FETCH(&tg_ctx->stopping_threads, ~ti->ltid_bit)) _HA_ATOMIC_AND(&stopping_tgroup_mask, ~tg->tgid_bit); - _HA_ATOMIC_AND(&all_threads_mask, ~tid_bit); if (tid > 0) pthread_exit(NULL); #endif diff --git a/src/thread.c b/src/thread.c index e38b7fea9..cc983a261 100644 --- a/src/thread.c +++ b/src/thread.c @@ -63,13 +63,11 @@ THREAD_LOCAL struct thread_ctx *th_ctx = &ha_thread_ctx[0]; #ifdef USE_THREAD -volatile unsigned long all_threads_mask __read_mostly = 1; // nbthread 1 assumed by default volatile unsigned long all_tgroups_mask __read_mostly = 1; // nbtgroup 1 assumed by default volatile unsigned int rdv_requests = 0; // total number of threads requesting RDV volatile unsigned int isolated_thread = ~0; // ID of the isolated thread, or ~0 when none THREAD_LOCAL unsigned int tgid = 1; // thread ID starts at 1 THREAD_LOCAL unsigned int tid = 0; -THREAD_LOCAL unsigned long tid_bit = (1UL << 0); int thread_cpus_enabled_at_boot = 1; static pthread_t ha_pthread[MAX_THREADS] = { }; @@ -1261,8 +1259,6 @@ static int cfg_parse_nbthread(char **args, int section_type, struct proxy *curpx memprintf(err, "'%s' value must be between 1 and %d (was %ld)", args[0], MAX_THREADS, nbthread); return -1; } - - all_threads_mask = nbits(nbthread); #endif HA_DIAG_WARNING_COND(global.nbthread,