session: full lock on session_send_evt_to_thread 50/20250/4
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Thu, 20 Jun 2019 07:58:37 +0000 (09:58 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 24 Jun 2019 23:35:28 +0000 (23:35 +0000)
Type: fix

This was causing issues in QUIC when an app client & the protocol
app compete for the worker msg_queue. Might not be ideal performance-
wise.

Change-Id: I629892253d5b5d968f31ad1d56f18463e143d6b4
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/svm/svm_fifo.c
src/vnet/session/session.c

index 6b4ea68..87e019a 100644 (file)
@@ -909,11 +909,11 @@ svm_fifo_dequeue_drop (svm_fifo_t * f, u32 len)
   if (PREDICT_FALSE (cursize == 0))
     return SVM_FIFO_EEMPTY;
 
-  svm_fifo_trace_add (f, tail, total_drop_bytes, 3);
-
   /* number of bytes we're going to drop */
   total_drop_bytes = clib_min (cursize, len);
 
+  svm_fifo_trace_add (f, tail, total_drop_bytes, 3);
+
   /* move head */
   head = (head + total_drop_bytes) % f->size;
 
index 8aa4af9..ea52b75 100644 (file)
@@ -32,18 +32,10 @@ session_send_evt_to_thread (void *data, void *args, u32 thread_index,
   session_event_t *evt;
   svm_msg_q_msg_t msg;
   svm_msg_q_t *mq;
-  u32 tries = 0, max_tries;
 
   mq = session_main_get_vpp_event_queue (thread_index);
-  while (svm_msg_q_try_lock (mq))
-    {
-      max_tries = vlib_get_current_process (vlib_get_main ())? 1e6 : 3;
-      if (tries++ == max_tries)
-       {
-         SESSION_DBG ("failed to enqueue evt");
-         return -1;
-       }
-    }
+  if (PREDICT_FALSE (svm_msg_q_lock (mq)))
+    return -1;
   if (PREDICT_FALSE (svm_msg_q_ring_is_full (mq, SESSION_MQ_IO_EVT_RING)))
     {
       svm_msg_q_unlock (mq);