netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dor Laor <dor.laor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Christian Borntraeger
	<borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH resent] virtio_net: Fix stalled inbound trafficon early packets
Date: Wed, 12 Dec 2007 01:34:30 +0200	[thread overview]
Message-ID: <475F1E86.8000503@qumranet.com> (raw)
In-Reply-To: <200712111627.21364.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>

Christian Borntraeger wrote:
> Am Dienstag, 11. Dezember 2007 schrieb Christian Borntraeger:
>   
>>> The way other physical NICs doing it is by dis/en/abling interrupt 
>>> using registers (look at e1000).
>>> I suggest we can export add_status and use the original code but
>>> before enabling napi add a call to add_status(dev, 
>>> VIRTIO_CONFIG_DEV_OPEN).
>>> The host won't trigger an irq until it sees the above.
>>>       
>> That would also work. We already have VRING_AVAIL_F_NO_INTERRUPT in
>> virtio_ring.c - maybe we can use that. Its hidden in callback and
>> restart handling, what about adding an explicit startup?
>>     
>
> Ok, just to give an example what I thought about:
> ---
>  drivers/block/virtio_blk.c   |    3 ++-
>  drivers/net/virtio_net.c     |    2 ++
>  drivers/virtio/virtio_ring.c |   16 +++++++++++++---
>  include/linux/virtio.h       |    5 +++++
>  4 files changed, 22 insertions(+), 4 deletions(-)
>
> Index: kvm/drivers/virtio/virtio_ring.c
> ===================================================================
> --- kvm.orig/drivers/virtio/virtio_ring.c
> +++ kvm/drivers/virtio/virtio_ring.c
> @@ -241,6 +241,16 @@ static bool vring_restart(struct virtque
>  	return true;
>  }
>  
> +static void vring_startup(struct virtqueue *_vq)
> +{
> +	struct vring_virtqueue *vq = to_vvq(_vq);
> +	START_USE(vq);
> +	if (vq->vq.callback)
> +		vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
> +	END_USE(vq);
> +}
> +
> +
>  irqreturn_t vring_interrupt(int irq, void *_vq)
>  {
>  	struct vring_virtqueue *vq = to_vvq(_vq);
> @@ -265,6 +275,7 @@ static struct virtqueue_ops vring_vq_ops
>  	.get_buf = vring_get_buf,
>  	.kick = vring_kick,
>  	.restart = vring_restart,
> +	.startup = vring_startup,
>  	.shutdown = vring_shutdown,
>  };
>  
> @@ -299,9 +310,8 @@ struct virtqueue *vring_new_virtqueue(un
>  	vq->in_use = false;
>  #endif
>  
> -	/* No callback?  Tell other side not to bother us. */
> -	if (!callback)
> -		vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
> +	/* disable interrupts until we enable them */
> +	vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
>  
>  	/* Put everything in free lists. */
>  	vq->num_free = num;
> Index: kvm/include/linux/virtio.h
> ===================================================================
> --- kvm.orig/include/linux/virtio.h
> +++ kvm/include/linux/virtio.h
> @@ -45,6 +45,9 @@ struct virtqueue
>   *	vq: the struct virtqueue we're talking about.
>   *	This returns "false" (and doesn't re-enable) if there are pending
>   *	buffers in the queue, to avoid a race.
> + * @startup: enable callbacks
> + *	vq: the struct virtqueue we're talking abount
> + *	Returns 0 or an error
>   * @shutdown: "unadd" all buffers.
>   *	vq: the struct virtqueue we're talking about.
>   *	Remove everything from the queue.
> @@ -67,6 +70,8 @@ struct virtqueue_ops {
>  
>  	bool (*restart)(struct virtqueue *vq);
>  
> +	void (*startup) (struct virtqueue *vq);
> +
>  	void (*shutdown)(struct virtqueue *vq);
>  };
>  
> Index: kvm/drivers/net/virtio_net.c
> ===================================================================
> --- kvm.orig/drivers/net/virtio_net.c
> +++ kvm/drivers/net/virtio_net.c
> @@ -292,6 +292,8 @@ static int virtnet_open(struct net_devic
>  		return -ENOMEM;
>  
>  	napi_enable(&vi->napi);
> +
> +	vi->rvq->vq_ops->startup(vi->rvq);
>  	return 0;
>  }
>  
> Index: kvm/drivers/block/virtio_blk.c
> ===================================================================
> --- kvm.orig/drivers/block/virtio_blk.c
> +++ kvm/drivers/block/virtio_blk.c
> @@ -183,7 +183,8 @@ static int virtblk_probe(struct virtio_d
>  		err = PTR_ERR(vblk->vq);
>  		goto out_free_vblk;
>  	}
> -
> +	/* enable interrupts */
> +	vblk->vq->vq_ops->startup(vblk->vq);
>  	vblk->pool = mempool_create_kmalloc_pool(1,sizeof(struct virtblk_req));
>  	if (!vblk->pool) {
>  		err = -ENOMEM;
>
>
>
> There is still one small problem: what if the host fills up all 
> host-to-guest buffers before we call startup? So I start to think that your 
> solution is better, given that the host is not only not sending interrupts 
>   
This is why initially I suggested another status code in order to split 
the ring logic with driver status.
> but also not filling any buffers as long as VIRTIO_CONFIG_DEV_OPEN is not 
> set. I will have a look but I think that add_status needs to be called 
>   
It can fill the buffers even without dev_open, when the dev is finally 
opened the host will issue an interrupt
if there are pending buffers. (I'm not sure it's worth solving, maybe 
just drop them like you suggested).
> after napi_enable, otherwise we have the same race.
>
>   
You're right, my mistake.
> Christian
>
>   


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

  parent reply	other threads:[~2007-12-11 23:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11 11:42 [PATCH resent] virtio_net: Fix stalled inbound traffic on early packets Christian Borntraeger
     [not found] ` <200712111242.28843.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-12-11 12:48   ` [PATCH resent] virtio_net: Fix stalled inbound trafficon " Dor Laor
     [not found]     ` <475E8716.2010500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-11 12:57       ` Dor Laor
     [not found]         ` <475E892D.9060400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-11 13:16           ` Christian Borntraeger
2007-12-12  1:54             ` [kvm-devel] " Rusty Russell
2007-12-12 11:39               ` Christian Borntraeger
2007-12-12 15:48                 ` Dor Laor
     [not found]                   ` <476002E7.5050301-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-12 18:14                     ` Christian Borntraeger
     [not found]                       ` <200712121914.38135.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-12-13 13:24                         ` Dor Laor
2007-12-13 18:30                           ` [kvm-devel] " Christian Borntraeger
     [not found]                             ` <200712131930.31602.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-12-18  6:54                               ` Rusty Russell
2007-12-11 13:19         ` [kvm-devel] " Christian Borntraeger
2007-12-11 15:27           ` Christian Borntraeger
     [not found]             ` <200712111627.21364.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-12-11 23:34               ` Dor Laor [this message]
2007-12-12 11:27                 ` Christian Borntraeger

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=475F1E86.8000503@qumranet.com \
    --to=dor.laor-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
    --cc=dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    /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).