DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Tetsuya Mukawa <mukawa@igel.co.jp>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 2/3] vhost: Fix RESET_OWNER handling not to close callfd
Date: Thu, 8 Oct 2015 14:19:47 +0800	[thread overview]
Message-ID: <20151008061947.GC3115@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1439977869-28091-2-git-send-email-mukawa@igel.co.jp>

On Wed, Aug 19, 2015 at 06:51:08PM +0900, Tetsuya Mukawa wrote:
> When RESET_OWNER message is issued, vhost backend shouldn't close
> 'callfd', because it will be valid while vhost-user connection
> is established. It should be closed when connection is closed.

Doesn't it mean the end of connection when RESET_OWNER is received?

If you check my latest patch set for enabling vhost mq, you will
find free_device() will be invoked immediately once RESET_OWNER
signal is received.

    http://dpdk.org/ml/archives/dev/2015-September/023752.html

So, I doubt this patch is necessary.

BTW, does these 3 patches fix a real issue, or just some potential
issue in your mind? I saw that you mentioned your vhost pmd won't
work without those 3 patches, but I never saw you mentioned what
issue you fixed exactly. And it'd be good if you can post them in
commit log.

And, if we encounter same issue, will my above patch fix yours?

	--yliu
> 
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> ---
>  lib/librte_vhost/virtio-net.c | 35 ++++++++++++++++++++++++-----------
>  1 file changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
> index 144f301..7794e8b 100644
> --- a/lib/librte_vhost/virtio-net.c
> +++ b/lib/librte_vhost/virtio-net.c
> @@ -189,13 +189,9 @@ cleanup_device(struct virtio_net *dev)
>  		free(dev->mem);
>  	}
>  
> -	/* Close any event notifiers opened by device. */
> -	if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
> -		close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);
> +	/* Close kickfd event notifiers opened by device. */
>  	if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0)
>  		close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd);
> -	if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0)
> -		close((int)dev->virtqueue[VIRTIO_TXQ]->callfd);
>  	if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0)
>  		close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd);
>  }
> @@ -206,6 +202,12 @@ cleanup_device(struct virtio_net *dev)
>  static void
>  free_device(struct virtio_net_config_ll *ll_dev)
>  {
> +	/* close callfd when connection is closed */
> +	if ((int)ll_dev->dev.virtqueue[VIRTIO_RXQ]->callfd >= 0)
> +		close((int)ll_dev->dev.virtqueue[VIRTIO_RXQ]->callfd);
> +	if ((int)ll_dev->dev.virtqueue[VIRTIO_TXQ]->callfd >= 0)
> +		close((int)ll_dev->dev.virtqueue[VIRTIO_TXQ]->callfd);
> +
>  	/* Free any malloc'd memory */
>  	rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]);
>  	rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]);
> @@ -241,6 +243,21 @@ rm_config_ll_entry(struct virtio_net_config_ll *ll_dev,
>  	}
>  }
>  
> +
> +/*
> + *  Rset variables in device structure.
> + */
> +static void
> +reset_device(struct virtio_net *dev)
> +{
> +	dev->virtqueue[VIRTIO_RXQ]->kickfd = (eventfd_t)-1;
> +	dev->virtqueue[VIRTIO_TXQ]->kickfd = (eventfd_t)-1;
> +
> +	/* Backends are set to -1 indicating an inactive device. */
> +	dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED;
> +	dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED;
> +}
> +
>  /*
>   *  Initialise all variables in device structure.
>   */
> @@ -261,14 +278,10 @@ init_device(struct virtio_net *dev)
>  	memset(dev->virtqueue[VIRTIO_RXQ], 0, sizeof(struct vhost_virtqueue));
>  	memset(dev->virtqueue[VIRTIO_TXQ], 0, sizeof(struct vhost_virtqueue));
>  
> -	dev->virtqueue[VIRTIO_RXQ]->kickfd = (eventfd_t)-1;
>  	dev->virtqueue[VIRTIO_RXQ]->callfd = (eventfd_t)-1;
> -	dev->virtqueue[VIRTIO_TXQ]->kickfd = (eventfd_t)-1;
>  	dev->virtqueue[VIRTIO_TXQ]->callfd = (eventfd_t)-1;
>  
> -	/* Backends are set to -1 indicating an inactive device. */
> -	dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED;
> -	dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED;
> +	reset_device(dev);
>  }
>  
>  /*
> @@ -403,7 +416,7 @@ reset_owner(struct vhost_device_ctx ctx)
>  	ll_dev = get_config_ll_entry(ctx);
>  
>  	cleanup_device(&ll_dev->dev);
> -	init_device(&ll_dev->dev);
> +	reset_device(&ll_dev->dev);
>  
>  	return 0;
>  }
> -- 
> 2.1.4

  reply	other threads:[~2015-10-08  6:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  9:51 [dpdk-dev] [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message Tetsuya Mukawa
2015-08-19  9:51 ` [dpdk-dev] [PATCH 2/3] vhost: Fix RESET_OWNER handling not to close callfd Tetsuya Mukawa
2015-10-08  6:19   ` Yuanhan Liu [this message]
2015-08-19  9:51 ` [dpdk-dev] [PATCH 3/3] vhost: Fix RESET_OWNER handling not to free virtqueue Tetsuya Mukawa
2015-09-25 13:12 ` [dpdk-dev] [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message Thomas Monjalon
2015-09-28  6:38   ` Xie, Huawei

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=20151008061947.GC3115@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=mukawa@igel.co.jp \
    /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).