mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MINOR: thread: add a new all_tgroups_mask variable to know about active tgroups
In order to kill all_threads_mask we'll need to have an equivalent for the thread groups. The all_tgroups_mask does just this, it keeps one bit set per enabled group.
This commit is contained in:
parent
c6cf64bb5e
commit
cce203aae5
@ -56,6 +56,7 @@ extern int thread_cpus_enabled_at_boot;
|
||||
* at build time.
|
||||
*/
|
||||
enum { all_threads_mask = 1UL };
|
||||
enum { all_tgroups_mask = 1UL };
|
||||
enum { threads_harmless_mask = 0 };
|
||||
enum { threads_idle_mask = 0 };
|
||||
enum { threads_sync_mask = 0 };
|
||||
@ -180,6 +181,7 @@ 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 long threads_harmless_mask;
|
||||
extern volatile unsigned long threads_idle_mask;
|
||||
extern volatile unsigned long threads_sync_mask;
|
||||
|
@ -2973,7 +2973,8 @@ 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);
|
||||
if (!_HA_ATOMIC_AND_FETCH(&ha_tgroup_info[ti->tgid].threads_enabled, ~ti->ltid_bit))
|
||||
_HA_ATOMIC_AND(&all_tgroups_mask, ~tg->tgid_bit);
|
||||
_HA_ATOMIC_AND(&all_threads_mask, ~tid_bit);
|
||||
if (tid > 0)
|
||||
pthread_exit(NULL);
|
||||
|
@ -65,6 +65,7 @@ volatile unsigned long threads_harmless_mask = 0;
|
||||
volatile unsigned long threads_idle_mask = 0;
|
||||
volatile unsigned long threads_sync_mask = 0;
|
||||
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
|
||||
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);
|
||||
@ -1008,6 +1009,7 @@ int thread_map_to_groups()
|
||||
{
|
||||
int t, g, ut, ug;
|
||||
int q, r;
|
||||
ulong m __maybe_unused;
|
||||
|
||||
ut = ug = 0; // unassigned threads & groups
|
||||
|
||||
@ -1082,11 +1084,18 @@ int thread_map_to_groups()
|
||||
ha_thread_info[t].ltid_bit = 1UL << ha_thread_info[t].ltid;
|
||||
}
|
||||
|
||||
m = 0;
|
||||
for (g = 0; g < global.nbtgroups; g++) {
|
||||
ha_tgroup_info[g].threads_enabled = nbits(ha_tgroup_info[g].count);
|
||||
if (!ha_tgroup_info[g].count)
|
||||
continue;
|
||||
m |= 1UL << g;
|
||||
|
||||
}
|
||||
|
||||
#ifdef USE_THREAD
|
||||
all_tgroups_mask = m;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user