From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80078.outbound.protection.outlook.com [40.107.8.78]) by dpdk.org (Postfix) with ESMTP id AFD601B4A0 for ; Wed, 10 Oct 2018 11:58:49 +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=S+eGYCDe6HbAmQW1zCEz9vJggMnBiUva4tCzjLEuHJ4=; b=AbG7CWLuLhNzR1grsviYJB7c1hF1QerJ0BdTALhqSBxuQOZCL/EhSsrxq0vtnK3pCz8AWOAV064T4N0sPnZMHxLOtiQ0mfnLSRXWGEdTz3fcs7E8LT2ZwBkokgUoqLsFcBoyYALLQ69tg8nuL7lfdu5+G0n6Uh9cNRInyUOroDc= Received: from DB7PR08MB3385.eurprd08.prod.outlook.com (20.176.238.90) by DB7PR08MB3531.eurprd08.prod.outlook.com (20.177.120.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.26; Wed, 10 Oct 2018 09:58:47 +0000 Received: from DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::eda0:7bf6:a891:3ae7]) by DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::eda0:7bf6:a891:3ae7%6]) with mapi id 15.20.1228.020; Wed, 10 Oct 2018 09:58:47 +0000 From: "Phil Yang (Arm Technology China)" To: Stephen Hemminger CC: "dev@dpdk.org" , "jerin.jacob@caviumnetworks.com" , "Gavin Hu (Arm Technology China)" , Honnappa Nagarahalli , Ola Liljedahl , "ferruh.yigit@intel.com" Thread-Topic: [dpdk-dev] [PATCH v3 2/4] kni: fix kni fifo synchronization Thread-Index: AQHUXub5PLUsehORa0CiD1WxmgKrMaUV5MoAgAJchFA= Date: Wed, 10 Oct 2018 09:58:47 +0000 Message-ID: References: <1537364560-4124-1-git-send-email-phil.yang@arm.com> <1538989906-8349-1-git-send-email-phil.yang@arm.com> <1538989906-8349-2-git-send-email-phil.yang@arm.com> <20181008145308.0fbc64de@xeon-e3> In-Reply-To: <20181008145308.0fbc64de@xeon-e3> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR08MB3531; 6:RW+8RCuYi66TqiHUsomAKqUBWGfYLBKyHe+I7lCCuAEee0lOQ5rpaVPcFmFkTMBXiFebZ1TfIRH2NPAFRMmXFL0LvJcZNaw4atWN+RWJ+Eja+SaNG4w0ajte5eteOy77kQHP8c50vbUCKA/Rd+ojtd8hejo1LKBIO/jjGw2gCOUc15VMERaIl5jwACpjuOemeMlX0i+uQpPLL+nesz8iAK0ygUy2jXGau7ELlSapVT2qK0goXHJQRJaOQAENYRT0Jqh14W7HSRXbDTzidYND/sA7E3PyoS0I08ucPBBL+Dfn78DQPTdl02iD9mlWJyGuL1fJZvQv2MskaFxhB8zi9OPV1mxUSZ7HvKoONuk+3GBqbqIIxfmldrWeKI1+hiTK+gBpbUZ65D8V7uLHSwM0FJQa8YYSOQBGzG5cE/YEFAwZSfGCHt7Y+H7rwc96OnS28I6eHHD4k/SpZfwwlfCmjg==; 5:XQ1+MFKR57cV41NeNYNRm9LFMnpKtWaMY47tTbmbCzgjW98UF1UAiQhnqVRACwvArKJgcK/Lse4ngnef6Mf5zElkMuU/xN7UfF2Fd1VLwqKHpvK45OPUZletwQsiqfZPQx8zcBO3iN/Psxmeb1TXUOe/pGRKVsVOw05hSBe8rxY=; 7:nBRsjqyxrdq9JReq+Uan8F4+Aaq4uh4ien6On/vFVPTq30+zhdoqjjoQQucisGKF3nVzOrOJJIX7umXEEmKUT/hfyT+Qfs7Ijv7MQdwui90TS/rIDpvCOSRIBNBZfmSTsb7+mLiVj3DiuhaSv8/8zeTTi9nO2N58/eu5Q8v/VDW3nLRgcPrAbpsajKokmX1Go0VroZKZ12UgnSmU9E2+uj+kaG1UL7socDSqhReeRc5c6bF75J1eHFpPAjH3UOxc x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 77c0906f-871a-4d0d-d729-08d62e96f8fd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR08MB3531; x-ms-traffictypediagnostic: DB7PR08MB3531: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699)(180628864354917); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:DB7PR08MB3531; BCL:0; PCL:0; RULEID:; SRVR:DB7PR08MB3531; x-forefront-prvs: 08213D42D3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(376002)(346002)(39860400002)(189003)(40434004)(13464003)(199004)(99286004)(26005)(186003)(7696005)(14454004)(54906003)(3846002)(5024004)(6116002)(76176011)(14444005)(33656002)(256004)(71200400001)(71190400001)(68736007)(7736002)(106356001)(74316002)(105586002)(5660300001)(305945005)(486006)(478600001)(86362001)(6506007)(53546011)(446003)(66066001)(2906002)(102836004)(55236004)(11346002)(476003)(72206003)(9686003)(55016002)(93886005)(53936002)(229853002)(8936002)(81156014)(8676002)(6436002)(81166006)(6246003)(4326008)(2900100001)(5250100002)(25786009)(316002)(97736004)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3531; H:DB7PR08MB3385.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HiQOxrzppPxxAerrzO7uE6gCKV/xXNs47g4zbr/H9xGZashxr52Ymprh0knvxt0va/VFdeoF45gVyE0EZpjP8AtzgDylG/QjeLlcyJ3PurnG4xoRbmQXWmvzUE1UYB8yTaYM/xfd7LkTZiIn51B/OBedfplImcbZC8mnM1VP8UpY7tHbH43Vq15MhYjo4aaexcN64F/TSGQR0kxjKcrDhjp5dhuqtFdy1Hk7f8lGang2mnTrj+Bqb2oAp7wnHGchbFLUaeAs9cI40Em5VDRzlQM4c9OECFcXGVd36s2JSqmdlyDRaPUYEV1eoCMP8xEJr3VlPNDOGu4NaihoSrsEGuhs5WfjH0z8pyrqBtfbJJg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77c0906f-871a-4d0d-d729-08d62e96f8fd X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2018 09:58:47.6090 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3531 Subject: Re: [dpdk-dev] [PATCH v3 2/4] 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: Wed, 10 Oct 2018 09:58:50 -0000 Hi Hemminger, > -----Original Message----- > From: Stephen Hemminger > Sent: Tuesday, October 9, 2018 5:53 AM > To: Phil Yang (Arm Technology China) > Cc: dev@dpdk.org; jerin.jacob@caviumnetworks.com; Gavin Hu (Arm > Technology China) ; Honnappa Nagarahalli > ; Ola Liljedahl ; > ferruh.yigit@intel.com > Subject: Re: [dpdk-dev] [PATCH v3 2/4] kni: fix kni fifo synchronization > > On Mon, 8 Oct 2018 17:11:44 +0800 > Phil Yang wrote: > > > diff --git a/lib/librte_kni/rte_kni_fifo.h > > b/lib/librte_kni/rte_kni_fifo.h index ac26a8c..70ac14e 100644 > > --- a/lib/librte_kni/rte_kni_fifo.h > > +++ b/lib/librte_kni/rte_kni_fifo.h > > @@ -28,8 +28,9 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, > > unsigned num) { > > unsigned i =3D 0; > > unsigned fifo_write =3D fifo->write; > > -unsigned fifo_read =3D fifo->read; > > unsigned new_write =3D fifo_write; > > +rte_smp_rmb(); > > +unsigned fifo_read =3D fifo->read; > > > > The patch makes sense, but this function should be changed to match kerne= l > code style. > That means no declarations after initial block, and use 'unsigned int' ra= ther than > 'unsigned' > > Also. why is i initialized? Best practice now is to not do gratitious ini= tialization > since it defeats compiler checks for accidental use of uninitialized var= iables. > > What makes sense is something like: > > kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) { > unsigned int i, fifo_read, fifo_write, new_write; > > fifo_write =3D fifo->write; > new_write =3D fifo_write; > rte_smb_rmb(); > fifo_read =3D fifo->read; > > Sorry, blaming you for issues which are inherited from original KNI code. > Maybe someone should run kernel checkpatch (not DPDK checkpatch) on it an= d > fix those. Thanks for your comment. I think I can submit a new separate patch to fix this historical issue. Thanks, Phil Yang 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.