]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
devlink: Reverse locking order for nested instances
authorCosmin Ratiu <cratiu@nvidia.com>
Wed, 28 Jan 2026 11:25:33 +0000 (13:25 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 3 Feb 2026 04:05:51 +0000 (20:05 -0800)
commit0061b5199d7c81076181a64529f7a799ebb89399
treee4e53c1a90a0c9106fd32cc46a4cc7d6b131e702
parent43af6628f3f69d7011d3fd6e0ef40246a7471d41
devlink: Reverse locking order for nested instances

Commit [1] defined the locking expectations for nested devlink
instances: the nested-in devlink instance lock needs to be acquired
before the nested devlink instance lock. The code handling devlink rels
was architected with that assumption in mind.

There are no actual users of double locking yet but that is about to
change in the upcoming patches in the series.

Code operating on nested devlink instances will require also obtaining
the nested-in instance lock, but such code may already be called from a
variety of places with the nested devlink instance lock. Then, there's
no way to acquire the nested-in lock other than making sure that all
callers acquire it first.

Reversing the nested lock order allows incrementally acquiring the
nested-in instance lock when needed (perhaps even a chain of locks up to
the root) without affecting any caller.

The only affected use of nesting is devlink_nl_nested_fill(), which
iterates over nested devlink instances with the RCU lock, without
locking them, so there's no possibility of deadlock.

So this commit just updates a comment regarding the nested locks.

[1] commit c137743bce02b ("devlink: introduce object and nested devlink
relationship infra")

Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260128112544.1661250-4-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/devlink/core.c