From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50042.outbound.protection.outlook.com [40.107.5.42]) by dpdk.org (Postfix) with ESMTP id 15265F11 for ; Wed, 29 Aug 2018 06:59:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QkNPKSikTLnlMNTtwjcXRmVVWELKxoLkQ3U3VR0gv+Q=; b=PkfPl26uOaWHn/ZFqx/D2kNE1hP5qb8dZRrYQ/nC6nW7LgOJouPtfL2U3PZS4/6cloAvWMZWdwH6CordNAz9YJ+KYs+j9fa+gk51ab2auDp0hRIMA8vwkBa5quoM4j8FqDLc/N3AF8SeOZtu+qb7AJYtQLl5EdDHi7TLP6pJtEM= Received: from AM6PR08MB3672.eurprd08.prod.outlook.com (20.177.115.29) by AM6PR08MB3014.eurprd08.prod.outlook.com (52.135.163.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 04:59:18 +0000 Received: from AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::649b:b10d:ef69:7fd2]) by AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::649b:b10d:ef69:7fd2%4]) with mapi id 15.20.1080.015; Wed, 29 Aug 2018 04:59:18 +0000 From: Honnappa Nagarahalli To: Gavin Hu , "Kokkilagadda, Kiran" , Ferruh Yigit , "Jacob, Jerin" CC: "dev@dpdk.org" , nd , Ola Liljedahl , Steve Capper Thread-Topic: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer synchronization Thread-Index: AQHUNUdKDAxxlajx7EqxtswFT/Xr1aTTtAyAgAAZYECAAUATgIAAj0wggACeoyA= Date: Wed, 29 Aug 2018 04:59:18 +0000 Message-ID: References: <1533810233-7706-1-git-send-email-kkokkilagadda@caviumnetworks.com> <1534413317-644-1-git-send-email-kkokkilagadda@caviumnetworks.com> <649064d2-430c-d761-44ce-453e1a14031a@intel.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR08MB3014; 6:GCPL4glM4NPn8aT1safzPNXtDEgoAQpwtTOVvghOg1sHnnLxr1SPq2bKweUB/J1MhaJ721y+7EeMtAad9/yB4kDNjnueBhxlqOD+4xPYYuCgypXpkZxzpKMLAVX34Dh1Vx9B/63HfwMc47i/XAzqWmIZMS+oKo3iiIe1RAPBd6DR9BUjMLYOXlazcEsFyfHMwJmXYiRR4YnXOo6tBIWcA5wucOp72wMKHI23FtS1giO0j2T96AWXo7ZKwlSMuZB/Ndni83Y41ri/qHKylKVds44qqJ2wGundFXC6X2q0DovVZ7DCS8VOaZsZzI+0nHw3ZSnkPT95Ho5SZLf5tYOOFEkpXslNCVBBYgVJeHyER344LN+vbus5laL1nM2MZrbOhenngOZ+uiMInzEhVAdagrmGYbwpbe3IQPcp+YKJcGy2qKWtJ5NpDsd1aLqnIl6fapEgsJ62EPdV7WjB1jMAVA==; 5:MGFgG6n+N6mv8oEn5LxBOCO6znV0vc0tzeWGxS+TVz2qsjEYL5lwWpinYyYUIlvPQSr4864M+N0f3Falq1hIL/HX0c5zNDCenZ8VMd6m7XWCFFLKN67McgYInwVD5DYzIT5g8KzZLYq5HI8sbiH8FJTWyLHtvoLVFfqQrZCizd4=; 7:CP5le8J1pO4UAvtWuwNZB4SbJJinTwsi4+61hMaijOli349sY1RIqR0hIKV18UiU+Ixem/h9xETZbmp/3hBfFE0VQI6WabdFe3OSbTADrP/XeoHN+Z0Rgcb8OMOM7Xb2+7MoyIoKRzB2HYLW/Mq3QyvzLe4kp146qI7bAp4UA/qK9ySA4eSXCeuxslwHJ/t1tZR000+MMC9heP+5LS6eVJFtvWIX2ElenQj08gLvunlSjovSwoiVr3DVpE/Fo/zX x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: abdf0294-da11-478b-9ca1-08d60d6c2d21 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR08MB3014; x-ms-traffictypediagnostic: AM6PR08MB3014: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(21748063052155)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016); SRVR:AM6PR08MB3014; BCL:0; PCL:0; RULEID:; SRVR:AM6PR08MB3014; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(39860400002)(376002)(346002)(13464003)(40434004)(199004)(189003)(7696005)(8676002)(7736002)(6306002)(54896002)(74316002)(2906002)(26005)(3846002)(256004)(5024004)(68736007)(14444005)(33656002)(53936002)(9686003)(5250100002)(486006)(446003)(229853002)(6246003)(11346002)(14454004)(6116002)(72206003)(5660300001)(4326008)(476003)(236005)(55016002)(6436002)(478600001)(790700001)(54906003)(106356001)(66066001)(93886005)(86362001)(99286004)(105586002)(110136005)(81166006)(316002)(6506007)(81156014)(25786009)(97736004)(8936002)(2900100001)(102836004)(76176011)(53546011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3014; H:AM6PR08MB3672.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: U0Xz4/v0I/suKPHlivVca2WRAnKIf0KCFgWN+iGl2Ch7v87yvVt07l+5o8FgIKwju0z7Mn39VBoJ8fTtmRXuJoSazYiF8NHHkgxO26SX2Yj2I6USMtF1xeLACxxpTifoiQcUhdBXU/18Sr0fWDmm6oPW6KFYskLgisGxMHHr+D+xu6R7Wyw14JRikZNyOB7uu62xtuV5r3WRj5nKo3O78c8Wa7eS9N/QC+eIG102hmwwCoKa47tJKZEkjX79SKIq8SF2q2W6cI3Af1bB2RJU8VEqtL+cxQFiCe2tC9Y1TRrkefoeTr/zyuB+O/otaIr2mnlhVbJZFMdyHckxnlxH/8RTu1b+QHLuMPTfsEXFxdI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: abdf0294-da11-478b-9ca1-08d60d6c2d21 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 04:59:18.2689 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3014 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer 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: Wed, 29 Aug 2018 04:59:20 -0000 I agree with Gavin here. Store to fifo->write and fifo->read can get hoiste= d resulting in accessing invalid buffer array entries or over writing of th= e buffer array entries. IMO, we should solve this using c11 atomics. This will also help remove the= use of 'volatile' from 'rte_kni_fifo' structure. If you want us to put together a patch with this idea, please let us know. Thank you, Honnappa From: Gavin Hu Sent: Tuesday, August 28, 2018 2:31 PM To: Kokkilagadda, Kiran ; Ferruh Yigit ; Jacob, Jerin Cc: dev@dpdk.org; Honnappa Nagarahalli ; nd <= nd@arm.com>; Ola Liljedahl ; Steve Capper Subject: RE: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer synchroniz= ation Assuming reader and writer may execute on different CPU's, this become stan= dard multithreaded programming. We are concerned about that update the reader pointer too early(weak orderi= ng may reorder it before reading from the slots), that means the slots are = released and may immediately overwritten by the writer then you get "too ne= w" data and get lost of the old data. From: Kokkilagadda, Kiran > Sent: Tuesday, August 28, 2018 6:44 PM To: Gavin Hu >; Ferruh Yigit >; Jacob, Jerin > Cc: dev@dpdk.org; Honnappa Nagarahalli > Subject: Re: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer synchroniz= ation In this instance there won't be any problem, as until the value of fifo->wr= ite changes, this loop won't get executed. As of now we didn't see any issu= e with it and for performance reasons, we don't want to keep read barrier. ________________________________ From: Gavin Hu > Sent: Monday, August 27, 2018 9:10 PM To: Ferruh Yigit; Kokkilagadda, Kiran; Jacob, Jerin Cc: dev@dpdk.org; Honnappa Nagarahalli Subject: RE: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer synchroniz= ation External Email This fix is not complete, kni_fifo_get requires a read fence also, otherwis= e it probably gets stale data on a weak ordering platform. > -----Original Message----- > From: dev > On Behalf O= f Ferruh Yigit > Sent: Monday, August 27, 2018 10:08 PM > To: Kiran Kumar >; > jerin.jacob@caviumnetworks.com > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v2] kni: fix kni Rx fifo producer > synchronization > > On 8/16/2018 10:55 AM, Kiran Kumar wrote: > > 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. So adding a write > > barrier to make sure the values being synced before updating fifo_write= . > > > > Fixes: 3fc5ca2f6352 ("kni: initial import") > > > > Signed-off-by: Kiran Kumar > > > Acked-by: Jerin Jacob > > > Acked-by: Ferruh Yigit > IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.