From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0072.outbound.protection.outlook.com [104.47.41.72]) by dpdk.org (Postfix) with ESMTP id 2BD3823D; Mon, 8 Oct 2018 08:06:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KmLjmDQIVttGHjdbKhXA1J6IBNHR0RSzP5eNMlzqofs=; b=Sr7eTPHxdURUO66JL6sFTlhoJiNYVGZOZkEDASHnVVjQSuEGx8xSYKy7MVTBF2I2XlEdyPH3NXMmEzyLzi7AVvBe2kVS8drLmayEO39N9df9VuKywbSPJgc3eRlH9Tjqrld2cNZXuH0FCGLXis6+katdrFAPEL1UTUckM7LWhOk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (122.167.112.78) by BYAPR07MB4999.namprd07.prod.outlook.com (2603:10b6:a03:5b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.28; Mon, 8 Oct 2018 06:06:46 +0000 Date: Mon, 8 Oct 2018 11:36:31 +0530 From: Jerin Jacob To: Ola Liljedahl Cc: "dev@dpdk.org" , Honnappa Nagarahalli , "Ananyev, Konstantin" , "Gavin Hu (Arm Technology China)" , Steve Capper , nd , "stable@dpdk.org" Message-ID: <20181008060629.GA5228@jerin> References: <20181005170725.GA18671@jerin> <1555626C-F2B8-44EB-98A3-79B1F7002587@arm.com> <60055965-A7C8-4E9F-8668-0AE1DCE57515@arm.com> <20181006074126.GA16715@jerin> <20181007040243.GA1850@jerin> <7A156041-23EC-4CCB-B129-3607AF34A992@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7A156041-23EC-4CCB-B129-3607AF34A992@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [122.167.112.78] X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To BYAPR07MB4999.namprd07.prod.outlook.com (2603:10b6:a03:5b::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb8889a0-ab73-46b7-a669-08d62ce43c18 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4999; X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4999; 3:tr+BWQGU8WSjSzThK9CW1Rf4CbxkFyaes68nHeUZ5NZhdAEyVTdmNGvIBmf6PksEKzYPt07RA08Dvk9ekEd8CcG/wwaWxhrP2nyZO4n8QM4BLrfH18bUQchfOd44H8osOB885BeK5ihRV0P5Lm9IXU/OX1rPv0nF9j2+AtBLKRGfhC5xGgrSQSkVvbpKyxBlfRfGnwddIrxqaQ/RJcDF9OagRe5XvTlgYtUkdCm7L6iErDInpWrn+UpEOR8AM0Ze; 25:6cmsa1Se8NazdLCGSo02fi1BdEzujdgfYikZDnvxudObIwgqA4WBijWA5DkUF3nroUW/TR5hU/ht8c2zRmCFbpe15fL+oFI6rMuRD0QSnb5k5y461nLawdu3wVvt9glQ3vnPYuEHmSHQgbJBWtmwh7ll3oiQaD3Vw7ImqZ/6UozJOedBRxZHzBZqwngE/889hxGCiB3ADyIcWXpy88ogBKiEiSg8i+Kyrq8sLXSwoYaoT4fVVraD5Cmvf1gjUe3jtzP8ydla2ch73uPMeYwmv+ZXQQqWEZq7Mm1WbKviODmxCYJOC5+7F02kmgNFRRMrf41oProAljG3euXn03Fe3g==; 31:/VGp6oo1k3z6XztnztYojYZo+xY/lmSFhb8gfqAeY5dI3wmpGfx9wsWfTRAiGXHtWdVm2D9ia/rUZrRuxVK3f0rsampH3F3cpODK9OleDMOnXWjozuRxCT+xhjbplSOrXjUui7TNOV3b8zaPzaVAgXGskx1QHt+/qOW3gtslh4AoL1MtbUtx9ts2/bKPpFHugh9ni8xL5ZezS4VzoRkd9L7mZl6qVEScLTDQlev//Yo= X-MS-TrafficTypeDiagnostic: BYAPR07MB4999: X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4999; 20:4nFAoGyWQ6Z89sK4NODnsQ7BV24Gzg7GmR93J1IiIryTNNX45rB3Z54/6rHXdkcKEZibt2zIdET3YC4sGHoC+nlEqCsCiCegRMFUGBVIaeG/cqo1nwxbsHzcah1oGutGTdbiINnHNxN1k8jAy8oXOJx/8i2HVP7wkzrVY3WMFvMVfGOTl/WK/r+Tuwc6e6CN0KbQQkUTKjOvo1ldyvuUbzMnkEHVPdarMn/ZmpJexB/Msf3IVtF3wmQYzHitCoNrdFblBU1I2GHE1yo5r5W+Tw67lcphdXeQQlqVEwjyzppGIJkpOG3gZ+nT/maTa64n6w4Hs31sQKUqInxN/hW+vzIjDPqtZdAln1X5eFLkRWu2zT7HSES7T5HeFaOhvrr0RaWMmD7ur0L9lA38KMr06Z9L5LtdJakqgYiSnl7d1IsIjpZiEf64LKj0inkR7dh2wsJ/ozRBLIUvZUc6jo7z11ZMsldFVOnw1tMUhuyQnILGf5nefCUy0iWXy4ICkJB7C2jKTCK8I3Bs5VB38hLqLJwJ6W4g4n5GZK2elVFL6SoL0J07z2QHHCcrPstasDEFeS36URPm7R44FJlWg8XXjIDsEZ36G/f1Boiu20i7eFM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(228905959029699)(166708455590820); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(93006095)(10201501046)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051); SRVR:BYAPR07MB4999; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4999; X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4999; 4:R4nNJuVcKzTwqEs9SCCSs2FU3cVF0uHOAkjeQ1E4Mmf4II2pttsuAelU+URhwNh+yF5Z3lFVIXFAOxJ/lQxahX8SVqxfJCgTyEoWX316KWTIRNGOe/eMvY8XfnPd/f96QO12zCq8caDc5ABjJv9KUEkYNS3AzEf0Zvn5X0VHQbAButeV1KEiRNQSTxChwsz526JBSa4IHBGRWw+TQlpZBKZe86RxW1y3Q0lqNIi+BMb175n6vO3SbIhpP/vK/qsU+6bSLvMOUvTEtB43uhQGYRhWAQehKTnnSkwFlnBII5SiLGnjHVodK99SwNOXFYThCZQ/vNRTW5DF4FqhAaZDWM4yg9fxSz7crN8FHnD8aRrihz8C5/UJcHSB73MLO96r X-Forefront-PRVS: 081904387B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(376002)(366004)(396003)(39860400002)(136003)(346002)(13464003)(199004)(189003)(42882007)(16526019)(44832011)(186003)(2870700001)(8676002)(25786009)(93886005)(6246003)(66066001)(26005)(1076002)(6116002)(316002)(81156014)(956004)(446003)(81166006)(486006)(3846002)(58126008)(19627235002)(47776003)(11346002)(476003)(4326008)(478600001)(6496006)(45080400002)(52146003)(76176011)(33896004)(105586002)(53936002)(33656002)(7736002)(305945005)(23676004)(52116002)(2486003)(97736004)(8936002)(386003)(966005)(5660300001)(54906003)(50466002)(106356001)(2906002)(33716001)(229853002)(9686003)(68736007)(72206003)(6306002)(55016002)(6916009)(6666003)(18370500001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4999; H:jerin; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWUFQUjA3TUI0OTk5OzIzOjdsOE80SUlIMzd5cU5TcXY0dXJGeXhSeHl0?= =?utf-8?B?N3JJZEJLa3Z3NDVxWmVhT3RkRW5xTTZFQVNXOC9jbnZDK2tnMkVBY2FTU2wx?= =?utf-8?B?Si9aU21XQVlvM3BQWWFGblJ3TnJHMWJaM0FwcE5mdE81M1grWnU4R3p1U2wv?= =?utf-8?B?V3B4MHRDTjFPZnJmRXN3M2d4K2g1VzZSd3NaNFhlU3YvZTJVckpDaDVlanZx?= =?utf-8?B?amR2YUswU3ZSalV1OStIMThHY1k0L3FNWHJMUXhibS9vUHNwa01HbnJ1Mkp5?= =?utf-8?B?WjRvNi9wWjdTT1dPWUVHM3p5WXFvLzdSWDVITjZVU0tLQjQxSnA4VzZrb0pM?= =?utf-8?B?cDM4VjdSK2ZYejE5MXBYbC9OaHFReld6dG50SFEzczNDNWNwOGZmREZJM1ho?= =?utf-8?B?QWx2bU1vdzQxYUttTVlZdDR1eUZDaWNRQmVUcTA0dlQrNmRGS1NOSlVEWndh?= =?utf-8?B?aVgrdHpVNEMvVHdsYUZnSEp4WDRBMzhXVDFDcHpiZTFxclB2YjZMdnpON3Jp?= =?utf-8?B?LzY4M1BISlE1NWIySUVubjVkMHQvZXRPV0RrTWpCUXY3b3p0YmRvYzl2RW5K?= =?utf-8?B?RDl0U2NyWU90SXF4eHJTS21RalJCZmUrSmVCbXdxK0wvK1RFdlc2TDNyeEVD?= =?utf-8?B?bU1HWXdJRVBsck1yS2V2SzBXcWRiODVuanhhU0pBeFdFTWx3bTcvZjl0YVRF?= =?utf-8?B?bEJ3OWFoS0RmeDVuMTRpQ3RwaG5Tb3NneGF1M3l6VE5UMUJ6enNIaFMxMG9m?= =?utf-8?B?UzhPM2MzeUpGNlRCQmZaVCticGxPL1V1dEJaVVdJTE9PZGlYcndiZGt5ZDhs?= =?utf-8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uDBXmvOXG3m6BxSXmHrx84ulTyr8JdjX+isWF+NO7+BAW2pLE65AoC1ZCP4Z8YFKHm6PXkKMyldmOXq5Xvz6rn6NbH/uPcxoFc1za2k53Pz7283jWVVDaOL3aZYMy6sKqYzncpwLLZIYTtAE+vQY8KKDqVjtLWXDGiCl+t/gecllbuDdM2emxIAK1hv6OxosFljNaV0wcg5ppy8lyHflkler7Yxqu14zmvFepucmfhMuI4GJqxEbNOZG6c3UqS/nlcalgBXJXhdGzR45jTBvIeebDcSuqMI3o9fEeGwFMsupEFfGaUZVcGXAKztgbrI7X08Kusv0tcRQ==; 5:eeGoj3cIcnnUXl2OSLX1p9rVpL/MOhWcPaXo397/mPupm+fDpb0BtLRQqZi5a8V4fH1TuJQgzUK2V6iIztuNUSaBMkgz40iUeTDtpBjaSwY/7C5ODTcX4bA4Yw/Vo4jWnCqGCuuJIfrcoU7CE6Yc51IgIBOvsHKXBS+AgnRkNmM=; 7:w50Au3PWstB1f6v56vMBhcYJ6VxxtABpJMlGyIBdUT0ErY6Ys1/wLi6At04+sfQC4qO4aEqmtiZ0Mr/FV3CHrus07mY/9Y8Hf57t9Nzzudi1DecuXStFEIlM1iZBRIZoLMxgbYg7swKi7FGZzP1Rd2W4gXnK3COpquRjW+t+Gmgpv+QN82tq/PX+3ev8BeNmL8ftNi0KQwG2iMSknmWblJTSVHlNamADO65QCxIMiVnyNfwnDPJ9TVymf/SLjkc7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2018 06:06:46.5560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb8889a0-ab73-46b7-a669-08d62ce43c18 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4999 Subject: Re: [dpdk-dev] [PATCH v3 1/3] ring: read tail using atomic load 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: Mon, 08 Oct 2018 06:06:51 -0000 -----Original Message----- > Date: Sun, 7 Oct 2018 20:44:54 +0000 > From: Ola Liljedahl > To: Jerin Jacob > CC: "dev@dpdk.org" , Honnappa Nagarahalli > , "Ananyev, Konstantin" > , "Gavin Hu (Arm Technology China)" > , Steve Capper , nd , > "stable@dpdk.org" > Subject: Re: [PATCH v3 1/3] ring: read tail using atomic load > user-agent: Microsoft-MacOutlook/10.11.0.180909 > Could you please fix the email client for inline reply. https://www.kernel.org/doc/html/v4.19-rc7/process/email-clients.html > > On 07/10/2018, 06:03, "Jerin Jacob" wrote: > > In arm64 case, it will have ATOMIC_RELAXED followed by asm volatile ("":::"memory") of rte_pause(). > I would n't have any issue, if the generated code code is same or better than the exiting case. but it not the case, Right? > The existing case is actually not interesting (IMO) as it exposes undefined behaviour which allows the compiler to do anything. But you seem to be satisfied with "works for me, right here right now". I think the cost of avoiding undefined behaviour is acceptable (actually I don't think it even will be noticeable). I am not convinced because of use of volatile in head and tail indexes. For me that brings the defined behavior.That the reason why I shared the generated assembly code. If you think other way, Pick any compiler and see generated output. And Freebsd implementation of ring buffer(Which DPDK derived from), Don't have such logic, See https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L108 See below too. > > Skipping the compiler memory barrier in rte_pause() potentially allows for optimisations that provide much more benefit, e.g. hiding some cache miss latency for later loads. The DPDK ring buffer implementation is defined so to enable inlining of enqueue/dequeue functions into the caller, any code could immediately follow these calls. > > From INTERNATIONAL STANDARD ©ISO/IEC ISO/IEC 9899:201x > Programming languages — C > > 5.1.2.4 > 4 Two expression evaluations conflict if one of them modifies a memory location and the other one reads or modifies the same memory location. > > 25 The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior. IMO, Both condition will satisfy if the variable is volatile and 32bit read will atomic for 32b and 64b machines. If not, the problem persist for generic case as well(lib/librte_ring/rte_ring_generic.h) I agree with you on C11 memory model semantics usage. The reason why I propose name for the file as rte_ring_c11_mem.h as DPDK it self did not had definitions for load acquire and store release semantics. I was looking for taking load acquire and store release semantics from C11 instead of creating new API like Linux kernel for FreeBSD(APIs like atomic_load_acq_32(), atomic_store_rel_32()). If the file name is your concern then we could create new abstractions as well. That would help exiting KNI problem as well. I think, currently it mixed usage because, the same variable declaration used for C11 vs non C11 usage.Ideally we wont need "volatile" for C11 case. Either we need to change only to C11 mode OR have APIs for atomic_load_acq_() and atomic_store_rel_() to allow both models like Linux kernel and FreeBSD. > > -- Ola > > >