netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: David Awogbemila <awogbemila@google.com>
Cc: Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v6 3/4] gve: Rx Buffer Recycling
Date: Thu, 19 Nov 2020 08:55:02 -0800	[thread overview]
Message-ID: <CAKgT0Uc8LdPKw27T-js5O-2g+e8o=QMwasA+57hjZt9ih_-T-w@mail.gmail.com> (raw)
In-Reply-To: <CAL9ddJfa3dpie_zjFG+6jyJ0H9wXGWXWs_TTaL540kQbGO4U+Q@mail.gmail.com>

On Wed, Nov 18, 2020 at 2:50 PM David Awogbemila <awogbemila@google.com> wrote:
>
> On Wed, Nov 11, 2020 at 9:20 AM Alexander Duyck
> <alexander.duyck@gmail.com> wrote:
> >
> > On Mon, Nov 9, 2020 at 3:39 PM David Awogbemila <awogbemila@google.com> wrote:
> > >
> > > This patch lets the driver reuse buffers that have been freed by the
> > > networking stack.
> > >
> > > In the raw addressing case, this allows the driver avoid allocating new
> > > buffers.
> > > In the qpl case, the driver can avoid copies.
> > >
> > > Signed-off-by: David Awogbemila <awogbemila@google.com>
> > > ---

<snip>

> > > +static int gve_rx_can_recycle_buffer(struct page *page)
> > > +{
> > > +       int pagecount = page_count(page);
> > > +
> > > +       /* This page is not being used by any SKBs - reuse */
> > > +       if (pagecount == 1)
> > > +               return 1;
> > > +       /* This page is still being used by an SKB - we can't reuse */
> > > +       else if (pagecount >= 2)
> > > +               return 0;
> > > +       WARN(pagecount < 1, "Pagecount should never be < 1");
> > > +       return -1;
> > > +}
> > > +
> >
> > So using a page count of 1 is expensive. Really if you are going to do
> > this you should probably look at how we do it currently in ixgbe.
> > Basically you want to batch the count updates to avoid expensive
> > atomic operations per skb.
>
> A separate patch will be coming along to change the way the driver
> tracks page count.
> I thought it would be better to have that reviewed separately since
> it's a different issue from what this patch addresses.

Okay, you might want to call that out in your patch description then
that this is just a temporary placeholder. Back when I did this for
ixgbe I think we had it doing a single page update for a few years,
however that code had a bug in it that would cause page count
corruption as I wasn't aware at the time that the mm tree had
functions that would take a reference on the page without us ever
handing it out.

> >
> > >  static struct sk_buff *
> > >  gve_rx_raw_addressing(struct device *dev, struct net_device *netdev,
> > >                       struct gve_rx_slot_page_info *page_info, u16 len,
> > >                       struct napi_struct *napi,
> > > -                     struct gve_rx_data_slot *data_slot)
> > > +                     struct gve_rx_data_slot *data_slot, bool can_flip)
> > >  {
> > > -       struct sk_buff *skb = gve_rx_add_frags(napi, page_info, len);
> > > +       struct sk_buff *skb;
> > >
> > > +       skb = gve_rx_add_frags(napi, page_info, len);
> >
> > Why split this up?It seemed fine as it was.
>
> It was based on a comment from v3 of the patchset.

Do you recall the comment? This just seems like noise to me since it
is moving code and doesn't seem to address either a formatting issue,
nor a functional issue.

> >
> > >         if (!skb)
> > >                 return NULL;
> > >
> > > +       /* Optimistically stop the kernel from freeing the page by increasing
> > > +        * the page bias. We will check the refcount in refill to determine if
> > > +        * we need to alloc a new page.
> > > +        */
> > > +       get_page(page_info->page);
> > > +       page_info->can_flip = can_flip;
> > > +
> >
> > Why pass can_flip and page_info only to set it here? Also I don't get
> > why you are taking an extra reference on the page without checking the
> > can_flip variable. It seems like this should be set in the page_info
> > before you call this function and then you call get_page if
> > page_info->can_flip is true.
>
> I think it's important to call get_page here even for buffers we know
> will not be flipped so that if the skb does a put_page twice we would
> not run into the WARNing in gve_rx_can_recycle_buffer when trying to
> refill buffers.
> (Also please note that a future patch changes the way the driver uses
> page refcounts)

It was your buffer recycling bit that I hadn't noticed. So you have
cases where if your page count gets to 2 you push it to 3 in the hopes
that the 2 that are already out there will be freed and you are left
holding the one remaining count. However I am not sure how much of an
advantage there is to that. If the page flipping is already failing I
wonder what percentage of the time you are able to recover from that.
It might be worthwhile to look at adding a couple of counters to track
the number of times you couldn't flip versus the number of times you
recycled the frame. You may find that the buffer recycling is adding
more overhead for very little gain versus just doing the page
flipping.

  reply	other threads:[~2020-11-19 16:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 23:36 [PATCH net-next v6 0/4] GVE Raw Addressing David Awogbemila
2020-11-09 23:36 ` [PATCH net-next v6 1/4] gve: Add support for raw addressing device option David Awogbemila
2020-11-11 17:20   ` Alexander Duyck
2020-11-18 23:14     ` David Awogbemila
2020-11-09 23:36 ` [PATCH net-next v6 2/4] gve: Add support for raw addressing to the rx path David Awogbemila
2020-11-11 17:20   ` Alexander Duyck
2020-11-18 23:15     ` David Awogbemila
2020-11-19 16:25       ` Alexander Duyck
2020-11-19 21:11         ` David Awogbemila
2020-11-09 23:36 ` [PATCH net-next v6 3/4] gve: Rx Buffer Recycling David Awogbemila
2020-11-11 17:20   ` Alexander Duyck
2020-11-18 22:50     ` David Awogbemila
2020-11-19 16:55       ` Alexander Duyck [this message]
2020-11-19 21:11         ` David Awogbemila
2020-11-09 23:36 ` [PATCH net-next v6 4/4] gve: Add support for raw addressing in the tx path David Awogbemila
2020-11-11 17:20   ` Alexander Duyck
2020-11-18 23:16     ` David Awogbemila
2020-11-19 16:33       ` Alexander Duyck
2020-11-19 21:11         ` David Awogbemila

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='CAKgT0Uc8LdPKw27T-js5O-2g+e8o=QMwasA+57hjZt9ih_-T-w@mail.gmail.com' \
    --to=alexander.duyck@gmail.com \
    --cc=awogbemila@google.com \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).