fq = clib_mem_alloc_aligned (sizeof (*fq), CLIB_CACHE_LINE_BYTES);
clib_memset (fq, 0, sizeof (*fq));
fq->nelts = nelts;
- fq->vector_threshold = 128; // packets
+ fq->vector_threshold = 2 * VLIB_FRAME_SIZE;
vec_validate_aligned (fq->elts, nelts - 1, CLIB_CACHE_LINE_BYTES);
- if (1)
+ if (nelts & (nelts - 1))
{
- if (((uword) & fq->tail) & (CLIB_CACHE_LINE_BYTES - 1))
- fformat (stderr, "WARNING: fq->tail unaligned\n");
- if (((uword) & fq->head) & (CLIB_CACHE_LINE_BYTES - 1))
- fformat (stderr, "WARNING: fq->head unaligned\n");
- if (((uword) fq->elts) & (CLIB_CACHE_LINE_BYTES - 1))
- fformat (stderr, "WARNING: fq->elts unaligned\n");
-
- if (sizeof (fq->elts[0]) % CLIB_CACHE_LINE_BYTES)
- fformat (stderr, "WARNING: fq->elts[0] size %d\n",
- sizeof (fq->elts[0]));
- if (nelts & (nelts - 1))
- {
- fformat (stderr, "FATAL: nelts MUST be a power of 2\n");
- abort ();
- }
+ fformat (stderr, "FATAL: nelts MUST be a power of 2\n");
+ abort ();
}
return (fq);
{
void *rv;
vlib_worker_thread_t *w = arg;
+ vlib_main_t *vm = 0;
w->lwp = syscall (SYS_gettid);
w->thread_id = pthread_self ();
__os_thread_index = w - vlib_worker_threads;
- vlib_process_start_switch_stack (vlib_get_main_by_index (__os_thread_index),
- 0);
+ vm = vlib_global_main.vlib_mains[__os_thread_index];
+
+ vlib_process_start_switch_stack (vm, 0);
rv = (void *) clib_calljmp
((uword (*)(uword)) w->thread_function,
(uword) arg, w->thread_stack + VLIB_THREAD_STACK_SIZE);
vm_clone->thread_index = worker_thread_index;
vm_clone->heap_base = w->thread_mheap;
- vm_clone->heap_aligned_base = (void *)
- (((uword) w->thread_mheap) & ~(VLIB_FRAME_ALIGN - 1));
+ vm_clone->heap_aligned_base =
+ (void *) (((uword) w->thread_mheap) &
+ ~(CLIB_CACHE_LINE_BYTES - 1));
vm_clone->pending_rpc_requests = 0;
vec_validate (vm_clone->pending_rpc_requests, 0);
_vec_len (vm_clone->pending_rpc_requests) = 0;
CLIB_CACHE_LINE_BYTES);
/* Create per-thread frame freelist */
- nm_clone->frame_sizes = vec_new (vlib_frame_size_t, 1);
-#ifdef VLIB_SUPPORTS_ARBITRARY_SCALAR_SIZES
- nm_clone->frame_size_hash = hash_create (0, sizeof (uword));
-#endif
+ nm_clone->frame_sizes = 0;
nm_clone->node_by_error = nm->node_by_error;
/* Packet trace buffers are guaranteed to be empty, nothing to do here */
fqm->node_index = node_index;
fqm->frame_queue_nelts = frame_queue_nelts;
- fqm->queue_hi_thresh = frame_queue_nelts - num_threads;
vec_validate (fqm->vlib_frame_queues, tm->n_vlib_mains - 1);
- vec_validate (fqm->per_thread_data, tm->n_vlib_mains - 1);
_vec_len (fqm->vlib_frame_queues) = 0;
for (i = 0; i < tm->n_vlib_mains; i++)
{
- vlib_frame_queue_per_thread_data_t *ptd;
fq = vlib_frame_queue_alloc (frame_queue_nelts);
vec_add1 (fqm->vlib_frame_queues, fq);
-
- ptd = vec_elt_at_index (fqm->per_thread_data, i);
- vec_validate (ptd->handoff_queue_elt_by_thread_index,
- tm->n_vlib_mains - 1);
- vec_validate_init_empty (ptd->congested_handoff_queue_by_thread_index,
- tm->n_vlib_mains - 1,
- (vlib_frame_queue_t *) (~0));
}
return (fqm - tm->frame_queue_mains);
show_clock_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- int i;
int verbose = 0;
clib_timebase_t _tb, *tb = &_tb;
verbose, format_clib_timebase_time,
clib_timebase_now (tb));
- if (vlib_get_n_threads () == 1)
- return 0;
-
vlib_cli_output (vm, "Time last barrier release %.9f",
vm->time_last_barrier_release);
- for (i = 1; i < vlib_get_n_threads (); i++)
+ foreach_vlib_main ()
{
- vlib_main_t *ovm = vlib_get_main_by_index (i);
- if (ovm == 0)
- continue;
-
- vlib_cli_output (vm, "%d: %U", i, format_clib_time, &ovm->clib_time,
- verbose);
-
- vlib_cli_output (
- vm, "Thread %d offset %.9f error %.9f", i, ovm->time_offset,
- vm->time_last_barrier_release - ovm->time_last_barrier_release);
+ vlib_cli_output (vm, "%d: %U", this_vlib_main->thread_index,
+ format_clib_time, &this_vlib_main->clib_time, verbose);
+
+ vlib_cli_output (vm, "Thread %d offset %.9f error %.9f",
+ this_vlib_main->thread_index,
+ this_vlib_main->time_offset,
+ vm->time_last_barrier_release -
+ this_vlib_main->time_last_barrier_release);
}
return 0;
}