From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50051.outbound.protection.outlook.com [40.107.5.51]) by dpdk.org (Postfix) with ESMTP id 43FFB4C96; Wed, 13 Mar 2019 09:12:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GoPgG6HH3zyNsubmPcS2SR5VN4L6Caw8rkxdBKcjtYE=; b=XGkqrwVZeIgQgkxmGqd2AwVu3ipljBzwLxNRo9eEeYTXy7QSV+OjBTFKfU+rH46WSmNbWmVnlNn7TLO2h2onVWR0JpvlFeIRykoxJuxITQYi2PxIfyaqDGtzQQn92mFKZRPdQ23RRbwSyxosRhAV1tMQZYcq27m0zztSDRMa8Fg= Received: from VI1PR04MB4480.eurprd04.prod.outlook.com (20.177.53.224) by VI1PR04MB4350.eurprd04.prod.outlook.com (52.134.122.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.19; Wed, 13 Mar 2019 08:12:11 +0000 Received: from VI1PR04MB4480.eurprd04.prod.outlook.com ([fe80::2c47:c855:d954:5dab]) by VI1PR04MB4480.eurprd04.prod.outlook.com ([fe80::2c47:c855:d954:5dab%4]) with mapi id 15.20.1709.011; Wed, 13 Mar 2019 08:12:11 +0000 From: Nipun Gupta To: Gavin Hu , "dev@dpdk.org" CC: "nd@arm.com" , "thomas@monjalon.net" , "konstantin.ananyev@intel.com" , "jerinj@marvell.com" , Hemant Agrawal , "Honnappa.Nagarahalli@arm.com" , "i.maximets@samsung.com" , "chaozhu@linux.vnet.ibm.com" , "stable@dpdk.org" Thread-Topic: [PATCH v3 1/1] ring: enforce reading the tail before reading ring slots Thread-Index: AQHU2PTqueQOMQvFxUGq4uAKTDTY8aYJNoGw Date: Wed, 13 Mar 2019 08:12:10 +0000 Message-ID: References: <1551841661-42892-1-git-send-email-gavin.hu@arm.com> <1552409933-45684-2-git-send-email-gavin.hu@arm.com> In-Reply-To: <1552409933-45684-2-git-send-email-gavin.hu@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [92.120.0.7] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dfcc8d53-e7ed-4e31-b466-08d6a78b97e3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4350; x-ms-traffictypediagnostic: VI1PR04MB4350: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; VI1PR04MB4350; 23:llLsJpUL8dyGGq75MTFUymErUheArC1a58Vq4sc9h?= =?us-ascii?Q?MBiz6fq0tuVfpq5XkRL9NLAYxZkUCINaDesZdVrwWChZ3CBL9jTIBss7lTp3?= =?us-ascii?Q?CG0d72e5lWMlioo2xAnIUkUJAGPfc4gvqO2vCTn/ifYrPkr0+OdAEyjIW5TT?= =?us-ascii?Q?6khopBy1td8c8XHz1AZyX+ZIrL0fHQM+rTntfJZ2Y19UwiOiPtnsuPgUva/5?= =?us-ascii?Q?6swf4qWMbHoZDNMBjcXeaMZjAEdFziVEcCUuoRmdYZcuQmy/Qe4S04jq8hQ0?= =?us-ascii?Q?VEEtKf5Rt6G70nXgGsqWLz323kb425BLisnz8O2r/rfXbfgAG81bdU5sb89p?= =?us-ascii?Q?LgFiltbbPV/0z2ITW7rkePdp4iHWudql+a8XMzjjVmNaKYWUijExfqlK0RmG?= =?us-ascii?Q?WgxMUfBdjiqXThOGPDFBhvw+a/7OYd7ElL23RUS0tOJpMur0vowO3eyWbuCs?= =?us-ascii?Q?sqx3qceFCNawARKKcNg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ii?Q?HG0xJI+esxtpL51Wx+mUnPoM0euzS3XoA9jEWkFDSaL36vU?= x-microsoft-antispam-prvs: x-forefront-prvs: 09752BC779 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(366004)(39860400002)(346002)(396003)(189003)(199004)(13464003)(66066001)(6116002)(7696005)(3846002)(6346003)(53546011)(11346002)(97736004)(71190400001)(71200400001)(68736007)(44832011)(186003)(8936002)(446003)(99286004)(76176011)(102836004)(26005)(5660300002)(476003)(52536013)(486006)(86362001)(6506007)(316002)(7416002)(6436002)(81166006)(8676002)(14454004)(33656002)(4326008)(81156014)(229853002)(25786009)(478600001)(9686003)(53936002)(6246003)(55016002)(6306002)(74316002)(54906003)(966005)(305945005)(110136005)(7736002)(2501003)(45080400002)(106356001)(256004)(105586002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4350; H:VI1PR04MB4480.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=nipun.gupta@nxp.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Lrzq30idryTeWnlpysBfmc9Opy7/Sf4ovfupSImx8bNTuttNhiuIwOH0UpdV6lfOCfUo5bbR8oS7teBsSFbEQR1qD+fGK3fRmhEhngdidE37EOg9M4MYlMzD9ftHA4npFxd2Z/0RIIBodqsU7PxnBL5hfQewJkvlPeLYV7kbi1mv+tuZDXiM2mDI8Gh8Tbq26cbADZH+x1vSGYp1DdpwW13WcNhwz+74ZoizfOI5kocoJ3gr0kWfVjbkRNmND3zPEEJkbEdXQzC9qXlGtlTx5CJHWSW/fRh5n4osfyzjTG8/XKqeCMl14Sb2/GXL6VJ/PaYywbhtY3bjPMlYWk7G+c/O2WHnOw+F0BtXm2szOaANvBC2uj29/9qJ+RkAcA20laGJo43Po0j2aTp1CZdBX8+GbOVHCsLjiwBiTWqKj68= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfcc8d53-e7ed-4e31-b466-08d6a78b97e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Mar 2019 08:12:10.9118 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4350 Subject: Re: [dpdk-dev] [PATCH v3 1/1] ring: enforce reading the tail before reading ring slots X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 08:12:12 -0000 > -----Original Message----- > From: Gavin Hu [mailto:gavin.hu@arm.com] > Sent: Tuesday, March 12, 2019 10:29 PM > To: dev@dpdk.org > Cc: nd@arm.com; gavin hu ; thomas@monjalon.net; > konstantin.ananyev@intel.com; jerinj@marvell.com; Hemant Agrawal > ; Nipun Gupta ; > Honnappa.Nagarahalli@arm.com; i.maximets@samsung.com; > chaozhu@linux.vnet.ibm.com; stable@dpdk.org > Subject: [PATCH v3 1/1] ring: enforce reading the tail before reading rin= g slots >=20 > From: gavin hu >=20 > 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 slo= ts > make RMB unnecessary. About the control dependency, read more at: > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps:%2F%2Fwww.c > l.cam.ac.uk%2F~pes20%2Fppc- > supplemental%2Ftest7.pdf&data=3D02%7C01%7Cnipun.gupta%40nxp.co > m%7Cc3df030ec49449bbaf0508d6a70c0b9f%7C686ea1d3bc2b4c6fa92cd99c5c > 301635%7C0%7C0%7C636880067514602937&sdata=3DogPdd%2F4UGYWE8 > nAwY1lkXPCB9MpUIFY0VOQr2N1lwe4%3D&reserved=3D0 >=20 > This patch is adding the required read barrier to prevent reading the rin= g > slots get reordered before reading prod.tail for SC case. >=20 > Fixes: c9fb3c62896f ("ring: move code in a new header file") > Cc: stable@dpdk.org >=20 > Signed-off-by: gavin hu > Reviewed-by: Ola Liljedahl > Tested-by: Nipun Gupta Acked-by: Nipun Gupta Also, I have revalidated this updated patch.