Subject: [PATCH net-next v2 09/15] devlink: health: combine loops in dump

From: Jakub Kicinski <[email-masked]>
Date: Wed, 4 Jan 2023 20:05:25 -0800

Walk devlink instances only once. Dump the instance reporters
and port reporters before moving to the next instance.
User space should not depend on ordering of messages.

This will make improving stability of the walk easier.

Reviewed-by: Jiri Pirko <[email-masked]>
Reviewed-by: Jacob Keller <[email-masked]>
Signed-off-by: Jakub Kicinski <[email-masked]>
---
 net/devlink/leftover.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index d88461b33ddf..83cd7bd55941 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -7940,10 +7940,7 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
 			idx++;
 		}
 		mutex_unlock(&devlink->reporters_lock);
-		devlink_put(devlink);
-	}
 
-	devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
 		devl_lock(devlink);
 		xa_for_each(&devlink->ports, port_index, port) {
 			mutex_lock(&port->reporters_lock);
-- 
2.38.1