On 19 Feb 2023, at 20:35, Stephen Hemminger <stephen@networkplumber.org> wrote:
On Sun, 19 Feb 2023 03:30:59 +0300Levend Sayar <levendsayar@gmail.com> wrote:rx no_mbufs stats counter update is added for another error case.
Fixes: 4f6b1dd8240c ("net/gve: support basic statistics")
Cc: junfeng.guo@intel.com
Signed-off-by: Levend Sayar <levendsayar@gmail.com>
---
drivers/net/gve/gve_rx.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/gve/gve_rx.c b/drivers/net/gve/gve_rx.c
index 66fbcf3930..b0427731f8 100644
--- a/drivers/net/gve/gve_rx.c
+++ b/drivers/net/gve/gve_rx.c
@@ -24,6 +24,7 @@ gve_rx_refill(struct gve_rx_queue *rxq)
nmb = rte_pktmbuf_alloc(rxq->mpool);
if (!nmb)
break;
+
rxq->sw_ring[idx + i] = nmb;
}
if (i != nb_alloc) {
Looks like accidental whitespace change included in this patch.
LS: Right. Let me correct.
@@ -59,9 +60,13 @@ gve_rx_refill(struct gve_rx_queue *rxq)
nmb = rte_pktmbuf_alloc(rxq->mpool);
if (!nmb)
break;
+
rxq->sw_ring[idx + i] = nmb;
}
- nb_alloc = i;
+ if (i != nb_alloc) {
+ rxq->no_mbufs += nb_alloc - i;
+ nb_alloc = i;
+ }
Would be better to add unlikely() here like: if (unlikely(i < nb_alloc)) { rxq->no_mbufs += nb_alloc - i; nb_alloc = i; }Or eliminate conditional branch in hot path completely. rxq->no_mbufs += nb_alloc - i; nb_alloc = i;Or better yet refactor code here to use rte_pktmbuf_alloc_bulk() whichdoes single ring operation. }
rxq->nb_avail -= nb_alloc;
next_avail += nb_alloc;
LS: “unlikely” can be added. You’re right. Code already tries to make a bulk allocation first.
If that bulk allocation does not work, it tries to allocate one my one.
I will supersede this one and create v2.
Thanks Stephen.
Best,
Levend