Skip to contentSkip to conversation

net/mlx5: fix threshold for mbuf replenishment in MPRQ

PATCH Superseded Alexander Kozyrev 2 participants 3 messages Jul 12, 2021 – Jul 14, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix threshold for mbuf replenishment in MPRQ

The replenishment scheme for the vectorized MPRQ Rx burst aims to improve the cache locality by allocating new mbufs only when there are almost no mbufs left: one burst gap between allocated and consumed indexes.

This gap is not big enough to accommodate a corner case when we have a very aggressive CQE compression with up to 4 regular CQEs and 64 zipped CQEs at the end.

Need to keep in mind this case and extend the replenishment threshold by MLX5_VPMD_DESCS_PER_LOOP (4) to avoid mbuf overflow.

Fixes 5fc2e5c27d6 ("net/mlx5: fix mbuf overflow in vectorized MPRQ")
---
 drivers/net/mlx5/mlx5_rxtx_vec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_rxtx_vec.c +2 -1
index d5af2d91ff..e22ab665df 100644
@@ -152,7 +152,8 @@ mlx5_rx_mprq_replenish_bulk_mbuf(struct mlx5_rxq_data *rxq)
 	unsigned int i;
 
 	if (n >= rxq->rq_repl_thresh &&
-	    rxq->elts_ci - rxq->rq_pi <= rxq->rq_repl_thresh) {
+	    rxq->elts_ci - rxq->rq_pi <=
+	    (uint32_t)rxq->rq_repl_thresh + MLX5_VPMD_DESCS_PER_LOOP) {
 		MLX5_ASSERT(n >= MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n));
 		MLX5_ASSERT(MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n) >
 			     MLX5_VPMD_DESCS_PER_LOOP);
Signature · 1 line
2.18.2
#1 lore raw

PATCH v2 1/1 net/mlx5: fix threshold for mbuf replenishment in MPRQ

The replenishment scheme for the vectorized MPRQ Rx burst aims to improve the cache locality by allocating new mbufs only when there are almost no mbufs left: one burst gap between allocated and consumed indexes.

This gap is not big enough to accommodate a corner case when we have a very aggressive CQE compression with multiple regular CQEs at the beginning and 64 zipped CQEs at the end.

Need to keep in mind this case and extend the replenishment threshold by MLX5_VPMD_RX_MAX_BURST (64) to avoid mbuf overflow.

Fixes 5fc2e5c27d6 ("net/mlx5: fix mbuf overflow in vectorized MPRQ")

---

v2: increased the replenishment gap to MLX5_VPMD_RX_MAX_BURST
v1: https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/mlx5/mlx5_rxtx_vec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_rxtx_vec.c +2 -1
index e64ef70181..e1b6d5422a 100644
@@ -157,7 +157,8 @@ mlx5_rx_mprq_replenish_bulk_mbuf(struct mlx5_rxq_data *rxq)
 	unsigned int i;
 
 	if (n >= rxq->rq_repl_thresh &&
-	    rxq->elts_ci - rxq->rq_pi <= rxq->rq_repl_thresh) {
+	    rxq->elts_ci - rxq->rq_pi <=
+	    rxq->rq_repl_thresh + MLX5_VPMD_RX_MAX_BURST) {
 		MLX5_ASSERT(n >= MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n));
 		MLX5_ASSERT(MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n) >
 			     MLX5_VPMD_DESCS_PER_LOOP);
Signature · 1 line
2.18.2
#2 lore raw

Hi,

Quoted 28 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 13, 2021 6:21 PM
To: [email protected]
Cc: Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]
Subject: [PATCH v2] net/mlx5: fix threshold for mbuf replenishment in MPRQ

The replenishment scheme for the vectorized MPRQ Rx burst aims to improve the cache locality by allocating new mbufs only when there are almost no mbufs left: one burst gap between allocated and consumed indexes.

This gap is not big enough to accommodate a corner case when we have a very aggressive CQE compression with multiple regular CQEs at the beginning and 64 zipped CQEs at the end.

Need to keep in mind this case and extend the replenishment threshold by MLX5_VPMD_RX_MAX_BURST (64) to avoid mbuf overflow.

Fixes 5fc2e5c27d6 ("net/mlx5: fix mbuf overflow in vectorized MPRQ")

---

Quoted 7 lines

v2: increased the replenishment gap to MLX5_VPMD_RX_MAX_BURST v1:
https://patchwork.dpdk.org/project/dpdk/patch/20210712142910.314572-1-
[email protected]/

 drivers/net/mlx5/mlx5_rxtx_vec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh