From patchwork Wed Feb 21 12:00:05 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: 129047 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp547587ljc; Wed, 21 Feb 2018 04:08:57 -0800 (PST) X-Google-Smtp-Source: AG47ELsKR5QeHbxFFB8RUWKIaFCplx1cj2s7FMp8L3Ztj3cagYbSMOmTV/muyAYpxKw34+WwsD5W X-Received: by 10.55.197.79 with SMTP id p76mr4603758qki.337.1519214937247; Wed, 21 Feb 2018 04:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519214937; cv=none; d=google.com; s=arc-20160816; b=XcnCM7tLupUqZABNnAcokzwBaNvlLTU/K3Q4PcX0TejH9fpsYUg09POKo50GFCo2s6 Ej9MK0qxCp5OZlErXpMkjC+drfqgavQbJtq9InVUfif2NEvDm9b4DuRutm32BU2bF6/N exnMLQ62kqCtWcN6NaQTWEglB8TQlQ64afXZOqR1QbTZbOf4HsBWfVtTA2YaRjzdccdT qGbi1xfZwzXR2biNxyDUpKOyrxIALaaIJEs/sLfavVP+H2znXJePRfergj6Xl6ItfKgQ fCM57o5NzE0pzO+T4m8wrf7ydIDwTY/g7XEanvZRZqdIFkmQTl6TJMqhx2k6Qdmb/mTR vhxQ== 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=xoilQgV0Ol0LTBaxzA4hakeixDP9lNuHMqxgMhzUOWo=; b=GTUIAkHVYfWoLCg9VF1VZvwgkAip1ciVVEocFJo/drGJzk9mh4BEckgu0Y0MUj0W8k /W8o+nBzcHbyaqAPJd2o0xEabnGDqxy+XaDjyzK3TYyR5Q/BR1BfVoxQLflWvtpl0RaY c6vaHxsPsOLW3yiHc0r/TSrPCk7DIqGRUzy3wfCyQXK18TBB5T+YHYP/Qp0QhmGWrUcY oEbwhh4Z/1BDZDq8kKJQZZZid3BSreae5VeI0qnL9oyVyrL5wwOYmIDDDJ5DGbRVeSV/ szpC5xRE5KngWefh95Jea/YYDbt4dergAP8fNDDUqXfbC2DVn6C0u4Bey4sK1b07WRAE t2hw== 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 a44si4104183qtb.8.2018.02.21.04.08.56; Wed, 21 Feb 2018 04:08:57 -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 DD8BD61747; Wed, 21 Feb 2018 12:08:56 +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, RCVD_IN_MSPIKE_H2 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 E7DBC6174E; Wed, 21 Feb 2018 12:02:30 +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 DF1986150D; Wed, 21 Feb 2018 12:02:01 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id 206516071D for ; Wed, 21 Feb 2018 12:00:30 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 848075D82DAF for ; Wed, 21 Feb 2018 15:00:15 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DcmTtguzaS-0FwKcJRF; Wed, 21 Feb 2018 15:00:15 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id a6UlmCoovI-0FvaGaQA; Wed, 21 Feb 2018 15:00:15 +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: Wed, 21 Feb 2018 15:00:05 +0300 Message-Id: <1519214407-28047-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519214407-28047-1-git-send-email-odpbot@yandex.ru> References: <1519214407-28047-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 492 Subject: [lng-odp] [PATCH v1 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: 82a6bfe942419330a430b63149220e6b472f419c **/ 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; }