]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads: set the tid, ltid and their bit in thread_cfg
authorWilly Tarreau <w@1wt.eu>
Tue, 28 Sep 2021 06:53:11 +0000 (08:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 8 Oct 2021 15:22:26 +0000 (17:22 +0200)
This will be a convenient way to communicate the thread ID and its
local ID in the group, as well as their respective bits when creating
the threads or when only a pointer is given.

include/haproxy/tinfo-t.h
src/thread.c

index ba24249755219409d2619205d5abaaa5cdb16bda..dde3fe9b8e22b4ed90a7999b3ebbb91a30663786 100644 (file)
@@ -60,6 +60,8 @@ struct tgroup_info {
  */
 struct thread_info {
        const struct tgroup_info *tg;     /* config of the thread-group this thread belongs to */
+       uint tid, ltid;                   /* process-wide and group-wide thread ID (start at 0) */
+       ulong tid_bit, ltid_bit;          /* bit masks for the tid/ltid */
 
        /* pad to cache line (64B) */
        char __pad[0];                    /* unused except to check remaining room */
index 0b979f91208286ab4a8ff788b8b3f7e76f2e03fe..2f904deae4974f3d890c7a4c8f37fc14d672b118 100644 (file)
@@ -1075,6 +1075,14 @@ int thread_map_to_groups()
                return -1;
        }
 
+       for (t = 0; t < global.nbthread; t++) {
+               ha_thread_info[t].tid      = t;
+               ha_thread_info[t].ltid     = t - ha_thread_info[t].tg->base;
+
+               ha_thread_info[t].tid_bit  = 1UL << ha_thread_info[t].tid;
+               ha_thread_info[t].ltid_bit = 1UL << ha_thread_info[t].ltid;
+       }
+
        return 0;
 }