From 0242d30fc717aeacb758281dad8e5b2e56bf6709 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 22 Dec 2022 15:03:44 -0800 Subject: session: async rx event notifications Move from synchronous flushing of io and ctrl events from transports to applications to an async model via a new session_input input node that runs in interrupt mode. Events are coalesced per application worker. On the one hand, this helps by minimizing message queue locking churn. And on the other, it opens the possibility for further optimizations of event message generation, obviates need for rx rescheduling rpcs and is a first step towards a fully async data/io rx path. Type: improvement Signed-off-by: Florin Coras Change-Id: Id6bebcb65fc9feef8aa02ddf1af6d9ba6f6745ce --- src/vnet/session/application_local.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'src/vnet/session/application_local.c') diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 6ac4da2c655..192c22b659a 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -1027,6 +1027,17 @@ ct_close_is_reset (ct_connection_t *ct, session_t *s) return (svm_fifo_max_dequeue (s->rx_fifo) > 0); } +static void +ct_session_cleanup_server_session (session_t *s) +{ + ct_connection_t *ct; + + ct = (ct_connection_t *) session_get_transport (s); + ct_session_dealloc_fifos (ct, s->rx_fifo, s->tx_fifo); + session_free (s); + ct_connection_free (ct); +} + static void ct_session_postponed_cleanup (ct_connection_t *ct) { @@ -1047,33 +1058,38 @@ ct_session_postponed_cleanup (ct_connection_t *ct) } session_transport_closed_notify (&ct->connection); + /* It would be cleaner to call session_transport_delete_notify + * but then we can't control session cleanup lower */ + session_set_state (s, SESSION_STATE_TRANSPORT_DELETED); + if (app_wrk) + app_worker_cleanup_notify (app_wrk, s, SESSION_CLEANUP_TRANSPORT); + if (ct->flags & CT_CONN_F_CLIENT) { - if (app_wrk) - app_worker_cleanup_notify (app_wrk, s, SESSION_CLEANUP_TRANSPORT); - /* Normal free for client session as the fifos are allocated through * the connects segment manager in a segment that's not shared with * the server */ ct_session_dealloc_fifos (ct, ct->client_rx_fifo, ct->client_tx_fifo); - session_free_w_fifos (s); + session_program_cleanup (s); + ct_connection_free (ct); } else { /* Manual session and fifo segment cleanup to avoid implicit * segment manager cleanups and notifications */ - app_wrk = app_worker_get_if_valid (s->app_wrk_index); if (app_wrk) { - app_worker_cleanup_notify (app_wrk, s, SESSION_CLEANUP_TRANSPORT); - app_worker_cleanup_notify (app_wrk, s, SESSION_CLEANUP_SESSION); + /* Remove custom cleanup notify infra when/if switching to normal + * session cleanup. Note that ct is freed in the cb function */ + app_worker_cleanup_notify_custom (app_wrk, s, + SESSION_CLEANUP_SESSION, + ct_session_cleanup_server_session); + } + else + { + ct_connection_free (ct); } - - ct_session_dealloc_fifos (ct, s->rx_fifo, s->tx_fifo); - session_free (s); } - - ct_connection_free (ct); } static void -- cgit 1.2.3-korg