From: Oleg Nesterov <oleg@redhat.com>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] exit: combine work under lock in synchronize_group_exit() and coredump_task_exit()
Date: Wed, 19 Mar 2025 20:25:33 +0100 [thread overview]
Message-ID: <20250319192533.GG26879@redhat.com> (raw)
In-Reply-To: <20250319190950.GF26879@redhat.com>
On 03/19, Oleg Nesterov wrote:
>
> On 03/19, Mateusz Guzik wrote:
> >
> > + spin_lock_irq(&sighand->siglock);
> > + synchronize_group_exit(tsk, code);
> > + core_state = coredump_task_exit_prep(tsk);
> > + spin_unlock_irq(&sighand->siglock);
>
> Well, but why do we need the new (and trivial) coredump_task_exit_prep?
>
> Can't synchronize_group_exit() be
>
> static struct core_state *synchronize_group_exit(struct task_struct *tsk, long code)
> {
> struct sighand_struct *sighand = tsk->sighand;
> struct signal_struct *signal = tsk->signal;
> struct core_state *core_state = NULL;
>
> spin_lock_irq(&sighand->siglock);
> signal->quick_threads--;
> if ((signal->quick_threads == 0) &&
> !(signal->flags & SIGNAL_GROUP_EXIT)) {
> signal->flags = SIGNAL_GROUP_EXIT;
> signal->group_exit_code = code;
> signal->group_stop_count = 0;
> }
> /*
> * Serialize with any possible pending coredump.
> * We must hold siglock around checking core_state
> * and setting PF_POSTCOREDUMP. The core-inducing thread
> * will increment ->nr_threads for each thread in the
> * group without PF_POSTCOREDUMP set.
> */
> tsk->flags |= PF_POSTCOREDUMP;
> core_state = tsk->signal->core_state;
> spin_unlock_irq(&sighand->siglock);
>
> return core_state;
> }
>
> ?
Or even better,
static void synchronize_group_exit(struct task_struct *tsk, long code)
{
struct sighand_struct *sighand = tsk->sighand;
struct signal_struct *signal = tsk->signal;
struct core_state *core_state = NULL;
spin_lock_irq(&sighand->siglock);
signal->quick_threads--;
if ((signal->quick_threads == 0) &&
!(signal->flags & SIGNAL_GROUP_EXIT)) {
signal->flags = SIGNAL_GROUP_EXIT;
signal->group_exit_code = code;
signal->group_stop_count = 0;
}
/*
* Serialize with any possible pending coredump.
* We must hold siglock around checking core_state
* and setting PF_POSTCOREDUMP. The core-inducing thread
* will increment ->nr_threads for each thread in the
* group without PF_POSTCOREDUMP set.
*/
tsk->flags |= PF_POSTCOREDUMP;
core_state = tsk->signal->core_state;
spin_unlock_irq(&sighand->siglock);
if (core_state)
coredump_task_exit(tsk, core_state);
}
> No need to shift spin_lock_irq(siglock) from synchronize_group_exit() to do_exit(),
> no need to rename coredump_task_exit...
do_exit() is already big enough...
Oleg.
prev parent reply other threads:[~2025-03-19 19:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 18:54 [PATCH v2] exit: combine work under lock in synchronize_group_exit() and coredump_task_exit() Mateusz Guzik
2025-03-19 19:09 ` Oleg Nesterov
2025-03-19 19:18 ` Mateusz Guzik
2025-03-19 19:25 ` Oleg Nesterov [this message]
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=20250319192533.GG26879@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox