]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
macvtap: zerocopy: fix truesize underestimation
authorJason Wang <jasowang@redhat.com>
Wed, 2 May 2012 03:41:44 +0000 (11:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Oct 2012 17:30:34 +0000 (10:30 -0700)
commit 4ef67ebedffa44ed9939b34708ac2fee06d2f65f upstream.

As the skb fragment were pinned/built from user pages, we should
account the page instead of length for truesize.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/macvtap.c

index 0302bc5adc69288ef30dcd7ccc51bbbd620852d3..cf096e0693e2e0553e1f1d5bbc87d552670b471d 100644 (file)
@@ -520,6 +520,7 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
                struct page *page[MAX_SKB_FRAGS];
                int num_pages;
                unsigned long base;
+               unsigned long truesize;
 
                len = from->iov_len - offset;
                if (!len) {
@@ -535,10 +536,11 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
                if (num_pages != size)
                        /* put_page is in skb free */
                        return -EFAULT;
+               truesize = size * PAGE_SIZE;
                skb->data_len += len;
                skb->len += len;
-               skb->truesize += len;
-               atomic_add(len, &skb->sk->sk_wmem_alloc);
+               skb->truesize += truesize;
+               atomic_add(truesize, &skb->sk->sk_wmem_alloc);
                while (len) {
                        int off = base & ~PAGE_MASK;
                        int size = min_t(int, len, PAGE_SIZE - off);