|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
52 .format =
"bar-trace-%s-#%d",
53 .format_args =
"T4i4",
58 u32 caller,
count, t_entry, t_open, t_closed;
65 ed->t_entry = (int) (1000000.0 * t_entry);
66 ed->t_open = (int) (1000000.0 * t_open);
67 ed->t_closed = (int) (1000000.0 * t_closed);
77 .format =
"bar-syncrec-%s-#%d",
78 .format_args =
"T4i4",
99 .format =
"bar-relrrec-#%d",
119 .format =
"bar-rel-#%d-e%d-u%d-t%d",
120 .format_args =
"i4i4i4i4",
125 u32 count, t_entry, t_update_main, t_closed_total;
129 ed->t_entry = (int) (1000000.0 * t_entry);
130 ed->t_update_main = (int) (1000000.0 * t_update_main);
131 ed->t_closed_total = (int) (1000000.0 * t_closed_total);
147 int pthread_setname_np (pthread_t __target_thread,
const char *__name);
149 pthread_t
thread = pthread_self ();
165 return ((
i32) ((*tr0)->no_data_structure_clone)
166 - ((
i32) ((*tr1)->no_data_structure_clone)));
178 u32 n_vlib_mains = 1;
235 pthread_setaffinity_np (pthread_self (),
sizeof (cpu_set_t), &cpuset);
245 w->
lwp = syscall (SYS_gettid);
253 struct sched_param sched_param;
254 if (!sched_getparam (w->
lwp, &sched_param))
278 first_index += tr->
count;
292 " for the '%s' thread",
c, tr->
name);
300 for (j = 0; j < tr->
count; j++)
308 if (
c == ~0 && avail_c0)
316 "no available cpus to be used for"
317 " the '%s' thread", tr->
name);
352 if (nelts & (nelts - 1))
354 fformat (stderr,
"FATAL: nelts MUST be a power of 2\n");
412 w->
lwp = syscall (SYS_gettid);
430 const char *sys_cpu_path =
"/sys/devices/system/cpu/cpu";
431 const char *sys_node_path =
"/sys/devices/system/node/node";
435 int core_id = -1, numa_id = -1;
437 p =
format (p,
"%s%u/topology/core_id%c", sys_cpu_path,
cpu_id, 0);
445 p =
format (p,
"%s%u/cpulist%c", sys_node_path,
node, 0);
466 void *(*fp_arg) (
void *) = fp;
499 CPU_SET (
cpu_id, &cpuset);
501 if (pthread_create (&worker, NULL , fp_arg, (
void *) w))
504 if (pthread_setaffinity_np (worker,
sizeof (cpu_set_t), &cpuset))
523 u32 worker_thread_index;
552 if (n_vlib_mains > 1)
577 worker_thread_index = 1;
590 for (k = 0; k < tr->
count; k++)
612 (
char *)
format (0,
"%s %d", tr->
name, k + 1);
650 u32 save_node_runtime_index;
657 nf->
flags = save_flags;
671 for (j = 0; j <
vec_len (
nm->nodes); j++)
734 #ifdef VLIB_SUPPORTS_ARBITRARY_SCALAR_SIZES
751 worker_thread_index, oldheap, 1);
757 worker_thread_index++;
768 for (j = 0; j < tr->
count; j++)
786 (
char *)
format (0,
"%s %d", tr->
name, j + 1);
794 worker_thread_index = 1;
805 for (j = 0; j < tr->
count; j++)
856 for (j = 0; j <
vec_len (
nm->nodes); j++)
872 n = nm_clone->
nodes[j];
926 u32 save_node_runtime_index;
933 nf->
flags = save_flags;
936 old_nodes_clone = nm_clone->
nodes;
944 for (j = 0; j <
vec_len (
nm->nodes); j++)
952 if (j >=
vec_len (old_nodes_clone))
1001 for (j = 0; j <
vec_len (old_rt); j++)
1032 for (j = 0; j <
vec_len (old_rt); j++)
1060 for (j = 0; j <
vec_len (old_rt); j++)
1089 u32 *
r = va_arg (*args,
u32 *);
1092 #define _(v,f,s) else if (unformat (input, s)) *r = SCHED_POLICY_##f;
1127 if (
unformat (input,
"use-pthreads"))
1135 else if (
unformat (input,
"numa-heap-size %U",
1151 "corelist cannot be set for '%s' threads",
1155 (0,
"core placement of '%s' threads is already configured",
1178 (0,
"number of '%s' threads not configurable",
name);
1181 (0,
"number of '%s' threads is already configured",
name);
1204 "scheduling priority (%d) is not allowed for `normal` scheduling policy",
1233 #ifndef BARRIER_MINIMUM_OPEN_LIMIT
1234 #define BARRIER_MINIMUM_OPEN_LIMIT 0.001
1237 #ifndef BARRIER_MINIMUM_OPEN_FACTOR
1238 #define BARRIER_MINIMUM_OPEN_FACTOR 3
1258 fformat (stderr,
"%s: worker thread deadlock\n", __FUNCTION__);
1286 f64 max_vector_rate;
1317 max_vector_rate = 0.0;
1321 max_vector_rate =
clib_max (max_vector_rate,
1334 if (max_vector_rate > 10.0)
1346 (
"clock change: would have waited for %.4f seconds",
1363 fformat (stderr,
"%s: worker thread deadlock\n", __FUNCTION__);
1383 f64 t_update_main = 0.0;
1384 int refork_needed = 0;
1439 fformat (stderr,
"%s: worker thread deadlock\n", __FUNCTION__);
1455 fformat (stderr,
"%s: worker thread refork deadlock\n",
1510 for (ii = 1; ii <
vec_len (counts); ii++)
1569 if (frame_queue_nelts == 0)
1573 ASSERT (frame_queue_nelts >= 8 + num_threads);
1621 (*fp) (callback, args, arg_size);
1624 clib_warning (
"BUG: rpc_call_main_thread_cb_fn NULL!");
1644 (void)
unformat (input,
"verbose %=", &verbose, 1);
1678 .path =
"show clock",
1679 .short_help =
"show clock",
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
void vlib_node_sync_stats(vlib_main_t *vm, vlib_node_t *n)
uword clib_calljmp(uword(*func)(uword func_arg), uword func_arg, void *stack)
const char * barrier_caller
vlib_thread_registration_t * next
void vlib_process_signal_event_mt_helper(vlib_process_signal_event_mt_args_t *args)
void * vlib_stats_push_heap(void *old)
u16 flags
Copy of main node flags.
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
clib_random_buffer_t random_buffer
f64 barrier_no_close_before
__clib_export int clib_mem_set_default_numa_affinity()
void vlib_worker_thread_fn(void *arg)
volatile u32 main_loop_count
#define VLIB_FRAME_NO_FREE_AFTER_DISPATCH
static clib_mem_heap_t * clib_mem_get_heap(void)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
#define clib_memcpy(d, s, n)
@ CLIB_TIMEBASE_DAYLIGHT_NONE
char * name
Track name vector.
vlib_process_t ** processes
@ VLIB_NODE_TYPE_PRE_INPUT
static_always_inline void vlib_process_finish_switch_stack(vlib_main_t *vm)
#define VLIB_INVALID_NODE_INDEX
static int sort_registrations_by_no_clone(void *a0, void *a1)
static void vlib_worker_thread_barrier_check(void)
@ VLIB_NODE_TYPE_INTERNAL
clib_spinlock_t pending_rpc_lock
static void clib_mem_free(void *p)
volatile u32 * node_reforks_required
vlib_main_t vlib_node_runtime_t * node
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
vlib_thread_callbacks_t cb
#define hash_create_string(elts, value_bytes)
#define clib_error_return(e, args...)
pthread_t thread[MAX_CONNS]
void vlib_worker_thread_barrier_sync_int(vlib_main_t *vm, const char *func_name)
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap, int lock)
vlib_error_main_t error_main
vlib_node_main_t node_main
#define hash_set_mem(h, key, value)
void vlib_worker_wait_one_loop(void)
Wait until each of the workers has been once around the track.
void(**volatile barrier_perf_callbacks)(struct vlib_main_t *, u64 t, int leave)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
VLIB_REGISTER_THREAD(worker_thread_reg, static)
void vl_msg_api_handler_no_free(void *)
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
struct vlib_thread_registration_ * next
uword * cpu_socket_bitmap
void(* thread_function)(void *)
void vlib_worker_loop(vlib_main_t *vm)
#define VLIB_NODE_RUNTIME_DATA_SIZE
#define clib_error_report(e)
vnet_hw_if_output_node_runtime_t * r
vlib_worker_thread_t * vlib_worker_threads
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u8 * vlib_thread_stack_init(uword thread_index)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
clib_error_t * threads_init(vlib_main_t *vm)
static vlib_global_main_t * vlib_get_global_main(void)
volatile u32 worker_thread_release
void vlib_stat_segment_unlock(void)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
__clib_export void clib_time_init(clib_time_t *c)
#define clib_callback_data_init(set_, lock_)
Initialize a callback set.
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
#define clib_mem_alloc_no_fail(size)
format_function_t format_clib_timebase_time
vlib_next_frame_t * next_frames
clib_error_t * vlib_call_init_exit_functions_no_sort(vlib_main_t *vm, _vlib_init_function_list_elt_t **headp, int call_once, int is_global)
void vlib_worker_thread_node_refork(void)
__clib_export clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
int need_vlib_worker_thread_node_runtime_update
volatile u32 * wait_at_barrier
__clib_export int clib_mem_set_numa_affinity(u8 numa_node, int force)
#define BARRIER_SYNC_TIMEOUT
static vlib_cli_command_t f_command
(constructor) VLIB_CLI_COMMAND (f_command)
void vlib_set_thread_name(char *name)
u32 unformat_sched_policy(unformat_input_t *input, va_list *args)
static clib_mem_heap_t * clib_mem_get_per_cpu_heap(void)
clib_mem_heap_t * clib_mem_create_heap(void *base, uword size, int is_locked, char *fmt,...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vlib_worker_thread_node_runtime_update(void)
#define ELOG_TYPE_DECLARE(f)
#define CLIB_MEMORY_STORE_BARRIER()
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u32 vlib_last_vectors_per_main_loop(vlib_main_t *vm)
__clib_export void clib_interrupt_resize(void **data, uword n_int)
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
#define vlib_worker_thread_barrier_sync(X)
static_always_inline uword vlib_get_thread_index(void)
void * per_numa_mheaps[CLIB_MAX_NUMAS]
vlib_global_main_t vlib_global_main
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static clib_error_t * vlib_launch_thread_int(void *fp, vlib_worker_thread_t *w, unsigned cpu_id)
__clib_export uword unformat_bitmap_mask(unformat_input_t *input, va_list *va)
unformat an any sized hexadecimal bitmask into a bitmap
u16 state
Input node state.
void * rpc_call_main_thread_cb_fn
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define clib_bitmap_free(v)
Free a bitmap.
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
vlib_thread_main_t vlib_thread_main
uword * thread_registrations_by_name
uword * worker_init_functions_called
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static elog_main_t * vlib_get_elog_main()
vlib_frame_queue_t ** vlib_frame_queues
const char * barrier_context
#define BARRIER_MINIMUM_OPEN_FACTOR
clib_error_t *(* vlib_launch_thread_cb)(void *fp, vlib_worker_thread_t *w, unsigned cpu_id)
int vlib_thread_cb_register(struct vlib_main_t *vm, vlib_thread_callbacks_t *cb)
__clib_export void clib_timebase_init(clib_timebase_t *tb, i32 timezone_offset_in_hours, clib_timebase_daylight_time_t daylight_type, clib_time_t *clib_time)
static_always_inline void vlib_process_start_switch_stack(vlib_main_t *vm, vlib_process_t *p)
void * thread_function_arg
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
u8 vlib_worker_thread_barrier_held(void)
Return true if the wroker thread barrier is held.
#define VLIB_CLI_COMMAND(x,...)
uword * pending_rpc_requests
format_function_t format_clib_time
void vlib_stat_segment_lock(void)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
#define vec_dup_aligned(V, A)
Return copy of vector (no header, alignment specified).
vlib_frame_size_t * frame_sizes
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define FRAME_QUEUE_MAX_NELTS
vlib_node_runtime_perf_callback_set_t vlib_node_runtime_perf_callbacks
#define clib_atomic_fetch_add(a, b)
static void barrier_trace_release(f64 t_entry, f64 t_closed_total, f64 t_update_main)
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
vlib_thread_function_t * function
__clib_export clib_mem_main_t clib_mem_main
#define hash_get_mem(h, key)
#define vec_free(V)
Free vector's memory (no header).
vlib_thread_registration_t * registration
vlib_thread_registration_t ** registrations
static clib_error_t * cpu_config(vlib_main_t *vm, unformat_input_t *input)
u64 * counters_last_clear
#define clib_call_callbacks(h,...)
call the specified callback set
description fragment has unexpected format
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
#define VLIB_THREAD_STACK_SIZE
vlib_frame_queue_t * vlib_frame_queue_alloc(int nelts)
#define BARRIER_MINIMUM_OPEN_LIMIT
#define VLIB_INIT_FUNCTION(x)
static f64 clib_timebase_now(clib_timebase_t *tb)
static clib_error_t * show_clock_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_stats_t stats_total
static vlib_main_t * vlib_get_first_main(void)
vlib_node_runtime_t * nodes_by_type[VLIB_N_NODE_TYPE]
#define vec_foreach(var, vec)
Vector iterator.
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
#define clib_error_return_unix(e, args...)
void * vlib_worker_thread_bootstrap_fn(void *arg)
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
void vlib_node_runtime_sync_stats(vlib_main_t *vm, vlib_node_runtime_t *r, uword n_calls, uword n_vectors, uword n_clocks)
int no_data_structure_clone
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
void vlib_worker_thread_initial_barrier_sync_and_release(vlib_main_t *vm)
#define foreach_sched_policy
clib_spinlock_t worker_thread_main_loop_callback_lock
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_node_stats_t stats_last_clear
static u32 vlib_get_n_threads()
void vlib_get_thread_core_numa(vlib_worker_thread_t *w, unsigned cpu_id)
static vlib_main_t * vlib_get_main(void)
vlib_frame_queue_elt_t * elts
void vlib_worker_thread_init(vlib_worker_thread_t *w)
vnet_interface_output_runtime_t * rt
volatile u32 * workers_at_barrier
__clib_export word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
uword os_get_nthreads(void)
clib_error_t *(* vlib_thread_set_lcore_cb)(u32 thread, u16 cpu)
_vlib_init_function_list_elt_t * worker_init_function_registrations
static void barrier_trace_sync_rec(f64 t_entry)
static clib_error_t * start_workers(vlib_main_t *vm)
#define clib_warning(format, args...)
static void * clib_mem_alloc_aligned(uword size, uword align)
static void barrier_trace_sync(f64 t_entry, f64 t_open, f64 t_closed)
vlib_pending_frame_t * pending_frames
static void barrier_trace_release_rec(f64 t_entry)
static f64 vlib_time_now(vlib_main_t *vm)
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
static void worker_thread_node_runtime_update_internal(void)
static vlib_thread_main_t * vlib_get_thread_main()
vlib_main_t ** vlib_mains
void vlib_stats_register_mem_heap(clib_mem_heap_t *heap)
uword * lock
SMP lock, non-zero means locking required.
#define hash_create(elts, value_bytes)
static void vlib_next_frame_init(vlib_next_frame_t *nf)
u8 runtime_data[0]
Function dependent node-runtime data.
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
vlib_frame_queue_main_t * frame_queue_mains
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x)
clib_error_t * vlib_thread_init(vlib_main_t *vm)
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
vlib_thread_main_t * vlib_get_thread_main_not_inline(void)
f64 time_last_barrier_release
__clib_export void clib_interrupt_init(void **data, uword n_int)
#define clib_bitmap_dup(v)
Duplicate a bitmap.
__clib_export uword * clib_sysfs_list_to_bitmap(char *filename)