netdev.vger.kernel.org archive mirror
 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>
Cc: netdev@vger.kernel.org, Maxim Mikityanskiy <maximmi@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net 04/11] net/mlx5e: Wrap mlx5e_trap_napi_poll into rcu_read_lock
Date: Tue, 17 May 2022 23:34:20 -0700	[thread overview]
Message-ID: <20220518063427.123758-5-saeed@kernel.org> (raw)
In-Reply-To: <20220518063427.123758-1-saeed@kernel.org>

From: Maxim Mikityanskiy <maximmi@nvidia.com>

The body of mlx5e_napi_poll is wrapped into rcu_read_lock to be able to
read the XDP program pointer using rcu_dereference. However, the trap RQ
NAPI doesn't use rcu_read_lock, because the trap RQ works only in the
non-linear mode, and mlx5e_skb_from_cqe_nonlinear, until recently,
didn't support XDP and didn't call rcu_dereference.

Starting from the cited commit, mlx5e_skb_from_cqe_nonlinear supports
XDP and calls rcu_dereference, but mlx5e_trap_napi_poll doesn't wrap it
into rcu_read_lock. It leads to RCU-lockdep warnings like this:

    WARNING: suspicious RCU usage

This commit fixes the issue by adding an rcu_read_lock to
mlx5e_trap_napi_poll, similarly to mlx5e_napi_poll.

Fixes: ea5d49bdae8b ("net/mlx5e: Add XDP multi buffer support to the non-linear legacy RQ")
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/trap.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
index a55b066746cb..857840ab1e91 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
@@ -14,19 +14,26 @@ static int mlx5e_trap_napi_poll(struct napi_struct *napi, int budget)
 	bool busy = false;
 	int work_done = 0;
 
+	rcu_read_lock();
+
 	ch_stats->poll++;
 
 	work_done = mlx5e_poll_rx_cq(&rq->cq, budget);
 	busy |= work_done == budget;
 	busy |= rq->post_wqes(rq);
 
-	if (busy)
-		return budget;
+	if (busy) {
+		work_done = budget;
+		goto out;
+	}
 
 	if (unlikely(!napi_complete_done(napi, work_done)))
-		return work_done;
+		goto out;
 
 	mlx5e_cq_arm(&rq->cq);
+
+out:
+	rcu_read_unlock();
 	return work_done;
 }
 
-- 
2.36.1


  parent reply	other threads:[~2022-05-18  6:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  6:34 [pull request][net 00/11] mlx5 fixes 2022-05-17 Saeed Mahameed
2022-05-18  6:34 ` [net 01/11] net/mlx5: DR, Fix missing flow_source when creating multi-destination FW table Saeed Mahameed
2022-05-18 11:10   ` patchwork-bot+netdevbpf
2022-05-18  6:34 ` [net 02/11] net/mlx5: Initialize flow steering during driver probe Saeed Mahameed
2022-05-18  6:34 ` [net 03/11] net/mlx5: DR, Ignore modify TTL on RX if device doesn't support it Saeed Mahameed
2022-05-18  6:34 ` Saeed Mahameed [this message]
2022-05-18  6:34 ` [net 05/11] net/mlx5e: Block rx-gro-hw feature in switchdev mode Saeed Mahameed
2022-05-18  6:34 ` [net 06/11] net/mlx5e: Properly block LRO when XDP is enabled Saeed Mahameed
2022-05-18  6:34 ` [net 07/11] net/mlx5e: Properly block HW GRO " Saeed Mahameed
2022-05-18  6:34 ` [net 08/11] net/mlx5e: Remove HW-GRO from reported features Saeed Mahameed
2022-05-18  6:34 ` [net 09/11] net/mlx5e: CT: Fix support for GRE tuples Saeed Mahameed
2022-05-18  6:34 ` [net 10/11] net/mlx5e: CT: Fix setting flow_source for smfs ct tuples Saeed Mahameed
2022-05-18  6:34 ` [net 11/11] net/mlx5: Drain fw_reset when removing device 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=20220518063427.123758-5-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).