diff options
author | Florin Coras <fcoras@cisco.com> | 2021-01-25 20:31:27 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2021-02-05 17:28:34 +0000 |
commit | 5398dfb2592d525018997a991a4f7bfde515adc4 (patch) | |
tree | d986e2bac410e8b630a0d5907b729550a28838da /src/plugins | |
parent | 2b97f597c6705809201ce6a6846d46c47c0933ba (diff) |
session svm: non blocking mq
Avoid synchronizing producers and the consumer. Instead, only use mutex
or spinlock (if eventfds are configured) to synchronize producers.
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ie2aafbdc2e07fced5d5e46ee2df6b30a186faa2f
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/hs_apps/sapi/vpp_echo.c | 10 | ||||
-rw-r--r-- | src/plugins/unittest/session_test.c | 11 |
2 files changed, 5 insertions, 16 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c index 19b5808c550..816b7d41c77 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo.c +++ b/src/plugins/hs_apps/sapi/vpp_echo.c @@ -808,15 +808,12 @@ echo_process_rpcs (echo_main_t * em) while (em->state < STATE_DATA_DONE && !em->time_to_stop) { - svm_msg_q_lock (mq); if (svm_msg_q_is_empty (mq) && svm_msg_q_timedwait (mq, 1)) { - svm_msg_q_unlock (mq); continue; } - svm_msg_q_sub_w_lock (mq, &msg); + svm_msg_q_sub_raw (mq, &msg); rpc = svm_msg_q_msg_data (mq, &msg); - svm_msg_q_unlock (mq); ((echo_rpc_t) rpc->fp) (em, &rpc->args); svm_msg_q_free_msg (mq, &msg); } @@ -876,18 +873,15 @@ echo_mq_thread_fn (void *arg) if (em->periodic_stats_delta) echo_print_periodic_stats (em); - svm_msg_q_lock (mq); if (svm_msg_q_is_empty (mq) && svm_msg_q_timedwait (mq, 1)) { - svm_msg_q_unlock (mq); continue; } for (i = 0; i < svm_msg_q_size (mq); i++) { vec_add2 (msg_vec, msg, 1); - svm_msg_q_sub_w_lock (mq, msg); + svm_msg_q_sub_raw (mq, msg); } - svm_msg_q_unlock (mq); for (i = 0; i < vec_len (msg_vec); i++) { diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c index 6496a99ba2c..cd99b0c5416 100644 --- a/src/plugins/unittest/session_test.c +++ b/src/plugins/unittest/session_test.c @@ -1738,9 +1738,7 @@ wait_for_event (svm_msg_q_t * mq, int fd, int epfd, u8 use_eventfd) { if (!use_eventfd) { - svm_msg_q_lock (mq); - while (svm_msg_q_is_empty (mq)) - svm_msg_q_wait (mq); + svm_msg_q_wait (mq, SVM_MQ_WAIT_EMPTY); } else { @@ -1764,10 +1762,7 @@ wait_for_event (svm_msg_q_t * mq, int fd, int epfd, u8 use_eventfd) continue; if (!svm_msg_q_is_empty (mq)) - { - svm_msg_q_lock (mq); - break; - } + break; } } } @@ -1871,7 +1866,7 @@ session_test_mq_speed (vlib_main_t * vm, unformat_input_t * input) for (i = 0; i < n_test_msgs; i++) { wait_for_event (mq, prod_fd, epfd, use_eventfd); - svm_msg_q_sub_w_lock (mq, &msg); + svm_msg_q_sub_raw (mq, &msg); svm_msg_q_free_msg (mq, &msg); svm_msg_q_unlock (mq); *counter = *counter + 1; |