vcl: fix libc epoll pwait starved 80/31680/3
authorwanghanlin <wanghanlin@corp.netease.com>
Thu, 18 Mar 2021 12:00:41 +0000 (20:00 +0800)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 22 Mar 2021 14:23:06 +0000 (14:23 +0000)
We call vls_epoll_wait with 0 timeout to process unhandled_evts_vector
in ldp_epoll_pwait_eventfd. But vls_epoll_wait will then call
vppcom_epoll_wait_eventfd to process events in event queue. If there are
continuous events to be handled, then libc_epoll_pwait have no chance to be called.

Type: fix

Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
Change-Id: Ia4f61d0d438a3475bfde9f6715805274671d4e75

src/vcl/ldp.c
src/vcl/vppcom.c

index a10d4d0..64a4e7c 100644 (file)
@@ -2516,7 +2516,8 @@ ldp_epoll_pwait_eventfd (int epfd, struct epoll_event *events,
       ldpw->mq_epfd_added = 1;
     }
 
-  rv = vls_epoll_wait (ep_vlsh, events, maxevents, 0);
+  /* Request to only drain unhandled to prevent libc_epoll_wait starved */
+  rv = vls_epoll_wait (ep_vlsh, events, maxevents, -2);
   if (rv > 0)
     goto done;
   else if (PREDICT_FALSE (rv < 0))
index cc4464b..3e4ba2f 100644 (file)
@@ -3042,6 +3042,9 @@ vppcom_epoll_wait (uint32_t vep_handle, struct epoll_event *events,
        }
       vec_reset_length (wrk->unhandled_evts_vector);
     }
+  /* Request to only drain unhandled */
+  if ((int) wait_for_time == -2)
+    return n_evts;
 
   if (vcm->cfg.use_mq_eventfd)
     return vppcom_epoll_wait_eventfd (wrk, events, maxevents, n_evts,