From: Oleg Nesterov <oleg@redhat.com>
To: Roman Penyaev <roman.penyaev@profitbricks.com>
Cc: Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] workqueue: ignore dead tasks in a workqueue sleep hook
Date: Tue, 25 Oct 2016 16:19:20 +0200 [thread overview]
Message-ID: <20161025141920.GC4326@redhat.com> (raw)
In-Reply-To: <CAJrWOzBCa5fqV0N_OK65F4wqJWyXLs+J_m4e8_VWP3BAPMMTxw@mail.gmail.com>
On 10/25, Roman Penyaev wrote:
>
> On Tue, Oct 25, 2016 at 2:56 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> > On 10/25, Roman Pen wrote:
> >>
> >> struct task_struct *wq_worker_sleeping(struct task_struct *task)
> >> {
> >> - struct worker *worker = kthread_data(task), *to_wakeup = NULL;
> >> + struct worker *worker, *to_wakeup = NULL;
> >> struct worker_pool *pool;
> >>
> >> +
> >> + if (task->state == TASK_DEAD) {
> >> + /*
> >> + * Here we try to catch the following path before
> >> + * accessing NULL kthread->vfork_done ptr thru
> >> + * kthread_data():
> >> + *
> >> + * oops_end()
> >> + * do_exit()
> >> + * schedule()
> >> + *
> >> + * If panic_on_oops is not set and oops happens on
> >> + * a workqueue execution path, thread will be killed.
> >> + * That is definitly sad, but not to make the situation
> >> + * even worse we have to ignore dead tasks in order not
> >> + * to step on zeroed out members (e.g. t->vfork_done is
> >> + * already NULL on that path, since we were called by
> >> + * do_exit())).
> >> + */
> >> + return NULL;
> >> + }
> >
> > I still think that PF_EXITING check makes more sense than TASK_DEAD,
> > but I won't insist.
>
> Why? I probably do not see the corner cases, so, please, explain.
If nothing else the crashed worker can schedule() before do_task_dead(),
But mainly, to me PF_EXITING just looks better. TASK_DEAD is the very
special state, only sched/core.c should use it.
and... perhaps we can just add
void oops_end_exit(void)
{
current->flags &= ~PF_WQ_WORKER;
perhaps sonething else;
}
called by oops_end() before rewind_stack_do_exit() ?
Oleg.
next prev parent reply other threads:[~2016-10-25 14:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 11:03 [PATCH v3 1/1] workqueue: ignore dead tasks in a workqueue sleep hook Roman Pen
2016-10-25 12:56 ` Oleg Nesterov
2016-10-25 13:00 ` Roman Penyaev
2016-10-25 14:19 ` Oleg Nesterov [this message]
2016-10-25 15:57 ` Oleg Nesterov
2016-10-25 16:08 ` Oleg Nesterov
2016-10-25 18:15 ` Roman Penyaev
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=20161025141920.GC4326@redhat.com \
--to=oleg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=roman.penyaev@profitbricks.com \
--cc=tglx@linutronix.de \
--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 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).