]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: thread: get rid of MAX_THREADS_MASK
authorWilly Tarreau <w@1wt.eu>
Tue, 14 Jun 2022 09:18:40 +0000 (11:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 Jun 2022 09:18:40 +0000 (11:18 +0200)
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.

doc/design-thoughts/thread-group.txt
include/haproxy/applet.h
include/haproxy/defaults.h
include/haproxy/task.h
src/check.c
src/dns.c
src/task.c

index a3b2b61f83d68073b24742b1879a1bfc23f6d857..9d7d151aa60a9011aad337423c12e038a5ae3f8a 100644 (file)
@@ -536,7 +536,7 @@ broadcast it to any group.
 
 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
index eaea8d138ea408658908216c5586d2f164eb23a8..84619de481796c8f24d8115742466d3dda052d8a 100644 (file)
@@ -58,7 +58,7 @@ static inline struct appctx *appctx_new_here(struct applet *applet, struct sedes
 
 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
index 80b2e643137843c4f39d5fdaefa0e55f62b29e80..21aae896dc53bb067328316146f932a383feea8f 100644 (file)
@@ -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
index 0ad4a1c85e69b7e8c83f517e69a1559bae6e1865..5d6501344795429d4de358cbc3fe0be7f699a8be 100644 (file)
@@ -581,7 +581,7 @@ static inline struct task *task_new_here()
  */
 static inline struct task *task_new_anywhere()
 {
-       return task_new(MAX_THREADS_MASK);
+       return task_new(all_threads_mask);
 }
 
 /*
index f7899597348361077f30a900f142aa86fe5e6413..ada79ed557c81456a6610ab50592c52b73e94f48 100644 (file)
@@ -1217,7 +1217,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
         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);
index 710cd5cb52c78bc244f320ab0aa4c21b195a3b14..75949b59bf80ec7412323cb9fff7390701066629 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -74,7 +74,7 @@ static int dns_connect_nameserver(struct dns_nameserver *ns)
 
        /* 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;
 }
index 09b8e72ff719b76318db9db36220d2142b85a646..95125006146f8c30c438ad2f769aae8ab3e8d2c6 100644 (file)
@@ -902,10 +902,10 @@ void mworker_cleantasks()
 
 #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 @@ void mworker_cleantasks()
 #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 */