Re: [RFC PATCH 2/3] exec: don't wait for zombie threads with cred_guard_mutex held

From
Oleg Nesterov <oleg@redhat.com>
Date
2025-11-10 15:09:17
Also in
linux-fsdevel, linux-kselftest, linux-mm, lkml
Reply to
Cyrill Gorcunov, 2025-11-10
Hi Cyrill,

On 11/10, Cyrill Gorcunov wrote:
On Sun, Nov 09, 2025 at 06:15:33PM +0100, Oleg Nesterov wrote:
..
quoted
static int kill_sub_threads(struct task_struct *tsk)
{
 	struct signal_struct *sig = tsk->signal;
	int err = -EINTR;

	read_lock(&tasklist_lock);
	spin_lock_irq(&tsk->sighand->siglock);
	if (!((sig->flags & SIGNAL_GROUP_EXIT) || sig->group_exec_task)) {
		sig->group_exec_task = tsk;
		sig->notify_count = -zap_other_threads(tsk);
Hi Oleg! I somehow manage to miss a moment -- why negative result here?
You know, initially I wrote

		sig->notify_count = 0 - zap_other_threads(tsk);

to make it clear that this is not a typo ;)


This is for exit_notify() which does

	/* mt-exec, de_thread() -> wait_for_notify_count() */
	if (tsk->signal->notify_count < 0 && !++tsk->signal->notify_count)
		wake_up_process(tsk->signal->group_exec_task);

Then setup_new_exec() sets notify_count > 0 for __exit_signal() which does

	/* mt-exec, setup_new_exec() -> wait_for_notify_count() */
	if (sig->notify_count > 0 && !--sig->notify_count)
		wake_up_process(sig->group_exec_task);

Yes this needs more comments and (with or without this patch) cleanups.
Note that exit_notify() and __exit_signal() already (before this patch)
use ->notify_count almost the same way, just exit_notify() assumes that
notify_count < 0 means the !thread_group_leader() case in de_thread().

Oleg.
Thread (28 messages) 28 messages, 5 authors, last reply 2025-12-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help