Commit 5234ffb9 authored by Alexander Gordeev's avatar Alexander Gordeev Committed by Thomas Gleixner

genirq: Get rid of unnecessary IRQTF_DIED flag

Currently IRQTF_DIED flag is set when a IRQ thread handler calls do_exit()
But also PF_EXITING per process flag gets set when a thread exits. This
fix eliminates the duplicate by using PF_EXITING flag.

Also, there is a race condition in exit_irq_thread(). In case a thread's
bit is cleared in desc->threads_oneshot (and the IRQ line gets unmasked),
but before IRQTF_DIED flag is set, a new interrupt might come in and set
just cleared bit again, this time forever. This fix throws IRQTF_DIED flag
away, eliminating the race as a result.

[ tglx: Test THREAD_EXITING first as suggested by Oleg ]
Reported-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
Link: http://lkml.kernel.org/r/20120309135958.GD2114@dhcp-26-207.brq.redhat.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 05d74efa
...@@ -935,8 +935,6 @@ void do_exit(long code) ...@@ -935,8 +935,6 @@ void do_exit(long code)
schedule(); schedule();
} }
exit_irq_thread();
exit_signals(tsk); /* sets PF_EXITING */ exit_signals(tsk); /* sets PF_EXITING */
/* /*
* tsk->flags are checked in the futex code to protect against * tsk->flags are checked in the futex code to protect against
...@@ -945,6 +943,8 @@ void do_exit(long code) ...@@ -945,6 +943,8 @@ void do_exit(long code)
smp_mb(); smp_mb();
raw_spin_unlock_wait(&tsk->pi_lock); raw_spin_unlock_wait(&tsk->pi_lock);
exit_irq_thread();
if (unlikely(in_atomic())) if (unlikely(in_atomic()))
printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n", printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
current->comm, task_pid_nr(current), current->comm, task_pid_nr(current),
......
...@@ -60,7 +60,7 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action) ...@@ -60,7 +60,7 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
* device interrupt, so no irq storm is lurking. If the * device interrupt, so no irq storm is lurking. If the
* RUNTHREAD bit is already set, nothing to do. * RUNTHREAD bit is already set, nothing to do.
*/ */
if (test_bit(IRQTF_DIED, &action->thread_flags) || if ((action->thread->flags & PF_EXITING) ||
test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags)) test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))
return; return;
......
...@@ -20,14 +20,12 @@ extern bool noirqdebug; ...@@ -20,14 +20,12 @@ extern bool noirqdebug;
/* /*
* Bits used by threaded handlers: * Bits used by threaded handlers:
* IRQTF_RUNTHREAD - signals that the interrupt handler thread should run * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
* IRQTF_DIED - handler thread died
* IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
* IRQTF_AFFINITY - irq thread is requested to adjust affinity * IRQTF_AFFINITY - irq thread is requested to adjust affinity
* IRQTF_FORCED_THREAD - irq action is force threaded * IRQTF_FORCED_THREAD - irq action is force threaded
*/ */
enum { enum {
IRQTF_RUNTHREAD, IRQTF_RUNTHREAD,
IRQTF_DIED,
IRQTF_WARNED, IRQTF_WARNED,
IRQTF_AFFINITY, IRQTF_AFFINITY,
IRQTF_FORCED_THREAD, IRQTF_FORCED_THREAD,
......
...@@ -845,17 +845,8 @@ void exit_irq_thread(void) ...@@ -845,17 +845,8 @@ void exit_irq_thread(void)
desc = irq_to_desc(action->irq); desc = irq_to_desc(action->irq);
/* /* Prevent a stale desc->threads_oneshot */
* Prevent a stale desc->threads_oneshot. Must be called
* before setting the IRQTF_DIED flag.
*/
irq_finalize_oneshot(desc, action, true); irq_finalize_oneshot(desc, action, true);
/*
* Set the THREAD DIED flag to prevent further wakeups of the
* soon to be gone threaded handler.
*/
set_bit(IRQTF_DIED, &action->flags);
} }
static void irq_setup_forced_threading(struct irqaction *new) static void irq_setup_forced_threading(struct irqaction *new)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment