From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id CE68D5F1A for ; Thu, 22 Nov 2018 13:55:04 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2018 04:55:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,265,1539673200"; d="scan'208";a="98245175" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2018 04:55:02 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 22 Nov 2018 04:55:02 -0800 Received: from lcsmsx154.ger.corp.intel.com (10.186.165.229) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 22 Nov 2018 04:55:01 -0800 Received: from hasmsx105.ger.corp.intel.com ([169.254.1.193]) by LCSMSX154.ger.corp.intel.com ([169.254.7.79]) with mapi id 14.03.0415.000; Thu, 22 Nov 2018 14:54:59 +0200 From: "Stojaczyk, Dariusz" To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: "dev@dpdk.org" , "thomas@monjalon.net" Thread-Topic: [PATCH v2] dev: don't remove devargs that are still referenced Thread-Index: AQHUgdNiLC2QgJK9JE2tNuSKHcAS4KVbbX8AgABII1A= Date: Thu, 22 Nov 2018 12:54:58 +0000 Message-ID: References: <20181121183750.33796-1-dariusz.stojaczyk@intel.com> <20181121193827.62540-1-dariusz.stojaczyk@intel.com> <20181122095420.kmxulb6jpwblbkbd@bidouze.vm.6wind.com> In-Reply-To: <20181122095420.kmxulb6jpwblbkbd@bidouze.vm.6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjY2YmU5MjEtMDQ2MC00ZDNkLTg5Y2QtZTg5NzI2MmJkNzk1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiS3hWVGpOMWtXdlJXVjF2cnA0S1FveFU1SmVsXC9tWmthYmJyTW1jSXEzeTVnazg5Rk16a3JDZWZXQXgyeHlrK2wifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.102.11.35] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] dev: don't remove devargs that are still referenced 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: Thu, 22 Nov 2018 12:55:05 -0000 > -----Original Message----- > From: Ga=EBtan Rivet [mailto:gaetan.rivet@6wind.com] > Sent: Thursday, November 22, 2018 10:54 AM > To: Stojaczyk, Dariusz > Cc: dev@dpdk.org; thomas@monjalon.net > Subject: Re: [PATCH v2] dev: don't remove devargs that are still referenc= ed >=20 > On Wed, Nov 21, 2018 at 08:38:27PM +0100, Darek Stojaczyk wrote: > > Even if a device failed to plug, it's still a device > > object that references the devargs. Those devargs will > > be freed automatically together with the device, but > > freeing them any earlier - like it's done in the hotplug > > error handling path right now - will give us a dangling > > pointer and a segfault scenario. > > > > Consider the following case: > > * secondary process receives the hotplug request IPC message > > * devargs are either created or updated > > * the bus is scanned > > * a new device object is created with the latest devargs > > * the device can't be plugged for whatever reason, > > bus->plug returns error > > * the devargs are freed, even though they're still referenced > > by the device object on the bus > > > > For PCI devices, the generic device name comes from > > a buffer within the devargs. Freeing those will make > > EAL segfault whenever the device name is checked. > > > > This patch just prevents the hotplug error handling > > path from removing the devargs when there's a device > > that references them. This is done by simply exiting > > early from the hotplug function. As mentioned in the > > beginning, those devargs will be freed later, together > > with the device itself. > > >=20 > This seems ok in conjunction with Thomas' patch on overwriting devargs > on insertion. >=20 > The only place a device will be freed is the unplug bus ops, it already > does remove the device devargs. >=20 > > Fixes: 7e8b26650146 ("eal: fix hotplug add / remove") > > Cc: gaetan.rivet@6wind.com > > Cc: thomas@monjalon.net > > > > Signed-off-by: Darek Stojaczyk > > --- > > lib/librte_eal/common/eal_common_dev.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_eal/common/eal_common_dev.c > b/lib/librte_eal/common/eal_common_dev.c > > index 1fdc9ab17..b6fc5e437 100644 > > --- a/lib/librte_eal/common/eal_common_dev.c > > +++ b/lib/librte_eal/common/eal_common_dev.c > > @@ -169,11 +169,10 @@ local_dev_probe(const char *devargs, struct > rte_device **new_dev) > > > > ret =3D dev->bus->plug(dev); > > if (ret) { > > - if (rte_dev_is_probed(dev)) /* if already succeeded earlier > */ > > - return ret; /* no rollback */ > > - RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", > > - dev->name); > > - goto err_devarg; > > + if (!rte_dev_is_probed(dev)) /* if hasn't succeeded earlier */ > > + RTE_LOG(ERR, EAL, "Driver cannot attach the device > (%s)\n", > > + dev->name); >=20 > Maybe a comment here to describe that the devargs is still the > responsibility of the rte_device and should not be removed. Ack, I'll do that. >=20 > > + return ret; > > } > > > > *new_dev =3D dev; > > -- > > 2.17.1 > > >=20 > -- > Ga=EBtan Rivet > 6WIND