Thread (20 messages) 20 messages, 3 authors, 2025-11-14
STALE216d

[PATCH 06/17] nstree: simplify owner list iteration

From: Christian Brauner <brauner@kernel.org>
Date: 2025-11-10 15:09:12
Also in: bpf, cgroups, linux-fsdevel, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

Make use of list_for_each_entry_from_rcu().

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 kernel/nstree.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/nstree.c b/kernel/nstree.c
index 6c7ec9fbf25f..476dd738d653 100644
--- a/kernel/nstree.c
+++ b/kernel/nstree.c
@@ -598,11 +598,15 @@ static ssize_t do_listns_userns(struct klistns *kls)
 	rcu_read_lock();
 
 	if (!first_ns)
-		first_ns = list_entry_rcu(head->next, typeof(*ns), ns_owner_node.ns_list_entry);
-	for (ns = first_ns; &ns->ns_owner_node.ns_list_entry != head && nr_ns_ids;
-	     ns = list_entry_rcu(ns->ns_owner_node.ns_list_entry.next, typeof(*ns), ns_owner_node.ns_list_entry)) {
+		first_ns = list_entry_rcu(head->next, typeof(*first_ns), ns_owner_node.ns_list_entry);
+
+	ns = first_ns;
+	list_for_each_entry_from_rcu(ns, head, ns_owner_node.ns_list_entry) {
 		struct ns_common *valid;
 
+		if (!nr_ns_ids)
+			break;
+
 		valid = legitimize_ns(kls, ns);
 		if (!valid)
 			continue;
-- 
2.47.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help