Skip to contentSkip to conversation

elf_fdpic_core_dump: don't take tasklist_lock

PATCH In review Oleg Nesterov 2 participants 2 messages Aug 13, 2006 – Aug 14, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 elf_fdpic_core_dump: don't take tasklist_lock

do_each_thread() is rcu-safe, and all tasks which use this ->mm must sleep in wait_for_completion(&mm->core_done) at this point, so we can use RCU locks.

Also, remove unneeded INIT_LIST_HEAD(new) before list_add(new, head).

fs/binfmt_elf_fdpic.c renamed from fs/binfmt_elf_fdpic.c~fdpic +3 -4
@@ -1597,20 +1597,19 @@ static int elf_fdpic_core_dump(long sign
 
 	if (signr) {
 		struct elf_thread_status *tmp;
-		read_lock(&tasklist_lock);
+		rcu_read_lock();
 		do_each_thread(g,p)
 			if (current->mm == p->mm && current != p) {
 				tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
 				if (!tmp) {
-					read_unlock(&tasklist_lock);
+					rcu_read_unlock();
 					goto cleanup;
 				}
-				INIT_LIST_HEAD(&tmp->list);
 				tmp->thread = p;
 				list_add(&tmp->list, &thread_list);
 			}
 		while_each_thread(g,p);
-		read_unlock(&tasklist_lock);
+		rcu_read_unlock();
 		list_for_each(t, &thread_list) {
 			struct elf_thread_status *tmp;
 			int sz;
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Oleg Nesterov

do_each_thread() is rcu-safe, and all tasks which use this ->mm must sleep in wait_for_completion(&mm->core_done) at this point, so we can use RCU locks.

Looks reasonable.