# \[patch net-next v3 7/7\] devlink: document devlink\_rel\_nested\_in\_notify() function

- From: Jiri Pirko \<jiri@resnulli.us\>
- Date: 2023-10-13 12:10:46 
- List: netdev
- Page: https://ratatoskr.run/netdev/2023/10/11274254
- Thread: https://ratatoskr.run/netdev/2023/10/11274247/t.md

```text
From: Jiri Pirko <redacted>

Add a documentation for devlink_rel_nested_in_notify() describing the
devlink instance locking consequences.

Signed-off-by: Jiri Pirko <redacted>
---
v2->v3:
- new patch
---
 net/devlink/core.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/net/devlink/core.c b/net/devlink/core.c
index 655903ddbdfd..6984877e9f10 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -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;
-- 
2.41.0

```
