From: Oleg Nesterov <oleg@redhat.com>
To: dl8bcu@dl8bcu.de, peterz@infradead.org, mingo@kernel.org,
linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 1/1] task_work: Add local_irq_enable() into task_work_run()
Date: Fri, 12 Oct 2012 18:03:59 +0200 [thread overview]
Message-ID: <20121012160359.GB30881@redhat.com> (raw)
In-Reply-To: <20121012160337.GA30881@redhat.com>
arch/alpha and probably some other architectures call
do_notify_resume()->task_work_run() with irqs disabled.
This wasn't noticed because key_replace_session_keyring() and
then task_work_run() did spin_lock_irq() + spin_unlock_irq(),
but this sequence was removed by 9da33de6.
Add local_irq_enable() as a workaround, and WARN_ONCE() to
catch other buggy callers.
While at it, remove the unnecessary initialization and add
smp_ to read_barrier_depends() in task_work_cancel().
Reported-by: Thorsten Kranzkowski <dl8bcu@dl8bcu.de>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/task_work.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/task_work.c b/kernel/task_work.c
index 65bd3c9..d39190c 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -25,7 +25,7 @@ struct callback_head *
task_work_cancel(struct task_struct *task, task_work_func_t func)
{
struct callback_head **pprev = &task->task_works;
- struct callback_head *work = NULL;
+ struct callback_head *work;
unsigned long flags;
/*
* If cmpxchg() fails we continue without updating pprev.
@@ -35,7 +35,7 @@ task_work_cancel(struct task_struct *task, task_work_func_t func)
*/
raw_spin_lock_irqsave(&task->pi_lock, flags);
while ((work = ACCESS_ONCE(*pprev))) {
- read_barrier_depends();
+ smp_read_barrier_depends();
if (work->func != func)
pprev = &work->next;
else if (cmpxchg(pprev, work, work->next) == work)
@@ -51,6 +51,10 @@ void task_work_run(void)
struct task_struct *task = current;
struct callback_head *work, *head, *next;
+ if (WARN_ONCE(irqs_disabled(),
+ "do_notify_resume() with irqs disabled, fix this arch."))
+ local_irq_enable();
+
for (;;) {
/*
* work->func() can do task_work_add(), do not set
--
1.5.5.1
next prev parent reply other threads:[~2012-10-12 16:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-06 20:47 [regression] boot failure on alpha, bisected Thorsten Kranzkowski
2012-10-07 16:55 ` Oleg Nesterov
2012-10-07 17:08 ` Al Viro
2012-10-07 17:33 ` Oleg Nesterov
2012-10-07 19:39 ` Al Viro
2012-10-08 14:14 ` Dialup Jon Norstog
2012-10-08 14:14 ` Dialup Jon Norstog
2012-10-08 18:59 ` Oleg Nesterov
2012-10-07 17:13 ` Oleg Nesterov
2012-10-07 18:04 ` Thorsten Kranzkowski
2012-10-07 19:16 ` Oleg Nesterov
2012-10-07 19:41 ` Thorsten Kranzkowski
2012-10-08 18:59 ` Geert Uytterhoeven
2012-10-08 19:10 ` Oleg Nesterov
2012-10-12 16:03 ` [PATCH 0/1] (Was: [regression] boot failure on alpha, bisected) Oleg Nesterov
2012-10-12 16:03 ` Oleg Nesterov [this message]
2012-10-13 1:09 ` [PATCH 1/1] task_work: Add local_irq_enable() into task_work_run() Linus Torvalds
2012-10-13 1:48 ` Al Viro
2012-10-13 9:59 ` Michael Cree
2012-10-13 15:39 ` Al Viro
2012-10-13 13:06 ` Thorsten Kranzkowski
2012-10-12 22:18 ` [PATCH 0/1] (Was: [regression] boot failure on alpha, bisected) Al Viro
2012-10-14 18:35 ` Oleg Nesterov
2012-10-14 18:42 ` 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=20121012160359.GB30881@redhat.com \
--to=oleg@redhat.com \
--cc=dl8bcu@dl8bcu.de \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.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).