[v1,2/3] linux-dpdk: queue: remove unnecessary locking from enqueue

Message ID 1533196817-19441-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Implement queues using multi-producer/consumer rings
Related show

Commit Message

Github ODP bot Aug. 2, 2018, 8 a.m.
From: Matias Elo <matias.elo@nokia.com>

Queue is implemented using multi-producer ring.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
/** Email created from pull request 55 (matiaselo:dev/queue_opt)
 ** https://github.com/Linaro/odp-dpdk/pull/55
 ** Patch: https://github.com/Linaro/odp-dpdk/pull/55.patch
 ** Base sha: d0bd42aa817eb79dffeab77cbe3ea2ea6f5e3db4
 ** Merge commit sha: 61963fb0b1b8f78768f4b20340a726619e6984c7
 **/
 platform/linux-dpdk/odp_queue_basic.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Patch

diff --git a/platform/linux-dpdk/odp_queue_basic.c b/platform/linux-dpdk/odp_queue_basic.c
index 2bc6688d..951d7ae7 100644
--- a/platform/linux-dpdk/odp_queue_basic.c
+++ b/platform/linux-dpdk/odp_queue_basic.c
@@ -470,10 +470,7 @@  static inline int enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[],
 	if (sched_fn->ord_enq_multi(q_int, (void **)buf_hdr, num, &ret))
 		return ret;
 
-	LOCK(queue);
-
 	if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) {
-		UNLOCK(queue);
 		ODP_ERR("Bad queue status\n");
 		return -1;
 	}
@@ -481,10 +478,10 @@  static inline int enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[],
 	num_enq = ring_mpmc_enq_multi(queue->s.ring_mpmc, (void **)buf_hdr,
 				      num);
 
-	if (odp_unlikely(num_enq == 0)) {
-		UNLOCK(queue);
+	if (odp_unlikely(num_enq == 0))
 		return 0;
-	}
+
+	LOCK(queue);
 
 	if (queue->s.status == QUEUE_STATUS_NOTSCHED) {
 		queue->s.status = QUEUE_STATUS_SCHED;