From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F93DA32A1 for ; Thu, 24 Oct 2019 10:36:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 762391E543; Thu, 24 Oct 2019 10:36:09 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id AE8C71E543 for ; Thu, 24 Oct 2019 10:36:07 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id v9so13763422wrq.5 for ; Thu, 24 Oct 2019 01:36:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-transfer-encoding:user-agent:mime-version; bh=zUhmAIGG/m1+vbMSDs6s7PDCVpgept++KAQAWg7812M=; b=mm9eJR+qbdHUWqhXxYhQ5/8XRBX1Yrpih9S15538qIwA7HkyJeZzjdz2w4T2dgVkrh daRnupgBufj+VGsaC2uD9p7iQWgQALxMfREEh9+d1653iH2JkM7efyGqeehS2pL7LwOA qvr22nJdEW7n0MnujPrwGXnj86OwawyRyItxpeaq4vZzx/IGdeobxiwpXo+ULHK2wbXV fUKfbO++44SK4RRXkFHVbtjCgP+gTnb1fQjbFKF6uWHmcvC4yc5I0eV6m88MXk1l4AuK fSntvB0ZDOx/7TGDiSuKODDK5fkNAAh12kCUnb7xxG+SwvB8/8pYjcwcZ+Y1HLm0qpvA yF3g== X-Gm-Message-State: APjAAAXbftoVME8bbaXmznKfyxUwOSMR6a2ripDDHnUw96CPul/NarTw XQKF3qte/hObGSAgKT1Roc8= X-Google-Smtp-Source: APXvYqzbDWuikKMXr8QdmEkhMj7SHhN6YvcHMstwYAemm12o/C5IoYH5KJRC+H2TVMLZX0gvxlmCHw== X-Received: by 2002:adf:f5cc:: with SMTP id k12mr2622758wrp.65.1571906167170; Thu, 24 Oct 2019 01:36:07 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 26sm1681827wmf.20.2019.10.24.01.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 01:36:06 -0700 (PDT) Message-ID: <897568e675f5d9b5e2ccda64a7c08d88f6f914e1.camel@debian.org> From: Luca Boccassi To: Gavin Hu , stable@dpdk.org Cc: nd@arm.com, thomas@monjalon.net, nipun.gupta@nxp.com, konstantin.ananyev@intel.com Date: Thu, 24 Oct 2019 09:36:05 +0100 In-Reply-To: <1570516723-10217-1-git-send-email-gavin.hu@arm.com> References: <1570516723-10217-1-git-send-email-gavin.hu@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH] ring: enforce reading tail before slots X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Tue, 2019-10-08 at 14:38 +0800, Gavin Hu wrote: > In weak memory models, like arm64, reading the prod.tail may get > reordered after reading the ring slots, which corrupts the ring and > stale data is observed. >=20 > This issue was reported by NXP on 8-A72 DPAA2 board. The problem is > most > likely caused by missing the acquire semantics when reading > prod.tail (in SC dequeue) which makes it possible to read a > stale value from the ring slots. >=20 > For MP (and MC) case, rte_atomic32_cmpset() already provides the > required > ordering. For SP case, the control depependency between if-statement > (which > depends on the read of r->cons.tail) and the later stores to the ring > slots > make RMB unnecessary. About the control dependency, read more at: > https://www.cl.cam.ac.uk/~pes20/ppc-supplemental/test7.pdf >=20 >=20 > This patch is adding the required read barrier to prevent reading the > ring > slots get reordered before reading prod.tail for SC case. >=20 > Fixes: 0dfc98c507b1 ("ring: separate out head index manipulation") > Cc:=20 > stable@dpdk.org >=20 >=20 > Signed-off-by: Gavin Hu < > gavin.hu@arm.com > > > Reviewed-by: Ola Liljedahl < > ola.liljedahl@arm.com > > > Tested-by: Nipun Gupta < > nipun.gupta@nxp.com > > > Acked-by: Nipun Gupta < > nipun.gupta@nxp.com > > > Acked-by: Konstantin Ananyev < > konstantin.ananyev@intel.com > > > --- > lib/librte_ring/rte_ring.h | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h > index e924438..9e6ccfe 100644 > --- a/lib/librte_ring/rte_ring.h > +++ b/lib/librte_ring/rte_ring.h > @@ -544,11 +544,14 @@ __rte_ring_move_cons_head(struct rte_ring *r, > int is_sc, > return 0; > =20 > *new_head =3D *old_head + n; > - if (is_sc) > - r->cons.head =3D *new_head, success =3D 1; > - else > + if (is_sc) { > + r->cons.head =3D *new_head; > + rte_smp_rmb(); > + success =3D 1; > + } else { > success =3D rte_atomic32_cmpset(&r->cons.head, > *old_head, > *new_head); > + } > } while (unlikely(success =3D=3D 0)); > return n; > } >=20 Acked-by: Luca Boccassi Thanks, applied --=20 Kind regards, Luca Boccassi