qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: Network shutdown under load


From: Herbert Xu
Subject: [Qemu-devel] Re: Network shutdown under load
Date: Tue, 9 Feb 2010 08:18:46 +1100
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, Feb 08, 2010 at 10:10:01AM -0600, Tom Lendacky wrote:
> 
> Fix a race condition where qemu finds that there are not enough virtio
> ring buffers available and the guest make more buffers available before
> qemu can enable notifications.
> 
> Signed-off-by: Tom Lendacky <address@hidden>
> Signed-off-by: Anthony Liguori <address@hidden>

Good cath!
 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 6e48997..5c0093e 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -379,7 +379,15 @@ static int virtio_net_has_buffers(VirtIONet *n, int 
> bufsize)
>          (n->mergeable_rx_bufs &&
>           !virtqueue_avail_bytes(n->rx_vq, bufsize, 0))) {
>          virtio_queue_set_notification(n->rx_vq, 1);
> -        return 0;
> +
> +        /* To avoid a race condition where the guest has made some buffers
> +         * available after the above check but before notification was
> +         * enabled, check for available buffers again.
> +         */

We should also add a full memory barrier right here to avoid
out-of-order loads.

> +        if (virtio_queue_empty(n->rx_vq) ||
> +            (n->mergeable_rx_bufs &&
> +             !virtqueue_avail_bytes(n->rx_vq, bufsize, 0)))
> +            return 0;
>      }

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <address@hidden>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]