From: Yong Zhang <yong.zhang0@gmail.com>
To: Christophe Huriaux <c.huriaux@gmail.com>
Cc: "Uwe Kleine-K�nig" <u.kleine-koenig@pengutronix.de>,
linux-rt-users@vger.kernel.org,
"Thomas Gleixner" <tglx@linutronix.de>,
"Steven Rostedt" <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org, "Andreas Mohr" <andi@lisas.de>
Subject: [PATCH v2] genirq: don't sync irq thread if current happen to be the very irq thread
Date: Sun, 20 May 2012 20:19:26 +0800 [thread overview]
Message-ID: <20120520121926.GA24585@zhy> (raw)
In-Reply-To: <20120520052731.GA3864@zhy>
On Sun, May 20, 2012 at 01:27:31PM +0800, Yong Zhang wrote:
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -41,6 +41,7 @@ early_param("threadirqs", setup_forced_irqthreads);
> void synchronize_irq(unsigned int irq)
> {
> struct irq_desc *desc = irq_to_desc(irq);
> + struct irqaction *action = desc->action;
Bad time for dereferencing *action.
---
From: Yong Zhang <yong.zhang@windriver.com>
Date: Sun, 20 May 2012 12:56:46 +0800
Subject: [PATCH v2] genirq: don't sync irq thread if current happen to be the very irq thread
Christophe reported against -rt http://marc.info/?l=linux-rt-users&m=133665600214984&w=2
BUG: scheduling while atomic: irq/37-s3c-mci/253/0x00000102
Modules linked in:
[<c000e9fc>] (unwind_backtrace+0x0/0x12c) from [<c029b82c>] (__schedule+0x58/0x2c0)
[<c029b82c>] (__schedule+0x58/0x2c0) from [<c029bc10>] (schedule+0x8c/0xb0)
[<c029bc10>] (schedule+0x8c/0xb0) from [<c0055614>] (synchronize_irq+0xbc/0xd8)
[<c0055614>] (synchronize_irq+0xbc/0xd8) from [<c01db6b0>] (pio_tasklet+0x34/0x11c)
[<c01db6b0>] (pio_tasklet+0x34/0x11c) from [<c0024914>] (__tasklet_action+0x68/0x80)
[<c0024914>] (__tasklet_action+0x68/0x80) from [<c0024ca4>] (__do_softirq+0x88/0x130)
[<c0024ca4>] (__do_softirq+0x88/0x130) from [<c0024ef0>] (do_softirq+0x48/0x54)
[<c0024ef0>] (do_softirq+0x48/0x54) from [<c0025048>] (local_bh_enable+0x8c/0xc0)
[<c0025048>] (local_bh_enable+0x8c/0xc0) from [<c0054678>] (irq_forced_thread_fn+0x4c/0x54)
[<c0054678>] (irq_forced_thread_fn+0x4c/0x54) from [<c0054454>] (irq_thread+0xa0/0x1c0)
[<c0054454>] (irq_thread+0xa0/0x1c0) from [<c0038628>] (kthread+0x84/0x8c)
[<c0038628>] (kthread+0x84/0x8c) from [<c000a100>] (kernel_thread_exit+0x0/0x8)
Whe looking at this issue, I find that there is a typical deadlock
scenario with forced treaded irq,
irq_forced_thread_fn()
local_bh_enable();
do_softirq();
disable_irq();
synchronize_irq();
wait_event();
/*DEAD*/
Cure it by unsync if current happen to be the very irq thread.
Reported-by: Christophe Huriaux <c.huriaux@gmail.com>
Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/irq/manage.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 89a3ea8..7a48f74 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -41,6 +41,7 @@ early_param("threadirqs", setup_forced_irqthreads);
void synchronize_irq(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
+ struct irqaction *action;
bool inprogress;
if (!desc)
@@ -67,7 +68,16 @@ void synchronize_irq(unsigned int irq)
/*
* We made sure that no hardirq handler is running. Now verify
* that no threaded handlers are active.
+ * But for theaded irq, we don't sync if current happens to be
+ * the irq thread; otherwise we could deadlock.
*/
+ action = desc->action;
+ while (action) {
+ if (action->thread && action->thread == current)
+ return;
+ action = action->next;
+ }
+
wait_event(desc->wait_for_threads, !atomic_read(&desc->threads_active));
}
EXPORT_SYMBOL(synchronize_irq);
--
1.7.1
next prev parent reply other threads:[~2012-05-20 12:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-09 14:07 BUG - "scheduling while atomic" on a irq handler (s3c-mci) Christophe Huriaux
2012-05-09 17:49 ` Uwe Kleine-König
2012-05-10 13:17 ` Christophe Huriaux
2012-05-15 17:38 ` Steven Rostedt
2012-05-20 5:27 ` [PATCH] genirq: don't sync irq thread if current happen to be the very irq thread Yong Zhang
2012-05-20 12:19 ` Yong Zhang [this message]
2012-05-22 13:50 ` [PATCH v2] " Thomas Gleixner
2012-05-23 6:54 ` Yong Zhang
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=20120520121926.GA24585@zhy \
--to=yong.zhang0@gmail.com \
--cc=andi@lisas.de \
--cc=c.huriaux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@pengutronix.de \
/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.