Re: [PATCH net-next 2/3] virtio-net: use per-receive queue page frag alloc for mergeable bufs

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

 



On Mon, 2013-12-23 at 16:12 +0800, Jason Wang wrote:
> On 12/17/2013 08:16 AM, Michael Dalton wrote:
> > The virtio-net driver currently uses netdev_alloc_frag() for GFP_ATOMIC
> > mergeable rx buffer allocations. This commit migrates virtio-net to use
> > per-receive queue page frags for GFP_ATOMIC allocation. This change unifies
> > mergeable rx buffer memory allocation, which now will use skb_refill_frag()
> > for both atomic and GFP-WAIT buffer allocations.
> >
> > To address fragmentation concerns, if after buffer allocation there
> > is too little space left in the page frag to allocate a subsequent
> > buffer, the remaining space is added to the current allocated buffer
> > so that the remaining space can be used to store packet data.
> >
> > Signed-off-by: Michael Dalton <mwdalton@xxxxxxxxxx>
> > ---
> >  drivers/net/virtio_net.c | 69 ++++++++++++++++++++++++++----------------------
> >  1 file changed, 38 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index c51a988..d38d130 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -78,6 +78,9 @@ struct receive_queue {
> >  	/* Chain pages by the private ptr. */
> >  	struct page *pages;
> >  
> > +	/* Page frag for GFP_ATOMIC packet buffer allocation. */
> > +	struct page_frag atomic_frag;
> > +
> >  	/* RX: fragments + linear part + virtio header */
> >  	struct scatterlist sg[MAX_SKB_FRAGS + 2];
> >  
> > @@ -127,9 +130,9 @@ struct virtnet_info {
> >  	struct mutex config_lock;
> >  
> >  	/* Page_frag for GFP_KERNEL packet buffer allocation when we run
> > -	 * low on memory.
> > +	 * low on memory. May sleep.
> >  	 */
> > -	struct page_frag alloc_frag;
> > +	struct page_frag sleep_frag;
> 
> Any reason to use two different page_frag consider only
> skb_page_frag_refill() is used?

One is used under process context, where preemption and GFP_KERNEL are
allowed.

One is used from softirq context and GFP_ATOMIC. You cant share a common
page_frag.

Acked-by: Eric Dumazet <edumazet@xxxxxxxxxx>



_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux