vcl session: minimize ct io events 44/29644/7
authorFlorin Coras <fcoras@cisco.com>
Wed, 28 Oct 2020 07:37:15 +0000 (00:37 -0700)
committerDave Barach <openvpp@barachs.net>
Thu, 29 Oct 2020 21:31:04 +0000 (21:31 +0000)
Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ic4072fbc182fff38a28b415be0bb16f0559a4064

src/vcl/vppcom.c
src/vnet/session/application_local.c

index 16f1076..95d8b41 100644 (file)
@@ -1884,7 +1884,9 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n,
        {
          if (vcl_session_is_closing (s))
            return vcl_session_closing_error (s);
-         svm_fifo_unset_event (s->rx_fifo);
+         if (is_ct)
+           svm_fifo_unset_event (s->rx_fifo);
+         svm_fifo_unset_event (rx_fifo);
          return VPPCOM_EWOULDBLOCK;
        }
       while (svm_fifo_is_empty_cons (rx_fifo))
@@ -1892,7 +1894,9 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n,
          if (vcl_session_is_closing (s))
            return vcl_session_closing_error (s);
 
-         svm_fifo_unset_event (s->rx_fifo);
+         if (is_ct)
+           svm_fifo_unset_event (s->rx_fifo);
+         svm_fifo_unset_event (rx_fifo);
          svm_msg_q_lock (mq);
          if (svm_msg_q_is_empty (mq))
            svm_msg_q_wait (mq);
@@ -1918,9 +1922,11 @@ read_again:
 
   if (svm_fifo_is_empty_cons (rx_fifo))
     {
-      svm_fifo_unset_event (s->rx_fifo);
+      if (is_ct)
+       svm_fifo_unset_event (s->rx_fifo);
+      svm_fifo_unset_event (rx_fifo);
       if (!svm_fifo_is_empty_cons (rx_fifo)
-         && svm_fifo_set_event (s->rx_fifo) && is_nonblocking)
+         && svm_fifo_set_event (rx_fifo) && is_nonblocking)
        {
          vec_add2 (wrk->unhandled_evts_vector, e, 1);
          e->event_type = SESSION_IO_EVT_RX;
index 58d3789..9de987d 100644 (file)
@@ -518,10 +518,16 @@ ct_custom_tx (void *session, transport_send_params_t * sp)
   session_t *s = (session_t *) session;
   if (session_has_transport (s))
     return 0;
-  /* As all other sessions, cut-throughs are scheduled by vpp for tx so let
-   * the scheduler's custom tx logic decide when to deschedule, i.e., after
-   * fifo is emptied. */
-  return ct_session_tx (s);
+  /* If event enqueued towards peer, remove from scheduler and
+   * remove session tx flag, i.e., accept new tx events */
+  if (!ct_session_tx (s))
+    {
+      sp->flags = TRANSPORT_SND_F_DESCHED;
+      svm_fifo_unset_event (s->tx_fifo);
+    }
+  /* The scheduler uses packet count as a means of upper bounding the amount
+   * of work done per dispatch. So make it look like we have sent something */
+  return 1;
 }
 
 static int
@@ -632,10 +638,7 @@ ct_session_tx (session_t * s)
   peer_s = session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
   if (peer_s->session_state >= SESSION_STATE_TRANSPORT_CLOSING)
     return 0;
-  session_enqueue_notify (peer_s);
-  /* The scheduler uses packet count as a means of upper bounding the amount
-   * of work done per dispatch. So make it look like we have sent something */
-  return 1;
+  return session_enqueue_notify (peer_s);
 }
 
 static clib_error_t *