All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Roi Dayan <roid@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next 06/14] net/mlx5e: Avoid false lock depenency warning on tc_ht
Date: Mon,  1 Feb 2021 22:54:49 -0800	[thread overview]
Message-ID: <20210202065457.613312-7-saeed@kernel.org> (raw)
In-Reply-To: <20210202065457.613312-1-saeed@kernel.org>

From: Roi Dayan <roid@nvidia.com>

To avoid false lock dependency warning set the tc_ht lock
class different than the lock class of the ht being used when deleting
last flow from a group and then deleting a group, we get into del_sw_flow_group()
which call rhashtable_destroy on fg->ftes_hash which will take ht->mutex but
it's different than the ht->mutex here.

======================================================
WARNING: possible circular locking dependency detected
5.11.0-rc4_net_next_mlx5_949fdcc #1 Not tainted
------------------------------------------------------
modprobe/12950 is trying to acquire lock:
ffff88816510f910 (&node->lock){++++}-{3:3}, at: mlx5_del_flow_rules+0x2a/0x210 [mlx5_core]

but task is already holding lock:
ffff88815834e3e8 (&ht->mutex){+.+.}-{3:3}, at: rhashtable_free_and_destroy+0x37/0x340

which lock already depends on the new lock.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 8fd38ad8113b..280ea1e1e039 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -190,6 +190,14 @@ struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[] = {
 	[NIC_ZONE_RESTORE_TO_REG] = nic_zone_restore_to_reg_ct,
 };
 
+/* To avoid false lock dependency warning set the tc_ht lock
+ * class different than the lock class of the ht being used when deleting
+ * last flow from a group and then deleting a group, we get into del_sw_flow_group()
+ * which call rhashtable_destroy on fg->ftes_hash which will take ht->mutex but
+ * it's different than the ht->mutex here.
+ */
+static struct lock_class_key tc_ht_lock_key;
+
 static void mlx5e_put_flow_tunnel_id(struct mlx5e_tc_flow *flow);
 
 void
@@ -5215,6 +5223,8 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
 	if (err)
 		return err;
 
+	lockdep_set_class(&tc->ht.mutex, &tc_ht_lock_key);
+
 	if (MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ignore_flow_level)) {
 		attr.flags = MLX5_CHAINS_AND_PRIOS_SUPPORTED |
 			MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED;
@@ -5333,6 +5343,8 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
 	if (err)
 		goto err_ht_init;
 
+	lockdep_set_class(&tc_ht->mutex, &tc_ht_lock_key);
+
 	return err;
 
 err_ht_init:
-- 
2.29.2


  parent reply	other threads:[~2021-02-02  6:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02  6:54 [pull request][net-next 00/14] mlx5 updates 2021-02-01 Saeed Mahameed
2021-02-02  6:54 ` [net-next 01/14] net/mlx5e: Separate between netdev objects and mlx5e profiles initialization Saeed Mahameed
2021-02-03  3:10   ` patchwork-bot+netdevbpf
2021-02-02  6:54 ` [net-next 02/14] net/mxl5e: Add change profile method Saeed Mahameed
2021-02-02  6:54 ` [net-next 03/14] net/mlx5e: Refactor mlx5e_netdev_init/cleanup to mlx5e_priv_init/cleanup Saeed Mahameed
2021-02-02  6:54 ` [net-next 04/14] net/mlx5e: Move netif_carrier_off() out of mlx5e_priv_init() Saeed Mahameed
2021-02-02  6:54 ` [net-next 05/14] net/mlx5e: Move set vxlan nic info to profile init Saeed Mahameed
2021-02-02  6:54 ` Saeed Mahameed [this message]
2021-02-02  6:54 ` [net-next 07/14] net/mlx5e: Move representor neigh init into profile enable Saeed Mahameed
2021-02-02  6:54 ` [net-next 08/14] net/mlx5e: Enable napi in channel's activation stage Saeed Mahameed
2021-02-02  6:54 ` [net-next 09/14] net/mlx5e: Increase indirection RQ table size to 256 Saeed Mahameed
2021-02-02  6:54 ` [net-next 10/14] net/mlx5e: remove h from printk format specifier Saeed Mahameed
2021-02-02  6:54 ` [net-next 11/14] net/mlx5e: kTLS, Improve TLS RX workqueue scope Saeed Mahameed
2021-02-02  6:54 ` [net-next 12/14] net/mlx5e: accel, remove redundant space Saeed Mahameed
2021-02-02  6:54 ` [net-next 13/14] net/mlx5e: CT: remove useless conversion to PTR_ERR then ERR_PTR Saeed Mahameed
2021-02-02  6:54 ` [net-next 14/14] net/mlx5: DR, Avoid unnecessary csum recalculation on supporting devices 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=20210202065457.613312-7-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=roid@nvidia.com \
    --cc=saeedm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.