From ce4635c4a79543654e8825614138f1d58b6d785c Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 23 Oct 2024 14:19:31 -0700 Subject: 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 Signed-off-by: Dave Wallace Change-Id: I1edcd6c4c81b6b3caf8b00781b339414e8945b0e --- src/vcl/vcl_locked.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/vcl/vcl_locked.c') diff --git a/src/vcl/vcl_locked.c b/src/vcl/vcl_locked.c index 93ece0027ff..24cc598694a 100644 --- a/src/vcl/vcl_locked.c +++ b/src/vcl/vcl_locked.c @@ -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; } -- cgit 1.2.3-korg