vcl: fix vls mt detection and select handling
Make sure num threads is 1 on process create and fork. Multi-thread locks are applied once num threads exceeds 1. For select, follow same pattern like epoll and add check for session migration. Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: I1edcd6c4c81b6b3caf8b00781b339414e8945b0e
This commit is contained in:

committed by
Dave Wallace

parent
bd32d6234c
commit
ce4635c4a7
@ -71,6 +71,7 @@
|
||||
/* from <linux/netfilter_ipv4.h> */
|
||||
#define SO_ORIGINAL_DST 80
|
||||
#endif
|
||||
|
||||
typedef struct ldp_worker_ctx_
|
||||
{
|
||||
u8 *io_buffer;
|
||||
@ -102,7 +103,6 @@ typedef struct ldp_worker_ctx_
|
||||
u8 epoll_wait_vcl;
|
||||
u8 mq_epfd_added;
|
||||
int vcl_mq_epfd;
|
||||
|
||||
} ldp_worker_ctx_t;
|
||||
|
||||
/* clib_bitmap_t, fd_mask and vcl_si_set are used interchangeably. Make sure
|
||||
@ -674,6 +674,8 @@ ldp_select_init_maps (fd_set * __restrict original,
|
||||
vlsh = ldp_fd_to_vlsh (fd);
|
||||
if (vlsh == VLS_INVALID_HANDLE)
|
||||
clib_bitmap_set_no_check (*libcb, fd, 1);
|
||||
else if (vlsh_to_worker_index (vlsh) != vppcom_worker_index ())
|
||||
clib_warning ("migration currently not supported");
|
||||
else
|
||||
*vclb = clib_bitmap_set (*vclb, vlsh_to_session_index (vlsh), 1);
|
||||
}
|
||||
@ -731,10 +733,10 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
|
||||
const __sigset_t * __restrict sigmask)
|
||||
{
|
||||
u32 minbits = clib_max (nfds, BITS (uword)), n_bytes;
|
||||
ldp_worker_ctx_t *ldpw = ldp_worker_get_current ();
|
||||
struct timespec libc_tspec = { 0 };
|
||||
f64 time_out, vcl_timeout = 0;
|
||||
uword si_bits, libc_bits;
|
||||
ldp_worker_ctx_t *ldpw;
|
||||
int rv, bits_set = 0;
|
||||
|
||||
if (nfds < 0)
|
||||
@ -743,6 +745,11 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PREDICT_FALSE (vppcom_worker_index () == ~0))
|
||||
vls_register_vcl_worker ();
|
||||
|
||||
ldpw = ldp_worker_get_current ();
|
||||
|
||||
if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
|
||||
clib_time_init (&ldpw->clib_time);
|
||||
|
||||
|
@ -559,6 +559,22 @@ vlsh_to_session_index (vls_handle_t vlsh)
|
||||
return vppcom_session_index (sh);
|
||||
}
|
||||
|
||||
int
|
||||
vlsh_to_worker_index (vls_handle_t vlsh)
|
||||
{
|
||||
vcl_locked_session_t *vls;
|
||||
u32 wrk_index;
|
||||
|
||||
vls = vls_get_w_dlock (vlsh);
|
||||
if (!vls)
|
||||
wrk_index = INVALID_SESSION_ID;
|
||||
else
|
||||
wrk_index = vls->vcl_wrk_index;
|
||||
vls_dunlock (vls);
|
||||
|
||||
return wrk_index;
|
||||
}
|
||||
|
||||
vls_handle_t
|
||||
vls_si_wi_to_vlsh (u32 session_index, u32 vcl_wrk_index)
|
||||
{
|
||||
@ -1799,7 +1815,7 @@ vls_app_fork_child_handler (void)
|
||||
vls_worker_alloc ();
|
||||
|
||||
/* Reset number of threads and set wrk index */
|
||||
vlsl->vls_mt_n_threads = 0;
|
||||
vlsl->vls_mt_n_threads = 1;
|
||||
vlsl->vls_wrk_index = vcl_get_worker_index ();
|
||||
vlsl->select_mp_check = 0;
|
||||
clib_rwlock_init (&vlsl->vls_pool_lock);
|
||||
@ -1983,9 +1999,11 @@ vls_app_create (char *app_name)
|
||||
atexit (vls_app_exit);
|
||||
vls_worker_alloc ();
|
||||
vlsl->vls_wrk_index = vcl_get_worker_index ();
|
||||
vlsl->vls_mt_n_threads = 1;
|
||||
clib_rwlock_init (&vlsl->vls_pool_lock);
|
||||
vls_mt_locks_init ();
|
||||
vcm->wrk_rpc_fn = vls_rpc_handler;
|
||||
|
||||
return VPPCOM_OK;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ int vls_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map,
|
||||
vcl_si_set * except_map, double wait_for_time);
|
||||
vcl_session_handle_t vlsh_to_sh (vls_handle_t vlsh);
|
||||
vcl_session_handle_t vlsh_to_session_index (vls_handle_t vlsh);
|
||||
int vlsh_to_worker_index (vls_handle_t vlsh);
|
||||
vls_handle_t vls_session_index_to_vlsh (uint32_t session_index);
|
||||
int vls_app_create (char *app_name);
|
||||
unsigned char vls_use_eventfd (void);
|
||||
|
Reference in New Issue
Block a user