Hi Cyrill,
On 11/10, Cyrill Gorcunov wrote:
On Sun, Nov 09, 2025 at 06:15:33PM +0100, Oleg Nesterov wrote: ..
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.