From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680059.outbound.protection.outlook.com [40.107.68.59]) by dpdk.org (Postfix) with ESMTP id C0046F04 for ; Fri, 21 Sep 2018 07:55:49 +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=7CiEAVy3kA799K1LSLtfXARAYbgd6aaQl4jNyAdMh04=; b=TiLluzEByefUoDjb46IrRdoVKANK9L6d80nn8mo8rS/prR5ymCIOn9C6M1NS17ImCrCF4T2646irJpfY5cZfwVSsVpRWmsUu7t91orm0c3UgHA+2cBTh2291UBQSlAFZv8fd0SkP15wB5uKJ5NPcL7y/+X1RnEn3XDyyMuOCL7I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (115.113.156.3) by BL0PR07MB4996.namprd07.prod.outlook.com (2603:10b6:208:49::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.17; Fri, 21 Sep 2018 05:55:45 +0000 Date: Fri, 21 Sep 2018 11:25:31 +0530 From: Jerin Jacob To: Honnappa Nagarahalli Cc: "Phil Yang (Arm Technology China)" , "dev@dpdk.org" , nd , "kkokkilagadda@caviumnetworks.com" , "Gavin Hu (Arm Technology China)" , "ferruh.yigit@intel.com" Message-ID: <20180921055529.GA15861@jerin> References: <1537363820-3827-1-git-send-email-phil.yang@arm.com> <1537364560-4124-1-git-send-email-phil.yang@arm.com> <1537364560-4124-2-git-send-email-phil.yang@arm.com> <20180920082846.GB19425@jerin> <20180920153700.GA9459@jerin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [115.113.156.3] X-ClientProxiedBy: PN1PR0101CA0004.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::14) To BL0PR07MB4996.namprd07.prod.outlook.com (2603:10b6:208:49::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ea8c38c-6f15-495c-3a72-08d61f86e0cd X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BL0PR07MB4996; X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4996; 3:WyaO1YcFCH7SpsphG7Y35IcaSKTbMcwlMft5znxoJtCrWSKOQyfN+I08slD9AKgMITEDxAsmhmhQIvVexCgoEPtFCQ9wz2AGECMD/g3U5wDXXvmiSLX6LK+AE3bd/suZcd/XZ+moVl3p7dbmUKoWt/etvOd8PoEwZKQDXaztHkloBgZnac5mIXrVQMoMVr8yndK7ptePvsMDrQS2zUm1nLIVxAo4CILIDP9rGmZ0zzqkNUnMT51Tej/f9l7l4Wgb; 25:zk4zxPkfQtuIZf7nhQKnxLB4OQjKJj2jvFtpLlG5I+V2BLiVfITVhw3aGR/6WZcZ3VttAxuYmny+lPhjJpYlKAtIeLEYPT9R7y/3vX/Gl2CAr/fLiKMGoT0yLyh5D7Ert9v4ux33925szt+AnmRzKPs0CQ+r8xwgFZAdwLB/GZknLTphGO9Ey3bNJzndrua5q18eiZrq8KJpB8Tyktd+KHcXBU5SzYCLZtswI31d1sMajT6Nj/jb/c0JaqVqzhpu7el6GXqABg5PCqsAA2ZJGncxvhz4zZhj0867uNHLhC+cM7Re0X5ET1BHWf0u34Ox675mJDUN7Icn1XjqphnTjw==; 31:2NL/5kgGj77VQ7utibHwWvTp+IT47yb52KaRIyMTa2D5A6hnV0+OX8n7xZfvGE+s4KUDkHnMRHofET5HheCjRaaIVz0XxyTzW5RjUCnTtPkHX0QcDeieoabv8C4xnkDMuK039QnjTE4ALGrvWy6MgbWoXnjOhCaIA0m69DAa1HCnzCkQ8LkBWn9adQjZop9huxR7BBb2q/Awl3GIHwh6LbUjvYEy2bXA9TWRnQu2ILk= X-MS-TrafficTypeDiagnostic: BL0PR07MB4996: X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4996; 20:cfBEA5o9FBgssmlTvCpGoOmQ6k5LMkAxWUccP9Gd57WSvzI5EkMxG6fHG7zpUz+YX0JmaVhbImn1M2rb1XRaVNuoNmw72RoIhVLsyaVeMCoGmSe2zj11V16pSR3EQd5oCkScdL+v7TILDerJbWzKPq3gTuadmxFQ12JRvm/gnNRSkFEoX6Gw1zQ7QLF8yVD7uh+UJpD9pH3SpD3edglTbT9sk+VqvaI/0+q8kGu88mN1tzhz3HfWDDYnS7+hf/LJWUj47Jd0nLPg25YOVBvjd3NPhidCsq3aeTAdBOTxWgZasKxsiE2MIKZRmHcIEXH/avwbovb4npwCwKwSG1c3FH3eeEIpUSibJXsq1oj3klu3cK52LYzxKZiqB0Y81RaDwaFT8rxRQjNrNQjur8GElWzVXCu9ZFTZ+QFI4funoAVp3QpmhJ9s3KF9NllIw61VU/XVllMyZEbmJ2UmmTfjd/PtuX/wUgAscplO9YehMQoO5h3pJ9FIeWZR3xa0GO6aUxnxAw6b5N66HMDAXx+/dZfLLjMcJraRwc6nyKiz8QeunQa5jkqMTfaXf0pOMpFVv2qY57lYGCy7a2IZKGj+4kPlpjIhFb5lrkPzlmfxL2Y= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(163750095850)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(10201501046)(93006095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:BL0PR07MB4996; BCL:0; PCL:0; RULEID:; SRVR:BL0PR07MB4996; X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4996; 4:wrlja3G0Q4xgtY2W1Lb9ZjL1AGnzXrdrefBQfE6058Mru4qKtx0Xnn1GiDSbViYrVJ8bIb8IN6c5293SD/iq7zuCHywg+EwYQ6Y1raRjzwLYvRaq5fJXDVMp8bzziF3PdN6flh5nXWkQnSzJynC3yEAC1CzC9v6ggZqQFe34HAG56/2qfwI6Dal3+RMmgQCjXu0zqZEFZIV7jnJ2ID08AoMOR5k4MTGCc3OpTHaBL4emdXcx1r3teqnSer9Pt43nqW9p86d+xpgPL5Tqxu2Qmn7WFNCBorYtUEDKF2uMjU9kJvAbtFPoPb7u5Ua5sG2dKwIIGxQ27LdC0pHfvhteTCbAvwgcHI0iuWYfe4ZgYSyj68bVjsUu+1/8Suif8xeL X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(376002)(136003)(366004)(346002)(396003)(39850400004)(199004)(189003)(57704003)(13464003)(229853002)(68736007)(9686003)(478600001)(4326008)(23726003)(305945005)(6496006)(55016002)(55236004)(47776003)(66066001)(33716001)(386003)(5660300001)(72206003)(8936002)(76176011)(33896004)(52116002)(316002)(14444005)(186003)(54906003)(33656002)(53936002)(106356001)(6116002)(16586007)(58126008)(6666003)(7736002)(6246003)(1076002)(6916009)(8676002)(3846002)(97736004)(476003)(486006)(446003)(956004)(93886005)(2906002)(50466002)(16526019)(11346002)(81166006)(81156014)(26005)(105586002)(25786009)(44832011)(42882007)(18370500001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR07MB4996; 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: =?us-ascii?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iagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 05:55:45.2041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea8c38c-6f15-495c-3a72-08d61f86e0cd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR07MB4996 Subject: Re: [dpdk-dev] [PATCH v2 2/3] kni: fix kni fifo synchronization 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: Fri, 21 Sep 2018 05:55:50 -0000 -----Original Message----- > Date: Fri, 21 Sep 2018 05:48:44 +0000 > From: Honnappa Nagarahalli > To: Jerin Jacob > CC: "Phil Yang (Arm Technology China)" , "dev@dpdk.org" > , nd , "kkokkilagadda@caviumnetworks.com" > , "Gavin Hu (Arm Technology China)" > , "ferruh.yigit@intel.com" > Subject: RE: [PATCH v2 2/3] kni: fix kni fifo synchronization > > > > > > -----Original Message----- > > > > > Date: Wed, 19 Sep 2018 21:42:39 +0800 > > > > > From: Phil Yang > > > > > To: dev@dpdk.org > > > > > CC: nd@arm.com, jerin.jacob@caviumnetworks.com, > > > > > kkokkilagadda@caviumnetworks.com, Honnappa.Nagarahalli@arm.com, > > > > > Gavin.Hu@arm.com > > > > > Subject: [PATCH v2 2/3] kni: fix kni fifo synchronization > > > > > X-Mailer: git-send-email 2.7.4 > > > > > > > > > > > > > + Ferruh Yigit > > > > > > > > > > > > > > With existing code in kni_fifo_put, rx_q values are not being > > > > > updated before updating fifo_write. While reading rx_q in > > > > > kni_net_rx_normal, This is causing the sync issue on other core. > > > > > The same situation happens in kni_fifo_get as well. > > > > > > > > > > So syncing the values by adding C11 atomic memory barriers to make > > > > > sure the values being synced before updating fifo_write and fifo_read. > > > > > > > > > > Fixes: 3fc5ca2 ("kni: initial import") > > > > > Signed-off-by: Phil Yang > > > > > Reviewed-by: Honnappa Nagarahalli > > > > > Reviewed-by: Gavin Hu > > > > > --- > > > > > .../linuxapp/eal/include/exec-env/rte_kni_common.h | 5 ++++ > > > > > lib/librte_kni/rte_kni_fifo.h | 30 +++++++++++++++++++++- > > > > > 2 files changed, 34 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git > > > > > a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > index cfa9448..1fd713b 100644 > > > > > --- > > > > > a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common. > > > > > +++ h > > > > > @@ -54,8 +54,13 @@ struct rte_kni_request { > > > > > * Writing should never overwrite the read position > > > > > */ > > > > > struct rte_kni_fifo { > > > > > +#ifndef RTE_USE_C11_MEM_MODEL > > > > > volatile unsigned write; /**< Next position to be written*/ > > > > > volatile unsigned read; /**< Next position to be read */ > > > > > +#else > > > > > + unsigned write; /**< Next position to be written*/ > > > > > + unsigned read; /**< Next position to be read */ > > > > > +#endif > > > > > unsigned len; /**< Circular buffer length */ > > > > > unsigned elem_size; /**< Pointer size - for 32/64 bit OS */ > > > > > void *volatile buffer[]; /**< The buffer contains mbuf pointers */ > > > > > diff --git a/lib/librte_kni/rte_kni_fifo.h > > > > > b/lib/librte_kni/rte_kni_fifo.h index ac26a8c..f4171a1 100644 > > > > > --- a/lib/librte_kni/rte_kni_fifo.h > > > > > +++ b/lib/librte_kni/rte_kni_fifo.h > > > > > @@ -28,8 +28,13 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void > > > > > **data, unsigned num) { > > > > > unsigned i = 0; > > > > > unsigned fifo_write = fifo->write; > > > > > - unsigned fifo_read = fifo->read; > > > > > unsigned new_write = fifo_write; > > > > > +#ifdef RTE_USE_C11_MEM_MODEL > > > > > + unsigned fifo_read = __atomic_load_n(&fifo->read, > > > > > + > > > > > +__ATOMIC_ACQUIRE); #else > > > > > + unsigned fifo_read = fifo->read; #endif > > > > > > > > Correct. > > > > > > My apologies, did not follow your comment here. Do you want us to correct > > anything here? '#endif' is not appearing on the correct line in the email, but it > > shows up fine on the patch work. > > > > No. What I meant is, code is correct. > > > > > > > > > > > > > > > > > > > > > > > for (i = 0; i < num; i++) { > > > > > new_write = (new_write + 1) & (fifo->len - 1); @@ > > > > > -39,7 +44,12 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void > > > > > **data, > > > > unsigned num) > > > > > fifo->buffer[fifo_write] = data[i]; > > > > > fifo_write = new_write; > > > > > } > > > > > +#ifdef RTE_USE_C11_MEM_MODEL > > > > > + __atomic_store_n(&fifo->write, fifo_write, > > > > > +__ATOMIC_RELEASE); #else > > > > > + rte_smp_wmb(); > > > > > fifo->write = fifo_write; > > > > > +#endif > > > > > > > > Correct. > > > > > return i; > > > > > } > > > > > > > > > > @@ -51,7 +61,12 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void > > > > > **data, unsigned num) { > > > > > unsigned i = 0; > > > > > unsigned new_read = fifo->read; > > > > > +#ifdef RTE_USE_C11_MEM_MODEL > > > > > + unsigned fifo_write = __atomic_load_n(&fifo->write, > > > > > +__ATOMIC_ACQUIRE); #else > > > > > unsigned fifo_write = fifo->write; > > > > > +#endif > > > > > > > > Correct. > > > > > > > > > + > > > > > for (i = 0; i < num; i++) { > > > > > if (new_read == fifo_write) > > > > > break; > > > > > @@ -59,7 +74,12 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void > > > > > **data, > > > > unsigned num) > > > > > data[i] = fifo->buffer[new_read]; > > > > > new_read = (new_read + 1) & (fifo->len - 1); > > > > > } > > > > > +#ifdef RTE_USE_C11_MEM_MODEL > > > > > + __atomic_store_n(&fifo->read, new_read, __ATOMIC_RELEASE); > > > > > +#else > > > > > + rte_smp_wmb(); > > > > > fifo->read = new_read; > > > > > +#endif > > > > > > > > Correct. > > > > > > > > > return i; > > > > > } > > > > > > > > > > @@ -69,5 +89,13 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void > > > > > **data, unsigned num) static inline uint32_t > > > > > kni_fifo_count(struct rte_kni_fifo *fifo) { > > > > > +#ifdef RTE_USE_C11_MEM_MODEL > > > > > + unsigned fifo_write = __atomic_load_n(&fifo->write, > > > > > + __ATOMIC_ACQUIRE); > > > > > + unsigned fifo_read = __atomic_load_n(&fifo->read, > > > > > + > > > > > +__ATOMIC_ACQUIRE); > > > > > > > > Isn't too heavy to have two __ATOMIC_ACQUIREs? a simple > > > > rte_smp_rmb() would be enough here. Right? > > > > or > > > > Do we need __ATOMIC_ACQUIRE for fifo_write case? > > > > > > > We also had some amount of debate internally on this: > > > 1) We do not want to use rte_smp_rmb() as we want to keep the memory > > models separated (for ex: while using C11, use C11 everywhere). It is also not > > sufficient, please see 3) below. > > > > But Nothing technically wrong in using rte_smp_rmb() here in terms > > functionally and code generated by the compiler. > > rte_smp_rmb() generates 'DMB ISHLD'. This works fine, but it is not optimal. 'LDAR' is a better option which is generated when C11 atomics are used. Yes. But which one is optimal 1 x DMB ISHLD vs 2 x LDAR ? > > > > > > 2) This API can get called from writer or reader, so both the loads > > > have to be __ATOMIC_ACQUIRE > > > 3) Other option is to use __ATOMIC_RELAXED. That would allow any > > loads/stores around of this API to get reordered, especially since this is an > > inline function. This would put burden on the application to manage the > > ordering depending on its usage. It will also require the application to > > understand the implementation of this API. > > > > __ATOMIC_RELAXED may be fine too for _count() case as it may not very > > important to get the exact count for the exact very moment, Application can > > retry. > > > > I am in favor of performance effective implementation. > > The requirement on the correctness of the count depends on the usage of this function. I see the following usage: > > In the file kni_net.c, function: kni_net_tx: > > if (kni_fifo_free_count(kni->tx_q) == 0 || > kni_fifo_count(kni->alloc_q) == 0) { > /** > * If no free entry in tx_q or no entry in alloc_q, > * drops skb and goes out. > */ > goto drop; > } > > There is no retry here, the packet is dropped. OK. Then pick an implementation which is an optimal this case. I think, then rte_smp_rmb() makes sense here as a) no #ifdef clutter b) it is optimal compared to 2 x LDAR > > > > > > > > > > > > > > Other than that, I prefer to avoid ifdef clutter by introducing two > > > > separate file just like ring C11 implementation. > > > > > > > > I don't have strong opinion on this this part, I let KNI MAINTAINER > > > > to decide on how to accommodate this change. > > > > > > I prefer to change this as well, I am open for suggestions. > > > Introducing two separate files would be too much for this library. A better > > way would be to have something similar to 'smp_store_release' provided by > > the kernel. i.e. create #defines for loads/stores. Hide the clutter behind the > > #defines. > > > > No Strong opinion on this, leaving to KNI Maintainer. > Will wait on this before re-spinning the patch > > > > > This patch needs to split by two, > > a) Fixes for non C11 implementation(i.e new addition to rte_smp_wmb()) > > b) add support for C11 implementation. > Agree > > > > > > > > > > > > > > > + return (fifo->len + fifo_write - fifo_read) & (fifo->len - > > > > > +1); #else > > > > > return (fifo->len + fifo->write - fifo->read) & (fifo->len > > > > > - 1); > > > > > +#endif > > > > > } > > > > > -- > > > > > 2.7.4 > > > > >