diff options
author | wanghanlin <wanghanlin@corp.netease.com> | 2021-06-25 17:40:13 +0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2021-06-29 14:22:13 +0000 |
commit | 9e42cc285f9e212a94319a15df54df791b75bab9 (patch) | |
tree | 6d4b11cd2baa4ab81e735cede19b1e181c13ea04 /src/vcl/vppcom.c | |
parent | 87f7600dd67debf68d1236395cefdc5d6e7484fb (diff) |
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 <wanghanlin@corp.netease.com>
Change-Id: I9b4e1d6e1c4d7217cf0b2529d8efed792dea7b40
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r-- | src/vcl/vppcom.c | 14 |
1 files changed, 6 insertions, 8 deletions
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++) |