From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C05352BE9 for ; Mon, 23 Jan 2017 14:06:11 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 23 Jan 2017 05:06:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,274,1477983600"; d="scan'208";a="812239068" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jan 2017 05:06:09 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.38]) by IRSMSX151.ger.corp.intel.com ([169.254.4.20]) with mapi id 14.03.0248.002; Mon, 23 Jan 2017 13:06:08 +0000 From: "Ananyev, Konstantin" To: Yuanhan Liu CC: "Yigit, Ferruh" , "dev@dpdk.org" , Thomas Monjalon , "Horton, Remy" Thread-Topic: [dpdk-dev] [PATCH] ethdev: fix wrong memset Thread-Index: AQHScvOtHWgM/Usc+U6FGskIrqD3PKFBOMAAgABE1YCAAk+ygIACBpeAgAAOuYCAAAizgIAABWeAgAACIoCAAAJcAIAABEkAgAALNhCAAASmAIAAAWag Date: Mon, 23 Jan 2017 13:06:07 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583F10A841@irsmsx105.ger.corp.intel.com> References: <4d897cf9-f1f4-d924-10cd-63e95b12b411@intel.com> <20170122024529.GZ10293@yliu-dev.sh.intel.com> <3451afa6-12fb-dc65-f379-873facc0301c@intel.com> <20170123103417.GB10293@yliu-dev.sh.intel.com> <53a23156-dcb9-b41f-c27c-5bd13d5874f6@intel.com> <20170123112445.GE10293@yliu-dev.sh.intel.com> <90752e37-444b-e2bf-6d4b-1bf2eda38deb@intel.com> <20170123114050.GF10293@yliu-dev.sh.intel.com> <20170123115610.GG10293@yliu-dev.sh.intel.com> <2601191342CEEE43887BDE71AB9772583F10A80C@irsmsx105.ger.corp.intel.com> <20170123125256.GH10293@yliu-dev.sh.intel.com> In-Reply-To: <20170123125256.GH10293@yliu-dev.sh.intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset 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, 23 Jan 2017 13:06:12 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Monday, January 23, 2017 12:53 PM > To: Ananyev, Konstantin > Cc: Yigit, Ferruh ; dev@dpdk.org; Thomas Monjalon= ; Horton, Remy > > Subject: Re: [dpdk-dev] [PATCH] ethdev: fix wrong memset >=20 > On Mon, Jan 23, 2017 at 12:44:11PM +0000, Ananyev, Konstantin wrote: > > > On Mon, Jan 23, 2017 at 07:40:50PM +0800, Yuanhan Liu wrote: > > > > On Mon, Jan 23, 2017 at 11:32:23AM +0000, Ferruh Yigit wrote: > > > > > On 1/23/2017 11:24 AM, Yuanhan Liu wrote: > > > > > > On Mon, Jan 23, 2017 at 11:05:25AM +0000, Ferruh Yigit wrote: > > > > > >>>>>>>> lib/librte_ether/rte_ethdev.c | 2 +- > > > > > >>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > >>>>>>>> > > > > > >>>>>>>> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_= ether/rte_ethdev.c > > > > > >>>>>>>> index 4790faf..61f44e2 100644 > > > > > >>>>>>>> --- a/lib/librte_ether/rte_ethdev.c > > > > > >>>>>>>> +++ b/lib/librte_ether/rte_ethdev.c > > > > > >>>>>>>> @@ -225,7 +225,7 @@ struct rte_eth_dev * > > > > > >>>>>>>> return NULL; > > > > > >>>>>>>> } > > > > > >>>>>>>> > > > > > >>>>>>>> - memset(&rte_eth_devices[port_id], 0, sizeof(*eth_dev->= data)); > > > > > >>>>>>>> + memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rt= e_eth_dev_data)); > > > > > >>>>>>> > > > > > >>>>>>> Not directly related to the this issue, but, after fix, t= his may have > > > > > >>>>>>> issues with secondary process. > > > > > >>>>>>> > > > > > >>>>>>> There were patches sent to fix this. > > > > > >>>>>> > > > > > >>>>>> I mean this one: > > > > > >>>>>> http://dpdk.org/ml/archives/dev/2017-January/054422.html > > > > > >>>>> > > > > > >>>>> d948f596fee2 ("ethdev: fix port data mismatched in multiple= process > > > > > >>>>> model") should have fixed it. > > > > > >>>> > > > > > >>>> Think about case, where secondary process uses a virtual PMD= , which does > > > > > >>>> a rte_eth_dev_allocate() call, shouldn't this corrupt primar= y process > > > > > >>>> device data? > > > > > >>> > > > > > >>> Yes, it may. However, I doubt that's the typical usage. > > > > > >> > > > > > >> But this is a use case, and broken now, > > > > > > > > > > > > I thought it was broken since the beginning? > > > > > > > > > > No, memset(&rte_eth_dev_data[port_id], ...) breaks it. > > > > > > > > Oh, you were talking about that particular case Remy's patch meant = to > > > > fix. > > > > > > > > > >> and fix is known. > > > > > > > > > > > > And there is already a fix? > > > > > > > > > > http://dpdk.org/ml/archives/dev/2017-January/054422.html > > > > > > > > Yes, it should fix that issue. > > > > > > Well, few more thoughts: it may fix the crash issue Remy saw, but it > > > looks like more a workaround to me. Basically, if primary and seconda= ry > > > shares a same port id, they should point to same device. Otherwise, > > > primary process may use eth_dev->data for a device A, while the > > > secondary process may use it for another device, as you said, it > > > could be a vdev. > > > > > > In such case, there is no way we could continue safely. That said, > > > the given patch avoids the total reset of eth_dev->data, while it > > > continues reset the eth_dev->data->name, which is wrong. > > > > > > So it's not a proper fix. > > > > > > Again, I think it's more about the usage. If primary starts with > > > a nic device A, while the secondary starts with a nic device B, > > > there is no way they could work well (unless they use different > > > port id). > > > > Why not? > > I think this is possible. >=20 > Yes, it's possible: find another port id if that one is already taken > by primary process (or even by secondary process: think that primary > process might attatch a port later). >=20 > > They just need to be initialized properly, > > so each rte_eth_devices[port_id]->data, etc. point to the right place. >=20 > My understanding is, as far as they use different port_id, it might > be fine. Just not sure it's enough or not. As I understand, the main problem is that rte_eth_devices[] is local, while rte_eth_dev_data points to the shared memory array. And rte_eth_dev_allocate() assumes that if rte_eth_devices[x] is free, then rte_eth_dev_data[port_id] is also free. Which is wrong in case when primary/secondary processes have different devi= ces attached. Another problem is that inside rte_ethdev.c we manipulate rte_eth_dev_data[= ] contents without grabbing any lock. I think it was an attempt to fix that issue in 16.07 timeframe or so, but I don't remember what happened with that patch. Konstantin=20