vlib: add VLIB_NUM_WORKERS_CHANGE_FN() handler
Allows features to update their data structures after change in number of worker threads. Type: improvement Change-Id: Icd4d197e28608f5bbb1edd13eb624cd98e33cafe Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:

committed by
Beno�t Ganne

parent
dd2f12ba6a
commit
321bd106a6
@ -636,25 +636,19 @@ VLIB_CLI_COMMAND (show_buffers_command, static) = {
|
|||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
clib_error_t *
|
clib_error_t *
|
||||||
vlib_buffer_worker_init (vlib_main_t * vm)
|
vlib_buffer_num_workers_change (vlib_main_t *vm)
|
||||||
{
|
{
|
||||||
vlib_buffer_main_t *bm = vm->buffer_main;
|
vlib_buffer_main_t *bm = vm->buffer_main;
|
||||||
vlib_buffer_pool_t *bp;
|
vlib_buffer_pool_t *bp;
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
vec_foreach (bp, bm->buffer_pools)
|
vec_foreach (bp, bm->buffer_pools)
|
||||||
{
|
vec_validate_aligned (bp->threads, vlib_get_n_threads () - 1,
|
||||||
clib_spinlock_lock (&bp->lock);
|
CLIB_CACHE_LINE_BYTES);
|
||||||
vec_validate_aligned (bp->threads, vlib_get_n_threads () - 1,
|
|
||||||
CLIB_CACHE_LINE_BYTES);
|
|
||||||
clib_spinlock_unlock (&bp->lock);
|
|
||||||
}
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VLIB_WORKER_INIT_FUNCTION (vlib_buffer_worker_init);
|
VLIB_NUM_WORKERS_CHANGE_FN (vlib_buffer_num_workers_change);
|
||||||
|
|
||||||
static clib_error_t *
|
static clib_error_t *
|
||||||
vlib_buffer_main_init_numa_alloc (struct vlib_main_t *vm, u32 numa_node,
|
vlib_buffer_main_init_numa_alloc (struct vlib_main_t *vm, u32 numa_node,
|
||||||
|
@ -171,6 +171,8 @@ static __clib_unused void * __clib_unused_##tag##_##x = x
|
|||||||
|
|
||||||
#define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init)
|
#define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init)
|
||||||
#define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init)
|
#define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init)
|
||||||
|
#define VLIB_NUM_WORKERS_CHANGE_FN(x) \
|
||||||
|
VLIB_DECLARE_INIT_FUNCTION (x, num_workers_change)
|
||||||
|
|
||||||
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \
|
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \
|
||||||
VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
|
VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
|
||||||
|
@ -306,6 +306,7 @@ typedef struct vlib_global_main_t
|
|||||||
_vlib_init_function_list_elt_t *main_loop_enter_function_registrations;
|
_vlib_init_function_list_elt_t *main_loop_enter_function_registrations;
|
||||||
_vlib_init_function_list_elt_t *main_loop_exit_function_registrations;
|
_vlib_init_function_list_elt_t *main_loop_exit_function_registrations;
|
||||||
_vlib_init_function_list_elt_t *worker_init_function_registrations;
|
_vlib_init_function_list_elt_t *worker_init_function_registrations;
|
||||||
|
_vlib_init_function_list_elt_t *num_workers_change_function_registrations;
|
||||||
_vlib_init_function_list_elt_t *api_init_function_registrations;
|
_vlib_init_function_list_elt_t *api_init_function_registrations;
|
||||||
vlib_config_function_runtime_t *config_function_registrations;
|
vlib_config_function_runtime_t *config_function_registrations;
|
||||||
|
|
||||||
|
@ -820,6 +820,14 @@ start_workers (vlib_main_t * vm)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vlib_worker_thread_barrier_sync (vm);
|
vlib_worker_thread_barrier_sync (vm);
|
||||||
|
{
|
||||||
|
clib_error_t *err;
|
||||||
|
err = vlib_call_init_exit_functions (
|
||||||
|
vm, &vgm->num_workers_change_function_registrations, 1 /* call_once */,
|
||||||
|
1 /* is_global */);
|
||||||
|
if (err)
|
||||||
|
clib_error_report (err);
|
||||||
|
}
|
||||||
vlib_worker_thread_barrier_release (vm);
|
vlib_worker_thread_barrier_release (vm);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user