|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
15 #ifndef included_vlib_threads_h
16 #define included_vlib_threads_h
20 #include <linux/sched.h>
54 #define VLIB_MAX_CPUS 256
57 #if VLIB_MAX_CPUS > CLIB_MAX_MHEAPS
58 #error Please increase number of per-cpu mheaps
61 #define VLIB_CPU_MASK (VLIB_MAX_CPUS - 1)
62 #define VLIB_OFFSET_MASK (~VLIB_CPU_MASK)
64 #define VLIB_LOG2_THREAD_STACK_SIZE (21)
65 #define VLIB_THREAD_STACK_SIZE (1<<VLIB_LOG2_THREAD_STACK_SIZE)
92 void (*thread_function) (
void *);
158 void (*thread_function) (
void *));
164 #define BARRIER_SYNC_DELAY (0.030000)
168 #define BARRIER_SYNC_TIMEOUT (600.1)
170 #define BARRIER_SYNC_TIMEOUT (1.0)
173 #define vlib_worker_thread_barrier_sync(X) {vlib_worker_thread_barrier_sync_int(X, __FUNCTION__);}
176 const char *func_name);
189 return __os_thread_index;
198 fformat (stderr,
"%s: SMP unsafe warning...\n", __FUNCTION__);
216 #define foreach_vlib_main() \
217 for (vlib_main_t *ii = 0, *this_vlib_main; \
218 __foreach_vlib_main_helper (ii, &this_vlib_main); ii++) \
221 #define foreach_sched_policy \
222 _(SCHED_OTHER, OTHER, "other") \
223 _(SCHED_BATCH, BATCH, "batch") \
224 _(SCHED_IDLE, IDLE, "idle") \
225 _(SCHED_FIFO, FIFO, "fifo") \
226 _(SCHED_RR, RR, "rr")
230 #define _(v,f,s) SCHED_POLICY_##f = v,
313 #define VLIB_REGISTER_THREAD(x,...) \
314 __VA_ARGS__ vlib_thread_registration_t x; \
315 static void __vlib_add_thread_registration_##x (void) \
316 __attribute__((__constructor__)) ; \
317 static void __vlib_add_thread_registration_##x (void) \
319 vlib_thread_main_t * tm = &vlib_thread_main; \
323 static void __vlib_rm_thread_registration_##x (void) \
324 __attribute__((__destructor__)) ; \
325 static void __vlib_rm_thread_registration_##x (void) \
327 vlib_thread_main_t * tm = &vlib_thread_main; \
328 VLIB_REMOVE_FROM_LINKED_LIST (tm->next, &x, next); \
330 __VA_ARGS__ vlib_thread_registration_t x
341 return worker_index + 1;
375 .format =
"barrier-wait-thread-%d",
424 .format =
"barrier-refork-thread-%d",
451 .format =
"barrier-released-thread-%d: %dus",
452 .format_args =
"i4i4",
464 ed->duration = (int) (1000000.0 * t);
478 ASSERT (worker_index < tm->n_vlib_mains - 1);
void() vlib_thread_function_t(void *arg)
const char * barrier_caller
vlib_thread_registration_t * next
void vlib_get_thread_core_numa(vlib_worker_thread_t *w, unsigned cpu_id)
static u32 vlib_num_workers()
vlib_worker_thread_t * vlib_worker_threads
static u32 vlib_get_worker_thread_index(u32 worker_index)
void vlib_set_thread_name(char *name)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
static void vlib_worker_thread_barrier_check(void)
static u32 vlib_get_worker_index(u32 thread_index)
static vlib_main_t * vlib_get_worker_vlib_main(u32 worker_index)
volatile u32 * node_reforks_required
void vlib_worker_thread_initial_barrier_sync_and_release(vlib_main_t *vm)
vlib_thread_callbacks_t cb
pthread_t thread[MAX_CONNS]
vlib_thread_main_t * vlib_get_thread_main_not_inline(void)
void(**volatile barrier_perf_callbacks)(struct vlib_main_t *, u64 t, int leave)
volatile int parked_at_barrier
static void vlib_smp_unsafe_warning(void)
void vlib_worker_thread_init(vlib_worker_thread_t *w)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
struct vlib_thread_registration_ * next
uword * cpu_socket_bitmap
void vlib_process_signal_event_mt_helper(vlib_process_signal_event_mt_args_t *args)
void vlib_rpc_call_main_thread(void *function, u8 *args, u32 size)
u8 * vlib_thread_stack_init(uword thread_index)
int vlib_thread_cb_register(struct vlib_main_t *vm, vlib_thread_callbacks_t *cb)
frame_queue_trace_t * frame_queue_traces
static vlib_global_main_t * vlib_get_global_main(void)
Callback multiplex scheme For a fully worked-out example, see .../src/vlib/main.[ch] and ....
volatile u32 worker_thread_release
volatile u32 * wait_at_barrier
vlib_worker_thread_t * worker_threads
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define ELOG_TYPE_DECLARE(f)
#define ELOG_TRACK_DATA(em, f, track)
static u32 vlib_get_current_worker_index()
static_always_inline uword vlib_get_thread_index(void)
vlib_global_main_t vlib_global_main
#define static_always_inline
static u8 vlib_thread_is_main_w_barrier(void)
uword * thread_registrations_by_name
vlib_frame_queue_t ** vlib_frame_queues
const char * barrier_context
void * thread_function_arg
void vlib_worker_thread_node_runtime_update(void)
#define clib_atomic_fetch_add(a, b)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
vlib_thread_registration_t * registration
vlib_thread_registration_t ** registrations
#define clib_call_callbacks(h,...)
call the specified callback set
void * rpc_call_main_thread_cb_fn
struct vlib_thread_registration_ vlib_thread_registration_t
clib_error_t * vlib_thread_init(vlib_main_t *vm)
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
void vlib_worker_thread_node_refork(void)
int no_data_structure_clone
u8 vlib_worker_thread_barrier_held(void)
Return true if the wroker thread barrier is held.
#define foreach_sched_policy
void vlib_create_worker_threads(vlib_main_t *vm, int n, void(*thread_function)(void *))
#define STRUCT_MARK(mark)
void vlib_worker_wait_one_loop(void)
Wait until each of the workers has been once around the track.
static vlib_main_t * vlib_get_main(void)
vlib_frame_queue_elt_t * elts
volatile u32 * workers_at_barrier
vlib_thread_main_t vlib_thread_main
static f64 vlib_time_now(vlib_main_t *vm)
frame_queue_nelt_counter_t * frame_queue_histogram
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
vlib_main_t ** vlib_mains
vlib_frame_queue_main_t * frame_queue_mains
f64 time_last_barrier_release
void vlib_worker_thread_barrier_sync_int(vlib_main_t *vm, const char *func_name)