public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel•org>
To: "David S. Miller" <davem@davemloft•net>,
	Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
	Eric Dumazet <edumazet@google•com>
Cc: Saeed Mahameed <saeedm@nvidia•com>,
	netdev@vger•kernel.org, Tariq Toukan <tariqt@nvidia•com>,
	Dragos Tatulea <dtatulea@nvidia•com>
Subject: [net 4/9] net/mlx5e: RX, Fix flush and close release flow of regular rq for legacy rq
Date: Fri, 30 Jun 2023 11:15:39 -0700	[thread overview]
Message-ID: <20230630181544.82958-5-saeed@kernel.org> (raw)
In-Reply-To: <20230630181544.82958-1-saeed@kernel.org>

From: Dragos Tatulea <dtatulea@nvidia•com>

Regular (non-XSK) RQs get flushed on XSK setup and re-activated on XSK
close. If the same regular RQ is closed (a config change for example)
soon after the XSK close, a double release occurs because the missing
wqes get released a second time.

Fixes: 3f93f82988bc ("net/mlx5e: RX, Defer page release in legacy rq for better recycling")
Signed-off-by: Dragos Tatulea <dtatulea@nvidia•com>
Reviewed-by: Tariq Toukan <tariqt@nvidia•com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia•com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 704b022cd1f0..a9575219e455 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -390,10 +390,18 @@ static void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix)
 {
 	struct mlx5e_wqe_frag_info *wi = get_frag(rq, ix);
 
-	if (rq->xsk_pool)
+	if (rq->xsk_pool) {
 		mlx5e_xsk_free_rx_wqe(wi);
-	else
+	} else {
 		mlx5e_free_rx_wqe(rq, wi);
+
+		/* Avoid a second release of the wqe pages: dealloc is called
+		 * for the same missing wqes on regular RQ flush and on regular
+		 * RQ close. This happens when XSK RQs come into play.
+		 */
+		for (int i = 0; i < rq->wqe.info.num_frags; i++, wi++)
+			wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
+	}
 }
 
 static void mlx5e_xsk_free_rx_wqes(struct mlx5e_rq *rq, u16 ix, int wqe_bulk)
-- 
2.41.0


  parent reply	other threads:[~2023-06-30 18:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30 18:15 [pull request][net 0/9] mlx5 fixes 2023-06-30 Saeed Mahameed
2023-06-30 18:15 ` [net 1/9] net/mlx5e: fix double free in mlx5e_destroy_flow_table Saeed Mahameed
2023-06-30 18:15 ` [net 2/9] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Saeed Mahameed
2023-06-30 18:15 ` [net 3/9] net/mlx5e: fix memory leak in mlx5e_ptp_open Saeed Mahameed
2023-06-30 18:15 ` Saeed Mahameed [this message]
2023-06-30 18:15 ` [net 5/9] net/mlx5: Register a unique thermal zone per device Saeed Mahameed
2023-06-30 20:10   ` Simon Horman
2023-06-30 18:15 ` [net 6/9] net/mlx5e: Check for NOT_READY flag state after locking Saeed Mahameed
2023-06-30 18:15 ` [net 7/9] net/mlx5e: TC, CT: Offload ct clear only once Saeed Mahameed
2023-06-30 18:15 ` [net 8/9] net/mlx5: Query hca_cap_2 only when supported Saeed Mahameed
2023-06-30 18:15 ` [net 9/9] net/mlx5e: RX, Fix page_pool page fragment tracking for XDP Saeed Mahameed

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=20230630181544.82958-5-saeed@kernel.org \
    --to=saeed@kernel$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=dtatulea@nvidia$(echo .)com \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=saeedm@nvidia$(echo .)com \
    --cc=tariqt@nvidia$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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