netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Awogbemila <awogbemila@google.com>
To: Saeed Mahameed <saeed@kernel.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 3/4] gve: Rx Buffer Recycling
Date: Fri, 6 Nov 2020 12:16:34 -0800	[thread overview]
Message-ID: <CAL9ddJeWcWYQKtgT36To_hpbMhf6=U2+iKKncmSwNrwtvdwRJg@mail.gmail.com> (raw)
In-Reply-To: <02019e49d43ba71d86f9caed761dbfe64a77331b.camel@kernel.org>

On Tue, Nov 3, 2020 at 4:01 PM Saeed Mahameed <saeed@kernel.org> wrote:
>
> On Tue, 2020-11-03 at 09:46 -0800, David Awogbemila 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>
> > ---
> >  drivers/net/ethernet/google/gve/gve.h    |  10 +-
> >  drivers/net/ethernet/google/gve/gve_rx.c | 194 +++++++++++++++----
> > ----
>
> > +     if (len <= priv->rx_copybreak) {
> > +             /* Just copy small packets */
> > +             skb = gve_rx_copy(dev, napi, page_info, len);
> > +             u64_stats_update_begin(&rx->statss);
> > +             rx->rx_copied_pkt++;
> > +             rx->rx_copybreak_pkt++;
> > +             u64_stats_update_end(&rx->statss);
> > +     } else {
> > +             bool can_flip = gve_rx_can_flip_buffers(dev);
> > +             int recycle = 0;
> > +
> > +             if (can_flip) {
> > +                     recycle = gve_rx_can_recycle_buffer(page_info-
> > >page);
> > +                     if (recycle < 0) {
> > +                             gve_schedule_reset(priv);
>
> How would a reset solve anything if your driver is handling pages with
> "bad" refcount, i don't agree here that reset is the best course of
> action, all you can do here is warn and leak the page ...
> this is a critical driver bug and not something that user should
> expect.
>
Thanks for pointing this out. For the raw addressing case it would be
fine to warn and leak the page, but for the qpl (non raw addressing)
case, the driver pre-allocates a set of pages which it registers with
the NIC so we'd want to avoid leaking pages - a reset will help here
because we'd allocate a new set of pages and register them with the
NIC.
I will handle both cases separately:
- in raw addressing mode, just warn and leak the page
- in qpl mode, schedule a reset.


> > +
> > +             } else {
> > +                     /* It is possible that the networking stack has
> > already
> > +                      * finished processing all outstanding packets
> > in the buffer
> > +                      * and it can be reused.
> > +                      * Flipping is unnecessary here - if the
> > networking stack still
> > +                      * owns half the page it is impossible to tell
> > which half. Either
> > +                      * the whole page is free or it needs to be
> > replaced.
> > +                      */
> > +                     int recycle =
> > gve_rx_can_recycle_buffer(page_info->page);
> > +
> > +                     if (recycle < 0) {
> > +                             gve_schedule_reset(priv);
> > +                             return false;
>
> Same.
>
>

  reply	other threads:[~2020-11-06 20:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 17:46 [PATCH net-next v5 0/4] GVE Raw Addressing David Awogbemila
2020-11-03 17:46 ` [PATCH 1/4] gve: Add support for raw addressing device option David Awogbemila
2020-11-03 22:43   ` Saeed Mahameed
2020-11-06 19:41     ` David Awogbemila
2020-11-09 21:02       ` David Awogbemila
2020-11-03 17:46 ` [PATCH 2/4] gve: Add support for raw addressing to the rx path David Awogbemila
2020-11-03 23:18   ` Saeed Mahameed
2020-11-06 20:11     ` David Awogbemila
2020-11-03 17:46 ` [PATCH 3/4] gve: Rx Buffer Recycling David Awogbemila
2020-11-04  0:01   ` Saeed Mahameed
2020-11-06 20:16     ` David Awogbemila [this message]
2020-11-03 17:46 ` [PATCH 4/4] gve: Add support for raw addressing in the tx path David Awogbemila
2020-11-04  0:35   ` Saeed Mahameed
2020-11-06 22:27     ` 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='CAL9ddJeWcWYQKtgT36To_hpbMhf6=U2+iKKncmSwNrwtvdwRJg@mail.gmail.com' \
    --to=awogbemila@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeed@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).