From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BE88B2B8B for ; Mon, 3 Jul 2017 10:38:48 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2017 01:38:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,302,1496127600"; d="scan'208";a="106481196" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 03 Jul 2017 01:38:46 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 3 Jul 2017 01:38:46 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 3 Jul 2017 01:38:46 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.56]) with mapi id 14.03.0319.002; Mon, 3 Jul 2017 16:38:43 +0800 From: "Tan, Jianfeng" To: Thomas Monjalon CC: "dev@dpdk.org" , "yuanhan.liu@linux.intel.com" , "maxime.coquelin@redhat.com" Thread-Topic: [dpdk-dev] [PATCH] eal: fix secondary process segfault on multipe virtio devices Thread-Index: AQHS27wWnBN+4TrkekmrZ4AIYzvFYKI+qfWAgANNyQA= Date: Mon, 3 Jul 2017 08:38:42 +0000 Message-ID: References: <1496420451-104928-1-git-send-email-jianfeng.tan@intel.com> <34094937.BVuX3fK5it@xps> In-Reply-To: <34094937.BVuX3fK5it@xps> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] eal: fix secondary process segfault on multipe virtio devices 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, 03 Jul 2017 08:38:49 -0000 HI Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Saturday, July 1, 2017 10:10 PM > To: Tan, Jianfeng > Cc: dev@dpdk.org; yuanhan.liu@linux.intel.com; > maxime.coquelin@redhat.com > Subject: Re: [dpdk-dev] [PATCH] eal: fix secondary process segfault on > multipe virtio devices >=20 > 02/06/2017 18:20, Jianfeng Tan: > > Suppose we have 2 virtio devices for a VM, with only the first one, > > virtio0, binding to igb_uio. Start a primary DPDK process, driving > > only virtio0. Then start a secondary DPDK process, it encounters > > segfault at eth_virtio_dev_init() because hw is NULL, when trying > > to initialize the 2nd virtio devices. > > 1539 if (!hw->virtio_user_dev) { > > > > We could add a precheck to return error when hw is NULL. But the > > root cause is that virtio devices which are not driven by the primary > > process are not exluded by secondary eal probe function. > > > > To support legacy virtio devices bound to none kernel driver, we > > removed RTE_PCI_DRV_NEED_MAPPING in > > commit 962cf902e6eb ("pci: export device mapping functions"). > > At the boot of primary process, ether dev is allocated in rte_eth_devic= es > > array, rte_eth_dev_data is also allocated in rte_eth_dev_data array; th= en > > probe function fails; and ether dev is released. However, the entry in > > rte_eth_dev_data array is not cleared. Then we start secondary process, > > and try to attach the virtio device that not used in primary process, > > the field, dev_private (or hw), in rte_eth_dev_data, is NULL. > > > > To fail the dev attach, we need to clear the field, name, when we > > release any ether devices in primary, so that below loop in > > rte_eth_dev_attach_secondary() will not find any matched names. > > for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) { > > if (strcmp(rte_eth_dev_data[i].name, name) =3D=3D 0) > > break; > > } > > > > Fixes: 6d890f8ab512 ("Fixes: net/virtio: fix multiple process support") >=20 > It probably needs to be Cc: stable@dpdk.org >=20 > > Reported-by: Reshma Pattan > > Signed-off-by: Jianfeng Tan > > --- > [...] > > eth_dev->data->dev_private =3D NULL; > > > > + /* Secondary process will use this field, name, for secondary attach, > > + * clear this field to avoid attaching any released ports in primary. > > + */ > > + memset(eth_dev->data->name, 0, RTE_ETH_NAME_MAX_LEN); >=20 > I think it may be sufficient to set an empty string: > eth_dev->data->name =3D '\0'; Thank you for the advice. And a new version has been sent. Thanks, Jianfeng