Skip to content

Commit

Permalink
devlink: Count struct devlink consumers
Browse files Browse the repository at this point in the history
The struct devlink itself is protected by internal lock and doesn't
need global lock during operation. That global lock is used to protect
addition/removal new devlink instances from the global list in use by
all devlink consumers in the system.

The future conversion of linked list to be xarray will allow us to
actually delete that lock, but first we need to count all struct devlink
users.

The reference counting provides us a way to ensure that no new user
space commands success to grab devlink instance which is going to be
destroyed makes it is safe to access it without lock.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Leon Romanovsky authored and David S. Miller committed Aug 14, 2021
1 parent 7ca973d commit 437ebfd
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 35 deletions.
2 changes: 2 additions & 0 deletions include/net/devlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct devlink {
*/
u8 reload_failed:1,
reload_enabled:1;
refcount_t refcount;
struct completion comp;
char priv[0] __aligned(NETDEV_ALIGN);
};

Expand Down
Loading

0 comments on commit 437ebfd

Please sign in to comment.