From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0068.outbound.protection.outlook.com [104.47.1.68]) by dpdk.org (Postfix) with ESMTP id 8850111DE for ; Mon, 11 Jul 2016 13:22:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coriant.onmicrosoft.com; s=selector1-coriant-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NXC1MzwA8RLB+LvL4wRpy3OwIvKQNLHml7I+bi10ja4=; b=QT26plS2+SdgCvyXf3ePK1OeJl3ooHQSZ3BIX8bu5mLesJ5RN8crL2NciQUrkfnSD4ualmfaR2dlD+iS87DWsnj5WAozDsWUZSAOuPZocoWZK3YA5RfQmdxcwumlAkEy/JwIoqnSzjPxf4YejVSCJsNBR+wNvQObEZVuwMs6+cI= Received: from HE1PR04MB1337.eurprd04.prod.outlook.com (10.163.175.23) by HE1PR04MB1339.eurprd04.prod.outlook.com (10.163.175.25) with Microsoft SMTP Server (TLS) id 15.1.539.14; Mon, 11 Jul 2016 11:22:43 +0000 Received: from HE1PR04MB1337.eurprd04.prod.outlook.com ([10.163.175.23]) by HE1PR04MB1337.eurprd04.prod.outlook.com ([10.163.175.23]) with mapi id 15.01.0539.018; Mon, 11 Jul 2016 11:22:44 +0000 From: "Kuusisaari, Juhamatti" To: "Ananyev, Konstantin" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] lib: move rte_ring read barrier to correct location Thread-Index: AQHR214MoG1fIZBOPEC9vEAt0w2bq6ATCsYAgAAIC6A= Date: Mon, 11 Jul 2016 11:22:43 +0000 Message-ID: References: <20160711102055.14855-1-juhamatti.kuusisaari@coriant.com> <2601191342CEEE43887BDE71AB97725836B7C858@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB97725836B7C858@irsmsx105.ger.corp.intel.com> Accept-Language: fi-FI, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Juhamatti.Kuusisaari@coriant.com; x-originating-ip: [138.111.130.175] x-ms-office365-filtering-correlation-id: a2f939b7-a19e-4383-3754-08d3a97dadcc x-microsoft-exchange-diagnostics: 1; HE1PR04MB1339; 6:+VbZnHZANFrXeiuejoRWScWW9RMorBK0RHMoStMTF9bsfycA7gxkABc0GoQ7HpBZA3YehsL6qbGhioe3xxYDmFBDK3V5S1Lt/IMbpjlaWDnAb1GgeXqZf9+HbpYUGhGPwR4WI5/QnG187aSg4XhHNqr6opicuH5hAgptvKctbGaXuy12KedbSaFPuRNC8mu9Ljn/K+SwDTGHhKL7Dh8J0qM/qIU8s3LbDc4yjcTXXbhV/q1Xe7bs4AJHeH4C0VhhvdkfCeE2pYZ+2SCfrTVxXnrXCnKzEIeC1EVoe6TbOhkRJKOkB2DgxKDiH6+XG8T0jjWxoW20Yieat41v4SJTMg==; 5:zooaZ3I389J3SQJ9F3U5KqUpc65l9zEpkRx85ucHbw/gINKVWe35ls3yIFcw9EgJWVX3SKzLk1QDnfTJ1zebk+8bCkroEDm83X2fPdxT7Nf6NyGsEVZ2WN+VpVaiDZXXHOwbhcKYSWiaEIkVXyRPgg==; 24:knpjkqY0I6Wiwv3dB+x5nHZ1iJWTuYHMeQxt6Y16an8xARigBXdXZAa34CoMyLblWVarwwOjEJdPmlQ4vwRhKuNnZ5fZq3N02NBysSd0QhM=; 7:pEs6FF+236VmOVu/m/B9NerjGoRHjCMA8V3ivfLESmmpYEq5fN/qOwDjh57daukZrPwpwKdkamLC8Z/p7ihffmmr4n0tfc/gbErvMYDdTZ4WKd/1g9DT1oIXDR1gGLuQFjADIp8Lw3R6lCmickkuKmJBHLSpayZEDlQzNUKiV3u/Qr8bY4ThRPBX985n9tSI49MyDn9lyZOo/u2aCQMd2zk0oufRFMR0iUgi4GY67F9BlLvP5odWJT/vtxo3jvCi x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR04MB1339; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(51653755401839); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:HE1PR04MB1339; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB1339; x-forefront-prvs: 00003DBFE7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(377454003)(189002)(199003)(13464003)(107886002)(122556002)(77096005)(87936001)(6116002)(19580405001)(105586002)(19580395003)(97736004)(2900100001)(2950100001)(5001770100001)(86362001)(305945005)(74316002)(8936002)(101416001)(54356999)(10400500002)(50986999)(76176999)(7696003)(5003600100003)(7736002)(7846002)(2501003)(106116001)(106356001)(81156014)(5002640100001)(81166006)(92566002)(66066001)(9686002)(2906002)(68736007)(3846002)(3280700002)(102836003)(3660700001)(76576001)(189998001)(33656002)(586003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB1339; H:HE1PR04MB1337.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: coriant.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: coriant.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jul 2016 11:22:43.8717 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 76595477-907e-4695-988b-a6b39087332d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1339 Subject: Re: [dpdk-dev] [PATCH] lib: move rte_ring read barrier to correct location X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2016 11:22:45 -0000 Hi, =20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Juhamatti > > Kuusisaari > > Sent: Monday, July 11, 2016 11:21 AM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH] lib: move rte_ring read barrier to correct > > location > > > > Fix the location of the rte_ring data dependency read barrier. > > It needs to be called before accessing indexed data to ensure that the > > data itself is guaranteed to be correctly updated. > > > > See more details at kernel/Documentation/memory-barriers.txt > > section 'Data dependency barriers'. >=20 >=20 > Any explanation why? > From my point smp_rmb()s are on the proper places here :) Konstantin The problem here is that on a weak memory model system the CPU is allowed to load the address data out-of-order in advance. If the read barrier is after the DEQUEUE, you might end up having the old=20 data there on a race situation when the buffer is continuously full. Having it before the DEQUEUE guarantees that the load is not done in advance.=20 On Intel, it should not matter due to different memory model, so this is=20 limited to weak memory model systems. -- Juhamatti =20 > > > > Signed-off-by: Juhamatti Kuusisaari > > --- > > lib/librte_ring/rte_ring.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h > > index eb45e41..a923e49 100644 > > --- a/lib/librte_ring/rte_ring.h > > +++ b/lib/librte_ring/rte_ring.h > > @@ -662,9 +662,10 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, > void **obj_table, > > cons_next); > > } while (unlikely(success =3D=3D 0)); > > > > + rte_smp_rmb(); > > + > > /* copy in table */ > > DEQUEUE_PTRS(); > > - rte_smp_rmb(); > > > > /* > > * If there are other dequeues in progress that preceded us, > > @@ -746,9 +747,10 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, > void **obj_table, > > cons_next =3D cons_head + n; > > r->cons.head =3D cons_next; > > > > + rte_smp_rmb(); > > + > > /* copy in table */ > > DEQUEUE_PTRS(); > > - rte_smp_rmb(); > > > > __RING_STAT_ADD(r, deq_success, n); > > r->cons.tail =3D cons_next; > > -- > > 2.9.0 > > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D > > The information contained in this message may be privileged and > > confidential and protected from disclosure. If the reader of this > > message is not the intended recipient, or an employee or agent > > responsible for delivering this message to the intended recipient, you > > are hereby notified that any reproduction, dissemination or > > distribution of this communication is strictly prohibited. If you have > > received this communication in error, please notify us immediately by > > replying to the message and deleting it from your computer. Thank you. > > Coriant-Tellabs > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D