net/mlx5: remove non constant size from type cast

Message ID 1699896038-28106-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State New
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: remove non constant size from type cast |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Tyler Retzlaff Nov. 13, 2023, 5:20 p.m. UTC
  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.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 5 ++---
 drivers/net/mlx5/mlx5_txq.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
  

Comments

Tyler Retzlaff Feb. 12, 2024, 6:03 p.m. UTC | #1
ping

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

thanks

On Mon, Nov 13, 2023 at 09:20:38AM -0800, Tyler Retzlaff wrote:
> 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.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  drivers/net/mlx5/mlx5_rxq.c | 5 ++---
>  drivers/net/mlx5/mlx5_txq.c | 2 +-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
> index 88b2dc5..f0ab77d 100644
> --- a/drivers/net/mlx5/mlx5_rxq.c
> +++ b/drivers/net/mlx5/mlx5_rxq.c
> @@ -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;
> diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
> index b584055..3d219c4 100644
> --- a/drivers/net/mlx5/mlx5_txq.c
> +++ b/drivers/net/mlx5/mlx5_txq.c
> @@ -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
  
Viacheslav Ovsiienko Feb. 13, 2024, 11:56 a.m. UTC | #2
Hi,

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

Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

With best regards,
Slava

> -----Original Message-----
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Sent: Monday, February 12, 2024 8:03 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Ori Kam <orika@nvidia.com>;
> Suanming Mou <suanmingm@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> 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
> 
> On Mon, Nov 13, 2023 at 09:20:38AM -0800, Tyler Retzlaff wrote:
> > 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.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  drivers/net/mlx5/mlx5_rxq.c | 5 ++---  drivers/net/mlx5/mlx5_txq.c |
> > 2 +-
> >  2 files changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
> > index 88b2dc5..f0ab77d 100644
> > --- a/drivers/net/mlx5/mlx5_rxq.c
> > +++ b/drivers/net/mlx5/mlx5_rxq.c
> > @@ -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;
> > diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
> > index b584055..3d219c4 100644
> > --- a/drivers/net/mlx5/mlx5_txq.c
> > +++ b/drivers/net/mlx5/mlx5_txq.c
> > @@ -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
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 88b2dc5..f0ab77d 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -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;
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index b584055..3d219c4 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -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);