Re: Network shutdown under load

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

 



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 <toml@xxxxxxxxxx>
> Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>

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~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux