From 9e42cc285f9e212a94319a15df54df791b75bab9 Mon Sep 17 00:00:00 2001 From: wanghanlin Date: Fri, 25 Jun 2021 17:40:13 +0800 Subject: vcl: Don't memset events to optimize CPU usage In stress test case, memset may consume a lot of CPU because vls_epoll_wait is called very frequently. Type: improvement Signed-off-by: wanghanlin Change-Id: I9b4e1d6e1c4d7217cf0b2529d8efed792dea7b40 --- src/vcl/vppcom.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index b74570d10da..5dc5eda2f3c 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -2980,7 +2980,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, || (s->flags & VCL_SESSION_F_HAS_RX_EVT)) break; add_event = 1; - events[*num_ev].events |= EPOLLIN; + events[*num_ev].events = EPOLLIN; session_evt_data = s->vep.ev.data.u64; s->flags |= VCL_SESSION_F_HAS_RX_EVT; break; @@ -2993,7 +2993,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, if (!(EPOLLOUT & session_events)) break; add_event = 1; - events[*num_ev].events |= EPOLLOUT; + events[*num_ev].events = EPOLLOUT; session_evt_data = s->vep.ev.data.u64; svm_fifo_reset_has_deq_ntf (vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo); @@ -3010,7 +3010,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, if (!(EPOLLIN & session_events)) break; add_event = 1; - events[*num_ev].events |= EPOLLIN; + events[*num_ev].events = EPOLLIN; session_evt_data = s->vep.ev.data.u64; break; case SESSION_CTRL_EVT_CONNECTED: @@ -3029,7 +3029,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, if (!(EPOLLOUT & session_events)) break; add_event = 1; - events[*num_ev].events |= EPOLLOUT; + events[*num_ev].events = EPOLLOUT; session_evt_data = s->vep.ev.data.u64; if (s->session_state == VCL_STATE_DETACHED) events[*num_ev].events |= EPOLLHUP; @@ -3050,7 +3050,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, sid = s->session_index; session_events = s->vep.ev.events; add_event = 1; - events[*num_ev].events |= EPOLLHUP | EPOLLRDHUP; + events[*num_ev].events = EPOLLHUP | EPOLLRDHUP; session_evt_data = s->vep.ev.data.u64; break; case SESSION_CTRL_EVT_RESET: @@ -3064,7 +3064,7 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, break; session_events = s->vep.ev.events; add_event = 1; - events[*num_ev].events |= EPOLLHUP | EPOLLRDHUP; + events[*num_ev].events = EPOLLHUP | EPOLLRDHUP; session_evt_data = s->vep.ev.data.u64; break; case SESSION_CTRL_EVT_UNLISTEN_REPLY: @@ -3307,8 +3307,6 @@ vppcom_epoll_wait (uint32_t vep_handle, struct epoll_event *events, return VPPCOM_EINVAL; } - memset (events, 0, sizeof (*events) * maxevents); - if (vec_len (wrk->unhandled_evts_vector)) { for (i = 0; i < vec_len (wrk->unhandled_evts_vector); i++) -- cgit 1.2.3-korg