All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/1] exit: kill signal_struct->quick_threads
Date: Mon, 10 Jun 2024 17:29:02 +0200	[thread overview]
Message-ID: <20240610152902.GC20640@redhat.com> (raw)
In-Reply-To: <87r0d5t2nt.fsf@email.froward.int.ebiederm.org>

Hi Eric, thanks for looking at this.

Let me answer your questions out-of-order. But, before anything else,
do you see anything wrong in 1/1 ?

On 06/10, Eric W. Biederman wrote:
>
> May I ask which direction you are coming at this from?  Are you trying
> to reduce the cost of do_exit?  Are you interested in untangling the
> mess that is exiting threads in a process?

I am trying to understand why do we need another counter.

And, I'd like to cleanup the usage of task->signal->live, I think it
should be avoided (if possible) when task != current. IIRC, we even
discussed this some time ago but I can't find any reference.

See also another thread about css_task_iter_advance().

> > Eric, I can't understand why the commit ("signal: Guarantee that
> > SIGNAL_GROUP_EXIT is set on process exit") added the new
> > quick_threads counter. And why, if we forget about --quick_threads,
> > synchronize_group_exit() has to take siglock unconditionally.
> > Did I miss something obvious?
>
> At a minimum it is the exact same locking as everywhere else that sets
> signal->flags, signal->group_exit_code, and signal->group_stop_count
> uses.
>
> So it would probably require some significant reason to not use
> the same locking and complicate reasoning about the code.  I suspect
> setting those values without siglock held is likely to lead to
> interesting races.

I guess I was not clear. Of course, SIGNAL_GROUP_EXIT must be always
set under ->siglock. But I think synchronize_group_exit() can just
return if SIGNAL_GROUP_EXIT is already set? If nothing else, this is
what do_group_exit() does.

Or I misunderstood you?

> That is where signal->quick_threads comes from.  In the work it is a
> part of I wind up moving the decrement up much sooner to the point where
> individual threads decide to exit.  The decrement of signal->live comes
> much too late to be useful in that context.

And that is why this patch moves the decrement of signal->live to the
start of do_exit().

> It is also part of me wanting to be able to uniformly use
> SIGNAL_GROUP_EXIT and signal->group_exit_code when talking about the
> process state, and p->exit_code when talking about the per task state.

Agreed,

> At the moment I am staring at wait_task_zombie and trying to understand
> how:
>
> 	status = (p->signal->flags & SIGNAL_GROUP_EXIT)
> 		? p->signal->group_exit_code : p->exit_code;
>
> works without any locks or barriers.

Agreed, at first glance this looks worrying without siglock... I'll try
to take a look, perhaps we can simply kill the SIGNAL_GROUP_EXIT check,
not sure.

But this patch should not make any difference ?

Oleg.


  reply	other threads:[~2024-06-10 15:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-09 14:23 [PATCH 0/1] exit: kill signal_struct->quick_threads Oleg Nesterov
2024-06-09 14:24 ` [PATCH 1/1] " Oleg Nesterov
2024-06-09 18:28 ` [PATCH 0/1] " Oleg Nesterov
2024-06-10 10:50 ` Q: css_task_iter_advance() && dying_tasks Oleg Nesterov
2024-06-10 11:08   ` Oleg Nesterov
2024-06-10 20:02     ` Tejun Heo
2024-06-10 20:00   ` Tejun Heo
2024-06-10 12:15 ` [PATCH 0/1] exit: kill signal_struct->quick_threads Eric W. Biederman
2024-06-10 15:29   ` Oleg Nesterov [this message]
2024-06-10 15:42     ` Oleg Nesterov
2024-06-10 16:18     ` Oleg Nesterov
2024-06-13 15:45     ` Oleg Nesterov
2024-06-15 14:53       ` Eric W. Biederman
2024-06-17 18:37         ` Oleg Nesterov
2024-06-19  3:48           ` Eric W. Biederman
2024-06-19  4:04             ` [PATCH 0/17] exit: complete synchronize_group_exit Eric W. Biederman
2024-06-19  4:05               ` [PATCH 01/17] signal: Make SIGKILL during coredumps an explicit special case Eric W. Biederman
2024-06-19 15:50                 ` Oleg Nesterov
2024-06-19 18:09                   ` Eric W. Biederman
2024-06-19 19:11                     ` Oleg Nesterov
2024-06-21  5:46                       ` Eric W. Biederman
2024-06-21 10:40                         ` Oleg Nesterov
2024-06-21 16:30                           ` Eric W. Biederman
2024-06-19  4:05               ` [PATCH 02/17] signal: Compute the process exit_code in get_signal Eric W. Biederman
2024-06-25 12:34                 ` Oleg Nesterov
2024-06-19  4:06               ` [PATCH 03/17] coredump: Consolidate the work to allow SIGKILL during coredumps Eric W. Biederman
2024-06-25 12:34                 ` Oleg Nesterov
2024-06-19  4:06               ` [PATCH 04/17] signal: In get_signal call do_exit when it is unnecessary to shoot down threads Eric W. Biederman
2024-06-25 12:35                 ` Oleg Nesterov
2024-06-19  4:07               ` [PATCH 05/17] signal: Bring down all threads when handling a non-coredump fatal signal Eric W. Biederman
2024-06-25 12:56                 ` Oleg Nesterov
2024-06-19  4:07               ` [PATCH 06/17] signal: Add JOBCTL_WILL_EXIT to mark exiting tasks Eric W. Biederman
2024-06-19  4:08               ` [PATCH 07/17] signal: Always set JOBCTL_WILL_EXIT for " Eric W. Biederman
2024-06-30 14:00                 ` kernel test robot
2024-06-19  4:08               ` [PATCH 08/17] signal: Don't target tasks that are exiting Eric W. Biederman
2024-06-19  4:09               ` [PATCH 09/17] signal: Test for process exit or de_thread using task_exit_pending Eric W. Biederman
2024-06-19  4:09               ` [PATCH 10/17] signal: Only set JOBCTL_WILL_EXIT if it is not already set Eric W. Biederman
2024-06-19  4:10               ` [PATCH 11/17] signal: Make individual tasks exiting a first class concept Eric W. Biederman
2024-06-19  4:10               ` [PATCH 12/17] signal: Remove zap_other_threads Eric W. Biederman
2024-06-19  4:11               ` [PATCH 13/17] signal: Stop skipping current in do_group_exit & get_signal Eric W. Biederman
2024-06-28  5:43                 ` [LTP] " kernel test robot
2024-06-28  5:43                   ` kernel test robot
2024-06-19  4:11               ` [PATCH 14/17] signal: Factor out schedule_group_exit_locked Eric W. Biederman
2024-06-19  4:12               ` [PATCH 15/17] ptrace: Separate task->ptrace_code out from task->exit_code Eric W. Biederman
2024-06-19  4:12               ` [PATCH 16/17] signal: Record the exit_code when an exit is scheduled Eric W. Biederman
2024-06-19  4:13               ` [PATCH 17/17] signal: Set SIGNAL_GROUP_EXIT when all tasks have decided to exit Eric W. Biederman
2024-06-19 20:18             ` [PATCH 0/1] exit: kill signal_struct->quick_threads Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240610152902.GC20640@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.