devlink: document devlink_rel_nested_in_notify() function
authorJiri Pirko <jiri@nvidia.com>
Fri, 13 Oct 2023 12:10:29 +0000 (14:10 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Oct 2023 08:23:01 +0000 (09:23 +0100)
Add a documentation for devlink_rel_nested_in_notify() describing the
devlink instance locking consequences.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/devlink/core.c

index 655903ddbdfdb897c6f3c413db4151de4ab4b8c0..6984877e9f10da8ce39050d8335ea79243a831b9 100644 (file)
@@ -168,6 +168,20 @@ int devlink_rel_nested_in_add(u32 *rel_index, u32 devlink_index,
        return 0;
 }
 
+/**
+ * devlink_rel_nested_in_notify - Notify the object this devlink
+ *                               instance is nested in.
+ * @devlink: devlink
+ *
+ * This is called upon network namespace change of devlink instance.
+ * In case this devlink instance is nested in another devlink object,
+ * a notification of a change of this object should be sent
+ * over netlink. The parent devlink instance lock needs to be
+ * taken during the notification preparation.
+ * However, since the devlink lock of nested instance is held here,
+ * we would end with wrong devlink instance lock ordering and
+ * deadlock. Therefore the work is utilized to avoid that.
+ */
 void devlink_rel_nested_in_notify(struct devlink *devlink)
 {
        struct devlink_rel *rel = devlink->rel;