DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Tan, Jianfeng" <jianfeng.tan@intel.com>
To: Junjie Chen <junjie.j.chen@intel.com>,
	maxime.coquelin@redhat.com, mtetsuyah@gmail.com
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/vhost: fix segfault when creating vdev dynamically
Date: Tue, 27 Mar 2018 16:56:54 +0800	[thread overview]
Message-ID: <f3d5f768-c1d9-011a-66ce-7c1402beae7e@intel.com> (raw)
In-Reply-To: <1522166726-42025-1-git-send-email-junjie.j.chen@intel.com>



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.

The issue is clear now. But this patch just puts the situation before 
below fix: "it doesn't create the actual datagram socket until you call 
.dev_start()."

To fix this issue, we might delay the queue setup until we really have 
queues?

> Fixes: aed0b12930b33("net/vhost: fix socket file deleted on stop")

Missed the space between commit number and title. And we keep 12 
characters for the commit id.

Thanks,
Jianfeng

> Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
> ---
>   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 = 0;
>   	struct pmd_internal *internal = dev->data->dev_private;
>   
> +	if (unlikely(rte_atomic32_read(&internal->once) == 0)) {
> +		ret = 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;

  reply	other threads:[~2018-03-27  8:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 16:05 Junjie Chen
2018-03-27  8:56 ` Tan, Jianfeng [this message]
2018-03-27  9:02   ` Chen, Junjie J
2018-03-27  9:10     ` Tan, Jianfeng
2018-03-27  9:24       ` Chen, Junjie J
2018-03-27  9:42         ` Tan, Jianfeng
2018-03-27 10:18           ` Chen, Junjie J
2018-03-27 13:54             ` Tan, Jianfeng
2018-03-27 11:28           ` Maxime Coquelin
2018-03-27 14:01             ` Tan, Jianfeng
2018-03-29 12:35               ` Maxime Coquelin
2018-03-29 15:35 ` [dpdk-dev] [PATCH v2] " Junjie Chen
2018-03-29 13:16   ` Maxime Coquelin
2018-03-30  6:58   ` [dpdk-dev] [PATCH v3] " Junjie Chen
2018-03-30  7:32     ` Yang, Zhiyong
2018-03-30  7:36       ` Maxime Coquelin
2018-03-30  7:35     ` Maxime Coquelin
2018-03-30  7:43     ` Maxime Coquelin
2018-04-09 12:37     ` Jens Freimann
2018-04-10  8:11       ` Chen, Junjie J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3d5f768-c1d9-011a-66ce-7c1402beae7e@intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=dev@dpdk.org \
    --cc=junjie.j.chen@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mtetsuyah@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).