From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 19D465F19 for ; Tue, 27 Mar 2018 11:02:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 02:02:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,366,1517904000"; d="scan'208";a="31672403" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 27 Mar 2018 02:02:40 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Mar 2018 02:02:40 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Mar 2018 02:02:40 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.166]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.108]) with mapi id 14.03.0319.002; Tue, 27 Mar 2018 17:02:37 +0800 From: "Chen, Junjie J" To: "Tan, Jianfeng" , "maxime.coquelin@redhat.com" , "mtetsuyah@gmail.com" CC: "dev@dpdk.org" Thread-Topic: [PATCH] net/vhost: fix segfault when creating vdev dynamically Thread-Index: AQHTxaVqK0TRGPuZ3E2cc4yFY55MuqPjQbQAgACG9mA= Date: Tue, 27 Mar 2018 09:02:37 +0000 Message-ID: References: <1522166726-42025-1-git-send-email-junjie.j.chen@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTY4NjFjOTctOTA2NS00YmE2LTk3MzItYWVjYjNiNTUzNTM4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJzU2hxZWw0RG4xcXR2dlNuQUpWa2JFZjFIMkxYajdDNUxDb0hzOG1wUkhEaEtsZVZocllERDJOaFFNbFphNlpSIn0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/vhost: fix segfault when creating vdev dynamically 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: Tue, 27 Mar 2018 09:02:43 -0000 Hi Jianfeng > On 3/28/2018 12:05 AM, Junjie Chen wrote: > > when creating vdev dynamically, vhost pmd driver start directly > > without checking TX/RX queues ready or not, and thus cause > > segmentation fault when vhost library accessing queues. This patch add > > flag to check whether queues setup or not, and add driver start call > > into dev_start to allow user start it after setting up queue. >=20 > The issue is clear now. But this patch just puts the situation before bel= ow fix: > "it doesn't create the actual datagram socket until you call .dev_start()= ." No, if the queue exist, the datagram socket still get created in vhost_crea= te API, since the vhost_driver_register still exist in vhost_create. >=20 > To fix this issue, we might delay the queue setup until we really have qu= eues? >=20 > > Fixes: aed0b12930b33("net/vhost: fix socket file deleted on stop") >=20 > Missed the space between commit number and title. And we keep 12 > characters for the commit id. Thanks for reminder, will update in v2. >=20 > Thanks, > Jianfeng >=20 > > Signed-off-by: Junjie Chen > > --- > > drivers/net/vhost/rte_eth_vhost.c | 21 +++++++++++++++++++-- > > 1 file changed, 19 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/vhost/rte_eth_vhost.c > > b/drivers/net/vhost/rte_eth_vhost.c > > index 3aae01c..719a150 100644 > > --- a/drivers/net/vhost/rte_eth_vhost.c > > +++ b/drivers/net/vhost/rte_eth_vhost.c > > @@ -118,6 +118,7 @@ struct pmd_internal { > > char *iface_name; > > uint16_t max_queues; > > rte_atomic32_t started; > > + rte_atomic32_t once; > > }; > > > > struct internal_list { > > @@ -772,12 +773,24 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t > port_id) > > static int > > eth_dev_start(struct rte_eth_dev *dev) > > { > > + int ret =3D 0; > > struct pmd_internal *internal =3D dev->data->dev_private; > > > > + if (unlikely(rte_atomic32_read(&internal->once) =3D=3D 0)) { > > + ret =3D rte_vhost_driver_start(internal->iface_name); > > + if (ret < 0) { > > + RTE_LOG(ERR, PMD, "Failed to start driver for %s\n", > > + internal->iface_name); > > + return ret; > > + } > > + > > + rte_atomic32_set(&internal->once, 1); > > + } > > + > > rte_atomic32_set(&internal->started, 1); > > update_queuing_status(dev); > > > > - return 0; > > + return ret; > > } > > > > static void > > @@ -1101,7 +1114,11 @@ eth_dev_vhost_create(struct rte_vdev_device > *dev, char *iface_name, > > goto error; > > } > > > > - if (rte_vhost_driver_start(iface_name) < 0) { > > + if (!data->rx_queues || !data->tx_queues) { > > + RTE_LOG(INFO, PMD, > > + "TX/RX queue is not ready, driver will not start\n"); > > + rte_atomic32_set(&internal->once, 0); > > + } else if (rte_vhost_driver_start(iface_name) < 0) { > > RTE_LOG(ERR, PMD, "Failed to start driver for %s\n", > > iface_name); > > goto error;