public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Rosen Penev <rosenp@gmail.com>, netdev@vger.kernel.org
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"open list:MELLANOX MLX5 core VPI driver"
	<linux-rdma@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net/mlx5e: use flex array for rqns
Date: Wed, 4 Mar 2026 10:29:05 +0200	[thread overview]
Message-ID: <639ae63d-dbb0-428f-a13b-4cc354e19566@gmail.com> (raw)
In-Reply-To: <20260304042042.7822-1-rosenp@gmail.com>



On 04/03/2026 6:20, Rosen Penev wrote:
> Simplifies allocation. Separate kcalloc and kfree not needed anymore.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c | 13 +++----------
>   1 file changed, 3 insertions(+), 10 deletions(-)
> 

This is not the typical structure that matches the usage of kvzalloc_flex().

I prefer keeping current code, being consistent with other dynamically 
allocated members like rss_vhca_ids.


> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
> index 92974b11ec75..fc71dd72938c 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
> @@ -16,7 +16,6 @@ struct mlx5e_rx_res {
>   
>   	struct mlx5e_rss *rss[MLX5E_MAX_NUM_RSS];
>   	bool rss_active;
> -	u32 *rss_rqns;
>   	u32 *rss_vhca_ids;
>   	unsigned int rss_nch;
>   
> @@ -29,6 +28,8 @@ struct mlx5e_rx_res {
>   		struct mlx5e_rqt rqt;
>   		struct mlx5e_tir tir;
>   	} ptp;
> +
> +	u32 rss_rqns[];
>   };
>   
>   /* API for rx_res_rss_* */
> @@ -316,7 +317,6 @@ struct mlx5e_rss *mlx5e_rx_res_rss_get(struct mlx5e_rx_res *res, u32 rss_idx)
>   static void mlx5e_rx_res_free(struct mlx5e_rx_res *res)
>   {
>   	kvfree(res->rss_vhca_ids);
> -	kvfree(res->rss_rqns);
>   	kvfree(res);
>   }
>   
> @@ -325,20 +325,13 @@ static struct mlx5e_rx_res *mlx5e_rx_res_alloc(struct mlx5_core_dev *mdev, unsig
>   {
>   	struct mlx5e_rx_res *rx_res;
>   
> -	rx_res = kvzalloc_obj(*rx_res);
> +	rx_res = kvzalloc_flex(*rx_res, rss_rqns, max_nch, GFP_KERNEL);
>   	if (!rx_res)
>   		return NULL;
>   
> -	rx_res->rss_rqns = kvcalloc(max_nch, sizeof(*rx_res->rss_rqns), GFP_KERNEL);
> -	if (!rx_res->rss_rqns) {
> -		kvfree(rx_res);
> -		return NULL;
> -	}
> -
>   	if (multi_vhca) {
>   		rx_res->rss_vhca_ids = kvcalloc(max_nch, sizeof(*rx_res->rss_vhca_ids), GFP_KERNEL);
>   		if (!rx_res->rss_vhca_ids) {
> -			kvfree(rx_res->rss_rqns);
>   			kvfree(rx_res);
>   			return NULL;
>   		}


      reply	other threads:[~2026-03-04  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04  4:20 [PATCH] net/mlx5e: use flex array for rqns Rosen Penev
2026-03-04  8:29 ` Tariq Toukan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=639ae63d-dbb0-428f-a13b-4cc354e19566@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox