All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Michael Dalton <mwdalton@google.com>,
	netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net-next 2/3] virtio-net: use per-receive queue page frag alloc for mergeable bufs
Date: Mon, 23 Dec 2013 21:37:04 +0200	[thread overview]
Message-ID: <20131223193704.GC1582@redhat.com> (raw)
In-Reply-To: <1387819627.12212.4.camel@edumazet-glaptop2.roam.corp.google.com>

On Mon, Dec 23, 2013 at 09:27:07AM -0800, Eric Dumazet wrote:
> 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@google.com>
> > > ---
> > >  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.

Yes but it is always used with napi disabled.

> One is used from softirq context and GFP_ATOMIC.

This one is used only under napi.

> You cant share a common
> page_frag.

So there isn't a conflict with respect to locking.

Is it problematic to use same page_frag with both GFP_ATOMIC and with
GFP_KERNEL? If yes why?

> Acked-by: Eric Dumazet <edumazet@google.com>
> 
> 

  reply	other threads:[~2013-12-23 19:37 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17  0:16 [PATCH net-next 1/3] net: allow > 0 order atomic page alloc in skb_page_frag_refill Michael Dalton
2013-12-17  0:16 ` [PATCH net-next 2/3] virtio-net: use per-receive queue page frag alloc for mergeable bufs Michael Dalton
2013-12-23  8:12   ` Jason Wang
2013-12-23 17:27     ` Eric Dumazet
2013-12-23 19:37       ` Michael S. Tsirkin [this message]
2013-12-26 21:28         ` Michael Dalton
2013-12-26 21:37           ` Michael S. Tsirkin
2013-12-26 22:00             ` Eric Dumazet
2013-12-26 22:00             ` Eric Dumazet
2014-01-08 17:21               ` Michael S. Tsirkin
2014-01-08 18:09                 ` Eric Dumazet
2014-01-08 18:57                   ` Michael S. Tsirkin
2014-01-08 19:54                   ` David Miller
2014-01-08 21:16                   ` Rick Jones
2013-12-26 21:56           ` Eric Dumazet
2013-12-27  4:55             ` Jason Wang
2013-12-27  5:46               ` Eric Dumazet
2013-12-27  6:12                 ` Jason Wang
2013-12-26 21:56           ` Eric Dumazet
2013-12-23 13:31   ` Michael S. Tsirkin
2013-12-17  0:16 ` [PATCH net-next 3/3] net: auto-tune mergeable rx buffer size for improved performance Michael Dalton
2013-12-17  0:16 ` Michael Dalton
2013-12-23 12:51   ` Michael S. Tsirkin
2013-12-23 13:33   ` Michael S. Tsirkin
2013-12-30 10:14     ` Amos Kong
2014-01-08 17:41       ` Michael S. Tsirkin
2013-12-26  7:33   ` Jason Wang
2013-12-26 20:06     ` Michael Dalton
2013-12-26 20:24       ` Michael S. Tsirkin
2013-12-27  3:04       ` Jason Wang
2013-12-27 21:41         ` Michael Dalton
2013-12-30  4:50           ` Jason Wang
2013-12-30  5:38           ` Jason Wang
2014-01-08 17:37           ` Michael S. Tsirkin
2013-12-19 19:58 ` [PATCH net-next 1/3] net: allow > 0 order atomic page alloc in skb_page_frag_refill David Miller
2013-12-23 13:35   ` Michael S. Tsirkin
2013-12-23  7:52 ` Jason Wang
2013-12-23 17:24   ` Eric Dumazet
2013-12-23 17:24   ` Eric Dumazet
2013-12-23 12:53 ` Michael S. Tsirkin
2013-12-23 17:30   ` Eric Dumazet
2013-12-23 19:19     ` Michael S. Tsirkin
2013-12-24 22:46 ` David Miller
2014-01-03  0:42   ` Debabrata Banerjee
2014-01-03  0:42   ` Debabrata Banerjee
2014-01-03  0:56     ` Eric Dumazet
2014-01-03  1:26       ` Eric Dumazet
2014-01-03  1:59         ` Debabrata Banerjee
2014-01-03  1:59         ` Debabrata Banerjee
2014-01-03 22:47           ` Debabrata Banerjee
2014-01-03 22:47           ` Debabrata Banerjee
2014-01-03 22:54             ` Eric Dumazet
2014-01-03 23:27               ` Debabrata Banerjee
2014-01-03 23:27               ` Debabrata Banerjee
2013-12-24 22:46 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131223193704.GC1582@redhat.com \
    --to=mst@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=mwdalton@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.