From patchwork Mon Nov 24 22:38:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 41436 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 712A825E18 for ; Mon, 24 Nov 2014 22:39:23 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf2589645wid.7 for ; Mon, 24 Nov 2014 14:39:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Y8PxEhh9zL1+HGB2fjL9kz5dsMUvCSdgazlfFe+gsyc=; b=Hepz3taNPZyIHUCP4UXRxd+AIghFeTriI+qJ/7FNObdNZGT9+3qTriWxYi2Ao6Pvrm PfUaJfE+gQ/iqbqI3NZvaa/C26/SOdj7gviWduqzqugyT+SuyiKia0ubMzQ0DLEDc3XE 6ZVZ+3I1OuwZWzDtHBJjBE2wnv8zaI/bvUX2t+lJztVxJIJ8F8dAacRzVYQzHIFxrNhN VH6n9v68wxtjpoj1js5uabyeTvvDs4XO3UiTqPxs0E1Lu6XeQLooYylyWhmGIw9O6BZd ROI6fs+QOKaesgdDQ/CtVZHW93v4vTzDr9n5mEErNNCTKMEUatBwBCdK9l2G7L9d8MTR bbjw== X-Gm-Message-State: ALoCoQnXoJ27UMp/9BgyB7NTeZ/aSfPFW6uu6EniTmSlTTo2xercjLVIzoQWwd5K36dZbZg3w3rM X-Received: by 10.180.98.165 with SMTP id ej5mr6200822wib.1.1416868762771; Mon, 24 Nov 2014 14:39:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.170 with SMTP id s10ls94207laa.58.gmail; Mon, 24 Nov 2014 14:39:22 -0800 (PST) X-Received: by 10.112.166.67 with SMTP id ze3mr21741630lbb.99.1416868762348; Mon, 24 Nov 2014 14:39:22 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id p7si16517478lae.87.2014.11.24.14.39.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 14:39:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so8440941lam.2 for ; Mon, 24 Nov 2014 14:39:22 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr22363806lbr.74.1416868762074; Mon, 24 Nov 2014 14:39:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp348157lbc; Mon, 24 Nov 2014 14:39:21 -0800 (PST) X-Received: by 10.52.243.41 with SMTP id wv9mr11412231vdc.20.1416868760489; Mon, 24 Nov 2014 14:39:20 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id fx10si6929763vdc.58.2014.11.24.14.39.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Nov 2014 14:39:20 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xt2Hu-0007oz-3d; Mon, 24 Nov 2014 22:39:18 +0000 Received: from mail-lb0-f173.google.com ([209.85.217.173]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xt2Hg-0007ly-R2 for lng-odp@lists.linaro.org; Mon, 24 Nov 2014 22:39:04 +0000 Received: by mail-lb0-f173.google.com with SMTP id z12so5380016lbi.18 for ; Mon, 24 Nov 2014 14:38:59 -0800 (PST) X-Received: by 10.112.150.71 with SMTP id ug7mr22876379lbb.73.1416868739044; Mon, 24 Nov 2014 14:38:59 -0800 (PST) Received: from macmini.lan (84-217-193-77.tn.glocalnet.net. [84.217.193.77]) by mx.google.com with ESMTPSA id pr9sm2952957lbc.12.2014.11.24.14.38.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Nov 2014 14:38:58 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 24 Nov 2014 23:38:42 +0100 Message-Id: <1416868730-26140-2-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416868730-26140-1-git-send-email-ola.liljedahl@linaro.org> References: <1416868730-26140-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 1/9] linux-generic: odp_ring.c use __atomic X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ola Liljedahl --- Added missing release barriers. Updated to use GCC __atomic cmpset facility (temporary fix). platform/linux-generic/odp_ring.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_ring.c b/platform/linux-generic/odp_ring.c index 632aa66..1d3130a 100644 --- a/platform/linux-generic/odp_ring.c +++ b/platform/linux-generic/odp_ring.c @@ -259,13 +259,16 @@ int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, } prod_next = prod_head + n; - success = odp_atomic_cmpset_u32(&r->prod.head, prod_head, - prod_next); + success = __atomic_compare_exchange_n(&r->prod.head, + &prod_head, + prod_next, + false/*strong*/, + __ATOMIC_ACQUIRE, + __ATOMIC_RELAXED); } while (odp_unlikely(success == 0)); /* write entries in ring */ ENQUEUE_PTRS(); - odp_mem_barrier(); /* if we exceed the watermark */ if (odp_unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) { @@ -282,6 +285,8 @@ int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, while (odp_unlikely(r->prod.tail != prod_head)) odp_spin(); + /* Release our entries and the memory they refer to */ + __atomic_thread_fence(__ATOMIC_RELEASE); r->prod.tail = prod_next; return ret; } @@ -324,7 +329,6 @@ int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, /* write entries in ring */ ENQUEUE_PTRS(); - odp_mem_barrier(); /* if we exceed the watermark */ if (odp_unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) { @@ -334,6 +338,8 @@ int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, ret = (behavior == ODPH_RING_QUEUE_FIXED) ? 0 : n; } + /* Release our entries and the memory they refer to */ + __atomic_thread_fence(__ATOMIC_RELEASE); r->prod.tail = prod_next; return ret; } @@ -378,13 +384,16 @@ int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, } cons_next = cons_head + n; - success = odp_atomic_cmpset_u32(&r->cons.head, cons_head, - cons_next); + success = __atomic_compare_exchange_n(&r->cons.head, + &cons_head, + cons_next, + false/*strong*/, + __ATOMIC_ACQUIRE, + __ATOMIC_RELAXED); } while (odp_unlikely(success == 0)); /* copy in table */ DEQUEUE_PTRS(); - odp_mem_barrier(); /* * If there are other dequeues in progress that preceded us, @@ -393,6 +402,8 @@ int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, while (odp_unlikely(r->cons.tail != cons_head)) odp_spin(); + /* Release our entries and the memory they refer to */ + __atomic_thread_fence(__ATOMIC_RELEASE); r->cons.tail = cons_next; return behavior == ODPH_RING_QUEUE_FIXED ? 0 : n; @@ -431,9 +442,10 @@ int __odph_ring_sc_do_dequeue(odph_ring_t *r, void **obj_table, cons_next = cons_head + n; r->cons.head = cons_next; + /* Acquire the pointers and the memory they refer to */ + __atomic_thread_fence(__ATOMIC_ACQUIRE); /* copy in table */ DEQUEUE_PTRS(); - odp_mem_barrier(); r->cons.tail = cons_next; return behavior == ODPH_RING_QUEUE_FIXED ? 0 : n;