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

Message ID 1533196817-19441-4-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-consumer 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 | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Patch

diff --git a/platform/linux-dpdk/odp_queue_basic.c b/platform/linux-dpdk/odp_queue_basic.c
index 951d7ae7..af967587 100644
--- a/platform/linux-dpdk/odp_queue_basic.c
+++ b/platform/linux-dpdk/odp_queue_basic.c
@@ -541,19 +541,14 @@  static inline int plain_queue_deq(queue_entry_t *queue,
 {
 	int num_deq;
 
-	LOCK(queue);
-
 	if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) {
 		/* Bad queue, or queue has been destroyed. */
-		UNLOCK(queue);
 		return -1;
 	}
 
 	num_deq = ring_mpmc_deq_multi(queue->s.ring_mpmc, (void **)buf_hdr,
 				      num);
 
-	UNLOCK(queue);
-
 	return num_deq;
 }
 
@@ -751,18 +746,17 @@  int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num,
 
 	ring_mpmc = queue->s.ring_mpmc;
 
-	LOCK(queue);
-
 	if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) {
 		/* Bad queue, or queue has been destroyed.
 		 * Scheduler finalizes queue destroy after this. */
-		UNLOCK(queue);
 		return -1;
 	}
 
 	num_deq = ring_mpmc_deq_multi(ring_mpmc, (void **)ev, max_num);
 
 	if (num_deq == 0) {
+		LOCK(queue);
+
 		/* Already empty queue */
 		if (update_status && queue->s.status == QUEUE_STATUS_SCHED) {
 			queue->s.status = QUEUE_STATUS_NOTSCHED;
@@ -779,8 +773,6 @@  int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num,
 	if (status_sync && queue->s.type == ODP_QUEUE_TYPE_SCHED)
 		sched_fn->save_context(queue->s.index);
 
-	UNLOCK(queue);
-
 	return num_deq;
 }