blob: 574547f3670b6746803a4f7c46462fd2a914a333 [file] [log] [blame]
Christopher Faulet1a2b56e2017-10-12 16:09:09 +02001/*
2 * include/common/hathreads.h
3 * definitions, macros and inline functions about threads.
4 *
5 * Copyright (C) 2017 Christopher Fauet - cfaulet@haproxy.com
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _COMMON_HATHREADS_H
23#define _COMMON_HATHREADS_H
24
25#include <common/config.h>
26
Willy Tarreau0ccd3222018-07-30 10:34:35 +020027/* Note about all_threads_mask :
28 * - with threads support disabled, this symbol is defined as zero (0UL).
29 * - with threads enabled, this variable is never zero, it contains the mask
30 * of enabled threads. Thus if only one thread is enabled, it equals 1.
31 */
32
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020033#ifndef USE_THREAD
34
Willy Tarreau421f02e2018-01-20 18:19:22 +010035#define MAX_THREADS 1
Willy Tarreau0c026f42018-08-01 19:12:20 +020036#define MAX_THREADS_MASK 1
37
38/* Only way found to replace variables with constants that are optimized away
39 * at build time.
40 */
41enum { all_threads_mask = 1UL };
42enum { tid_bit = 1UL };
43enum { tid = 0 };
Willy Tarreau421f02e2018-01-20 18:19:22 +010044
Christopher Faulet9dcf9b62017-11-13 10:34:01 +010045#define __decl_hathreads(decl)
46
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020047#define HA_ATOMIC_CAS(val, old, new) ({((*val) == (*old)) ? (*(val) = (new) , 1) : (*(old) = *(val), 0);})
48#define HA_ATOMIC_ADD(val, i) ({*(val) += (i);})
49#define HA_ATOMIC_SUB(val, i) ({*(val) -= (i);})
50#define HA_ATOMIC_AND(val, flags) ({*(val) &= (flags);})
51#define HA_ATOMIC_OR(val, flags) ({*(val) |= (flags);})
52#define HA_ATOMIC_XCHG(val, new) \
53 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020054 typeof(*(val)) __old_xchg = *(val); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020055 *(val) = new; \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020056 __old_xchg; \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020057 })
Willy Tarreau5266b3e2018-01-25 17:43:58 +010058#define HA_ATOMIC_BTS(val, bit) \
59 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020060 typeof((val)) __p_bts = (val); \
61 typeof(*__p_bts) __b_bts = (1UL << (bit)); \
62 typeof(*__p_bts) __t_bts = *__p_bts & __b_bts; \
63 if (!__t_bts) \
64 *__p_bts |= __b_bts; \
65 __t_bts; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +010066 })
67#define HA_ATOMIC_BTR(val, bit) \
68 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020069 typeof((val)) __p_btr = (val); \
70 typeof(*__p_btr) __b_btr = (1UL << (bit)); \
71 typeof(*__p_btr) __t_btr = *__p_btr & __b_btr; \
72 if (__t_btr) \
73 *__p_btr &= ~__b_btr; \
74 __t_btr; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +010075 })
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020076#define HA_ATOMIC_STORE(val, new) ({*(val) = new;})
77#define HA_ATOMIC_UPDATE_MAX(val, new) \
78 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020079 typeof(*(val)) __new_max = (new); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020080 \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020081 if (*(val) < __new_max) \
82 *(val) = __new_max; \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020083 *(val); \
84 })
85
86#define HA_ATOMIC_UPDATE_MIN(val, new) \
87 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020088 typeof(*(val)) __new_min = (new); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020089 \
Christopher Faulet48aa13f2018-04-09 08:45:43 +020090 if (*(val) > __new_min) \
91 *(val) = __new_min; \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +020092 *(val); \
93 })
94
Willy Tarreaub29dc952017-10-31 18:00:20 +010095#define HA_BARRIER() do { } while (0)
Christopher Faulet339fff82017-10-19 11:59:15 +020096
Willy Tarreau0ccd3222018-07-30 10:34:35 +020097#define THREAD_SYNC_INIT() do { /* do nothing */ } while(0)
Christopher Faulet339fff82017-10-19 11:59:15 +020098#define THREAD_SYNC_ENABLE() do { /* do nothing */ } while(0)
99#define THREAD_WANT_SYNC() do { /* do nothing */ } while(0)
100#define THREAD_ENTER_SYNC() do { /* do nothing */ } while(0)
101#define THREAD_EXIT_SYNC() do { /* do nothing */ } while(0)
102#define THREAD_NO_SYNC() ({ 0; })
103#define THREAD_NEED_SYNC() ({ 1; })
104
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100105#define HA_SPIN_INIT(l) do { /* do nothing */ } while(0)
106#define HA_SPIN_DESTROY(l) do { /* do nothing */ } while(0)
107#define HA_SPIN_LOCK(lbl, l) do { /* do nothing */ } while(0)
108#define HA_SPIN_TRYLOCK(lbl, l) ({ 0; })
109#define HA_SPIN_UNLOCK(lbl, l) do { /* do nothing */ } while(0)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200110
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100111#define HA_RWLOCK_INIT(l) do { /* do nothing */ } while(0)
112#define HA_RWLOCK_DESTROY(l) do { /* do nothing */ } while(0)
113#define HA_RWLOCK_WRLOCK(lbl, l) do { /* do nothing */ } while(0)
114#define HA_RWLOCK_TRYWRLOCK(lbl, l) ({ 0; })
115#define HA_RWLOCK_WRUNLOCK(lbl, l) do { /* do nothing */ } while(0)
116#define HA_RWLOCK_RDLOCK(lbl, l) do { /* do nothing */ } while(0)
117#define HA_RWLOCK_TRYRDLOCK(lbl, l) ({ 0; })
118#define HA_RWLOCK_RDUNLOCK(lbl, l) do { /* do nothing */ } while(0)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200119
William Lallemand6e1796e2018-06-07 11:23:40 +0200120#define ha_sigmask(how, set, oldset) sigprocmask(how, set, oldset)
121
Willy Tarreau0c026f42018-08-01 19:12:20 +0200122static inline void ha_set_tid(unsigned int tid)
123{
124}
William Lallemand6e1796e2018-06-07 11:23:40 +0200125
Olivier Houchardf61f0cb2017-12-21 17:13:05 +0100126static inline void __ha_barrier_load(void)
127{
128}
129
130static inline void __ha_barrier_store(void)
131{
132}
133
134static inline void __ha_barrier_full(void)
135{
136}
137
Willy Tarreau60b639c2018-08-02 10:16:17 +0200138static inline void thread_harmless_now()
139{
140}
141
142static inline void thread_harmless_end()
143{
144}
145
146static inline void thread_isolate()
147{
148}
149
150static inline void thread_release()
151{
152}
153
154static inline unsigned long thread_isolated()
155{
156 return 1;
157}
158
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200159#else /* USE_THREAD */
160
161#include <stdio.h>
162#include <stdlib.h>
163#include <string.h>
164#include <pthread.h>
165#include <import/plock.h>
166
Willy Tarreau421f02e2018-01-20 18:19:22 +0100167#define MAX_THREADS LONGBITS
Willy Tarreau0c026f42018-08-01 19:12:20 +0200168#define MAX_THREADS_MASK ((unsigned long)-1)
Willy Tarreau421f02e2018-01-20 18:19:22 +0100169
Christopher Faulet9dcf9b62017-11-13 10:34:01 +0100170#define __decl_hathreads(decl) decl
171
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200172/* TODO: thread: For now, we rely on GCC builtins but it could be a good idea to
173 * have a header file regrouping all functions dealing with threads. */
Willy Tarreau1a69af62018-01-04 18:49:31 +0100174
David Carlierec5e8452018-01-11 14:20:43 +0000175#if defined(__GNUC__) && (__GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ < 7) && !defined(__clang__)
Willy Tarreau1a69af62018-01-04 18:49:31 +0100176/* gcc < 4.7 */
177
178#define HA_ATOMIC_ADD(val, i) __sync_add_and_fetch(val, i)
179#define HA_ATOMIC_SUB(val, i) __sync_sub_and_fetch(val, i)
180#define HA_ATOMIC_AND(val, flags) __sync_and_and_fetch(val, flags)
181#define HA_ATOMIC_OR(val, flags) __sync_or_and_fetch(val, flags)
182
183/* the CAS is a bit complicated. The older API doesn't support returning the
184 * value and the swap's result at the same time. So here we take what looks
185 * like the safest route, consisting in using the boolean version guaranteeing
186 * that the operation was performed or not, and we snoop a previous value. If
187 * the compare succeeds, we return. If it fails, we return the previous value,
188 * but only if it differs from the expected one. If it's the same it's a race
189 * thus we try again to avoid confusing a possibly sensitive caller.
190 */
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200191#define HA_ATOMIC_CAS(val, old, new) \
192 ({ \
193 typeof((val)) __val_cas = (val); \
194 typeof((old)) __oldp_cas = (old); \
195 typeof(*(old)) __oldv_cas; \
196 typeof((new)) __new_cas = (new); \
197 int __ret_cas; \
198 do { \
199 __oldv_cas = *__val_cas; \
200 __ret_cas = __sync_bool_compare_and_swap(__val_cas, *__oldp_cas, __new_cas); \
201 } while (!__ret_cas && *__oldp_cas == __oldv_cas); \
202 if (!__ret_cas) \
203 *__oldp_cas = __oldv_cas; \
204 __ret_cas; \
Willy Tarreau1a69af62018-01-04 18:49:31 +0100205 })
206
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200207#define HA_ATOMIC_XCHG(val, new) \
208 ({ \
209 typeof((val)) __val_xchg = (val); \
210 typeof(*(val)) __old_xchg; \
211 typeof((new)) __new_xchg = (new); \
212 do { __old_xchg = *__val_xchg; \
213 } while (!__sync_bool_compare_and_swap(__val_xchg, __old_xchg, __new_xchg)); \
214 __old_xchg; \
Willy Tarreau1a69af62018-01-04 18:49:31 +0100215 })
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100216
217#define HA_ATOMIC_BTS(val, bit) \
218 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200219 typeof(*(val)) __b_bts = (1UL << (bit)); \
220 __sync_fetch_and_or((val), __b_bts) & __b_bts; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100221 })
222
223#define HA_ATOMIC_BTR(val, bit) \
224 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200225 typeof(*(val)) __b_btr = (1UL << (bit)); \
226 __sync_fetch_and_and((val), ~__b_btr) & __b_btr; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100227 })
228
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200229#define HA_ATOMIC_STORE(val, new) \
230 ({ \
231 typeof((val)) __val_store = (val); \
232 typeof(*(val)) __old_store; \
233 typeof((new)) __new_store = (new); \
234 do { __old_store = *__val_store; \
235 } while (!__sync_bool_compare_and_swap(__val_store, __old_store, __new_store)); \
Willy Tarreau1a69af62018-01-04 18:49:31 +0100236 })
237#else
238/* gcc >= 4.7 */
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200239#define HA_ATOMIC_CAS(val, old, new) __atomic_compare_exchange_n(val, old, new, 0, 0, 0)
240#define HA_ATOMIC_ADD(val, i) __atomic_add_fetch(val, i, 0)
241#define HA_ATOMIC_SUB(val, i) __atomic_sub_fetch(val, i, 0)
242#define HA_ATOMIC_AND(val, flags) __atomic_and_fetch(val, flags, 0)
243#define HA_ATOMIC_OR(val, flags) __atomic_or_fetch(val, flags, 0)
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100244#define HA_ATOMIC_BTS(val, bit) \
245 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200246 typeof(*(val)) __b_bts = (1UL << (bit)); \
247 __sync_fetch_and_or((val), __b_bts) & __b_bts; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100248 })
249
250#define HA_ATOMIC_BTR(val, bit) \
251 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200252 typeof(*(val)) __b_btr = (1UL << (bit)); \
253 __sync_fetch_and_and((val), ~__b_btr) & __b_btr; \
Willy Tarreau5266b3e2018-01-25 17:43:58 +0100254 })
255
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200256#define HA_ATOMIC_XCHG(val, new) __atomic_exchange_n(val, new, 0)
257#define HA_ATOMIC_STORE(val, new) __atomic_store_n(val, new, 0)
Willy Tarreau1a69af62018-01-04 18:49:31 +0100258#endif
259
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200260#define HA_ATOMIC_UPDATE_MAX(val, new) \
261 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200262 typeof(*(val)) __old_max = *(val); \
263 typeof(*(val)) __new_max = (new); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200264 \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200265 while (__old_max < __new_max && \
266 !HA_ATOMIC_CAS(val, &__old_max, __new_max)); \
267 *(val); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200268 })
269#define HA_ATOMIC_UPDATE_MIN(val, new) \
270 ({ \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200271 typeof(*(val)) __old_min = *(val); \
272 typeof(*(val)) __new_min = (new); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200273 \
Christopher Faulet48aa13f2018-04-09 08:45:43 +0200274 while (__old_min > __new_min && \
275 !HA_ATOMIC_CAS(val, &__old_min, __new_min)); \
276 *(val); \
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200277 })
278
Willy Tarreaub29dc952017-10-31 18:00:20 +0100279#define HA_BARRIER() pl_barrier()
280
Willy Tarreau0ccd3222018-07-30 10:34:35 +0200281#define THREAD_SYNC_INIT() thread_sync_init()
Christopher Faulet339fff82017-10-19 11:59:15 +0200282#define THREAD_SYNC_ENABLE() thread_sync_enable()
283#define THREAD_WANT_SYNC() thread_want_sync()
284#define THREAD_ENTER_SYNC() thread_enter_sync()
285#define THREAD_EXIT_SYNC() thread_exit_sync()
286#define THREAD_NO_SYNC() thread_no_sync()
287#define THREAD_NEED_SYNC() thread_need_sync()
288
Willy Tarreau0ccd3222018-07-30 10:34:35 +0200289int thread_sync_init();
Christopher Faulet339fff82017-10-19 11:59:15 +0200290void thread_sync_enable(void);
291void thread_want_sync(void);
292void thread_enter_sync(void);
293void thread_exit_sync(void);
294int thread_no_sync(void);
295int thread_need_sync(void);
Willy Tarreau60b639c2018-08-02 10:16:17 +0200296void thread_harmless_till_end();
297void thread_isolate();
298void thread_release();
Christopher Faulet339fff82017-10-19 11:59:15 +0200299
Willy Tarreau0c026f42018-08-01 19:12:20 +0200300extern THREAD_LOCAL unsigned int tid; /* The thread id */
301extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */
Christopher Fauletddb6c162018-07-20 09:31:53 +0200302extern volatile unsigned long all_threads_mask;
Willy Tarreau60b639c2018-08-02 10:16:17 +0200303extern volatile unsigned long threads_want_rdv_mask;
304extern volatile unsigned long threads_harmless_mask;
305
306/* explanation for threads_want_rdv_mask and threads_harmless_mask :
307 * - threads_want_rdv_mask is a bit field indicating all threads that have
308 * requested a rendez-vous of other threads using thread_isolate().
309 * - threads_harmless_mask is a bit field indicating all threads that are
310 * currently harmless in that they promise not to access a shared resource.
311 *
312 * For a given thread, its bits in want_rdv and harmless can be translated like
313 * this :
314 *
315 * ----------+----------+----------------------------------------------------
316 * want_rdv | harmless | description
317 * ----------+----------+----------------------------------------------------
318 * 0 | 0 | thread not interested in RDV, possibly harmful
319 * 0 | 1 | thread not interested in RDV but harmless
320 * 1 | 1 | thread interested in RDV and waiting for its turn
321 * 1 | 0 | thread currently working isolated from others
322 * ----------+----------+----------------------------------------------------
323 */
Olivier Houchard6b96f722018-04-25 16:58:25 +0200324
William Lallemand6e1796e2018-06-07 11:23:40 +0200325#define ha_sigmask(how, set, oldset) pthread_sigmask(how, set, oldset)
326
Willy Tarreau0c026f42018-08-01 19:12:20 +0200327/* sets the thread ID and the TID bit for the current thread */
328static inline void ha_set_tid(unsigned int data)
329{
330 tid = data;
331 tid_bit = (1UL << tid);
332}
333
Willy Tarreau60b639c2018-08-02 10:16:17 +0200334/* Marks the thread as harmless. Note: this must be true, i.e. the thread must
335 * not be touching any unprotected shared resource during this period. Usually
336 * this is called before poll(), but it may also be placed around very slow
337 * calls (eg: some crypto operations). Needs to be terminated using
338 * thread_harmless_end().
339 */
340static inline void thread_harmless_now()
341{
342 HA_ATOMIC_OR(&threads_harmless_mask, tid_bit);
343}
344
345/* Ends the harmless period started by thread_harmless_now(). Usually this is
346 * placed after the poll() call. If it is discovered that a job was running and
347 * is relying on the thread still being harmless, the thread waits for the
348 * other one to finish.
349 */
350static inline void thread_harmless_end()
351{
352 while (1) {
353 HA_ATOMIC_AND(&threads_harmless_mask, ~tid_bit);
354 if (likely((threads_want_rdv_mask & all_threads_mask) == 0))
355 break;
356 thread_harmless_till_end();
357 }
358}
359
360/* an isolated thread has harmless cleared and want_rdv set */
361static inline unsigned long thread_isolated()
362{
363 return threads_want_rdv_mask & ~threads_harmless_mask & tid_bit;
364}
365
William Lallemand6e1796e2018-06-07 11:23:40 +0200366
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200367#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
368
Christopher Fauletf51bac22018-01-30 11:04:29 +0100369/* WARNING!!! if you update this enum, please also keep lock_label() up to date below */
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200370enum lock_label {
Christopher Faulet339fff82017-10-19 11:59:15 +0200371 THREAD_SYNC_LOCK = 0,
Christopher Fauletd4604ad2017-05-29 10:40:41 +0200372 FD_LOCK,
Emeric Brunc60def82017-09-27 14:59:38 +0200373 TASK_RQ_LOCK,
374 TASK_WQ_LOCK,
Christopher Fauletb349e482017-08-29 09:52:38 +0200375 POOL_LOCK,
Christopher Faulet8d8aa0d2017-05-30 15:36:50 +0200376 LISTENER_LOCK,
377 LISTENER_QUEUE_LOCK,
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200378 PROXY_LOCK,
Christopher Faulet29f77e82017-06-08 14:04:45 +0200379 SERVER_LOCK,
Christopher Faulet5d42e092017-10-16 12:00:40 +0200380 UPDATED_SERVERS_LOCK,
Christopher Faulet5b517552017-06-09 14:17:53 +0200381 LBPRM_LOCK,
Christopher Fauletb79a94c2017-05-30 15:34:30 +0200382 SIGNALS_LOCK,
Emeric Brun819fc6f2017-06-13 19:37:32 +0200383 STK_TABLE_LOCK,
384 STK_SESS_LOCK,
Emeric Brun1138fd02017-06-19 12:38:55 +0200385 APPLETS_LOCK,
Emeric Brun80527f52017-06-19 17:46:37 +0200386 PEER_LOCK,
Emeric Bruna1dd2432017-06-21 15:42:52 +0200387 BUF_WQ_LOCK,
Emeric Brun6b35e9b2017-06-30 16:23:45 +0200388 STRMS_LOCK,
Emeric Brun821bb9b2017-06-15 16:37:39 +0200389 SSL_LOCK,
390 SSL_GEN_CERTS_LOCK,
Emeric Brunb5997f72017-07-03 11:34:05 +0200391 PATREF_LOCK,
392 PATEXP_LOCK,
393 PATLRU_LOCK,
Christopher Faulete95f2c32017-07-24 16:30:34 +0200394 VARS_LOCK,
Christopher Faulet8ca3b4b2017-07-25 11:07:15 +0200395 COMP_POOL_LOCK,
Thierry FOURNIER61ba0e22017-07-12 11:41:21 +0200396 LUA_LOCK,
Thierry FOURNIER738a6d72017-07-17 00:14:07 +0200397 NOTIF_LOCK,
Christopher Faulet24289f22017-09-25 14:48:02 +0200398 SPOE_APPLET_LOCK,
Christopher Fauletb2812a62017-10-04 16:17:58 +0200399 DNS_LOCK,
Christopher Fauletcfda8472017-10-20 15:40:23 +0200400 PID_LIST_LOCK,
Christopher Fauletc2a89a62017-10-23 15:54:24 +0200401 EMAIL_ALERTS_LOCK,
Emeric Brund8b3b652017-11-07 11:19:48 +0100402 PIPES_LOCK,
Willy Tarreau1605c7a2018-01-23 19:01:49 +0100403 START_LOCK,
Christopher Faulet16f45c82018-02-16 11:23:49 +0100404 TLSKEYS_REF_LOCK,
Christopher Faulet339fff82017-10-19 11:59:15 +0200405 LOCK_LABELS
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200406};
407struct lock_stat {
408 uint64_t nsec_wait_for_write;
409 uint64_t nsec_wait_for_read;
410 uint64_t num_write_locked;
411 uint64_t num_write_unlocked;
412 uint64_t num_read_locked;
413 uint64_t num_read_unlocked;
414};
415
416extern struct lock_stat lock_stats[LOCK_LABELS];
417
418#define __HA_SPINLOCK_T unsigned long
419
420#define __SPIN_INIT(l) ({ (*l) = 0; })
421#define __SPIN_DESTROY(l) ({ (*l) = 0; })
Willy Tarreau88ac59b2017-11-06 01:03:26 +0100422#define __SPIN_LOCK(l) pl_take_s(l)
423#define __SPIN_TRYLOCK(l) !pl_try_s(l)
424#define __SPIN_UNLOCK(l) pl_drop_s(l)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200425
426#define __HA_RWLOCK_T unsigned long
427
428#define __RWLOCK_INIT(l) ({ (*l) = 0; })
429#define __RWLOCK_DESTROY(l) ({ (*l) = 0; })
430#define __RWLOCK_WRLOCK(l) pl_take_w(l)
431#define __RWLOCK_TRYWRLOCK(l) !pl_try_w(l)
432#define __RWLOCK_WRUNLOCK(l) pl_drop_w(l)
433#define __RWLOCK_RDLOCK(l) pl_take_r(l)
434#define __RWLOCK_TRYRDLOCK(l) !pl_try_r(l)
435#define __RWLOCK_RDUNLOCK(l) pl_drop_r(l)
436
437#define HA_SPINLOCK_T struct ha_spinlock
438
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100439#define HA_SPIN_INIT(l) __spin_init(l)
440#define HA_SPIN_DESTROY(l) __spin_destroy(l)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200441
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100442#define HA_SPIN_LOCK(lbl, l) __spin_lock(lbl, l, __func__, __FILE__, __LINE__)
443#define HA_SPIN_TRYLOCK(lbl, l) __spin_trylock(lbl, l, __func__, __FILE__, __LINE__)
444#define HA_SPIN_UNLOCK(lbl, l) __spin_unlock(lbl, l, __func__, __FILE__, __LINE__)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200445
446#define HA_RWLOCK_T struct ha_rwlock
447
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100448#define HA_RWLOCK_INIT(l) __ha_rwlock_init((l))
449#define HA_RWLOCK_DESTROY(l) __ha_rwlock_destroy((l))
450#define HA_RWLOCK_WRLOCK(lbl,l) __ha_rwlock_wrlock(lbl, l, __func__, __FILE__, __LINE__)
451#define HA_RWLOCK_TRYWRLOCK(lbl,l) __ha_rwlock_trywrlock(lbl, l, __func__, __FILE__, __LINE__)
452#define HA_RWLOCK_WRUNLOCK(lbl,l) __ha_rwlock_wrunlock(lbl, l, __func__, __FILE__, __LINE__)
453#define HA_RWLOCK_RDLOCK(lbl,l) __ha_rwlock_rdlock(lbl, l)
454#define HA_RWLOCK_TRYRDLOCK(lbl,l) __ha_rwlock_tryrdlock(lbl, l)
455#define HA_RWLOCK_RDUNLOCK(lbl,l) __ha_rwlock_rdunlock(lbl, l)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200456
457struct ha_spinlock {
458 __HA_SPINLOCK_T lock;
459 struct {
460 unsigned long owner; /* a bit is set to 1 << tid for the lock owner */
461 unsigned long waiters; /* a bit is set to 1 << tid for waiting threads */
462 struct {
463 const char *function;
464 const char *file;
465 int line;
466 } last_location; /* location of the last owner */
467 } info;
468};
469
470struct ha_rwlock {
471 __HA_RWLOCK_T lock;
472 struct {
473 unsigned long cur_writer; /* a bit is set to 1 << tid for the lock owner */
474 unsigned long wait_writers; /* a bit is set to 1 << tid for waiting writers */
475 unsigned long cur_readers; /* a bit is set to 1 << tid for current readers */
476 unsigned long wait_readers; /* a bit is set to 1 << tid for waiting waiters */
477 struct {
478 const char *function;
479 const char *file;
480 int line;
481 } last_location; /* location of the last write owner */
482 } info;
483};
484
Christopher Fauletf51bac22018-01-30 11:04:29 +0100485static inline const char *lock_label(enum lock_label label)
486{
487 switch (label) {
488 case THREAD_SYNC_LOCK: return "THREAD_SYNC";
Christopher Fauletf51bac22018-01-30 11:04:29 +0100489 case FD_LOCK: return "FD";
490 case TASK_RQ_LOCK: return "TASK_RQ";
491 case TASK_WQ_LOCK: return "TASK_WQ";
492 case POOL_LOCK: return "POOL";
493 case LISTENER_LOCK: return "LISTENER";
494 case LISTENER_QUEUE_LOCK: return "LISTENER_QUEUE";
495 case PROXY_LOCK: return "PROXY";
496 case SERVER_LOCK: return "SERVER";
497 case UPDATED_SERVERS_LOCK: return "UPDATED_SERVERS";
498 case LBPRM_LOCK: return "LBPRM";
499 case SIGNALS_LOCK: return "SIGNALS";
500 case STK_TABLE_LOCK: return "STK_TABLE";
501 case STK_SESS_LOCK: return "STK_SESS";
502 case APPLETS_LOCK: return "APPLETS";
503 case PEER_LOCK: return "PEER";
504 case BUF_WQ_LOCK: return "BUF_WQ";
505 case STRMS_LOCK: return "STRMS";
506 case SSL_LOCK: return "SSL";
507 case SSL_GEN_CERTS_LOCK: return "SSL_GEN_CERTS";
508 case PATREF_LOCK: return "PATREF";
509 case PATEXP_LOCK: return "PATEXP";
510 case PATLRU_LOCK: return "PATLRU";
511 case VARS_LOCK: return "VARS";
512 case COMP_POOL_LOCK: return "COMP_POOL";
513 case LUA_LOCK: return "LUA";
514 case NOTIF_LOCK: return "NOTIF";
515 case SPOE_APPLET_LOCK: return "SPOE_APPLET";
516 case DNS_LOCK: return "DNS";
517 case PID_LIST_LOCK: return "PID_LIST";
518 case EMAIL_ALERTS_LOCK: return "EMAIL_ALERTS";
519 case PIPES_LOCK: return "PIPES";
520 case START_LOCK: return "START";
Christopher Faulet16f45c82018-02-16 11:23:49 +0100521 case TLSKEYS_REF_LOCK: return "TLSKEYS_REF";
Christopher Fauletf51bac22018-01-30 11:04:29 +0100522 case LOCK_LABELS: break; /* keep compiler happy */
523 };
524 /* only way to come here is consecutive to an internal bug */
525 abort();
526}
527
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200528static inline void show_lock_stats()
529{
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200530 int lbl;
531
532 for (lbl = 0; lbl < LOCK_LABELS; lbl++) {
533 fprintf(stderr,
534 "Stats about Lock %s: \n"
535 "\t # write lock : %lu\n"
536 "\t # write unlock: %lu (%ld)\n"
537 "\t # wait time for write : %.3f msec\n"
538 "\t # wait time for write/lock: %.3f nsec\n"
539 "\t # read lock : %lu\n"
540 "\t # read unlock : %lu (%ld)\n"
541 "\t # wait time for read : %.3f msec\n"
542 "\t # wait time for read/lock : %.3f nsec\n",
Christopher Fauletf51bac22018-01-30 11:04:29 +0100543 lock_label(lbl),
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200544 lock_stats[lbl].num_write_locked,
545 lock_stats[lbl].num_write_unlocked,
546 lock_stats[lbl].num_write_unlocked - lock_stats[lbl].num_write_locked,
547 (double)lock_stats[lbl].nsec_wait_for_write / 1000000.0,
548 lock_stats[lbl].num_write_locked ? ((double)lock_stats[lbl].nsec_wait_for_write / (double)lock_stats[lbl].num_write_locked) : 0,
549 lock_stats[lbl].num_read_locked,
550 lock_stats[lbl].num_read_unlocked,
551 lock_stats[lbl].num_read_unlocked - lock_stats[lbl].num_read_locked,
552 (double)lock_stats[lbl].nsec_wait_for_read / 1000000.0,
553 lock_stats[lbl].num_read_locked ? ((double)lock_stats[lbl].nsec_wait_for_read / (double)lock_stats[lbl].num_read_locked) : 0);
554 }
555}
556
557/* Following functions are used to collect some stats about locks. We wrap
558 * pthread functions to known how much time we wait in a lock. */
559
560static uint64_t nsec_now(void) {
561 struct timespec ts;
562
563 clock_gettime(CLOCK_MONOTONIC, &ts);
564 return ((uint64_t) ts.tv_sec * 1000000000ULL +
565 (uint64_t) ts.tv_nsec);
566}
567
568static inline void __ha_rwlock_init(struct ha_rwlock *l)
569{
570 memset(l, 0, sizeof(struct ha_rwlock));
571 __RWLOCK_INIT(&l->lock);
572}
573
574static inline void __ha_rwlock_destroy(struct ha_rwlock *l)
575{
576 __RWLOCK_DESTROY(&l->lock);
577 memset(l, 0, sizeof(struct ha_rwlock));
578}
579
580
581static inline void __ha_rwlock_wrlock(enum lock_label lbl, struct ha_rwlock *l,
582 const char *func, const char *file, int line)
583{
584 uint64_t start_time;
585
586 if (unlikely(l->info.cur_writer & tid_bit)) {
587 /* the thread is already owning the lock for write */
588 abort();
589 }
590
591 if (unlikely(l->info.cur_readers & tid_bit)) {
592 /* the thread is already owning the lock for read */
593 abort();
594 }
595
596 HA_ATOMIC_OR(&l->info.wait_writers, tid_bit);
597
598 start_time = nsec_now();
599 __RWLOCK_WRLOCK(&l->lock);
600 HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time));
601
602 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_locked, 1);
603
604 l->info.cur_writer = tid_bit;
605 l->info.last_location.function = func;
606 l->info.last_location.file = file;
607 l->info.last_location.line = line;
608
609 HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit);
610}
611
612static inline int __ha_rwlock_trywrlock(enum lock_label lbl, struct ha_rwlock *l,
613 const char *func, const char *file, int line)
614{
615 uint64_t start_time;
616 int r;
617
618 if (unlikely(l->info.cur_writer & tid_bit)) {
619 /* the thread is already owning the lock for write */
620 abort();
621 }
622
623 if (unlikely(l->info.cur_readers & tid_bit)) {
624 /* the thread is already owning the lock for read */
625 abort();
626 }
627
628 /* We set waiting writer because trywrlock could wait for readers to quit */
629 HA_ATOMIC_OR(&l->info.wait_writers, tid_bit);
630
631 start_time = nsec_now();
632 r = __RWLOCK_TRYWRLOCK(&l->lock);
633 HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time));
634 if (unlikely(r)) {
635 HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit);
636 return r;
637 }
638 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_locked, 1);
639
640 l->info.cur_writer = tid_bit;
641 l->info.last_location.function = func;
642 l->info.last_location.file = file;
643 l->info.last_location.line = line;
644
645 HA_ATOMIC_AND(&l->info.wait_writers, ~tid_bit);
646
647 return 0;
648}
649
650static inline void __ha_rwlock_wrunlock(enum lock_label lbl,struct ha_rwlock *l,
651 const char *func, const char *file, int line)
652{
653 if (unlikely(!(l->info.cur_writer & tid_bit))) {
654 /* the thread is not owning the lock for write */
655 abort();
656 }
657
658 l->info.cur_writer = 0;
659 l->info.last_location.function = func;
660 l->info.last_location.file = file;
661 l->info.last_location.line = line;
662
663 __RWLOCK_WRUNLOCK(&l->lock);
664
665 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_unlocked, 1);
666}
667
668static inline void __ha_rwlock_rdlock(enum lock_label lbl,struct ha_rwlock *l)
669{
670 uint64_t start_time;
671
672 if (unlikely(l->info.cur_writer & tid_bit)) {
673 /* the thread is already owning the lock for write */
674 abort();
675 }
676
677 if (unlikely(l->info.cur_readers & tid_bit)) {
678 /* the thread is already owning the lock for read */
679 abort();
680 }
681
682 HA_ATOMIC_OR(&l->info.wait_readers, tid_bit);
683
684 start_time = nsec_now();
685 __RWLOCK_RDLOCK(&l->lock);
686 HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_read, (nsec_now() - start_time));
687 HA_ATOMIC_ADD(&lock_stats[lbl].num_read_locked, 1);
688
689 HA_ATOMIC_OR(&l->info.cur_readers, tid_bit);
690
691 HA_ATOMIC_AND(&l->info.wait_readers, ~tid_bit);
692}
693
694static inline int __ha_rwlock_tryrdlock(enum lock_label lbl,struct ha_rwlock *l)
695{
696 int r;
697
698 if (unlikely(l->info.cur_writer & tid_bit)) {
699 /* the thread is already owning the lock for write */
700 abort();
701 }
702
703 if (unlikely(l->info.cur_readers & tid_bit)) {
704 /* the thread is already owning the lock for read */
705 abort();
706 }
707
708 /* try read should never wait */
709 r = __RWLOCK_TRYRDLOCK(&l->lock);
710 if (unlikely(r))
711 return r;
712 HA_ATOMIC_ADD(&lock_stats[lbl].num_read_locked, 1);
713
714 HA_ATOMIC_OR(&l->info.cur_readers, tid_bit);
715
716 return 0;
717}
718
719static inline void __ha_rwlock_rdunlock(enum lock_label lbl,struct ha_rwlock *l)
720{
721 if (unlikely(!(l->info.cur_readers & tid_bit))) {
722 /* the thread is not owning the lock for read */
723 abort();
724 }
725
726 HA_ATOMIC_AND(&l->info.cur_readers, ~tid_bit);
727
728 __RWLOCK_RDUNLOCK(&l->lock);
729
730 HA_ATOMIC_ADD(&lock_stats[lbl].num_read_unlocked, 1);
731}
732
733static inline void __spin_init(struct ha_spinlock *l)
734{
735 memset(l, 0, sizeof(struct ha_spinlock));
736 __SPIN_INIT(&l->lock);
737}
738
739static inline void __spin_destroy(struct ha_spinlock *l)
740{
741 __SPIN_DESTROY(&l->lock);
742 memset(l, 0, sizeof(struct ha_spinlock));
743}
744
745static inline void __spin_lock(enum lock_label lbl, struct ha_spinlock *l,
746 const char *func, const char *file, int line)
747{
748 uint64_t start_time;
749
750 if (unlikely(l->info.owner & tid_bit)) {
751 /* the thread is already owning the lock */
752 abort();
753 }
754
755 HA_ATOMIC_OR(&l->info.waiters, tid_bit);
756
757 start_time = nsec_now();
758 __SPIN_LOCK(&l->lock);
759 HA_ATOMIC_ADD(&lock_stats[lbl].nsec_wait_for_write, (nsec_now() - start_time));
760
761 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_locked, 1);
762
763
764 l->info.owner = tid_bit;
765 l->info.last_location.function = func;
766 l->info.last_location.file = file;
767 l->info.last_location.line = line;
768
769 HA_ATOMIC_AND(&l->info.waiters, ~tid_bit);
770}
771
772static inline int __spin_trylock(enum lock_label lbl, struct ha_spinlock *l,
773 const char *func, const char *file, int line)
774{
775 int r;
776
777 if (unlikely(l->info.owner & tid_bit)) {
778 /* the thread is already owning the lock */
779 abort();
780 }
781
782 /* try read should never wait */
783 r = __SPIN_TRYLOCK(&l->lock);
784 if (unlikely(r))
785 return r;
786 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_locked, 1);
787
788 l->info.owner = tid_bit;
789 l->info.last_location.function = func;
790 l->info.last_location.file = file;
791 l->info.last_location.line = line;
792
793 return 0;
794}
795
796static inline void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l,
797 const char *func, const char *file, int line)
798{
799 if (unlikely(!(l->info.owner & tid_bit))) {
800 /* the thread is not owning the lock */
801 abort();
802 }
803
804 l->info.owner = 0;
805 l->info.last_location.function = func;
806 l->info.last_location.file = file;
807 l->info.last_location.line = line;
808
Willy Tarreau7c2a2ad2017-11-02 16:26:02 +0100809 __SPIN_UNLOCK(&l->lock);
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200810 HA_ATOMIC_ADD(&lock_stats[lbl].num_write_unlocked, 1);
811}
812
813#else /* DEBUG_THREAD */
814
815#define HA_SPINLOCK_T unsigned long
816
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100817#define HA_SPIN_INIT(l) ({ (*l) = 0; })
818#define HA_SPIN_DESTROY(l) ({ (*l) = 0; })
819#define HA_SPIN_LOCK(lbl, l) pl_take_s(l)
820#define HA_SPIN_TRYLOCK(lbl, l) !pl_try_s(l)
821#define HA_SPIN_UNLOCK(lbl, l) pl_drop_s(l)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200822
823#define HA_RWLOCK_T unsigned long
824
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100825#define HA_RWLOCK_INIT(l) ({ (*l) = 0; })
826#define HA_RWLOCK_DESTROY(l) ({ (*l) = 0; })
827#define HA_RWLOCK_WRLOCK(lbl,l) pl_take_w(l)
828#define HA_RWLOCK_TRYWRLOCK(lbl,l) !pl_try_w(l)
829#define HA_RWLOCK_WRUNLOCK(lbl,l) pl_drop_w(l)
830#define HA_RWLOCK_RDLOCK(lbl,l) pl_take_r(l)
831#define HA_RWLOCK_TRYRDLOCK(lbl,l) !pl_try_r(l)
832#define HA_RWLOCK_RDUNLOCK(lbl,l) pl_drop_r(l)
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200833
834#endif /* DEBUG_THREAD */
835
Olivier Houchardf61f0cb2017-12-21 17:13:05 +0100836#ifdef __x86_64__
837#define HA_HAVE_CAS_DW 1
838#define HA_CAS_IS_8B
839static __inline int
840__ha_cas_dw(void *target, void *compare, const void *set)
841{
842 char ret;
843
844 __asm __volatile("lock cmpxchg16b %0; setz %3"
845 : "+m" (*(void **)target),
846 "=a" (((void **)compare)[0]),
847 "=d" (((void **)compare)[1]),
848 "=q" (ret)
849 : "a" (((void **)compare)[0]),
850 "d" (((void **)compare)[1]),
851 "b" (((const void **)set)[0]),
852 "c" (((const void **)set)[1])
853 : "memory", "cc");
854 return (ret);
855}
856
857static __inline void
858__ha_barrier_load(void)
859{
860 __asm __volatile("lfence" ::: "memory");
861}
862
863static __inline void
864__ha_barrier_store(void)
865{
866 __asm __volatile("sfence" ::: "memory");
867}
868
869static __inline void
870__ha_barrier_full(void)
871{
872 __asm __volatile("mfence" ::: "memory");
873}
874
875#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
876#define HA_HAVE_CAS_DW 1
877static __inline void
878__ha_barrier_load(void)
879{
880 __asm __volatile("dmb" ::: "memory");
881}
882
883static __inline void
884__ha_barrier_store(void)
885{
886 __asm __volatile("dsb" ::: "memory");
887}
888
889static __inline void
890__ha_barrier_full(void)
891{
892 __asm __volatile("dmb" ::: "memory");
893}
894
Willy Tarreau41ccb192018-02-14 14:16:28 +0100895static __inline int __ha_cas_dw(void *target, void *compare, const void *set)
Olivier Houchardf61f0cb2017-12-21 17:13:05 +0100896{
897 uint64_t previous;
898 int tmp;
899
900 __asm __volatile("1:"
901 "ldrexd %0, [%4];"
902 "cmp %Q0, %Q2;"
903 "ittt eq;"
904 "cmpeq %R0, %R2;"
905 "strexdeq %1, %3, [%4];"
906 "cmpeq %1, #1;"
907 "beq 1b;"
908 : "=&r" (previous), "=&r" (tmp)
Willy Tarreau41ccb192018-02-14 14:16:28 +0100909 : "r" (*(uint64_t *)compare), "r" (*(uint64_t *)set), "r" (target)
Olivier Houchardf61f0cb2017-12-21 17:13:05 +0100910 : "memory", "cc");
911 tmp = (previous == *(uint64_t *)compare);
912 *(uint64_t *)compare = previous;
913 return (tmp);
914}
915
916#elif defined (__aarch64__)
917#define HA_HAVE_CAS_DW 1
918#define HA_CAS_IS_8B
919
920static __inline void
921__ha_barrier_load(void)
922{
923 __asm __volatile("dmb ishld" ::: "memory");
924}
925
926static __inline void
927__ha_barrier_store(void)
928{
929 __asm __volatile("dmb ishst" ::: "memory");
930}
931
932static __inline void
933__ha_barrier_full(void)
934{
935 __asm __volatile("dmb ish" ::: "memory");
936}
937
938static __inline int __ha_cas_dw(void *target, void *compare, void *set)
939{
940 void *value[2];
941 uint64_t tmp1, tmp2;
942
943 __asm__ __volatile__("1:"
944 "ldxp %0, %1, [%4];"
945 "mov %2, %0;"
946 "mov %3, %1;"
947 "eor %0, %0, %5;"
948 "eor %1, %1, %6;"
949 "orr %1, %0, %1;"
950 "mov %w0, #0;"
951 "cbnz %1, 2f;"
952 "stxp %w0, %7, %8, [%4];"
953 "cbnz %w0, 1b;"
954 "mov %w0, #1;"
955 "2:"
956 : "=&r" (tmp1), "=&r" (tmp2), "=&r" (value[0]), "=&r" (value[1])
957 : "r" (target), "r" (((void **)(compare))[0]), "r" (((void **)(compare))[1]), "r" (((void **)(set))[0]), "r" (((void **)(set))[1])
958 : "cc", "memory");
959
960 memcpy(compare, &value, sizeof(value));
961 return (tmp1);
962}
963
964#else
965#define __ha_barrier_load __sync_synchronize
966#define __ha_barrier_store __sync_synchronize
967#define __ha_barrier_full __sync_synchronize
968#endif
969
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200970#endif /* USE_THREAD */
971
Olivier Houchardf61f0cb2017-12-21 17:13:05 +0100972static inline void __ha_compiler_barrier(void)
973{
974 __asm __volatile("" ::: "memory");
975}
976
Willy Tarreau4037a3f2018-03-28 18:06:47 +0200977/* Dummy I/O handler used by the sync pipe.*/
978void thread_sync_io_handler(int fd);
Willy Tarreau0ccd3222018-07-30 10:34:35 +0200979int parse_nbthread(const char *arg, char **err);
Willy Tarreau4037a3f2018-03-28 18:06:47 +0200980
Christopher Faulet1a2b56e2017-10-12 16:09:09 +0200981#endif /* _COMMON_HATHREADS_H */