diff mbox

virtio-net: pass gfp to add_buf

Message ID 201005312040.01737.rusty@rustcorp.com.au
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Rusty Russell May 31, 2010, 11:10 a.m. UTC
From: "Michael S. Tsirkin" <mst@redhat.com>

(Dave: the virtqueue_add_buf_gfp is in Linus' tree, so please queue
 this trivial use now.  Thanks!)

virtio-net bounces buffer allocations off to
a thread if it can't allocate buffers from the atomic
pool. However, if posting buffers still requires atomic
buffers, this is unlikely to succeed.
Fix by passing in the proper gfp_t parameter.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/net/virtio_net.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller June 1, 2010, 7:22 a.m. UTC | #1
From: Rusty Russell <rusty@rustcorp.com.au>
Date: Mon, 31 May 2010 20:40:01 +0930

> From: "Michael S. Tsirkin" <mst@redhat.com>
> 
> (Dave: the virtqueue_add_buf_gfp is in Linus' tree, so please queue
>  this trivial use now.  Thanks!)
> 
> virtio-net bounces buffer allocations off to
> a thread if it can't allocate buffers from the atomic
> pool. However, if posting buffers still requires atomic
> buffers, this is unlikely to succeed.
> Fix by passing in the proper gfp_t parameter.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Your code sucks, and you're wrong.

Please give me positive feedback and tell me how right I am to pump up
my ego or else I will verbally destroy you and make you feel small.

Applied :-)))))))))))))))
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rusty Russell June 1, 2010, 7:28 a.m. UTC | #2
On Tue, 1 Jun 2010 04:52:46 pm David Miller wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> Date: Mon, 31 May 2010 20:40:01 +0930
> 
> > From: "Michael S. Tsirkin" <mst@redhat.com>
> > 
> > (Dave: the virtqueue_add_buf_gfp is in Linus' tree, so please queue
> >  this trivial use now.  Thanks!)
> > 
> > virtio-net bounces buffer allocations off to
> > a thread if it can't allocate buffers from the atomic
> > pool. However, if posting buffers still requires atomic
> > buffers, this is unlikely to succeed.
> > Fix by passing in the proper gfp_t parameter.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> 
> Your code sucks, and you're wrong.
> 
> Please give me positive feedback and tell me how right I am to pump up
> my ego or else I will verbally destroy you and make you feel small.
> 
> Applied :-)))))))))))))))

Thanks Dave, that made my day :)

Cheers,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -341,7 +341,7 @@  static int add_recvbuf_small(struct virt
 
 	skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len);
 
-	err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 2, skb);
+	err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, 2, skb, gfp);
 	if (err < 0)
 		dev_kfree_skb(skb);
 
@@ -386,8 +386,8 @@  static int add_recvbuf_big(struct virtne
 
 	/* chain first in list head */
 	first->private = (unsigned long)list;
-	err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2,
-				       first);
+	err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2,
+				    first, gfp);
 	if (err < 0)
 		give_pages(vi, first);
 
@@ -405,7 +405,7 @@  static int add_recvbuf_mergeable(struct 
 
 	sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE);
 
-	err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 1, page);
+	err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, 1, page, gfp);
 	if (err < 0)
 		give_pages(vi, page);