Thread (36 messages) 36 messages, 4 authors, 17d ago

[PATCH v4 05/15] cpu/hotplug: convert process iterator to for_each_process_rculock

flat view
COLD17d REVIEWED: 4 (4M)

From: Ye Liu <hidden>
Date: 2026-09-21 09:22:42
Also in: linux-fsdevel, linux-mm, linux-pm, linux-security-module, lkml, rcu
Subsystem: cpu hotplug, the rest · Maintainers: Thomas Gleixner, Peter Zijlstra, Linus Torvalds

Status: Reviewed.

Revision v4 (3 revisions archived); 4 review trailers.

Revisions (3)
  1. v2
  2. v3 [diff against previous]
  3. v4 current [diff against previous]
From: Ye Liu <liuye@kylinos.cn>

Replace the manual rcu_read_lock()/rcu_read_unlock() pair combined
with for_each_process() loop in kernel/cpu.c with for_each_process_rculock(),
which scopes the RCU read lock to the loop body via scoped_guard(rcu).

No functional change.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/cpu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index b3c8553d7bd6..00638d2abc0f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1254,8 +1254,7 @@ void clear_tasks_mm_cpumask(int cpu)
 	 * full-fledged tasklist_lock.
 	 */
 	WARN_ON(cpu_online(cpu));
-	rcu_read_lock();
-	for_each_process(p) {
+	for_each_process_rculock(p) {
 		struct task_struct *t;
 
 		/*
@@ -1268,7 +1267,6 @@ void clear_tasks_mm_cpumask(int cpu)
 		arch_clear_mm_cpumask_cpu(cpu, t->mm);
 		task_unlock(t);
 	}
-	rcu_read_unlock();
 }
 
 /* Take this CPU down. */
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help