[RFC patch 5/5] genirq: make irq threading robust

Previous thread: [RFC patch 3/5] genirq: add threaded interrupt handler support by Thomas Gleixner on Wednesday, October 1, 2008 - 4:02 pm. (2 messages)

Next thread: [patch x86/core] x86: allow number of additional hotplug CPUs to be set at compile time by Chuck Ebbert on Wednesday, October 1, 2008 - 4:19 pm. (22 messages)
From: Thomas Gleixner
Date: Wednesday, October 1, 2008 - 4:02 pm

To make sure that a crashed irq thread does not cause more trouble
when the irq code tries to wake up a gone thread or the device code
calling free_irq and trying to kthread_stop the dead thread, we plug a
pointer to irqaction into task_struct, which is evaluated in
do_exit(). When the thread crashes the do_exit code marks the thread
as DIED in irqaction->flags to prevent further wakeups from the
interrupt handler code.

On thread creation we get a reference to task_struct so it stays
around until the free_irq code releases it again.

The procedure vs. the crashed irq handler thread is slightly racy, but
we do not want to have additional locking in the hard interrupt code
path. The worst things which can happen are a warning that we tried to
wakeup a dead task and a hung kthread_stop in free_irq. I'm not
worried about that at all, as removing a module which had a crashed
interrupt handler is critical anyway.

The main purpose of this is to keep the system alive w/o the affected
device working.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/interrupt.h |    3 +++
 include/linux/sched.h     |    1 +
 kernel/exit.c             |    2 ++
 kernel/irq/handle.c       |   13 +++++++++++--
 kernel/irq/manage.c       |   44 +++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 58 insertions(+), 5 deletions(-)

Index: linux-2.6-tip/include/linux/interrupt.h
===================================================================
--- linux-2.6-tip.orig/include/linux/interrupt.h
+++ linux-2.6-tip/include/linux/interrupt.h
@@ -61,6 +61,7 @@
 #define IRQF_THREADED		0x00002000
 #define IRQF_RUNTHREAD		0x00004000
 #define IRQF_WARNED_THREADED	0x00008000
+#define IRQF_THREAD_DIED	0x00010000
 
 typedef irqreturn_t (*irq_handler_t)(int, void *);
 
@@ -114,6 +115,8 @@ static inline int irq_thread_should_run(
 	return test_and_clear_bit(IRQF_RUNTHREAD, &action->flags);
 }
 
+extern void exit_irq_thread(struct ...
From: Jon Masters
Date: Wednesday, October 1, 2008 - 5:52 pm

Is that going to fly? For the vast majority of task_structs this is now
a wasted 4/8 bytes that won't be used.

Jon.


--

From: Steven Rostedt
Date: Wednesday, October 1, 2008 - 10:20 pm

Perhaps we could convert parts of the task_struct into a union.
There is quite a lot of things that I'm not sure kernel threads use.

fpu_counter? well, it is only one byte.
binfmt?

Do kernel threads use group_leader?

What about the ptraced items?

group ids/info on kernel threads?

do kernel threads need robust futex info?

This was just a quick look at the task struct. Perhaps we could separate
out kernel only and user space only info and bring the total size down?

Although I'm not sure how much is there that is kernel_thread only :-/
Of course this irqaction will be.

-- Steve
--

Previous thread: [RFC patch 3/5] genirq: add threaded interrupt handler support by Thomas Gleixner on Wednesday, October 1, 2008 - 4:02 pm. (2 messages)

Next thread: [patch x86/core] x86: allow number of additional hotplug CPUs to be set at compile time by Chuck Ebbert on Wednesday, October 1, 2008 - 4:19 pm. (22 messages)