On Wed, Nov 18, 2020 at 3:15 PM David Awogbemila <awogbem...@google.com> wrote: > > On Wed, Nov 11, 2020 at 9:20 AM Alexander Duyck > <alexander.du...@gmail.com> wrote: > > > > On Mon, Nov 9, 2020 at 3:39 PM David Awogbemila <awogbem...@google.com> > > wrote: > > > > > > From: Catherine Sullivan <csu...@google.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 <yangc...@google.com> > > > Signed-off-by: Catherine Sullivan <csu...@google.com> > > > Signed-off-by: David Awogbemila <awogbem...@google.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.