From: chenqiwu <qiwuchen55@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>,
christian.brauner@ubuntu.com, peterz@infradead.org,
mingo@kernel.org
Cc: kernel-team@android.com, linux-kernel@vger.kernel.org,
chenqiwu@xiaomi.com
Subject: Re: [PATCH v2] kernel/exit: do panic earlier to get coredump if global init task exit
Date: Tue, 17 Dec 2019 22:56:20 +0800 [thread overview]
Message-ID: <20191217145620.GA26585@cqw-OptiPlex-7050> (raw)
In-Reply-To: <20191217142515.GB23152@redhat.com>
On Tue, Dec 17, 2019 at 03:25:15PM +0100, Oleg Nesterov wrote:
> On 12/17, chenqiwu wrote:
> >
> > @@ -728,6 +724,15 @@ void __noreturn do_exit(long code)
> > panic("Attempted to kill the idle task!");
> >
> > /*
> > + * If all threads of global init have exited, do panic imeddiately
> > + * to get the coredump to find any clue for init task in userspace.
> > + */
> > + if (unlikely(is_global_init(tsk) &&
> > + (atomic_read(&tsk->signal->live) == 1)))
>
> Well, I guess this will work in practice, but in theory this is racy.
>
> Suppose that signal->live == 2 and both threads exit in parallel. They
> both can see tsk->signal->live == 2 before atomic_dec_and_test().
>
> If you are fine with this race I won't object, but please add a comment.
>
> But why can't you simply do
>
> --- x/kernel/exit.c
> +++ x/kernel/exit.c
> @@ -786,6 +786,8 @@ void __noreturn do_exit(long code)
> acct_update_integrals(tsk);
> group_dead = atomic_dec_and_test(&tsk->signal->live);
> if (group_dead) {
> + if (unlikely(is_global_init(tsk)
> + panic(...);
> #ifdef CONFIG_POSIX_TIMERS
> hrtimer_cancel(&tsk->signal->real_timer);
> exit_itimers(tsk->signal);
>
> ?
>
> Oleg.
>
Oh, yeah, thanks for your reminds! But in fact, I think atomic_read()
can avoid the racy even if both threads exit in parallel, since it is
an atomic operation forever. I agree your simply modify, is there any
other questions?
next prev parent reply other threads:[~2019-12-17 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 3:18 [PATCH v2] kernel/exit: do panic earlier to get coredump if global init task exit qiwuchen55
2019-12-16 10:27 ` Christian Brauner
2019-12-16 17:28 ` Oleg Nesterov
2019-12-16 17:44 ` Christian Brauner
2019-12-17 10:50 ` chenqiwu
2019-12-17 14:25 ` Oleg Nesterov
2019-12-17 14:56 ` chenqiwu [this message]
2019-12-17 15:23 ` Oleg Nesterov
2019-12-17 19:33 ` Peter Zijlstra
2019-12-18 8:08 ` chenqiwu
2019-12-17 14:14 ` 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=20191217145620.GA26585@cqw-OptiPlex-7050 \
--to=qiwuchen55@gmail.com \
--cc=chenqiwu@xiaomi.com \
--cc=christian.brauner@ubuntu.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).