DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ
@ 2020-11-21  3:42 Alexander Kozyrev
  2020-11-22  8:44 ` Slava Ovsiienko
  2020-11-22 13:01 ` Raslan Darawsheh
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Kozyrev @ 2020-11-21  3:42 UTC (permalink / raw)
  To: dev; +Cc: rasland, viacheslavo, matan

Changing the allocation scheme to improve mbufs locality caused mbufs
overrun in some cases. Revert the previous replenish logic back.
Calculate a number of unused mbufs and replenish max this number of mbufs.

Mark the last 4 mbufs as fake mbufs to prevent overflowing into consumed
mbufs in the future. Keep the consumed index and the produced index 4 mbufs
apart for this purpose.

Replenish some mbufs only in case the consumed index is within the
replenish threshold of the produced index in order to retain the cache
locality for the vectorized MPRQ routine.

Fixes: 5c68764377 ("net/mlx5: improve vectorized MPRQ descriptors locality")

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxtx_vec.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 68c51dce31..028e0f6121 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -145,22 +145,29 @@ mlx5_rx_mprq_replenish_bulk_mbuf(struct mlx5_rxq_data *rxq)
 	const uint32_t strd_n = 1 << rxq->strd_num_n;
 	const uint32_t elts_n = wqe_n * strd_n;
 	const uint32_t wqe_mask = elts_n - 1;
-	uint32_t n = rxq->elts_ci - rxq->rq_pi;
+	uint32_t n = elts_n - (rxq->elts_ci - rxq->rq_pi);
 	uint32_t elts_idx = rxq->elts_ci & wqe_mask;
 	struct rte_mbuf **elts = &(*rxq->elts)[elts_idx];
+	unsigned int i;
 
-	if (n <= rxq->rq_repl_thresh) {
-		MLX5_ASSERT(n + MLX5_VPMD_RX_MAX_BURST >=
-			    MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n));
+	if (n >= rxq->rq_repl_thresh &&
+	    rxq->elts_ci - rxq->rq_pi <= rxq->rq_repl_thresh) {
+		MLX5_ASSERT(n >= MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n));
 		MLX5_ASSERT(MLX5_VPMD_RXQ_RPLNSH_THRESH(elts_n) >
 			     MLX5_VPMD_DESCS_PER_LOOP);
 		/* Not to cross queue end. */
-		n = RTE_MIN(n + MLX5_VPMD_RX_MAX_BURST, elts_n - elts_idx);
+		n = RTE_MIN(n - MLX5_VPMD_DESCS_PER_LOOP, elts_n - elts_idx);
+		/* Limit replenish number to threshold value. */
+		n = RTE_MIN(n, rxq->rq_repl_thresh);
 		if (rte_mempool_get_bulk(rxq->mp, (void *)elts, n) < 0) {
 			rxq->stats.rx_nombuf += n;
 			return;
 		}
 		rxq->elts_ci += n;
+		/* Prevent overflowing into consumed mbufs. */
+		elts_idx = rxq->elts_ci & wqe_mask;
+		for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
+			(*rxq->elts)[elts_idx + i] = &rxq->fake_mbuf;
 	}
 }
 
-- 
2.24.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ
  2020-11-21  3:42 [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ Alexander Kozyrev
@ 2020-11-22  8:44 ` Slava Ovsiienko
  2020-11-22 13:01 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Slava Ovsiienko @ 2020-11-22  8:44 UTC (permalink / raw)
  To: Alexander Kozyrev, dev; +Cc: Raslan Darawsheh, Matan Azrad

> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Saturday, November 21, 2020 5:43
> To: dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Matan Azrad <matan@nvidia.com>
> Subject: [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ
> 
> Changing the allocation scheme to improve mbufs locality caused mbufs
> overrun in some cases. Revert the previous replenish logic back.
> Calculate a number of unused mbufs and replenish max this number of mbufs.
> 
> Mark the last 4 mbufs as fake mbufs to prevent overflowing into consumed
> mbufs in the future. Keep the consumed index and the produced index 4
> mbufs apart for this purpose.
> 
> Replenish some mbufs only in case the consumed index is within the replenish
> threshold of the produced index in order to retain the cache locality for the
> vectorized MPRQ routine.
> 
> Fixes: 5c68764377 ("net/mlx5: improve vectorized MPRQ descriptors locality")
> 
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ
  2020-11-21  3:42 [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ Alexander Kozyrev
  2020-11-22  8:44 ` Slava Ovsiienko
@ 2020-11-22 13:01 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2020-11-22 13:01 UTC (permalink / raw)
  To: Alexander Kozyrev, dev; +Cc: Slava Ovsiienko, Matan Azrad

Hi,


> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Saturday, November 21, 2020 5:43 AM
> To: dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Matan Azrad <matan@nvidia.com>
> Subject: [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ
> 
> Changing the allocation scheme to improve mbufs locality caused mbufs
> overrun in some cases. Revert the previous replenish logic back.
> Calculate a number of unused mbufs and replenish max this number of
> mbufs.
> 
> Mark the last 4 mbufs as fake mbufs to prevent overflowing into consumed
> mbufs in the future. Keep the consumed index and the produced index 4
> mbufs
> apart for this purpose.
> 
> Replenish some mbufs only in case the consumed index is within the
> replenish threshold of the produced index in order to retain the cache
> locality for the vectorized MPRQ routine.
> 
> Fixes: 5c68764377 ("net/mlx5: improve vectorized MPRQ descriptors
> locality")
> 
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_rxtx_vec.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21  3:42 [dpdk-dev] [PATCH] net/mlx5: fix mbufs overflow in vectorized MPRQ Alexander Kozyrev
2020-11-22  8:44 ` Slava Ovsiienko
2020-11-22 13:01 ` Raslan Darawsheh

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox