From: Simon Horman <horms@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
davem@davemloft.net, edumazet@google.com
Subject: Re: [patch net-next v3 4/7] devlink: don't take instance lock for nested handle put
Date: Tue, 17 Oct 2023 10:51:46 +0200 [thread overview]
Message-ID: <20231017085146.GL1751252@kernel.org> (raw)
In-Reply-To: <20231013121029.353351-5-jiri@resnulli.us>
On Fri, Oct 13, 2023 at 02:10:26PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
>
> Lockdep reports following issue:
>
> WARNING: possible circular locking dependency detected
> ------------------------------------------------------
> devlink/8191 is trying to acquire lock:
> ffff88813f32c250 (&devlink->lock_key#14){+.+.}-{3:3}, at: devlink_rel_devlink_handle_put+0x11e/0x2d0
>
> but task is already holding lock:
> ffffffff8511eca8 (rtnl_mutex){+.+.}-{3:3}, at: unregister_netdev+0xe/0x20
>
> which lock already depends on the new lock.
>
> the existing dependency chain (in reverse order) is:
>
> -> #3 (rtnl_mutex){+.+.}-{3:3}:
...
> Possible unsafe locking scenario:
>
> CPU0 CPU1
> ---- ----
> lock(rtnl_mutex);
> lock(mlx5_intf_mutex);
> lock(rtnl_mutex);
> lock(&devlink->lock_key#14);
>
> Problem is taking the devlink instance lock of nested instance when RTNL
> is already held.
>
> To fix this, don't take the devlink instance lock when putting nested
> handle. Instead, rely on the preparations done by previous two patches
> to be able to access device pointer and obtain netns id without devlink
> instance lock held.
>
> Fixes: c137743bce02 ("devlink: introduce object and nested devlink relationship infra")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
next prev parent reply other threads:[~2023-10-17 8:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 12:10 [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock Jiri Pirko
2023-10-13 12:10 ` [patch net-next v3 1/7] net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu() Jiri Pirko
2023-10-17 8:49 ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 2/7] devlink: call peernet2id_alloc() with net pointer under RCU read lock Jiri Pirko
2023-10-17 8:50 ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 3/7] devlink: take device reference for devlink object Jiri Pirko
2023-10-17 8:50 ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 4/7] devlink: don't take instance lock for nested handle put Jiri Pirko
2023-10-17 8:51 ` Simon Horman [this message]
2023-10-13 12:10 ` [patch net-next v3 5/7] Documentation: devlink: add nested instance section Jiri Pirko
2023-10-17 8:52 ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 6/7] Documentation: devlink: add a note about RTNL lock into locking section Jiri Pirko
2023-10-17 8:53 ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 7/7] devlink: document devlink_rel_nested_in_notify() function Jiri Pirko
2023-10-17 8:53 ` Simon Horman
2023-10-18 8:30 ` [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock patchwork-bot+netdevbpf
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=20231017085146.GL1751252@kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).