Re: [PATCH 2/2] virtio_net: Defer skb allocation in receive path
From: Amit Shah <hidden>
Date: 2009-12-24 13:38:52
Also in:
kvm
From: Amit Shah <hidden>
Date: 2009-12-24 13:38:52
Also in:
kvm
On (Thu) Dec 17 2009 [23:44:49], Shirley Ma wrote:
virtio_net receives packets from its pre-allocated vring buffers, then it delivers these packets to upper layer protocols as skb buffs. So it's not necessary to pre-allocate skb for each mergable buffer, then frees extra skbs when buffers are merged into a large packet. This patch has deferred skb allocation in receiving packets for both big packets and mergeable buffers to reduce skb pre-allocations and skb frees. It frees unused buffers by calling detach_unused_buf in vring, so recv skb queue is not needed. Signed-off-by: Shirley Ma <redacted>
...
+static void free_unused_bufs(struct virtnet_info *vi)
+{
+ void *buf;
+ while (vi->num) {
+ buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq);
+ if (!buf)
+ continue;Do you mean 'break' here?
+ if (vi->mergeable_rx_bufs || vi->big_packets) + give_pages(vi, buf); + else + dev_kfree_skb(buf); + --vi->num; + } +} +
Amit