From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vaibhav Shinde <v.bhav.shinde@gmail.com>,
Ajeet Yadav <ajeet.yadav.77@gmail.com>, Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] skip increamenting nr for TASK_UNINTERRUPTIBLE
Date: Sun, 22 Dec 2013 16:09:18 +0100 [thread overview]
Message-ID: <20131222150918.GB12544@redhat.com> (raw)
In-Reply-To: <CA+55aFwBwrindu1AJU4S7XgYyxpuBUyq=wrwdDVn2EJUuChVDg@mail.gmail.com>
Vaibhav,
again, I think that everything was explained by Linus, let me
add some details.
> > In coredump case, where thread_1 faults while thread_2 is in
> > TASK_UNINTERRUPTIBLE state, it cannot handle the SIGKILL.
> > Thus the process hangs on event.
> > The coredump routine freezes until the thread state is
> > uninterruptible.
Yes. But why we should even try to "fix" coredump in this case?
> > Solution: Continue for coredump, without waiting for uninterruptible
> > thread,
This can't work, please see below.
> > as it will get killed as soon as it returns from
> > uninterruptible state.
Not necessarily. It can play with ->mm before it notices the pending
SIGKILL. And, if nothing else, the coredumping paths do not even take
mmap_sem because we assume that the dumper is the only user.
But even if this doesn't happen,
> > Therefore do not increament thread count for threads with
> > TASK_UNINTERRUPTIBLE.
This is very wrong too. This means that we can start the coredump before
the _accounted_ thread exits (because a skipped thread can exit first and
decrement the counter). This also means that coredump_finish() can race
with the unaccounted threads.
> > sigaddset(&t->pending.signal, SIGKILL);
> > signal_wake_up(t, 1);
> > - nr++;
> > + if(!(t->state & TASK_UNINTERRUPTIBLE))
> > + nr++;
Again, we can't simply check t->state & TASK_UNINTERRUPTIBLE. This can
be false positive or it can sleep in TASK_UNINTERRUPTIBLE right after
the check. And even "& TASK_UNINTERRUPTIBLE" is wrong, please look at
TASK_KILLABLE.
Oleg.
prev parent reply other threads:[~2013-12-22 15:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-21 12:18 [PATCH] skip increamenting nr for TASK_UNINTERRUPTIBLE Vaibhav Shinde
2013-12-21 17:47 ` Linus Torvalds
2013-12-21 18:30 ` Oleg Nesterov
2013-12-22 15:09 ` 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=20131222150918.GB12544@redhat.com \
--to=oleg@redhat.com \
--cc=ajeet.yadav.77@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=v.bhav.shinde@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