From patchwork Fri Aug 24 14: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: 145068 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1303603ljw; Fri, 24 Aug 2018 07:01:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYwEWJyD5rsYQCcxuaMJgDIUur3l78Zxf1mZrBTQXtT/G8biWMuuUYl7n/ydeLZf8VyO5PV X-Received: by 2002:ac8:611c:: with SMTP id a28-v6mr1857735qtm.130.1535119290801; Fri, 24 Aug 2018 07:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535119290; cv=none; d=google.com; s=arc-20160816; b=o2TOUw0cnDFnyQfs3FWLsH4JdNehtnnz+0AL2KQjQm4+OCnq8yDcaKYq3P2wX9O5ag C22jNNijfrUmI6Lxj0z4HC536J1LISRZemFUr1tIwgQSkqONSF3HL6STHLCE30qQGLlL 5gc65O3Nhu2+TYS4pd13Bi2if9YAocEnCWx1lqnqbcmnoydfQbmVYXSSb3kc9Kk6e38s Xl4I5Z8P3Siyo1hv1GXfAQ+qeC+nNi6ObpJPQ9dnLyruMr7/yAYAAmxsngOeilEXWpow VoJAyW3lMgDmLeMXS38KVCv/KG588RgP+IaeQys1bVRDB8d0SEk6IjIFD79hmL0qRWU4 LXTw== 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=mGilxw4b6WOpj2LyrNCgX0Hldl7PC8VY5ENdSElOq+g=; b=B32DjHS/2SjX04YHzetg9TPnnPcZ7HX1KuqpRj0nBpDGK8d8OZ+BBfMEayaMRZ2+ZH MYbA50rUgri3C1Zc8C9FrShiESSqIhLymxu4ZjdXRfVXEroapmPSRqF5PHdwjrNXz9BA AqLCXG8ytLpZjrsEJqooLHQOiqVECLsTOFgDcSNxAjR7k55WAvPfWFACbUwCik5J5r2t O/BeJ6u078cDrvL4dDL4I/881u7QenqCJQcRi+I5vpySO4DMH6JluUInLOw8dbTbXX0w acs4iB6IxqxJqb/8lvQ/p0lwVjUufaYWZ8usvXmD1pYfVW6lC9Gn5XIuU2x648OMyj7M 7YAg== 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 r7-v6si2024666qvm.102.2018.08.24.07.01.30; Fri, 24 Aug 2018 07:01:30 -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 6056660F00; Fri, 24 Aug 2018 14:01:30 +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 AF76260833; Fri, 24 Aug 2018 14:00:25 +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 7C42D607C8; Fri, 24 Aug 2018 14:00:16 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 1131C60800 for ; Fri, 24 Aug 2018 14:00:12 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward100p.mail.yandex.net (Yandex) with ESMTP id C62D6510519D for ; Fri, 24 Aug 2018 17:00:10 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id pGIWWdcLVi-0AG4V3vX; Fri, 24 Aug 2018 17:00:10 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2CVvDjLgK3-0AjGME75; Fri, 24 Aug 2018 17:00:10 +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: Fri, 24 Aug 2018 14:00:05 +0000 Message-Id: <1535119206-23556-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535119206-23556-1-git-send-email-odpbot@yandex.ru> References: <1535119206-23556-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 683 Subject: [lng-odp] [PATCH v1 3/4] linux-gen: ring_st: move ring mask and data pointer 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 Store mask and data pointer in queue entry instead of ring structure. Data is constant and can be stored among other frequently used read only data. Also other ring type use the same variables. Signed-off-by: Petri Savolainen --- /** Email created from pull request 683 (psavol:master-queue-lockless-enqdeq-3) ** https://github.com/Linaro/odp/pull/683 ** Patch: https://github.com/Linaro/odp/pull/683.patch ** Base sha: 989df5d2f97ab4711328b11282dcc743f5740e00 ** Merge commit sha: 28073c54671148efdd01c9cf38c1a235d5a133f0 **/ .../include/odp_ring_st_internal.h | 34 ++++++++----------- platform/linux-generic/odp_queue_basic.c | 12 ++++--- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/platform/linux-generic/include/odp_ring_st_internal.h b/platform/linux-generic/include/odp_ring_st_internal.h index 5fb37d4ef..1bc18cda0 100644 --- a/platform/linux-generic/include/odp_ring_st_internal.h +++ b/platform/linux-generic/include/odp_ring_st_internal.h @@ -19,30 +19,25 @@ extern "C" { typedef struct { uint32_t head; uint32_t tail; - uint32_t mask; - uint32_t *data; - } ring_st_t; /* Initialize ring. Ring size must be a power of two. */ -static inline void ring_st_init(ring_st_t *ring, uint32_t *data, uint32_t size) +static inline void ring_st_init(ring_st_t *ring) { ring->head = 0; ring->tail = 0; - ring->mask = size - 1; - ring->data = data; } /* Dequeue data from the ring head. Max_num is smaller than ring size.*/ -static inline uint32_t ring_st_deq_multi(ring_st_t *ring, uint32_t data[], +static inline uint32_t ring_st_deq_multi(ring_st_t *ring, uint32_t *ring_data, + uint32_t ring_mask, uint32_t data[], uint32_t max_num) { - uint32_t head, tail, mask, idx; + uint32_t head, tail, idx; uint32_t num, i; head = ring->head; tail = ring->tail; - mask = ring->mask; num = tail - head; /* Empty */ @@ -52,11 +47,11 @@ static inline uint32_t ring_st_deq_multi(ring_st_t *ring, uint32_t data[], if (num > max_num) num = max_num; - idx = head & mask; + idx = head & ring_mask; for (i = 0; i < num; i++) { - data[i] = ring->data[idx]; - idx = (idx + 1) & mask; + data[i] = ring_data[idx]; + idx = (idx + 1) & ring_mask; } ring->head = head + num; @@ -65,16 +60,17 @@ static inline uint32_t ring_st_deq_multi(ring_st_t *ring, uint32_t data[], } /* Enqueue data into the ring tail. Num_data is smaller than ring size. */ -static inline uint32_t ring_st_enq_multi(ring_st_t *ring, const uint32_t data[], +static inline uint32_t ring_st_enq_multi(ring_st_t *ring, uint32_t *ring_data, + uint32_t ring_mask, + const uint32_t data[], uint32_t num_data) { - uint32_t head, tail, mask, size, idx; + uint32_t head, tail, size, idx; uint32_t num, i; head = ring->head; tail = ring->tail; - mask = ring->mask; - size = mask + 1; + size = ring_mask + 1; num = size - (tail - head); /* Full */ @@ -84,11 +80,11 @@ static inline uint32_t ring_st_enq_multi(ring_st_t *ring, const uint32_t data[], if (num > num_data) num = num_data; - idx = tail & mask; + idx = tail & ring_mask; for (i = 0; i < num; i++) { - ring->data[idx] = data[i]; - idx = (idx + 1) & mask; + ring_data[idx] = data[i]; + idx = (idx + 1) & ring_mask; } ring->tail = tail + num; diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 8b9a70bbc..7e8b7e34d 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -687,7 +687,8 @@ static inline int _sched_queue_enq_multi(odp_queue_t handle, return -1; } - num_enq = ring_st_enq_multi(ring_st, buf_idx, num); + num_enq = ring_st_enq_multi(ring_st, queue->s.ring_data, + queue->s.ring_mask, buf_idx, num); if (odp_unlikely(num_enq == 0)) { UNLOCK(queue); @@ -728,7 +729,8 @@ int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, return -1; } - num_deq = ring_st_deq_multi(ring_st, buf_idx, max_num); + num_deq = ring_st_deq_multi(ring_st, queue->s.ring_data, + queue->s.ring_mask, buf_idx, max_num); if (num_deq == 0) { /* Already empty queue */ @@ -875,8 +877,10 @@ static int queue_init(queue_entry_t *queue, const char *name, } else { queue->s.enqueue = sched_queue_enq; queue->s.enqueue_multi = sched_queue_enq_multi; - ring_st_init(&queue->s.ring_st, - &queue_glb->ring_data[offset], queue_size); + + queue->s.ring_data = &queue_glb->ring_data[offset]; + queue->s.ring_mask = queue_size - 1; + ring_st_init(&queue->s.ring_st); } }