From patchwork Tue Sep 11 14:00:11 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: 146454 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3677593ljw; Tue, 11 Sep 2018 07:03:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZOpl61+6DN/Mg6Gf7Lul+SweCH9YsBZkUAEsU64h/rUuORYjH+IXO9XdZWvknDaht765m X-Received: by 2002:ac8:1b5b:: with SMTP id p27-v6mr19390988qtk.99.1536674601327; Tue, 11 Sep 2018 07:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536674601; cv=none; d=google.com; s=arc-20160816; b=LXW8bHzx4Vcb7f9qKkiayCdLLNNX1rj1Tx34vsafxk6x6C42Ijj2kH28WVaOnIuIHN 5ab4n2AHwdw56h1PMc0t8PtvH6uEzcAHLNVehLej+2PD1jeqwKI7u0/bttNSul8i8Vu6 bMhrzdtUFQ3/7E7Ta+wAokvHrroJfALZU2l4OY0C+RXhtRqXe7y6LsD7WU8vzddrTgBK 4FX7QI7bQ5ar7WzRX4kmEGGQPqv+WwWwIEg+AYCX7C3GRAYNKgUBYr4CEs89OhjG+DV/ 4LhaHuKg1D5WFa4+i+lIxzgotbndo9fITrHHwxNBrKXfWxTVzByoAhHH3tlhIktqpJyq 5H6Q== 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; bh=QaTxxBD2E3U2D0puVhdLE9rAfff0Rydffm59g1dqGNo=; b=H0WsqvLtUV4KvR7NZg8ZqhYAwjTBfM70z71P7K/lKFtk65q76Tj/yaEe5oUdE28RDS K2NCFQ5tHMzdnWhXygvmeVXSDVSFAVskdnaBD4s02JtSd9ZjBNAw0Ox9UP0kRMf/j3/T ZqWCrLLhLV8HLNb2EBDzysXDAf1yuDcgeQ1E6ur1FPTWRkImfUeiJLeGcBz6t2yev3I6 8LC5CAAu2oM0h90m6eDwhCxGSlf7xjgLTtoUVhnRt5dov71+k5vF+CZKqTe9cCx1ydgf TOpeFRaR8Qg+LwOQnLrH1yCFYDsdk4iVE1hXQwFzvPr9CfLrMwO/z5JsYkgI+3ZIvSmt Yj7A== 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 i19-v6si205628qvc.125.2018.09.11.07.03.18; Tue, 11 Sep 2018 07:03:21 -0700 (PDT) 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 08D6861C52; Tue, 11 Sep 2018 14:03:18 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, 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 4357561C0D; Tue, 11 Sep 2018 14:01:54 +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 3733661C13; Tue, 11 Sep 2018 14:01:48 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 2C48F61C20 for ; Tue, 11 Sep 2018 14:00:28 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 4727856063D6 for ; Tue, 11 Sep 2018 17:00:22 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ZIAFwPzxPu-0MsSaCNm; Tue, 11 Sep 2018 17:00:22 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mBghUNGHde-0IS4tYw9; Tue, 11 Sep 2018 17:00:18 +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: Tue, 11 Sep 2018 14:00:11 +0000 Message-Id: <1536674416-8465-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536674416-8465-1-git-send-email-odpbot@yandex.ru> References: <1536674416-8465-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 699 Subject: [lng-odp] [PATCH v1 1/6] linux-gen: queue: remove extra checks 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 Remove unnecessary checks from critical sections of scheduled queue enqueue and dequeue operations. Parallelism improves when the number of instructions and (potential) cache misses decreases when holding the lock. Signed-off-by: Petri Savolainen --- /** Email created from pull request 699 (psavol:master-sched-optim-clean-ups) ** https://github.com/Linaro/odp/pull/699 ** Patch: https://github.com/Linaro/odp/pull/699.patch ** Base sha: 33fbc04b6373960ec3f84de4e7e7b34c49d71508 ** Merge commit sha: 32d7a11f22e6f2e1e378b653993c5377d4116d8f **/ platform/linux-generic/odp_queue_basic.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 7e8b7e34d..61cf8a56c 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -681,12 +681,6 @@ static inline int _sched_queue_enq_multi(odp_queue_t handle, LOCK(queue); - if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { - UNLOCK(queue); - ODP_ERR("Bad queue status\n"); - return -1; - } - num_enq = ring_st_enq_multi(ring_st, queue->s.ring_data, queue->s.ring_mask, buf_idx, num); @@ -712,7 +706,7 @@ static inline int _sched_queue_enq_multi(odp_queue_t handle, int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, int update_status) { - int num_deq; + int num_deq, status; ring_st_t *ring_st; queue_entry_t *queue = qentry_from_index(queue_index); int status_sync = sched_fn->status_sync; @@ -722,7 +716,9 @@ int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, LOCK(queue); - if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { + status = queue->s.status; + + if (odp_unlikely(status < QUEUE_STATUS_READY)) { /* Bad queue, or queue has been destroyed. * Scheduler finalizes queue destroy after this. */ UNLOCK(queue); @@ -734,10 +730,10 @@ int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, if (num_deq == 0) { /* Already empty queue */ - if (update_status && queue->s.status == QUEUE_STATUS_SCHED) { + if (update_status && status == QUEUE_STATUS_SCHED) { queue->s.status = QUEUE_STATUS_NOTSCHED; - if (status_sync) + if (odp_unlikely(status_sync)) sched_fn->unsched_queue(queue->s.index); } @@ -746,7 +742,7 @@ int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, return 0; } - if (status_sync && queue->s.type == ODP_QUEUE_TYPE_SCHED) + if (odp_unlikely(status_sync)) sched_fn->save_context(queue->s.index); UNLOCK(queue);