From patchwork Thu Feb 22 10:00:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 129179 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp426869lja; Thu, 22 Feb 2018 02:11:43 -0800 (PST) X-Google-Smtp-Source: AH8x227BW7maeeuBqkDF2mNMHSajOvct1gZO/7p/Psfc0UY7hUd9FnTrqwK5LHuRLFGOutDCFBIz X-Received: by 10.200.45.79 with SMTP id o15mr10010351qta.277.1519294303615; Thu, 22 Feb 2018 02:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519294303; cv=none; d=google.com; s=arc-20160816; b=B54/9p0uEp2jN1hX8Zt2HlqskuHt1GrtSLEpqmwEX+dqJIHfiUYqM3cMK95JR/Nlx/ ITMpPOTeE39ezYTB920f+0ODfQ3/1oM1Qn+CoU7lfAZAMg9p35lC5S/7FidLThnGgtPi ybNuDEVYfNqaA8twvkRQoXWGKeFVjSTPpCiQkRsq/xeaR0/uY9WUMspH7BGDzCtFOMp1 vdkeMnyRRmtwwmcjcBKMB65yYsb6kQo4fO4F/ytfEhCBhPRyDqlNwB4m9DK770pBChzW OTqAg1tqV2L3gbEnMjqA2SNIk7mREJ9q5pqpAYaxfTrS1ldhHJGCsZGQ0qFiUI3E8JRd qHdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=gMl6QAJbw7AkS2Kk2p+oqGS/annc+i0La/9GK/IVyLk=; b=nQZVBb4HoNrH8w1ojer5qSMHvz8bh9AUnmWWAZzkRG3giB4TcGHZ51IywA6GBDSbh+ Y/NCJ/YL0pmFryXFpoiE2owfIfBSWGj3/XuNalpoInhRJx0gN8f0LQVSNci/bmBwG6oh bUxGX9H1Pseonu75M7QOZPilPwFi0Keh3lzbJc9rdgbsZfOtaAgSLp2aquQWKZX5jL9l RhkN0ItTSnnKyhyfZYxiuEHazP0QSazHlX2ZGWdg7r6QgnXGP02QINBMWVyJJxNF0KJ0 TugpU6zJ6oxvH6z2b54GFx9hOv4pZSqsiJV6YXJxtkYsorQxZbHVLLM3IM2fv0h9ntQa xMYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id l186si5304713qkb.369.2018.02.22.02.11.43; Thu, 22 Feb 2018 02:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 38BE7608E4; Thu, 22 Feb 2018 10:11:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2180561776; Thu, 22 Feb 2018 10:01:52 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5BB8260698; Thu, 22 Feb 2018 10:01:26 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 14AB9607CC for ; Thu, 22 Feb 2018 10:00:30 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward102o.mail.yandex.net (Yandex) with ESMTP id DA1A95A02282 for ; Thu, 22 Feb 2018 13:00:28 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id qYkXuix3hX-0SbejQ8L; Thu, 22 Feb 2018 13:00:28 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id azPEnBhLoH-0SvCm9ef; Thu, 22 Feb 2018 13:00:28 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 22 Feb 2018 13:00:20 +0300 Message-Id: <1519293622-14665-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519293622-14665-1-git-send-email-odpbot@yandex.ru> References: <1519293622-14665-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 492 Subject: [lng-odp] [PATCH v2 8/10] linux-gen: queue: simplify lock macro usage X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Use queue entry pointer as macro parameter instead of lock pointer. Signed-off-by: Petri Savolainen --- /** Email created from pull request 492 (psavol:master-sched-optim) ** https://github.com/Linaro/odp/pull/492 ** Patch: https://github.com/Linaro/odp/pull/492.patch ** Base sha: 5a58bbf2bb331fd7dde2ebbc0430634ace6900fb ** Merge commit sha: b29563293c1bca56419d2dc355a8e64d961e024a **/ platform/linux-generic/odp_queue.c | 68 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index eda872321..f22b17b03 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -29,9 +29,9 @@ #define NUM_INTERNAL_QUEUES 64 #include -#define LOCK(a) _odp_ticketlock_lock(a) -#define UNLOCK(a) _odp_ticketlock_unlock(a) -#define LOCK_INIT(a) odp_ticketlock_init(a) +#define LOCK(queue_ptr) _odp_ticketlock_lock(&((queue_ptr)->s.lock)) +#define UNLOCK(queue_ptr) _odp_ticketlock_unlock(&((queue_ptr)->s.lock)) +#define LOCK_INIT(queue_ptr) odp_ticketlock_init(&((queue_ptr)->s.lock)) #include #include @@ -88,7 +88,7 @@ static int queue_init_global(void) for (i = 0; i < ODP_CONFIG_QUEUES; i++) { /* init locks */ queue_entry_t *queue = get_qentry(i); - LOCK_INIT(&queue->s.lock); + LOCK_INIT(queue); queue->s.index = i; queue->s.handle = queue_from_index(i); } @@ -123,12 +123,12 @@ static int queue_term_global(void) for (i = 0; i < ODP_CONFIG_QUEUES; i++) { queue = &queue_tbl->queue[i]; - LOCK(&queue->s.lock); + LOCK(queue); if (queue->s.status != QUEUE_STATUS_FREE) { ODP_ERR("Not destroyed queue: %s\n", queue->s.name); rc = -1; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); } ret = odp_shm_free(odp_shm_lookup("odp_queues")); @@ -210,10 +210,10 @@ static odp_queue_t queue_create(const char *name, if (queue->s.status != QUEUE_STATUS_FREE) continue; - LOCK(&queue->s.lock); + LOCK(queue); if (queue->s.status == QUEUE_STATUS_FREE) { if (queue_init(queue, name, param)) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); return handle; } @@ -225,10 +225,10 @@ static odp_queue_t queue_create(const char *name, queue->s.status = QUEUE_STATUS_READY; handle = queue->s.handle; - UNLOCK(&queue->s.lock); + UNLOCK(queue); break; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); } if (handle != ODP_QUEUE_INVALID && type == ODP_QUEUE_TYPE_SCHED) { @@ -247,13 +247,13 @@ void sched_cb_queue_destroy_finalize(uint32_t queue_index) { queue_entry_t *queue = get_qentry(queue_index); - LOCK(&queue->s.lock); + LOCK(queue); if (queue->s.status == QUEUE_STATUS_DESTROYED) { queue->s.status = QUEUE_STATUS_FREE; sched_fn->destroy_queue(queue_index); } - UNLOCK(&queue->s.lock); + UNLOCK(queue); } static int queue_destroy(odp_queue_t handle) @@ -264,19 +264,19 @@ static int queue_destroy(odp_queue_t handle) if (handle == ODP_QUEUE_INVALID) return -1; - LOCK(&queue->s.lock); + LOCK(queue); if (queue->s.status == QUEUE_STATUS_FREE) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); ODP_ERR("queue \"%s\" already free\n", queue->s.name); return -1; } if (queue->s.status == QUEUE_STATUS_DESTROYED) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); ODP_ERR("queue \"%s\" already destroyed\n", queue->s.name); return -1; } if (ring_st_is_empty(&queue->s.ring_st) == 0) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); ODP_ERR("queue \"%s\" not empty\n", queue->s.name); return -1; } @@ -296,7 +296,7 @@ static int queue_destroy(odp_queue_t handle) default: ODP_ABORT("Unexpected queue status\n"); } - UNLOCK(&queue->s.lock); + UNLOCK(queue); return 0; } @@ -326,13 +326,13 @@ static odp_queue_t queue_lookup(const char *name) queue->s.status == QUEUE_STATUS_DESTROYED) continue; - LOCK(&queue->s.lock); + LOCK(queue); if (strcmp(name, queue->s.name) == 0) { /* found it */ - UNLOCK(&queue->s.lock); + UNLOCK(queue); return queue->s.handle; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); } return ODP_QUEUE_INVALID; @@ -376,10 +376,10 @@ static inline int enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], buffer_index_from_buf(buf_idx, buf_hdr, num); - LOCK(&queue->s.lock); + LOCK(queue); if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); ODP_ERR("Bad queue status\n"); return -1; } @@ -387,7 +387,7 @@ static inline int enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], num_enq = ring_st_enq_multi(ring_st, buf_idx, num); if (odp_unlikely(num_enq == 0)) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); return 0; } @@ -396,7 +396,7 @@ static inline int enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], sched = 1; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); /* Add queue to scheduling */ if (sched && sched_fn->sched_queue(queue->s.index)) @@ -455,12 +455,12 @@ static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], ring_st = &queue->s.ring_st; - LOCK(&queue->s.lock); + 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->s.lock); + UNLOCK(queue); return -1; } @@ -475,7 +475,7 @@ static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], sched_fn->unsched_queue(queue->s.index); } - UNLOCK(&queue->s.lock); + UNLOCK(queue); return 0; } @@ -483,7 +483,7 @@ static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], if (status_sync && queue->s.type == ODP_QUEUE_TYPE_SCHED) sched_fn->save_context(queue->s.index); - UNLOCK(&queue->s.lock); + UNLOCK(queue); buffer_index_to_buf(buf_hdr, buf_idx, num_deq); @@ -596,12 +596,12 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) queue = get_qentry(queue_id); - LOCK(&queue->s.lock); + LOCK(queue); status = queue->s.status; if (odp_unlikely(status == QUEUE_STATUS_FREE || status == QUEUE_STATUS_DESTROYED)) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); ODP_ERR("Invalid queue status:%d\n", status); return -1; } @@ -609,7 +609,7 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) info->name = queue->s.name; info->param = queue->s.param; - UNLOCK(&queue->s.lock); + UNLOCK(queue); return 0; } @@ -626,11 +626,11 @@ int sched_cb_queue_empty(uint32_t queue_index) queue_entry_t *queue = get_qentry(queue_index); int ret = 0; - LOCK(&queue->s.lock); + LOCK(queue); if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { /* Bad queue, or queue has been destroyed. */ - UNLOCK(&queue->s.lock); + UNLOCK(queue); return -1; } @@ -642,7 +642,7 @@ int sched_cb_queue_empty(uint32_t queue_index) ret = 1; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); return ret; }