net/mlx5: remove non constant size from type cast
Checks
Commit Message
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
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
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
Hi,
> -----Original Message-----
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Sent: Monday, November 13, 2023 7:21 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>; Tyler Retzlaff <roretzla@linux.microsoft.com>
> Subject: [PATCH] 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.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh
@@ -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;
@@ -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);