From patchwork Tue Apr 4 18:47:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Brooks X-Patchwork-Id: 96757 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp362056obc; Tue, 4 Apr 2017 11:51:11 -0700 (PDT) X-Received: by 10.200.37.13 with SMTP id 13mr24161854qtm.209.1491331871145; Tue, 04 Apr 2017 11:51:11 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g22si8042574qkh.266.2017.04.04.11.51.10; Tue, 04 Apr 2017 11:51:11 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 43279609C3; Tue, 4 Apr 2017 18:50:49 +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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, URIBL_BLOCKED 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 24FD663FF4; Tue, 4 Apr 2017 18:48:47 +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 B688163FEB; Tue, 4 Apr 2017 18:48:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by lists.linaro.org (Postfix) with ESMTP id 256FA63FE8 for ; Tue, 4 Apr 2017 18:48:29 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7C9E1597; Tue, 4 Apr 2017 11:48:28 -0700 (PDT) Received: from localhost.localdomain (unknown [10.119.48.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8CD983F4FF; Tue, 4 Apr 2017 11:48:28 -0700 (PDT) From: Brian Brooks To: lng-odp@lists.linaro.org Date: Tue, 4 Apr 2017 13:47:54 -0500 Message-Id: <20170404184808.59470-3-brian.brooks@arm.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170404184808.59470-1-brian.brooks@arm.com> References: <20170404184808.59470-1-brian.brooks@arm.com> Cc: Ola Liljedahl Subject: [lng-odp] [API-NEXT PATCH v2 02/16] linux-generic: ring.c: use required memory orderings 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: Ola Liljedahl Signed-off-by: Ola Liljedahl Reviewed-by: Brian Brooks --- platform/linux-generic/pktio/ring.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.12.2 diff --git a/platform/linux-generic/pktio/ring.c b/platform/linux-generic/pktio/ring.c index aeda04b2..e3c73d1c 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -263,8 +263,8 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, /* Reset n to the initial burst count */ n = max; - prod_head = r->prod.head; - cons_tail = r->cons.tail; + prod_head = __atomic_load_n(&r->prod.head, __ATOMIC_RELAXED); + cons_tail = __atomic_load_n(&r->cons.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have * prod_head > cons_tail). So 'free_entries' is always between 0 @@ -306,12 +306,12 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, * If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ - while (odp_unlikely(r->prod.tail != prod_head)) + while (odp_unlikely(__atomic_load_n(&r->prod.tail, __ATOMIC_RELAXED) != + prod_head)) odp_cpu_pause(); /* Release our entries and the memory they refer to */ - __atomic_thread_fence(__ATOMIC_RELEASE); - r->prod.tail = prod_next; + __atomic_store_n(&r->prod.tail, prod_next, __ATOMIC_RELEASE); return ret; } @@ -328,7 +328,7 @@ int ___ring_sp_do_enqueue(_ring_t *r, void * const *obj_table, int ret; prod_head = r->prod.head; - cons_tail = r->cons.tail; + cons_tail = __atomic_load_n(&r->cons.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have * prod_head > cons_tail). So 'free_entries' is always between 0 @@ -361,8 +361,7 @@ int ___ring_sp_do_enqueue(_ring_t *r, void * const *obj_table, } /* Release our entries and the memory they refer to */ - __atomic_thread_fence(__ATOMIC_RELEASE); - r->prod.tail = prod_next; + __atomic_store_n(&r->prod.tail, prod_next, __ATOMIC_RELEASE); return ret; } @@ -385,8 +384,8 @@ int ___ring_mc_do_dequeue(_ring_t *r, void **obj_table, /* Restore n as it may change every loop */ n = max; - cons_head = r->cons.head; - prod_tail = r->prod.tail; + cons_head = __atomic_load_n(&r->cons.head, __ATOMIC_RELAXED); + prod_tail = __atomic_load_n(&r->prod.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have * cons_head > prod_tail). So 'entries' is always between 0 @@ -419,12 +418,12 @@ int ___ring_mc_do_dequeue(_ring_t *r, void **obj_table, * If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ - while (odp_unlikely(r->cons.tail != cons_head)) + while (odp_unlikely(__atomic_load_n(&r->cons.tail, __ATOMIC_RELAXED) != + cons_head)) odp_cpu_pause(); /* Release our entries and the memory they refer to */ - __atomic_thread_fence(__ATOMIC_RELEASE); - r->cons.tail = cons_next; + __atomic_store_n(&r->cons.tail, cons_next, __ATOMIC_RELEASE); return behavior == _RING_QUEUE_FIXED ? 0 : n; } @@ -441,7 +440,7 @@ int ___ring_sc_do_dequeue(_ring_t *r, void **obj_table, uint32_t mask = r->prod.mask; cons_head = r->cons.head; - prod_tail = r->prod.tail; + prod_tail = __atomic_load_n(&r->prod.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have * cons_head > prod_tail). So 'entries' is always between 0 @@ -461,11 +460,10 @@ int ___ring_sc_do_dequeue(_ring_t *r, void **obj_table, r->cons.head = cons_next; /* Acquire the pointers and the memory they refer to */ - __atomic_thread_fence(__ATOMIC_ACQUIRE); /* copy in table */ DEQUEUE_PTRS(); - r->cons.tail = cons_next; + __atomic_store_n(&r->cons.tail, cons_next, __ATOMIC_RELEASE); return behavior == _RING_QUEUE_FIXED ? 0 : n; } From patchwork Tue Apr 4 18:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Brooks X-Patchwork-Id: 96756 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp361769obc; Tue, 4 Apr 2017 11:50:16 -0700 (PDT) X-Received: by 10.55.41.218 with SMTP id p87mr19311594qkp.110.1491331816086; Tue, 04 Apr 2017 11:50:16 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t21si15784600qta.36.2017.04.04.11.50.15; Tue, 04 Apr 2017 11:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B776963FE9; Tue, 4 Apr 2017 18:50:15 +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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, URIBL_BLOCKED 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 D552363FF7; Tue, 4 Apr 2017 18:48:44 +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 9109863FF0; Tue, 4 Apr 2017 18:48:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by lists.linaro.org (Postfix) with ESMTP id E5D8963FEA for ; Tue, 4 Apr 2017 18:48:29 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E40015BF; Tue, 4 Apr 2017 11:48:29 -0700 (PDT) Received: from localhost.localdomain (unknown [10.119.48.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 631123F4FF; Tue, 4 Apr 2017 11:48:29 -0700 (PDT) From: Brian Brooks To: lng-odp@lists.linaro.org Date: Tue, 4 Apr 2017 13:47:56 -0500 Message-Id: <20170404184808.59470-5-brian.brooks@arm.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170404184808.59470-1-brian.brooks@arm.com> References: <20170404184808.59470-1-brian.brooks@arm.com> Cc: Ola Liljedahl Subject: [lng-odp] [API-NEXT PATCH v2 04/16] helper: cuckootable: Specify queue ring_size 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: Ola Liljedahl The cuckoo code may enqueue a million events onto a queue. When queues are implemented as bounded buffers, a default queue size can be used during queue create, otherwise this information needs to be passed down from the application. The reverse information flow, default queue size passed up to the application via capabilities, currently has no known use case. Signed-off-by: Ola Liljedahl Reviewed-by: Brian Brooks Reviewed-by: Honnappa Nagarahalli --- helper/cuckootable.c | 1 + 1 file changed, 1 insertion(+) -- 2.12.2 diff --git a/helper/cuckootable.c b/helper/cuckootable.c index 80ff4989..d3d1563c 100644 --- a/helper/cuckootable.c +++ b/helper/cuckootable.c @@ -256,6 +256,7 @@ odph_cuckoo_table_create( /* initialize free_slots queue */ odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_PLAIN; + qparam.ring_size = capacity; snprintf(queue_name, sizeof(queue_name), "fs_%s", name); queue = odp_queue_create(queue_name, &qparam);