Subject: Re: [PATCH RFC] virtio_net: use NAPI for xmit (UNTESTED)

From: Shirley Ma <[email-masked]>
Date: Wed, 31 Mar 2010 00:13:21 -0700

On Wed, 2010-03-31 at 14:29 +1030, Rusty Russell wrote:
> +static int virtnet_xmit_poll(struct napi_struct *xmit_napi, int
> budget)
> +{
> +       struct virtnet_info *vi =
> +               container_of(xmit_napi, struct virtnet_info,
> xmit_napi);
> +
> +       /* Don't access vq/capacity at same time as start_xmit. */
> +       __netif_tx_lock(netdev_get_tx_queue(vi->dev, 0),
> smp_processor_id());
> +
> +       vi->capacity += free_old_xmit_skbs(vi);
> +       if (vi->capacity >= 2 + MAX_SKB_FRAGS) {
> +               /* Suppress further xmit interrupts. */
> +               vi->svq->vq_ops->disable_cb(vi->svq);
> +               napi_complete(xmit_napi);
> +
> +               /* Don't wake it if link is down. */
> +               if (likely(netif_carrier_ok(vi->vdev)))

This should be if (likely(netif_carrier_ok(vi->dev)))

> +                       netif_wake_queue(vi->dev);
> +       }
> +
> +       __netif_tx_unlock(netdev_get_tx_queue(vi->dev, 0));
> +       return 1;
> +}
> + 

I tested the backport patch with vhost on, the initial netperf test
result showed BW performance decreased 10% with same cpu utilization. I
will look at it tomorrow.

Shirley