Skip to contentSkip to conversation

exit: avoid sig->count in __exit_signal() to detect the group-dead case

PATCH In review Oleg Nesterov 1 participant 1 message Mar 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 exit: avoid sig->count in __exit_signal() to detect the group-dead case

Change __exit_signal() to check thread_group_leader() instead of atomic_dec_and_test(&sig->count). This must be equivalent, the group leader must be released only after all other threads have exited and passed __exit_signal().

Quoted 1 line

From now sig->count is not actually used, except in fs/proc for

get_nr_threads/etc.

---

kernel/exit.c renamed from kernel/exit.c~4_EXIT_SIGNAL +3 -2
@@ -89,11 +89,12 @@ static void __exit_signal(struct task_st
 					rcu_read_lock_held() ||
 					lockdep_is_held(&tasklist_lock));
 	spin_lock(&sighand->siglock);
+	atomic_dec(&sig->count);
 
 	posix_cpu_timers_exit(tsk);
-	if (atomic_dec_and_test(&sig->count))
+	if (thread_group_leader(tsk)) {
 		posix_cpu_timers_exit_group(tsk);
-	else {
+	} else {
 		/*
 		 * If there is any task waiting for the group exit
 		 * then notify it: