Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 2 | * include/haproxy/thread.h |
| 3 | * definitions, macros and inline functions used by threads. |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 4 | * |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 5 | * Copyright (C) 2017 Christopher Faulet - cfaulet@haproxy.com |
| 6 | * Copyright (C) 2020 Willy Tarreau - w@1wt.eu |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation, version 2.1 |
| 11 | * exclusively. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 23 | #ifndef _HAPROXY_THREAD_H |
| 24 | #define _HAPROXY_THREAD_H |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 25 | |
Willy Tarreau | 2beaaf7 | 2019-05-22 08:43:34 +0200 | [diff] [blame] | 26 | #include <signal.h> |
Willy Tarreau | 38171da | 2019-05-17 16:33:13 +0200 | [diff] [blame] | 27 | #include <unistd.h> |
| 28 | #ifdef _POSIX_PRIORITY_SCHEDULING |
| 29 | #include <sched.h> |
| 30 | #endif |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 31 | |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 32 | #include <haproxy/api.h> |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 33 | #include <haproxy/thread-t.h> |
Willy Tarreau | e4d1505 | 2020-06-29 09:57:23 +0200 | [diff] [blame] | 34 | #include <haproxy/tinfo.h> |
Willy Tarreau | 38171da | 2019-05-17 16:33:13 +0200 | [diff] [blame] | 35 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 36 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 37 | /* Note: this file mainly contains 5 sections: |
| 38 | * - a small common part, which also corresponds to the common API |
| 39 | * - one used solely when USE_THREAD is *not* set |
| 40 | * - one used solely when USE_THREAD is set |
| 41 | * - one used solely when USE_THREAD is set WITHOUT debugging |
| 42 | * - one used solely when USE_THREAD is set WITH debugging |
| 43 | * |
Willy Tarreau | 0ccd322 | 2018-07-30 10:34:35 +0200 | [diff] [blame] | 44 | */ |
| 45 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 46 | |
| 47 | /* Generic exports */ |
| 48 | int parse_nbthread(const char *arg, char **err); |
| 49 | int thread_get_default_count(); |
| 50 | extern int thread_cpus_enabled_at_boot; |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 51 | |
| 52 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 53 | #ifndef USE_THREAD |
| 54 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 55 | /********************** THREADS DISABLED ************************/ |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 56 | |
| 57 | /* Only way found to replace variables with constants that are optimized away |
| 58 | * at build time. |
| 59 | */ |
| 60 | enum { all_threads_mask = 1UL }; |
Willy Tarreau | 441259c | 2019-05-22 07:48:18 +0200 | [diff] [blame] | 61 | enum { threads_harmless_mask = 0 }; |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 62 | enum { threads_sync_mask = 0 }; |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 63 | enum { threads_want_rdv_mask = 0 }; |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 64 | enum { tid_bit = 1UL }; |
| 65 | enum { tid = 0 }; |
Willy Tarreau | 421f02e | 2018-01-20 18:19:22 +0100 | [diff] [blame] | 66 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 67 | #define HA_SPIN_INIT(l) do { /* do nothing */ } while(0) |
| 68 | #define HA_SPIN_DESTROY(l) do { /* do nothing */ } while(0) |
| 69 | #define HA_SPIN_LOCK(lbl, l) do { /* do nothing */ } while(0) |
| 70 | #define HA_SPIN_TRYLOCK(lbl, l) ({ 0; }) |
| 71 | #define HA_SPIN_UNLOCK(lbl, l) do { /* do nothing */ } while(0) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 72 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 73 | #define HA_RWLOCK_INIT(l) do { /* do nothing */ } while(0) |
| 74 | #define HA_RWLOCK_DESTROY(l) do { /* do nothing */ } while(0) |
| 75 | #define HA_RWLOCK_WRLOCK(lbl, l) do { /* do nothing */ } while(0) |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 76 | #define HA_RWLOCK_TRYWRLOCK(lbl, l) ({ 0; }) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 77 | #define HA_RWLOCK_WRUNLOCK(lbl, l) do { /* do nothing */ } while(0) |
| 78 | #define HA_RWLOCK_RDLOCK(lbl, l) do { /* do nothing */ } while(0) |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 79 | #define HA_RWLOCK_TRYRDLOCK(lbl, l) ({ 0; }) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 80 | #define HA_RWLOCK_RDUNLOCK(lbl, l) do { /* do nothing */ } while(0) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 81 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 82 | #define HA_RWLOCK_SKLOCK(lbl,l) do { /* do nothing */ } while(0) |
| 83 | #define HA_RWLOCK_SKTOWR(lbl,l) do { /* do nothing */ } while(0) |
| 84 | #define HA_RWLOCK_WRTOSK(lbl,l) do { /* do nothing */ } while(0) |
| 85 | #define HA_RWLOCK_SKTORD(lbl,l) do { /* do nothing */ } while(0) |
| 86 | #define HA_RWLOCK_WRTORD(lbl,l) do { /* do nothing */ } while(0) |
| 87 | #define HA_RWLOCK_SKUNLOCK(lbl,l) do { /* do nothing */ } while(0) |
| 88 | #define HA_RWLOCK_TRYSKLOCK(lbl,l) ({ 0; }) |
| 89 | #define HA_RWLOCK_TRYRDTOSK(lbl,l) ({ 0; }) |
| 90 | |
William Lallemand | 6e1796e | 2018-06-07 11:23:40 +0200 | [diff] [blame] | 91 | #define ha_sigmask(how, set, oldset) sigprocmask(how, set, oldset) |
| 92 | |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 93 | static inline void ha_set_tid(unsigned int tid) |
| 94 | { |
David Carlier | a92c5ce | 2019-09-13 05:03:12 +0100 | [diff] [blame] | 95 | ti = &ha_thread_info[tid]; |
Willy Tarreau | 38171da | 2019-05-17 16:33:13 +0200 | [diff] [blame] | 96 | } |
| 97 | |
Willy Tarreau | f0e5da2 | 2020-05-01 12:26:03 +0200 | [diff] [blame] | 98 | static inline unsigned long long ha_get_pthread_id(unsigned int thr) |
Willy Tarreau | ff64d3b | 2020-05-01 11:28:49 +0200 | [diff] [blame] | 99 | { |
| 100 | return 0; |
| 101 | } |
| 102 | |
Willy Tarreau | 38171da | 2019-05-17 16:33:13 +0200 | [diff] [blame] | 103 | static inline void ha_thread_relax(void) |
| 104 | { |
| 105 | #if _POSIX_PRIORITY_SCHEDULING |
| 106 | sched_yield(); |
| 107 | #endif |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 108 | } |
William Lallemand | 6e1796e | 2018-06-07 11:23:40 +0200 | [diff] [blame] | 109 | |
Willy Tarreau | 2beaaf7 | 2019-05-22 08:43:34 +0200 | [diff] [blame] | 110 | /* send signal <sig> to thread <thr> */ |
| 111 | static inline void ha_tkill(unsigned int thr, int sig) |
| 112 | { |
| 113 | raise(sig); |
| 114 | } |
| 115 | |
| 116 | /* send signal <sig> to all threads */ |
| 117 | static inline void ha_tkillall(int sig) |
| 118 | { |
| 119 | raise(sig); |
| 120 | } |
| 121 | |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 122 | static inline void thread_harmless_now() |
| 123 | { |
| 124 | } |
| 125 | |
| 126 | static inline void thread_harmless_end() |
| 127 | { |
| 128 | } |
| 129 | |
| 130 | static inline void thread_isolate() |
| 131 | { |
| 132 | } |
| 133 | |
| 134 | static inline void thread_release() |
| 135 | { |
| 136 | } |
| 137 | |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 138 | static inline void thread_sync_release() |
| 139 | { |
| 140 | } |
| 141 | |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 142 | static inline unsigned long thread_isolated() |
| 143 | { |
| 144 | return 1; |
| 145 | } |
| 146 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 147 | #else /* !USE_THREAD */ |
| 148 | |
| 149 | /********************** THREADS ENABLED ************************/ |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 150 | |
| 151 | #include <stdio.h> |
| 152 | #include <stdlib.h> |
| 153 | #include <string.h> |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 154 | #include <import/plock.h> |
| 155 | |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 156 | void thread_harmless_till_end(); |
| 157 | void thread_isolate(); |
| 158 | void thread_release(); |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 159 | void thread_sync_release(); |
Willy Tarreau | 2beaaf7 | 2019-05-22 08:43:34 +0200 | [diff] [blame] | 160 | void ha_tkill(unsigned int thr, int sig); |
| 161 | void ha_tkillall(int sig); |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 162 | void ha_spin_init(HA_SPINLOCK_T *l); |
| 163 | void ha_rwlock_init(HA_RWLOCK_T *l); |
Willy Tarreau | 5a6e224 | 2019-05-20 18:56:48 +0200 | [diff] [blame] | 164 | |
Christopher Faulet | ddb6c16 | 2018-07-20 09:31:53 +0200 | [diff] [blame] | 165 | extern volatile unsigned long all_threads_mask; |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 166 | extern volatile unsigned long threads_harmless_mask; |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 167 | extern volatile unsigned long threads_sync_mask; |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 168 | extern volatile unsigned long threads_want_rdv_mask; |
| 169 | extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */ |
| 170 | extern THREAD_LOCAL unsigned int tid; /* The thread id */ |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 171 | |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 172 | /* explanation for threads_want_rdv_mask, threads_harmless_mask, and |
| 173 | * threads_sync_mask : |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 174 | * - threads_want_rdv_mask is a bit field indicating all threads that have |
| 175 | * requested a rendez-vous of other threads using thread_isolate(). |
| 176 | * - threads_harmless_mask is a bit field indicating all threads that are |
| 177 | * currently harmless in that they promise not to access a shared resource. |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 178 | * - threads_sync_mask is a bit field indicating that a thread waiting for |
| 179 | * others to finish wants to leave synchronized with others and as such |
| 180 | * promises to do so as well using thread_sync_release(). |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 181 | * |
| 182 | * For a given thread, its bits in want_rdv and harmless can be translated like |
| 183 | * this : |
| 184 | * |
| 185 | * ----------+----------+---------------------------------------------------- |
| 186 | * want_rdv | harmless | description |
| 187 | * ----------+----------+---------------------------------------------------- |
| 188 | * 0 | 0 | thread not interested in RDV, possibly harmful |
| 189 | * 0 | 1 | thread not interested in RDV but harmless |
| 190 | * 1 | 1 | thread interested in RDV and waiting for its turn |
| 191 | * 1 | 0 | thread currently working isolated from others |
| 192 | * ----------+----------+---------------------------------------------------- |
Willy Tarreau | 9a1f573 | 2019-06-09 12:20:02 +0200 | [diff] [blame] | 193 | * |
| 194 | * thread_sync_mask only delays the leaving of threads_sync_release() to make |
| 195 | * sure that each thread's harmless bit is cleared before leaving the function. |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 196 | */ |
Olivier Houchard | 6b96f72 | 2018-04-25 16:58:25 +0200 | [diff] [blame] | 197 | |
William Lallemand | 6e1796e | 2018-06-07 11:23:40 +0200 | [diff] [blame] | 198 | #define ha_sigmask(how, set, oldset) pthread_sigmask(how, set, oldset) |
| 199 | |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 200 | /* sets the thread ID and the TID bit for the current thread */ |
| 201 | static inline void ha_set_tid(unsigned int data) |
| 202 | { |
| 203 | tid = data; |
| 204 | tid_bit = (1UL << tid); |
David Carlier | a92c5ce | 2019-09-13 05:03:12 +0100 | [diff] [blame] | 205 | ti = &ha_thread_info[tid]; |
Willy Tarreau | 0c026f4 | 2018-08-01 19:12:20 +0200 | [diff] [blame] | 206 | } |
| 207 | |
Willy Tarreau | ff64d3b | 2020-05-01 11:28:49 +0200 | [diff] [blame] | 208 | /* Retrieves the opaque pthread_t of thread <thr> cast to an unsigned long long |
| 209 | * since POSIX took great care of not specifying its representation, making it |
| 210 | * hard to export for post-mortem analysis. For this reason we copy it into a |
| 211 | * union and will use the smallest scalar type at least as large as its size, |
| 212 | * which will keep endianness and alignment for all regular sizes. As a last |
| 213 | * resort we end up with a long long ligned to the first bytes in memory, which |
| 214 | * will be endian-dependent if pthread_t is larger than a long long (not seen |
| 215 | * yet). |
| 216 | */ |
| 217 | static inline unsigned long long ha_get_pthread_id(unsigned int thr) |
| 218 | { |
| 219 | union { |
| 220 | pthread_t t; |
| 221 | unsigned long long ll; |
| 222 | unsigned int i; |
| 223 | unsigned short s; |
| 224 | unsigned char c; |
| 225 | } u; |
| 226 | |
| 227 | memset(&u, 0, sizeof(u)); |
| 228 | u.t = ha_thread_info[thr].pthread; |
| 229 | |
| 230 | if (sizeof(u.t) <= sizeof(u.c)) |
| 231 | return u.c; |
| 232 | else if (sizeof(u.t) <= sizeof(u.s)) |
| 233 | return u.s; |
| 234 | else if (sizeof(u.t) <= sizeof(u.i)) |
| 235 | return u.i; |
| 236 | return u.ll; |
| 237 | } |
| 238 | |
Willy Tarreau | 38171da | 2019-05-17 16:33:13 +0200 | [diff] [blame] | 239 | static inline void ha_thread_relax(void) |
| 240 | { |
| 241 | #if _POSIX_PRIORITY_SCHEDULING |
| 242 | sched_yield(); |
| 243 | #else |
| 244 | pl_cpu_relax(); |
| 245 | #endif |
| 246 | } |
| 247 | |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 248 | /* Marks the thread as harmless. Note: this must be true, i.e. the thread must |
| 249 | * not be touching any unprotected shared resource during this period. Usually |
| 250 | * this is called before poll(), but it may also be placed around very slow |
| 251 | * calls (eg: some crypto operations). Needs to be terminated using |
| 252 | * thread_harmless_end(). |
| 253 | */ |
| 254 | static inline void thread_harmless_now() |
| 255 | { |
| 256 | HA_ATOMIC_OR(&threads_harmless_mask, tid_bit); |
| 257 | } |
| 258 | |
| 259 | /* Ends the harmless period started by thread_harmless_now(). Usually this is |
| 260 | * placed after the poll() call. If it is discovered that a job was running and |
| 261 | * is relying on the thread still being harmless, the thread waits for the |
| 262 | * other one to finish. |
| 263 | */ |
| 264 | static inline void thread_harmless_end() |
| 265 | { |
| 266 | while (1) { |
| 267 | HA_ATOMIC_AND(&threads_harmless_mask, ~tid_bit); |
Christopher Faulet | 76b4419 | 2021-04-16 11:33:39 +0200 | [diff] [blame] | 268 | if (likely((threads_want_rdv_mask & all_threads_mask & ~tid_bit) == 0)) |
Willy Tarreau | 60b639c | 2018-08-02 10:16:17 +0200 | [diff] [blame] | 269 | break; |
| 270 | thread_harmless_till_end(); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /* an isolated thread has harmless cleared and want_rdv set */ |
| 275 | static inline unsigned long thread_isolated() |
| 276 | { |
| 277 | return threads_want_rdv_mask & ~threads_harmless_mask & tid_bit; |
| 278 | } |
| 279 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 280 | |
| 281 | #if !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) |
| 282 | |
| 283 | /* Thread debugging is DISABLED, these are the regular locking functions */ |
| 284 | |
| 285 | #define HA_SPIN_INIT(l) ({ (*l) = 0; }) |
| 286 | #define HA_SPIN_DESTROY(l) ({ (*l) = 0; }) |
| 287 | #define HA_SPIN_LOCK(lbl, l) pl_take_s(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 288 | #define HA_SPIN_TRYLOCK(lbl, l) (!pl_try_s(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 289 | #define HA_SPIN_UNLOCK(lbl, l) pl_drop_s(l) |
| 290 | |
| 291 | #define HA_RWLOCK_INIT(l) ({ (*l) = 0; }) |
| 292 | #define HA_RWLOCK_DESTROY(l) ({ (*l) = 0; }) |
| 293 | #define HA_RWLOCK_WRLOCK(lbl,l) pl_take_w(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 294 | #define HA_RWLOCK_TRYWRLOCK(lbl,l) (!pl_try_w(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 295 | #define HA_RWLOCK_WRUNLOCK(lbl,l) pl_drop_w(l) |
| 296 | #define HA_RWLOCK_RDLOCK(lbl,l) pl_take_r(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 297 | #define HA_RWLOCK_TRYRDLOCK(lbl,l) (!pl_try_r(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 298 | #define HA_RWLOCK_RDUNLOCK(lbl,l) pl_drop_r(l) |
| 299 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 300 | /* rwlock upgrades via seek locks */ |
| 301 | #define HA_RWLOCK_SKLOCK(lbl,l) pl_take_s(l) /* N --> S */ |
| 302 | #define HA_RWLOCK_SKTOWR(lbl,l) pl_stow(l) /* S --> W */ |
| 303 | #define HA_RWLOCK_WRTOSK(lbl,l) pl_wtos(l) /* W --> S */ |
| 304 | #define HA_RWLOCK_SKTORD(lbl,l) pl_stor(l) /* S --> R */ |
| 305 | #define HA_RWLOCK_WRTORD(lbl,l) pl_wtor(l) /* W --> R */ |
| 306 | #define HA_RWLOCK_SKUNLOCK(lbl,l) pl_drop_s(l) /* S --> N */ |
| 307 | #define HA_RWLOCK_TRYSKLOCK(lbl,l) (!pl_try_s(l)) /* N -?> S */ |
| 308 | #define HA_RWLOCK_TRYRDTOSK(lbl,l) (!pl_try_rtos(l)) /* R -?> S */ |
| 309 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 310 | #else /* !defined(DEBUG_THREAD) && !defined(DEBUG_FULL) */ |
| 311 | |
| 312 | /* Thread debugging is ENABLED, these are the instrumented functions */ |
| 313 | |
| 314 | #define __SPIN_INIT(l) ({ (*l) = 0; }) |
| 315 | #define __SPIN_DESTROY(l) ({ (*l) = 0; }) |
| 316 | #define __SPIN_LOCK(l) pl_take_s(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 317 | #define __SPIN_TRYLOCK(l) (!pl_try_s(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 318 | #define __SPIN_UNLOCK(l) pl_drop_s(l) |
William Lallemand | 6e1796e | 2018-06-07 11:23:40 +0200 | [diff] [blame] | 319 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 320 | #define __RWLOCK_INIT(l) ({ (*l) = 0; }) |
| 321 | #define __RWLOCK_DESTROY(l) ({ (*l) = 0; }) |
| 322 | #define __RWLOCK_WRLOCK(l) pl_take_w(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 323 | #define __RWLOCK_TRYWRLOCK(l) (!pl_try_w(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 324 | #define __RWLOCK_WRUNLOCK(l) pl_drop_w(l) |
| 325 | #define __RWLOCK_RDLOCK(l) pl_take_r(l) |
Willy Tarreau | db57a14 | 2020-06-12 11:42:25 +0200 | [diff] [blame] | 326 | #define __RWLOCK_TRYRDLOCK(l) (!pl_try_r(l)) |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 327 | #define __RWLOCK_RDUNLOCK(l) pl_drop_r(l) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 328 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 329 | /* rwlock upgrades via seek locks */ |
| 330 | #define __RWLOCK_SKLOCK(l) pl_take_s(l) /* N --> S */ |
| 331 | #define __RWLOCK_SKTOWR(l) pl_stow(l) /* S --> W */ |
| 332 | #define __RWLOCK_WRTOSK(l) pl_wtos(l) /* W --> S */ |
| 333 | #define __RWLOCK_SKTORD(l) pl_stor(l) /* S --> R */ |
| 334 | #define __RWLOCK_WRTORD(l) pl_wtor(l) /* W --> R */ |
| 335 | #define __RWLOCK_SKUNLOCK(l) pl_drop_s(l) /* S --> N */ |
| 336 | #define __RWLOCK_TRYSKLOCK(l) (!pl_try_s(l)) /* N -?> S */ |
| 337 | #define __RWLOCK_TRYRDTOSK(l) (!pl_try_rtos(l)) /* R -?> S */ |
| 338 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 339 | #define HA_SPIN_INIT(l) __spin_init(l) |
| 340 | #define HA_SPIN_DESTROY(l) __spin_destroy(l) |
| 341 | |
| 342 | #define HA_SPIN_LOCK(lbl, l) __spin_lock(lbl, l, __func__, __FILE__, __LINE__) |
| 343 | #define HA_SPIN_TRYLOCK(lbl, l) __spin_trylock(lbl, l, __func__, __FILE__, __LINE__) |
| 344 | #define HA_SPIN_UNLOCK(lbl, l) __spin_unlock(lbl, l, __func__, __FILE__, __LINE__) |
| 345 | |
| 346 | #define HA_RWLOCK_INIT(l) __ha_rwlock_init((l)) |
| 347 | #define HA_RWLOCK_DESTROY(l) __ha_rwlock_destroy((l)) |
| 348 | #define HA_RWLOCK_WRLOCK(lbl,l) __ha_rwlock_wrlock(lbl, l, __func__, __FILE__, __LINE__) |
| 349 | #define HA_RWLOCK_TRYWRLOCK(lbl,l) __ha_rwlock_trywrlock(lbl, l, __func__, __FILE__, __LINE__) |
| 350 | #define HA_RWLOCK_WRUNLOCK(lbl,l) __ha_rwlock_wrunlock(lbl, l, __func__, __FILE__, __LINE__) |
| 351 | #define HA_RWLOCK_RDLOCK(lbl,l) __ha_rwlock_rdlock(lbl, l) |
| 352 | #define HA_RWLOCK_TRYRDLOCK(lbl,l) __ha_rwlock_tryrdlock(lbl, l) |
| 353 | #define HA_RWLOCK_RDUNLOCK(lbl,l) __ha_rwlock_rdunlock(lbl, l) |
| 354 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 355 | #define HA_RWLOCK_SKLOCK(lbl,l) __ha_rwlock_sklock(lbl, l, __func__, __FILE__, __LINE__) |
| 356 | #define HA_RWLOCK_SKTOWR(lbl,l) __ha_rwlock_sktowr(lbl, l, __func__, __FILE__, __LINE__) |
| 357 | #define HA_RWLOCK_WRTOSK(lbl,l) __ha_rwlock_wrtosk(lbl, l, __func__, __FILE__, __LINE__) |
| 358 | #define HA_RWLOCK_SKTORD(lbl,l) __ha_rwlock_sktord(lbl, l, __func__, __FILE__, __LINE__) |
| 359 | #define HA_RWLOCK_WRTORD(lbl,l) __ha_rwlock_wrtord(lbl, l, __func__, __FILE__, __LINE__) |
| 360 | #define HA_RWLOCK_SKUNLOCK(lbl,l) __ha_rwlock_skunlock(lbl, l, __func__, __FILE__, __LINE__) |
| 361 | #define HA_RWLOCK_TRYSKLOCK(lbl,l) __ha_rwlock_trysklock(lbl, l, __func__, __FILE__, __LINE__) |
| 362 | #define HA_RWLOCK_TRYRDTOSK(lbl,l) __ha_rwlock_tryrdtosk(lbl, l, __func__, __FILE__, __LINE__) |
| 363 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 364 | /* WARNING!!! if you update this enum, please also keep lock_label() up to date |
| 365 | * below. |
| 366 | */ |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 367 | enum lock_label { |
Emeric Brun | c60def8 | 2017-09-27 14:59:38 +0200 | [diff] [blame] | 368 | TASK_RQ_LOCK, |
| 369 | TASK_WQ_LOCK, |
Christopher Faulet | b349e48 | 2017-08-29 09:52:38 +0200 | [diff] [blame] | 370 | POOL_LOCK, |
Christopher Faulet | 8d8aa0d | 2017-05-30 15:36:50 +0200 | [diff] [blame] | 371 | LISTENER_LOCK, |
Christopher Faulet | ff8abcd | 2017-06-02 15:33:24 +0200 | [diff] [blame] | 372 | PROXY_LOCK, |
Christopher Faulet | 29f77e8 | 2017-06-08 14:04:45 +0200 | [diff] [blame] | 373 | SERVER_LOCK, |
Christopher Faulet | 5b51755 | 2017-06-09 14:17:53 +0200 | [diff] [blame] | 374 | LBPRM_LOCK, |
Christopher Faulet | b79a94c | 2017-05-30 15:34:30 +0200 | [diff] [blame] | 375 | SIGNALS_LOCK, |
Emeric Brun | 819fc6f | 2017-06-13 19:37:32 +0200 | [diff] [blame] | 376 | STK_TABLE_LOCK, |
| 377 | STK_SESS_LOCK, |
Emeric Brun | 1138fd0 | 2017-06-19 12:38:55 +0200 | [diff] [blame] | 378 | APPLETS_LOCK, |
Emeric Brun | 80527f5 | 2017-06-19 17:46:37 +0200 | [diff] [blame] | 379 | PEER_LOCK, |
Emeric Brun | 821bb9b | 2017-06-15 16:37:39 +0200 | [diff] [blame] | 380 | SSL_LOCK, |
| 381 | SSL_GEN_CERTS_LOCK, |
Emeric Brun | b5997f7 | 2017-07-03 11:34:05 +0200 | [diff] [blame] | 382 | PATREF_LOCK, |
| 383 | PATEXP_LOCK, |
Christopher Faulet | e95f2c3 | 2017-07-24 16:30:34 +0200 | [diff] [blame] | 384 | VARS_LOCK, |
Christopher Faulet | 8ca3b4b | 2017-07-25 11:07:15 +0200 | [diff] [blame] | 385 | COMP_POOL_LOCK, |
Thierry FOURNIER | 61ba0e2 | 2017-07-12 11:41:21 +0200 | [diff] [blame] | 386 | LUA_LOCK, |
Thierry FOURNIER | 738a6d7 | 2017-07-17 00:14:07 +0200 | [diff] [blame] | 387 | NOTIF_LOCK, |
Christopher Faulet | 24289f2 | 2017-09-25 14:48:02 +0200 | [diff] [blame] | 388 | SPOE_APPLET_LOCK, |
Christopher Faulet | b2812a6 | 2017-10-04 16:17:58 +0200 | [diff] [blame] | 389 | DNS_LOCK, |
Christopher Faulet | cfda847 | 2017-10-20 15:40:23 +0200 | [diff] [blame] | 390 | PID_LIST_LOCK, |
Christopher Faulet | c2a89a6 | 2017-10-23 15:54:24 +0200 | [diff] [blame] | 391 | EMAIL_ALERTS_LOCK, |
Emeric Brun | d8b3b65 | 2017-11-07 11:19:48 +0100 | [diff] [blame] | 392 | PIPES_LOCK, |
Christopher Faulet | 16f45c8 | 2018-02-16 11:23:49 +0100 | [diff] [blame] | 393 | TLSKEYS_REF_LOCK, |
Willy Tarreau | 34d4b52 | 2018-10-29 18:02:54 +0100 | [diff] [blame] | 394 | AUTH_LOCK, |
Frédéric Lécaille | d803e47 | 2019-04-25 07:42:09 +0200 | [diff] [blame] | 395 | LOGSRV_LOCK, |
Frédéric Lécaille | 4a3fef8 | 2019-05-28 14:47:17 +0200 | [diff] [blame] | 396 | DICT_LOCK, |
Willy Tarreau | d6e0c03 | 2019-07-25 07:53:56 +0200 | [diff] [blame] | 397 | PROTO_LOCK, |
William Lallemand | 150bfa8 | 2019-09-19 17:12:49 +0200 | [diff] [blame] | 398 | CKCH_LOCK, |
| 399 | SNI_LOCK, |
William Lallemand | 3ce6eed | 2021-02-08 10:43:44 +0100 | [diff] [blame] | 400 | SSL_SERVER_LOCK, |
Emeric Brun | 494c505 | 2020-05-28 11:13:15 +0200 | [diff] [blame] | 401 | SFT_LOCK, /* sink forward target */ |
Amaury Denoyelle | 5c7086f | 2021-01-11 09:21:52 +0100 | [diff] [blame] | 402 | IDLE_CONNS_LOCK, |
Ben51Degrees | 4ddf59d | 2019-02-05 13:24:00 +0000 | [diff] [blame] | 403 | OTHER_LOCK, |
Willy Tarreau | ccea3c5 | 2021-02-17 14:33:58 +0100 | [diff] [blame] | 404 | /* WT: make sure never to use these ones outside of development, |
| 405 | * we need them for lock profiling! |
| 406 | */ |
| 407 | DEBUG1_LOCK, |
| 408 | DEBUG2_LOCK, |
| 409 | DEBUG3_LOCK, |
| 410 | DEBUG4_LOCK, |
| 411 | DEBUG5_LOCK, |
Christopher Faulet | 339fff8 | 2017-10-19 11:59:15 +0200 | [diff] [blame] | 412 | LOCK_LABELS |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 413 | }; |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 414 | |
| 415 | extern struct lock_stat lock_stats[LOCK_LABELS]; |
| 416 | |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 417 | static inline const char *lock_label(enum lock_label label) |
| 418 | { |
| 419 | switch (label) { |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 420 | case TASK_RQ_LOCK: return "TASK_RQ"; |
| 421 | case TASK_WQ_LOCK: return "TASK_WQ"; |
| 422 | case POOL_LOCK: return "POOL"; |
| 423 | case LISTENER_LOCK: return "LISTENER"; |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 424 | case PROXY_LOCK: return "PROXY"; |
| 425 | case SERVER_LOCK: return "SERVER"; |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 426 | case LBPRM_LOCK: return "LBPRM"; |
| 427 | case SIGNALS_LOCK: return "SIGNALS"; |
| 428 | case STK_TABLE_LOCK: return "STK_TABLE"; |
| 429 | case STK_SESS_LOCK: return "STK_SESS"; |
| 430 | case APPLETS_LOCK: return "APPLETS"; |
| 431 | case PEER_LOCK: return "PEER"; |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 432 | case SSL_LOCK: return "SSL"; |
| 433 | case SSL_GEN_CERTS_LOCK: return "SSL_GEN_CERTS"; |
| 434 | case PATREF_LOCK: return "PATREF"; |
| 435 | case PATEXP_LOCK: return "PATEXP"; |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 436 | case VARS_LOCK: return "VARS"; |
| 437 | case COMP_POOL_LOCK: return "COMP_POOL"; |
| 438 | case LUA_LOCK: return "LUA"; |
| 439 | case NOTIF_LOCK: return "NOTIF"; |
| 440 | case SPOE_APPLET_LOCK: return "SPOE_APPLET"; |
| 441 | case DNS_LOCK: return "DNS"; |
| 442 | case PID_LIST_LOCK: return "PID_LIST"; |
| 443 | case EMAIL_ALERTS_LOCK: return "EMAIL_ALERTS"; |
| 444 | case PIPES_LOCK: return "PIPES"; |
Christopher Faulet | 16f45c8 | 2018-02-16 11:23:49 +0100 | [diff] [blame] | 445 | case TLSKEYS_REF_LOCK: return "TLSKEYS_REF"; |
Willy Tarreau | 34d4b52 | 2018-10-29 18:02:54 +0100 | [diff] [blame] | 446 | case AUTH_LOCK: return "AUTH"; |
Frédéric Lécaille | d803e47 | 2019-04-25 07:42:09 +0200 | [diff] [blame] | 447 | case LOGSRV_LOCK: return "LOGSRV"; |
Frédéric Lécaille | 4a3fef8 | 2019-05-28 14:47:17 +0200 | [diff] [blame] | 448 | case DICT_LOCK: return "DICT"; |
Willy Tarreau | d6e0c03 | 2019-07-25 07:53:56 +0200 | [diff] [blame] | 449 | case PROTO_LOCK: return "PROTO"; |
William Lallemand | 150bfa8 | 2019-09-19 17:12:49 +0200 | [diff] [blame] | 450 | case CKCH_LOCK: return "CKCH"; |
| 451 | case SNI_LOCK: return "SNI"; |
William Lallemand | 7b41654 | 2021-02-10 16:17:19 +0100 | [diff] [blame] | 452 | case SSL_SERVER_LOCK: return "SSL_SERVER"; |
Emeric Brun | 494c505 | 2020-05-28 11:13:15 +0200 | [diff] [blame] | 453 | case SFT_LOCK: return "SFT"; |
Amaury Denoyelle | 5c7086f | 2021-01-11 09:21:52 +0100 | [diff] [blame] | 454 | case IDLE_CONNS_LOCK: return "IDLE_CONNS"; |
Ben51Degrees | 4ddf59d | 2019-02-05 13:24:00 +0000 | [diff] [blame] | 455 | case OTHER_LOCK: return "OTHER"; |
Willy Tarreau | ccea3c5 | 2021-02-17 14:33:58 +0100 | [diff] [blame] | 456 | case DEBUG1_LOCK: return "DEBUG1"; |
| 457 | case DEBUG2_LOCK: return "DEBUG2"; |
| 458 | case DEBUG3_LOCK: return "DEBUG3"; |
| 459 | case DEBUG4_LOCK: return "DEBUG4"; |
| 460 | case DEBUG5_LOCK: return "DEBUG5"; |
Christopher Faulet | f51bac2 | 2018-01-30 11:04:29 +0100 | [diff] [blame] | 461 | case LOCK_LABELS: break; /* keep compiler happy */ |
| 462 | }; |
| 463 | /* only way to come here is consecutive to an internal bug */ |
| 464 | abort(); |
| 465 | } |
| 466 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 467 | static inline void show_lock_stats() |
| 468 | { |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 469 | int lbl; |
| 470 | |
| 471 | for (lbl = 0; lbl < LOCK_LABELS; lbl++) { |
Willy Tarreau | 23d3b00 | 2020-10-22 08:00:09 +0200 | [diff] [blame] | 472 | if (!lock_stats[lbl].num_write_locked && |
| 473 | !lock_stats[lbl].num_seek_locked && |
| 474 | !lock_stats[lbl].num_read_locked) { |
| 475 | fprintf(stderr, |
| 476 | "Stats about Lock %s: not used\n", |
| 477 | lock_label(lbl)); |
| 478 | continue; |
| 479 | } |
| 480 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 481 | fprintf(stderr, |
Willy Tarreau | de785f0 | 2020-10-22 08:04:23 +0200 | [diff] [blame] | 482 | "Stats about Lock %s: \n", |
| 483 | lock_label(lbl)); |
| 484 | |
| 485 | if (lock_stats[lbl].num_write_locked) |
| 486 | fprintf(stderr, |
| 487 | "\t # write lock : %lu\n" |
| 488 | "\t # write unlock: %lu (%ld)\n" |
| 489 | "\t # wait time for write : %.3f msec\n" |
| 490 | "\t # wait time for write/lock: %.3f nsec\n", |
| 491 | lock_stats[lbl].num_write_locked, |
| 492 | lock_stats[lbl].num_write_unlocked, |
| 493 | lock_stats[lbl].num_write_unlocked - lock_stats[lbl].num_write_locked, |
| 494 | (double)lock_stats[lbl].nsec_wait_for_write / 1000000.0, |
| 495 | lock_stats[lbl].num_write_locked ? ((double)lock_stats[lbl].nsec_wait_for_write / (double)lock_stats[lbl].num_write_locked) : 0); |
| 496 | |
| 497 | if (lock_stats[lbl].num_seek_locked) |
| 498 | fprintf(stderr, |
| 499 | "\t # seek lock : %lu\n" |
| 500 | "\t # seek unlock : %lu (%ld)\n" |
| 501 | "\t # wait time for seek : %.3f msec\n" |
| 502 | "\t # wait time for seek/lock : %.3f nsec\n", |
| 503 | lock_stats[lbl].num_seek_locked, |
| 504 | lock_stats[lbl].num_seek_unlocked, |
| 505 | lock_stats[lbl].num_seek_unlocked - lock_stats[lbl].num_seek_locked, |
| 506 | (double)lock_stats[lbl].nsec_wait_for_seek / 1000000.0, |
| 507 | lock_stats[lbl].num_seek_locked ? ((double)lock_stats[lbl].nsec_wait_for_seek / (double)lock_stats[lbl].num_seek_locked) : 0); |
Willy Tarreau | 8d5360c | 2020-10-16 16:49:38 +0200 | [diff] [blame] | 508 | |
Willy Tarreau | de785f0 | 2020-10-22 08:04:23 +0200 | [diff] [blame] | 509 | if (lock_stats[lbl].num_read_locked) |
| 510 | fprintf(stderr, |
| 511 | "\t # read lock : %lu\n" |
| 512 | "\t # read unlock : %lu (%ld)\n" |
| 513 | "\t # wait time for read : %.3f msec\n" |
| 514 | "\t # wait time for read/lock : %.3f nsec\n", |
| 515 | lock_stats[lbl].num_read_locked, |
| 516 | lock_stats[lbl].num_read_unlocked, |
| 517 | lock_stats[lbl].num_read_unlocked - lock_stats[lbl].num_read_locked, |
| 518 | (double)lock_stats[lbl].nsec_wait_for_read / 1000000.0, |
| 519 | lock_stats[lbl].num_read_locked ? ((double)lock_stats[lbl].nsec_wait_for_read / (double)lock_stats[lbl].num_read_locked) : 0); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | |
| 523 | /* Following functions are used to collect some stats about locks. We wrap |
| 524 | * pthread functions to known how much time we wait in a lock. */ |
| 525 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 526 | static uint64_t nsec_now(void) |
| 527 | { |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 528 | struct timespec ts; |
| 529 | |
| 530 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 531 | return ((uint64_t) ts.tv_sec * 1000000000ULL + |
| 532 | (uint64_t) ts.tv_nsec); |
| 533 | } |
| 534 | |
| 535 | static inline void __ha_rwlock_init(struct ha_rwlock *l) |
| 536 | { |
| 537 | memset(l, 0, sizeof(struct ha_rwlock)); |
| 538 | __RWLOCK_INIT(&l->lock); |
| 539 | } |
| 540 | |
| 541 | static inline void __ha_rwlock_destroy(struct ha_rwlock *l) |
| 542 | { |
| 543 | __RWLOCK_DESTROY(&l->lock); |
| 544 | memset(l, 0, sizeof(struct ha_rwlock)); |
| 545 | } |
| 546 | |
| 547 | |
| 548 | static inline void __ha_rwlock_wrlock(enum lock_label lbl, struct ha_rwlock *l, |
| 549 | const char *func, const char *file, int line) |
| 550 | { |
| 551 | uint64_t start_time; |
| 552 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 553 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 554 | abort(); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 555 | |
| 556 | HA_ATOMIC_OR(&l->info.wait_writers, tid_bit); |
| 557 | |
| 558 | start_time = nsec_now(); |
| 559 | __RWLOCK_WRLOCK(&l->lock); |
| 560 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time)); |
| 561 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 562 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 563 | |
| 564 | l->info.cur_writer = tid_bit; |
| 565 | l->info.last_location.function = func; |
| 566 | l->info.last_location.file = file; |
| 567 | l->info.last_location.line = line; |
| 568 | |
| 569 | HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit); |
| 570 | } |
| 571 | |
| 572 | static inline int __ha_rwlock_trywrlock(enum lock_label lbl, struct ha_rwlock *l, |
| 573 | const char *func, const char *file, int line) |
| 574 | { |
| 575 | uint64_t start_time; |
| 576 | int r; |
| 577 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 578 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 579 | abort(); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 580 | |
| 581 | /* We set waiting writer because trywrlock could wait for readers to quit */ |
| 582 | HA_ATOMIC_OR(&l->info.wait_writers, tid_bit); |
| 583 | |
| 584 | start_time = nsec_now(); |
| 585 | r = __RWLOCK_TRYWRLOCK(&l->lock); |
| 586 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time)); |
| 587 | if (unlikely(r)) { |
| 588 | HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit); |
| 589 | return r; |
| 590 | } |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 591 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 592 | |
| 593 | l->info.cur_writer = tid_bit; |
| 594 | l->info.last_location.function = func; |
| 595 | l->info.last_location.file = file; |
| 596 | l->info.last_location.line = line; |
| 597 | |
| 598 | HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit); |
| 599 | |
| 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | static inline void __ha_rwlock_wrunlock(enum lock_label lbl,struct ha_rwlock *l, |
| 604 | const char *func, const char *file, int line) |
| 605 | { |
| 606 | if (unlikely(!(l->info.cur_writer & tid_bit))) { |
| 607 | /* the thread is not owning the lock for write */ |
| 608 | abort(); |
| 609 | } |
| 610 | |
| 611 | l->info.cur_writer = 0; |
| 612 | l->info.last_location.function = func; |
| 613 | l->info.last_location.file = file; |
| 614 | l->info.last_location.line = line; |
| 615 | |
| 616 | __RWLOCK_WRUNLOCK(&l->lock); |
| 617 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 618 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_unlocked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | static inline void __ha_rwlock_rdlock(enum lock_label lbl,struct ha_rwlock *l) |
| 622 | { |
| 623 | uint64_t start_time; |
| 624 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 625 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 626 | abort(); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 627 | |
| 628 | HA_ATOMIC_OR(&l->info.wait_readers, tid_bit); |
| 629 | |
| 630 | start_time = nsec_now(); |
| 631 | __RWLOCK_RDLOCK(&l->lock); |
| 632 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_read, (nsec_now() - start_time)); |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 633 | HA_ATOMIC_INC(&lock_stats[lbl].num_read_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 634 | |
| 635 | HA_ATOMIC_OR(&l->info.cur_readers, tid_bit); |
| 636 | |
| 637 | HA_ATOMIC_AND(&l->info.wait_readers, ~tid_bit); |
| 638 | } |
| 639 | |
| 640 | static inline int __ha_rwlock_tryrdlock(enum lock_label lbl,struct ha_rwlock *l) |
| 641 | { |
| 642 | int r; |
| 643 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 644 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 645 | abort(); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 646 | |
| 647 | /* try read should never wait */ |
| 648 | r = __RWLOCK_TRYRDLOCK(&l->lock); |
| 649 | if (unlikely(r)) |
| 650 | return r; |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 651 | HA_ATOMIC_INC(&lock_stats[lbl].num_read_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 652 | |
| 653 | HA_ATOMIC_OR(&l->info.cur_readers, tid_bit); |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | static inline void __ha_rwlock_rdunlock(enum lock_label lbl,struct ha_rwlock *l) |
| 659 | { |
| 660 | if (unlikely(!(l->info.cur_readers & tid_bit))) { |
| 661 | /* the thread is not owning the lock for read */ |
| 662 | abort(); |
| 663 | } |
| 664 | |
| 665 | HA_ATOMIC_AND(&l->info.cur_readers, ~tid_bit); |
| 666 | |
| 667 | __RWLOCK_RDUNLOCK(&l->lock); |
| 668 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 669 | HA_ATOMIC_INC(&lock_stats[lbl].num_read_unlocked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 670 | } |
| 671 | |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 672 | static inline void __ha_rwlock_wrtord(enum lock_label lbl, struct ha_rwlock *l, |
| 673 | const char *func, const char *file, int line) |
| 674 | { |
| 675 | uint64_t start_time; |
| 676 | |
| 677 | if ((l->info.cur_readers | l->info.cur_seeker) & tid_bit) |
| 678 | abort(); |
| 679 | |
| 680 | if (!(l->info.cur_writer & tid_bit)) |
| 681 | abort(); |
| 682 | |
| 683 | HA_ATOMIC_OR(&l->info.wait_readers, tid_bit); |
| 684 | |
| 685 | start_time = nsec_now(); |
| 686 | __RWLOCK_WRTORD(&l->lock); |
| 687 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_read, (nsec_now() - start_time)); |
| 688 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 689 | HA_ATOMIC_INC(&lock_stats[lbl].num_read_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 690 | |
| 691 | HA_ATOMIC_OR(&l->info.cur_readers, tid_bit); |
| 692 | HA_ATOMIC_AND(&l->info.cur_writer, ~tid_bit); |
| 693 | l->info.last_location.function = func; |
| 694 | l->info.last_location.file = file; |
| 695 | l->info.last_location.line = line; |
| 696 | |
| 697 | HA_ATOMIC_AND(&l->info.wait_readers, ~tid_bit); |
| 698 | } |
| 699 | |
| 700 | static inline void __ha_rwlock_wrtosk(enum lock_label lbl, struct ha_rwlock *l, |
| 701 | const char *func, const char *file, int line) |
| 702 | { |
| 703 | uint64_t start_time; |
| 704 | |
| 705 | if ((l->info.cur_readers | l->info.cur_seeker) & tid_bit) |
| 706 | abort(); |
| 707 | |
| 708 | if (!(l->info.cur_writer & tid_bit)) |
| 709 | abort(); |
| 710 | |
| 711 | HA_ATOMIC_OR(&l->info.wait_seekers, tid_bit); |
| 712 | |
| 713 | start_time = nsec_now(); |
| 714 | __RWLOCK_WRTOSK(&l->lock); |
| 715 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_seek, (nsec_now() - start_time)); |
| 716 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 717 | HA_ATOMIC_INC(&lock_stats[lbl].num_seek_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 718 | |
| 719 | HA_ATOMIC_OR(&l->info.cur_seeker, tid_bit); |
| 720 | HA_ATOMIC_AND(&l->info.cur_writer, ~tid_bit); |
| 721 | l->info.last_location.function = func; |
| 722 | l->info.last_location.file = file; |
| 723 | l->info.last_location.line = line; |
| 724 | |
| 725 | HA_ATOMIC_AND(&l->info.wait_seekers, ~tid_bit); |
| 726 | } |
| 727 | |
| 728 | static inline void __ha_rwlock_sklock(enum lock_label lbl, struct ha_rwlock *l, |
| 729 | const char *func, const char *file, int line) |
| 730 | { |
| 731 | uint64_t start_time; |
| 732 | |
| 733 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
| 734 | abort(); |
| 735 | |
| 736 | HA_ATOMIC_OR(&l->info.wait_seekers, tid_bit); |
| 737 | |
| 738 | start_time = nsec_now(); |
| 739 | __RWLOCK_SKLOCK(&l->lock); |
| 740 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_seek, (nsec_now() - start_time)); |
| 741 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 742 | HA_ATOMIC_INC(&lock_stats[lbl].num_seek_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 743 | |
| 744 | HA_ATOMIC_OR(&l->info.cur_seeker, tid_bit); |
| 745 | l->info.last_location.function = func; |
| 746 | l->info.last_location.file = file; |
| 747 | l->info.last_location.line = line; |
| 748 | |
| 749 | HA_ATOMIC_AND(&l->info.wait_seekers, ~tid_bit); |
| 750 | } |
| 751 | |
| 752 | static inline void __ha_rwlock_sktowr(enum lock_label lbl, struct ha_rwlock *l, |
| 753 | const char *func, const char *file, int line) |
| 754 | { |
| 755 | uint64_t start_time; |
| 756 | |
| 757 | if ((l->info.cur_readers | l->info.cur_writer) & tid_bit) |
| 758 | abort(); |
| 759 | |
| 760 | if (!(l->info.cur_seeker & tid_bit)) |
| 761 | abort(); |
| 762 | |
| 763 | HA_ATOMIC_OR(&l->info.wait_writers, tid_bit); |
| 764 | |
| 765 | start_time = nsec_now(); |
| 766 | __RWLOCK_SKTOWR(&l->lock); |
| 767 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time)); |
| 768 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 769 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 770 | |
| 771 | HA_ATOMIC_OR(&l->info.cur_writer, tid_bit); |
| 772 | HA_ATOMIC_AND(&l->info.cur_seeker, ~tid_bit); |
| 773 | l->info.last_location.function = func; |
| 774 | l->info.last_location.file = file; |
| 775 | l->info.last_location.line = line; |
| 776 | |
| 777 | HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit); |
| 778 | } |
| 779 | |
| 780 | static inline void __ha_rwlock_sktord(enum lock_label lbl, struct ha_rwlock *l, |
| 781 | const char *func, const char *file, int line) |
| 782 | { |
| 783 | uint64_t start_time; |
| 784 | |
| 785 | if ((l->info.cur_readers | l->info.cur_writer) & tid_bit) |
| 786 | abort(); |
| 787 | |
| 788 | if (!(l->info.cur_seeker & tid_bit)) |
| 789 | abort(); |
| 790 | |
| 791 | HA_ATOMIC_OR(&l->info.wait_readers, tid_bit); |
| 792 | |
| 793 | start_time = nsec_now(); |
| 794 | __RWLOCK_SKTORD(&l->lock); |
| 795 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_read, (nsec_now() - start_time)); |
| 796 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 797 | HA_ATOMIC_INC(&lock_stats[lbl].num_read_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 798 | |
| 799 | HA_ATOMIC_OR(&l->info.cur_readers, tid_bit); |
| 800 | HA_ATOMIC_AND(&l->info.cur_seeker, ~tid_bit); |
| 801 | l->info.last_location.function = func; |
| 802 | l->info.last_location.file = file; |
| 803 | l->info.last_location.line = line; |
| 804 | |
| 805 | HA_ATOMIC_AND(&l->info.wait_readers, ~tid_bit); |
| 806 | } |
| 807 | |
| 808 | static inline void __ha_rwlock_skunlock(enum lock_label lbl,struct ha_rwlock *l, |
| 809 | const char *func, const char *file, int line) |
| 810 | { |
| 811 | if (!(l->info.cur_seeker & tid_bit)) |
| 812 | abort(); |
| 813 | |
| 814 | HA_ATOMIC_AND(&l->info.cur_seeker, ~tid_bit); |
| 815 | l->info.last_location.function = func; |
| 816 | l->info.last_location.file = file; |
| 817 | l->info.last_location.line = line; |
| 818 | |
| 819 | __RWLOCK_SKUNLOCK(&l->lock); |
| 820 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 821 | HA_ATOMIC_INC(&lock_stats[lbl].num_seek_unlocked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | static inline int __ha_rwlock_trysklock(enum lock_label lbl, struct ha_rwlock *l, |
| 825 | const char *func, const char *file, int line) |
| 826 | { |
| 827 | uint64_t start_time; |
| 828 | int r; |
| 829 | |
| 830 | if ((l->info.cur_readers | l->info.cur_seeker | l->info.cur_writer) & tid_bit) |
| 831 | abort(); |
| 832 | |
| 833 | HA_ATOMIC_OR(&l->info.wait_seekers, tid_bit); |
| 834 | |
| 835 | start_time = nsec_now(); |
| 836 | r = __RWLOCK_TRYSKLOCK(&l->lock); |
| 837 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_seek, (nsec_now() - start_time)); |
| 838 | |
| 839 | if (likely(!r)) { |
| 840 | /* got the lock ! */ |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 841 | HA_ATOMIC_INC(&lock_stats[lbl].num_seek_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 842 | HA_ATOMIC_OR(&l->info.cur_seeker, tid_bit); |
| 843 | l->info.last_location.function = func; |
| 844 | l->info.last_location.file = file; |
| 845 | l->info.last_location.line = line; |
| 846 | } |
| 847 | |
| 848 | HA_ATOMIC_AND(&l->info.wait_seekers, ~tid_bit); |
| 849 | return r; |
| 850 | } |
| 851 | |
| 852 | static inline int __ha_rwlock_tryrdtosk(enum lock_label lbl, struct ha_rwlock *l, |
| 853 | const char *func, const char *file, int line) |
| 854 | { |
| 855 | uint64_t start_time; |
| 856 | int r; |
| 857 | |
| 858 | if ((l->info.cur_writer | l->info.cur_seeker) & tid_bit) |
| 859 | abort(); |
| 860 | |
| 861 | if (!(l->info.cur_readers & tid_bit)) |
| 862 | abort(); |
| 863 | |
| 864 | HA_ATOMIC_OR(&l->info.wait_seekers, tid_bit); |
| 865 | |
| 866 | start_time = nsec_now(); |
| 867 | r = __RWLOCK_TRYRDTOSK(&l->lock); |
| 868 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_seek, (nsec_now() - start_time)); |
| 869 | |
| 870 | if (likely(!r)) { |
| 871 | /* got the lock ! */ |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 872 | HA_ATOMIC_INC(&lock_stats[lbl].num_seek_locked); |
Willy Tarreau | 61f799b | 2020-10-16 16:53:46 +0200 | [diff] [blame] | 873 | HA_ATOMIC_OR(&l->info.cur_seeker, tid_bit); |
| 874 | HA_ATOMIC_AND(&l->info.cur_readers, ~tid_bit); |
| 875 | l->info.last_location.function = func; |
| 876 | l->info.last_location.file = file; |
| 877 | l->info.last_location.line = line; |
| 878 | } |
| 879 | |
| 880 | HA_ATOMIC_AND(&l->info.wait_seekers, ~tid_bit); |
| 881 | return r; |
| 882 | } |
| 883 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 884 | static inline void __spin_init(struct ha_spinlock *l) |
| 885 | { |
| 886 | memset(l, 0, sizeof(struct ha_spinlock)); |
| 887 | __SPIN_INIT(&l->lock); |
| 888 | } |
| 889 | |
| 890 | static inline void __spin_destroy(struct ha_spinlock *l) |
| 891 | { |
| 892 | __SPIN_DESTROY(&l->lock); |
| 893 | memset(l, 0, sizeof(struct ha_spinlock)); |
| 894 | } |
| 895 | |
| 896 | static inline void __spin_lock(enum lock_label lbl, struct ha_spinlock *l, |
| 897 | const char *func, const char *file, int line) |
| 898 | { |
| 899 | uint64_t start_time; |
| 900 | |
| 901 | if (unlikely(l->info.owner & tid_bit)) { |
| 902 | /* the thread is already owning the lock */ |
| 903 | abort(); |
| 904 | } |
| 905 | |
| 906 | HA_ATOMIC_OR(&l->info.waiters, tid_bit); |
| 907 | |
| 908 | start_time = nsec_now(); |
| 909 | __SPIN_LOCK(&l->lock); |
| 910 | HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time)); |
| 911 | |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 912 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 913 | |
| 914 | |
| 915 | l->info.owner = tid_bit; |
| 916 | l->info.last_location.function = func; |
| 917 | l->info.last_location.file = file; |
| 918 | l->info.last_location.line = line; |
| 919 | |
| 920 | HA_ATOMIC_AND(&l->info.waiters, ~tid_bit); |
| 921 | } |
| 922 | |
| 923 | static inline int __spin_trylock(enum lock_label lbl, struct ha_spinlock *l, |
| 924 | const char *func, const char *file, int line) |
| 925 | { |
| 926 | int r; |
| 927 | |
| 928 | if (unlikely(l->info.owner & tid_bit)) { |
| 929 | /* the thread is already owning the lock */ |
| 930 | abort(); |
| 931 | } |
| 932 | |
| 933 | /* try read should never wait */ |
| 934 | r = __SPIN_TRYLOCK(&l->lock); |
| 935 | if (unlikely(r)) |
| 936 | return r; |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 937 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_locked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 938 | |
| 939 | l->info.owner = tid_bit; |
| 940 | l->info.last_location.function = func; |
| 941 | l->info.last_location.file = file; |
| 942 | l->info.last_location.line = line; |
| 943 | |
| 944 | return 0; |
| 945 | } |
| 946 | |
| 947 | static inline void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l, |
| 948 | const char *func, const char *file, int line) |
| 949 | { |
| 950 | if (unlikely(!(l->info.owner & tid_bit))) { |
| 951 | /* the thread is not owning the lock */ |
| 952 | abort(); |
| 953 | } |
| 954 | |
| 955 | l->info.owner = 0; |
| 956 | l->info.last_location.function = func; |
| 957 | l->info.last_location.file = file; |
| 958 | l->info.last_location.line = line; |
| 959 | |
Willy Tarreau | 7c2a2ad | 2017-11-02 16:26:02 +0100 | [diff] [blame] | 960 | __SPIN_UNLOCK(&l->lock); |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 961 | HA_ATOMIC_INC(&lock_stats[lbl].num_write_unlocked); |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 962 | } |
| 963 | |
Christopher Faulet | 1a2b56e | 2017-10-12 16:09:09 +0200 | [diff] [blame] | 964 | #endif /* DEBUG_THREAD */ |
| 965 | |
| 966 | #endif /* USE_THREAD */ |
| 967 | |
Willy Tarreau | 3f567e4 | 2020-05-28 15:29:19 +0200 | [diff] [blame] | 968 | #endif /* _HAPROXY_THREAD_H */ |