MINOR: thread: get rid of MAX_THREADS_MASK
This macro was used both for binding and for lookups. When binding tasks
or FDs, using all_threads_mask instead is better as it will later be per
group. For lookups, ~0UL always does the job. Thus in practice the macro
was already almost not used anymore since the rest of the code could run
fine with a constant of all ones there.
diff --git a/doc/design-thoughts/thread-group.txt b/doc/design-thoughts/thread-group.txt
index a3b2b61..9d7d151 100644
--- a/doc/design-thoughts/thread-group.txt
+++ b/doc/design-thoughts/thread-group.txt
@@ -536,7 +536,7 @@
Right now in the code we have:
- 18 calls of task_new(tid_bit)
- - 18 calls of task_new(MAX_THREADS_MASK)
+ - 17 calls of task_new_anywhere()
- 2 calls with a single bit
Thus it looks like "task_new_anywhere()", "task_new_on()" and
diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h
index eaea8d1..84619de 100644
--- a/include/haproxy/applet.h
+++ b/include/haproxy/applet.h
@@ -58,7 +58,7 @@
static inline struct appctx *appctx_new_anywhere(struct applet *applet, struct sedesc *sedesc)
{
- return appctx_new(applet, sedesc, MAX_THREADS_MASK);
+ return appctx_new(applet, sedesc, all_threads_mask);
}
/* Helper function to call .init applet callback function, if it exists. Returns 0
diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h
index 80b2e64..21aae89 100644
--- a/include/haproxy/defaults.h
+++ b/include/haproxy/defaults.h
@@ -29,7 +29,6 @@
#ifndef USE_THREAD
/* threads disabled, 1 thread max, 1 group max (note: group ids start at 1) */
#define MAX_THREADS 1
-#define MAX_THREADS_MASK 1
#define MAX_TGROUPS 1
#define MAX_THREADS_PER_GROUP 1
@@ -39,7 +38,6 @@
#ifndef MAX_THREADS
#define MAX_THREADS LONGBITS
#endif
-#define MAX_THREADS_MASK (~0UL >> (LONGBITS - MAX_THREADS))
/* still limited to 1 group for now by default (note: group ids start at 1) */
#ifndef MAX_TGROUPS
diff --git a/include/haproxy/task.h b/include/haproxy/task.h
index 0ad4a1c..5d65013 100644
--- a/include/haproxy/task.h
+++ b/include/haproxy/task.h
@@ -581,7 +581,7 @@
*/
static inline struct task *task_new_anywhere()
{
- return task_new(MAX_THREADS_MASK);
+ return task_new(all_threads_mask);
}
/*
diff --git a/src/check.c b/src/check.c
index f789959..ada79ed 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1217,7 +1217,7 @@
if (LIST_INLIST(&check->buf_wait.list))
LIST_DEL_INIT(&check->buf_wait.list);
- task_set_affinity(t, MAX_THREADS_MASK);
+ task_set_affinity(t, all_threads_mask);
check_release_buf(check, &check->bi);
check_release_buf(check, &check->bo);
check->state &= ~(CHK_ST_INPROGRESS|CHK_ST_IN_ALLOC|CHK_ST_OUT_ALLOC);
diff --git a/src/dns.c b/src/dns.c
index 710cd5c..75949b5 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -74,7 +74,7 @@
/* Add the fd in the fd list and update its parameters */
dgram->t.sock.fd = fd;
- fd_insert(fd, dgram, dgram_fd_handler, MAX_THREADS_MASK);
+ fd_insert(fd, dgram, dgram_fd_handler, all_threads_mask);
fd_want_recv(fd);
return 0;
}
diff --git a/src/task.c b/src/task.c
index 09b8e72..9512500 100644
--- a/src/task.c
+++ b/src/task.c
@@ -902,10 +902,10 @@
#ifdef USE_THREAD
/* cleanup the global run queue */
- tmp_rq = eb32sc_first(&rqueue, MAX_THREADS_MASK);
+ tmp_rq = eb32sc_first(&rqueue, ~0UL);
while (tmp_rq) {
t = eb32sc_entry(tmp_rq, struct task, rq);
- tmp_rq = eb32sc_next(tmp_rq, MAX_THREADS_MASK);
+ tmp_rq = eb32sc_next(tmp_rq, ~0UL);
task_destroy(t);
}
/* cleanup the timers queue */
@@ -918,10 +918,10 @@
#endif
/* clean the per thread run queue */
for (i = 0; i < global.nbthread; i++) {
- tmp_rq = eb32sc_first(&ha_thread_ctx[i].rqueue, MAX_THREADS_MASK);
+ tmp_rq = eb32sc_first(&ha_thread_ctx[i].rqueue, ~0UL);
while (tmp_rq) {
t = eb32sc_entry(tmp_rq, struct task, rq);
- tmp_rq = eb32sc_next(tmp_rq, MAX_THREADS_MASK);
+ tmp_rq = eb32sc_next(tmp_rq, ~0UL);
task_destroy(t);
}
/* cleanup the per thread timers queue */