Skip to contentSkip to conversation

net/mlx5: remove non constant size from type cast

PATCH In review Tyler Retzlaff 3 participants 4 messages Nov 13, 2023 – Feb 25, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: remove non constant size from type cast

Placing a non-constant size in the subscript [size] of a type cast is causing unnecessary generation of a VLA. Remove size and just provide [] indicating the type is an array of unspecified size.

---
 drivers/net/mlx5/mlx5_rxq.c | 5 ++---
 drivers/net/mlx5/mlx5_txq.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +2 -3
index 88b2dc5..f0ab77d 100644
@@ -1951,9 +1951,8 @@ struct mlx5_rxq_ctrl *
 	tmpl->rxq.mp = rx_seg[0].mp;
 	tmpl->rxq.elts_n = log2above(desc);
 	tmpl->rxq.rq_repl_thresh = MLX5_VPMD_RXQ_RPLNSH_THRESH(desc_n);
-	tmpl->rxq.elts = (struct rte_mbuf *(*)[desc_n])(tmpl + 1);
-	tmpl->rxq.mprq_bufs =
-		(struct mlx5_mprq_buf *(*)[desc])(*tmpl->rxq.elts + desc_n);
+	tmpl->rxq.elts = (struct rte_mbuf *(*)[])(tmpl + 1);
+	tmpl->rxq.mprq_bufs = (struct mlx5_mprq_buf *(*)[])(*tmpl->rxq.elts + desc_n);
 	tmpl->rxq.idx = idx;
 	if (conf->share_group > 0) {
 		tmpl->rxq.shared = 1;
drivers/net/mlx5/mlx5_txq.c +1 -1
index b584055..3d219c4 100644
@@ -64,7 +64,7 @@
 	const uint16_t elts_m = elts_n - 1;
 	uint16_t elts_head = txq_ctrl->txq.elts_head;
 	uint16_t elts_tail = txq_ctrl->txq.elts_tail;
-	struct rte_mbuf *(*elts)[elts_n] = &txq_ctrl->txq.elts;
+	struct rte_mbuf *(*elts)[] = &txq_ctrl->txq.elts;
 
 	DRV_LOG(DEBUG, "port %u Tx queue %u freeing WRs",
 		PORT_ID(txq_ctrl->priv), txq_ctrl->txq.idx);
Signature · 1 line
1.8.3.1
#1 lore raw

ping

this one seems pretty obvious, maintainers could you please take a look?

thanks

Quoted 41 lines · Tyler Retzlaff

Placing a non-constant size in the subscript [size] of a type cast is causing unnecessary generation of a VLA. Remove size and just provide [] indicating the type is an array of unspecified size.

---
 drivers/net/mlx5/mlx5_rxq.c | 5 ++---
 drivers/net/mlx5/mlx5_txq.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +2 -3
index 88b2dc5..f0ab77d 100644
@@ -1951,9 +1951,8 @@ struct mlx5_rxq_ctrl *
 	tmpl->rxq.mp = rx_seg[0].mp;
 	tmpl->rxq.elts_n = log2above(desc);
 	tmpl->rxq.rq_repl_thresh = MLX5_VPMD_RXQ_RPLNSH_THRESH(desc_n);
-	tmpl->rxq.elts = (struct rte_mbuf *(*)[desc_n])(tmpl + 1);
-	tmpl->rxq.mprq_bufs =
-		(struct mlx5_mprq_buf *(*)[desc])(*tmpl->rxq.elts + desc_n);
+	tmpl->rxq.elts = (struct rte_mbuf *(*)[])(tmpl + 1);
+	tmpl->rxq.mprq_bufs = (struct mlx5_mprq_buf *(*)[])(*tmpl->rxq.elts + desc_n);
 	tmpl->rxq.idx = idx;
 	if (conf->share_group > 0) {
 		tmpl->rxq.shared = 1;
drivers/net/mlx5/mlx5_txq.c +1 -1
index b584055..3d219c4 100644
@@ -64,7 +64,7 @@
 	const uint16_t elts_m = elts_n - 1;
 	uint16_t elts_head = txq_ctrl->txq.elts_head;
 	uint16_t elts_tail = txq_ctrl->txq.elts_tail;
-	struct rte_mbuf *(*elts)[elts_n] = &txq_ctrl->txq.elts;
+	struct rte_mbuf *(*elts)[] = &txq_ctrl->txq.elts;
 
 	DRV_LOG(DEBUG, "port %u Tx queue %u freeing WRs",
 		PORT_ID(txq_ctrl->priv), txq_ctrl->txq.idx);
Signature · 1 line
1.8.3.1
#2 lore raw

Hi,

Sorry for the delay - we considered the opportunity to get rid of the pointer to array at all. Not this time. So:

With best regards,
Slava

Quoted 59 lines

-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Monday, February 12, 2024 8:03 PM
To: [email protected]
Cc: Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [PATCH] net/mlx5: remove non constant size from type cast

ping

this one seems pretty obvious, maintainers could you please take a look?

thanks

Quoted 15 lines · Tyler Retzlaff

Placing a non-constant size in the subscript [size] of a type cast is causing unnecessary generation of a VLA. Remove size and just provide [] indicating the type is an array of unspecified size.

---
drivers/net/mlx5/mlx5_rxq.c | 5 ++--- drivers/net/mlx5/mlx5_txq.c |
2 +-

 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -0
index 88b2dc5..f0ab77d 100644

drivers/net/mlx5/mlx5_rxq.c struct mlx5_rxq_ctrl * · line 1953

Quoted 3 lines
drivers/net/mlx5/mlx5_rxq.c +0 -0
@@ -1951,9 +1951,8 @@ struct mlx5_rxq_ctrl *
 	tmpl->rxq.mp = rx_seg[0].mp;
 	tmpl->rxq.elts_n = log2above(desc);
 	tmpl->rxq.rq_repl_thresh =

MLX5_VPMD_RXQ_RPLNSH_THRESH(desc_n);

Quoted 24 lines
drivers/net/mlx5/mlx5_rxq.c +3 -3
-	tmpl->rxq.elts = (struct rte_mbuf *(*)[desc_n])(tmpl + 1);
-	tmpl->rxq.mprq_bufs =
-		(struct mlx5_mprq_buf *(*)[desc])(*tmpl->rxq.elts + desc_n);
+	tmpl->rxq.elts = (struct rte_mbuf *(*)[])(tmpl + 1);
+	tmpl->rxq.mprq_bufs = (struct mlx5_mprq_buf *(*)[])(*tmpl->rxq.elts
++ desc_n);
 	tmpl->rxq.idx = idx;
 	if (conf->share_group > 0) {
 		tmpl->rxq.shared = 1;
drivers/net/mlx5/mlx5_txq.c +1 -2
index b584055..3d219c4 100644
@@ -64,7 +64,7 @@
 	const uint16_t elts_m = elts_n - 1;
 	uint16_t elts_head = txq_ctrl->txq.elts_head;
 	uint16_t elts_tail = txq_ctrl->txq.elts_tail;
-	struct rte_mbuf *(*elts)[elts_n] = &txq_ctrl->txq.elts;
+	struct rte_mbuf *(*elts)[] = &txq_ctrl->txq.elts;
 
 	DRV_LOG(DEBUG, "port %u Tx queue %u freeing WRs",
 		PORT_ID(txq_ctrl->priv), txq_ctrl->txq.idx);
--

1.8.3.1

#3 lore raw
In reply to Tyler Retzlaff

Hi,

Quoted 9 lines

-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Monday, November 13, 2023 7:21 PM
To: [email protected]
Cc: Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Slava Ovsiienko <[email protected]>; Tyler Retzlaff <[email protected]>
Subject: [PATCH] net/mlx5: remove non constant size from type cast

Quoted 5 lines

Placing a non-constant size in the subscript [size] of a type cast is causing unnecessary generation of a VLA. Remove size and just provide [] indicating the type is an array of unspecified size.

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh