From patchwork Wed Feb 28 12:00:16 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: 129976 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp950745lja; Wed, 28 Feb 2018 04:12:53 -0800 (PST) X-Google-Smtp-Source: AG47ELvvCIu0ciyhKJerSeIUUSYQ8YLzt0xARJgJkvAcxQ7/+CI+iL5jatPAv2+AYeq1+QMAsv/V X-Received: by 10.200.18.67 with SMTP id g3mr29646149qtj.82.1519819973758; Wed, 28 Feb 2018 04:12:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519819973; cv=none; d=google.com; s=arc-20160816; b=YJpJWxAkpHOvZbZj4RQXXOoD3d0CfrCddIl7GyVFnusbiYySj1am16qAsRjPMr/azL QEllu3twWmll7hzME6ouibxt0qiDocLVMOirLwJ4hmBBlhY951pVSBSMzrCzHe2jrZuF EoYZtIFW3kUgU2nC4TK1JTdN2txobhWYzLa5QKHTLZUx8AzxQvu+jl2beMf6Q3jmBK+B x1YD6dKDwmcJD8W2vE3F7VPM4pattwg/UajED+E957e6TxI6TsIIZp5xqhGrkb10Y8eU KohF21yuOtRWUdVZX2iv2ke7HcSH7IStgsmMh62uKBj1Rz2hk5fQe43IxKxmrLnIDqka ZxwQ== 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=jCS/Z/lS5go4DOcBUP/z/wbKo9uVn8AklS/6qyMOnN0=; b=oZDRy43lVnQXjom3j28PoMVCuZlnQKVGK72TUBeEmIrI1Do9VNIceZnwTxvl4uhpg5 u2pN2g44FcTpuQlVqiR9Xmol40Hqpv91qfYpbrBN/4RcBrkUgGJ69xVRgSRHjzbDGSGv BY4O/SgRocBejBgNVqOC7RM68acNV+WEG7nMdaDe2XFwmXf6I4OVLRhPiofBed97WIuq joauiOHt4+6JPGV9+WU855s7lKtI7K/rUaPpt7bVe63wa4YWAf/zBFDl5F462Y+yZlHE v2Xg5kV1o9prdJVlTMOfHeHU9b0p9WXoEJy3D4bj7ipCUwVKmMZvsf2GR8rrrr6K3RY0 uiSw== 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 w190si1580124qkc.446.2018.02.28.04.12.53; Wed, 28 Feb 2018 04:12:53 -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 6F181616F5; Wed, 28 Feb 2018 12:12:53 +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 1D365617B1; Wed, 28 Feb 2018 12:04:24 +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 D7E3261737; Wed, 28 Feb 2018 12:04:09 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 637996176D for ; Wed, 28 Feb 2018 12:01:56 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 994AC58876C7 for ; Wed, 28 Feb 2018 15:00:27 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fEIWugcLCd-0R6WglcY; Wed, 28 Feb 2018 15:00:27 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id iE1m40jcci-0QS4Y2MN; Wed, 28 Feb 2018 15:00:26 +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, 28 Feb 2018 15:00:16 +0300 Message-Id: <1519819218-27901-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519819218-27901-1-git-send-email-odpbot@yandex.ru> References: <1519819218-27901-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 492 Subject: [lng-odp] [PATCH v3 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: f5e12df388352b27f09787028a0040afb28564f4 ** Merge commit sha: 56e6340663c8679516a24dc81df13a53488b86b8 **/ platform/linux-generic/odp_queue_basic.c | 70 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 9e99994da..e4f6fd820 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -30,9 +30,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 @@ -91,7 +91,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); } @@ -130,12 +130,12 @@ static int queue_term_global(void) for (i = 0; i < ODP_CONFIG_QUEUES; i++) { queue = &queue_glb->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); } queue_lf_term_global(); @@ -231,10 +231,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 ODP_QUEUE_INVALID; } @@ -246,7 +246,7 @@ static odp_queue_t queue_create(const char *name, queue_lf = queue_lf_create(queue); if (queue_lf == NULL) { - UNLOCK(&queue->s.lock); + UNLOCK(queue); return ODP_QUEUE_INVALID; } queue->s.queue_lf = queue_lf; @@ -265,10 +265,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) @@ -290,13 +290,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) @@ -307,19 +307,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; } @@ -343,7 +343,7 @@ static int queue_destroy(odp_queue_t handle) if (queue->s.param.nonblocking == ODP_NONBLOCKING_LF) queue_lf_destroy(queue->s.queue_lf); - UNLOCK(&queue->s.lock); + UNLOCK(queue); return 0; } @@ -373,13 +373,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; @@ -423,10 +423,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; } @@ -434,7 +434,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; } @@ -443,7 +443,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)) @@ -502,12 +502,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; } @@ -522,7 +522,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; } @@ -530,7 +530,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); @@ -643,12 +643,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; } @@ -656,7 +656,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; } @@ -673,11 +673,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; } @@ -689,7 +689,7 @@ int sched_cb_queue_empty(uint32_t queue_index) ret = 1; } - UNLOCK(&queue->s.lock); + UNLOCK(queue); return ret; }