diff options
author | 2020-02-09 20:03:12 +0000 | |
---|---|---|
committer | 2020-08-12 15:59:46 +0000 | |
commit | e700b5e43166f2131596034e63ad2c51ef882827 (patch) | |
tree | 1803954242000b3a7b8bee16a18b9f549705241c /src/vnet | |
parent | 5733ea661a358447314a92e55f78ee987c70028d (diff) |
session: avoid scanning new io list under load
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Idaa7cc26ad941be86daec4ed5920727237712f4a
(cherry picked from commit 16d974ec59776f0103ad62d0d04dc57989eef7ed)
Diffstat (limited to 'src/vnet')
-rwxr-xr-x | src/vnet/session/session_cli.c | 42 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 30 |
2 files changed, 51 insertions, 21 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c index b03353e564a..2dc9b4903d6 100755 --- a/src/vnet/session/session_cli.c +++ b/src/vnet/session/session_cli.c @@ -388,6 +388,39 @@ session_cli_show_session_filter (vlib_main_t * vm, u32 thread_index, count); } +void +session_cli_show_events_thread (vlib_main_t * vm, u32 thread_index) +{ + session_worker_t *wrk; + + wrk = session_main_get_worker_if_valid (thread_index); + if (!wrk) + { + vlib_cli_output (vm, "invalid thread index %u", thread_index); + return; + } + + vlib_cli_output (vm, "Thread %d:\n", thread_index); + vlib_cli_output (vm, " evt elements alloc: %u", + pool_elts (wrk->event_elts)); + vlib_cli_output (vm, " ctrl evt elt data alloc: %d", + pool_elts (wrk->ctrl_evts_data)); +} + +static void +session_cli_show_events (vlib_main_t * vm, u32 thread_index) +{ + session_main_t *smm = &session_main; + if (!thread_index) + { + session_cli_show_events_thread (vm, thread_index); + return; + } + + for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++) + session_cli_show_events_thread (vm, thread_index); +} + static void session_cli_print_transport_protos (vlib_main_t * vm) { @@ -418,6 +451,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, app_worker_t *app_wrk; u32 transport_index; const u8 *app_name; + u8 do_events = 0; int verbose = 0; session_t *s; @@ -508,6 +542,8 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, session_cli_print_session_states (vm); goto done; } + else if (unformat (line_input, "events")) + do_events = 1; else { error = clib_error_return (0, "unknown input `%U'", @@ -556,6 +592,12 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input, goto done; } + if (do_events) + { + session_cli_show_events (vm, thread_index); + goto done; + } + if (do_filter) { if (end < start) diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index b0939cf4d72..eb5876d2c3d 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -1239,8 +1239,8 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 thread_index = vm->thread_index, n_to_dequeue; session_worker_t *wrk = &smm->wrk[thread_index]; session_evt_elt_t *elt, *ctrl_he, *new_he, *old_he; + clib_llist_index_t ei, next_ei, old_ti; svm_msg_q_msg_t _msg, *msg = &_msg; - clib_llist_index_t old_ti; int i, n_tx_packets = 0; session_event_t *evt; svm_msg_q_t *mq; @@ -1296,24 +1296,14 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, old_he = pool_elt_at_index (wrk->event_elts, wrk->old_head); old_ti = clib_llist_prev_index (old_he, evt_list); - /* *INDENT-OFF* */ - clib_llist_foreach_safe (wrk->event_elts, evt_list, new_he, elt, ({ - session_evt_type_t et; - - et = elt->evt.event_type; - clib_llist_remove (wrk->event_elts, evt_list, elt); - - /* Postpone tx events if we can't handle them this dispatch cycle */ - if (n_tx_packets >= VLIB_FRAME_SIZE - && (et == SESSION_IO_EVT_TX || et == SESSION_IO_EVT_TX_FLUSH)) - { - clib_llist_add (wrk->event_elts, evt_list, elt, new_he); - continue; - } - - session_event_dispatch_io (wrk, node, elt, thread_index, &n_tx_packets); - })); - /* *INDENT-ON* */ + ei = clib_llist_next_index (new_he, evt_list); + while (ei != wrk->new_head && n_tx_packets < VLIB_FRAME_SIZE) + { + elt = pool_elt_at_index (wrk->event_elts, ei); + ei = clib_llist_next_index (elt, evt_list); + clib_llist_remove (wrk->event_elts, evt_list, elt); + session_event_dispatch_io (wrk, node, elt, thread_index, &n_tx_packets); + } /* * Handle the old io events, if we had any prior to processing the new ones @@ -1321,8 +1311,6 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (old_ti != wrk->old_head) { - clib_llist_index_t ei, next_ei; - old_he = pool_elt_at_index (wrk->event_elts, wrk->old_head); ei = clib_llist_next_index (old_he, evt_list); |