From: Oleg Nesterov <oleg@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Roman Pen <roman.penyaev@profitbricks.com>,
Andy Lutomirski <luto@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
"H . Peter Anvin" <hpa@zytor.com>,
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" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] sched: do not call workqueue sleep hook if task is already dead
Date: Fri, 21 Oct 2016 17:47:36 +0200 [thread overview]
Message-ID: <20161021154735.GA22949@redhat.com> (raw)
In-Reply-To: <CALCETrUxRSGg=AwyX5eYxWq=bYG=JAjTv4V1g9UX3ng5WANoUA@mail.gmail.com>
On 10/20, Andy Lutomirski wrote:
>
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -3380,8 +3380,22 @@ static void __sched notrace __schedule(bool preempt)
> > * If a worker went to sleep, notify and ask workqueue
> > * whether it wants to wake up a task to maintain
> > * concurrency.
> > + *
> > + * Also the following stack is possible:
> > + * 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()))
And we have more problems like this. Say, if blk_flush_plug_list()
crashes it will likely crash again and again recursively.
> > */
> > - if (prev->flags & PF_WQ_WORKER) {
> > + if (prev->flags & PF_WQ_WORKER &&
> > + prev->state != TASK_DEAD) {
I don't think we should change __schedule()... Can't we simply clear
PF_WQ_WORKER in complete_vfork_done() ? Or add the PF_EXITING checks
into wq_worker_sleeping() and wq_worker_waking_up().
Or perhaps something like the change below.
Oleg.
--- x/kernel/workqueue.c
+++ x/kernel/workqueue.c
@@ -2157,6 +2157,14 @@ static void process_scheduled_works(stru
}
}
+static void oops_handler(struct callback_head *oops_work)
+{
+ if (!(current->flags & PF_WQ_WORKER))
+ return;
+
+ clear PF_WQ_WORKER, probably do more cleanups
+}
+
/**
* worker_thread - the worker thread function
* @__worker: self
@@ -2171,11 +2179,14 @@ static void process_scheduled_works(stru
*/
static int worker_thread(void *__worker)
{
+ struct callback_head oops_work;
struct worker *worker = __worker;
struct worker_pool *pool = worker->pool;
/* tell the scheduler that this is a workqueue worker */
worker->task->flags |= PF_WQ_WORKER;
+ init_task_work(&oops_work, oops_handler);
+ task_work_add(current, &oops_work, false);
woke_up:
spin_lock_irq(&pool->lock);
next prev parent reply other threads:[~2016-10-21 15:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 15:43 [PATCH 1/2] x86/dumpstack: on oops do not rewind stack for kthread Roman Pen
2016-09-21 15:43 ` [PATCH 2/2] sched: do not call workqueue sleep hook if task is already dead Roman Pen
2016-10-20 23:08 ` Andy Lutomirski
2016-10-21 15:47 ` Oleg Nesterov [this message]
2016-10-24 16:01 ` Roman Penyaev
2016-10-21 5:39 ` Peter Zijlstra
2016-10-20 23:07 ` [PATCH 1/2] x86/dumpstack: on oops do not rewind stack for kthread Andy Lutomirski
2016-10-21 5:56 ` Peter Zijlstra
2016-10-21 8:05 ` Thomas Gleixner
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=20161021154735.GA22949@redhat.com \
--to=oleg@redhat.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--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 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.