[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKgT0UdG+fB=KNzro7zMg-617KcNCAL_dMZcqeL0JrcJuT4_CQ@mail.gmail.com>
Date: Thu, 19 Nov 2020 08:25:34 -0800
From: Alexander Duyck <alexander.duyck@...il.com>
To: David Awogbemila <awogbemila@...gle.com>
Cc: Netdev <netdev@...r.kernel.org>,
Catherine Sullivan <csully@...gle.com>,
Yangchun Fu <yangchun@...gle.com>
Subject: Re: [PATCH net-next v6 2/4] gve: Add support for raw addressing to
the rx path
On Wed, Nov 18, 2020 at 3:15 PM David Awogbemila <awogbemila@...gle.com> wrote:
>
> On Wed, Nov 11, 2020 at 9:20 AM Alexander Duyck
> <alexander.duyck@...il.com> wrote:
> >
> > On Mon, Nov 9, 2020 at 3:39 PM David Awogbemila <awogbemila@...gle.com> wrote:
> > >
> > > From: Catherine Sullivan <csully@...gle.com>
> > >
> > > Add support to use raw dma addresses in the rx path. Due to this new
> > > support we can alloc a new buffer instead of making a copy.
> > >
> > > RX buffers are handed to the networking stack and are
> > > re-allocated as needed, avoiding the need to use
> > > skb_copy_to_linear_data() as in "qpl" mode.
> > >
> > > Reviewed-by: Yangchun Fu <yangchun@...gle.com>
> > > Signed-off-by: Catherine Sullivan <csully@...gle.com>
> > > Signed-off-by: David Awogbemila <awogbemila@...gle.com>
> > > ---
<snip>
> > > @@ -399,19 +487,45 @@ static bool gve_rx_work_pending(struct gve_rx_ring *rx)
> > > return (GVE_SEQNO(flags_seq) == rx->desc.seqno);
> > > }
> > >
> > > +static bool gve_rx_refill_buffers(struct gve_priv *priv, struct gve_rx_ring *rx)
> > > +{
> > > + bool empty = rx->fill_cnt == rx->cnt;
> > > + u32 fill_cnt = rx->fill_cnt;
> > > +
> > > + while (empty || ((fill_cnt & rx->mask) != (rx->cnt & rx->mask))) {
> >
> > So one question I would have is why do you need to mask fill_cnt and
> > cnt here, but not above? Something doesn't match up.
>
> fill_cnt and cnt are both free-running uints with fill_cnt generally
> greater than cnt
> as fill_cnt tracks freed/available buffers while cnt tracks used buffers.
> The difference between "fill_cnt == cnt" and "(fill_cnt & rx->mask) ==
> (cnt & rx->mask)" is
> useful when all the buffers are completely used up.
> If all the descriptors are used up ("fill_cnt == cnt") when we attempt
> to refill buffers, the right
> hand side of the while loop's OR condition, "(fill_cnt & rx->mask) !=
> (rx->cnt & rx->mask)"
> will be false and we wouldn't get to attempt to refill the queue's buffers.
I think I see what you are trying to get at, but it seems convoluted.
Your first check is checking for the empty case where rx->fill_cnt ==
rx->cnt. The second half of this is about pushing the count up so that
you cause fill_cnt to wrap and come back around and be equal to cnt.
That seems like a really convoluted way to get there.
Why not just simplify this and do something like the following?:
while (fill_cnt - rx->cnt < rx->mask)
I would argue that is much easier to read and understand rather than
having to double up the cases by using the mask field as a mask on the
free running counters.
Powered by blists - more mailing lists