Skip to content

Commit 5234ffb

Browse files
Alexander GordeevKAGA-KOKO
authored andcommitted
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: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Link: http://lkml.kernel.org/r/20120309135958.GD2114@dhcp-26-207.brq.redhat.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 05d74ef commit 5234ffb

4 files changed

Lines changed: 4 additions & 15 deletions

File tree

‎kernel/exit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,6 @@ void do_exit(long code)
935935
schedule();
936936
}
937937

938-
exit_irq_thread();
939-
940938
exit_signals(tsk); /* sets PF_EXITING */
941939
/*
942940
* tsk->flags are checked in the futex code to protect against
@@ -945,6 +943,8 @@ void do_exit(long code)
945943
smp_mb();
946944
raw_spin_unlock_wait(&tsk->pi_lock);
947945

946+
exit_irq_thread();
947+
948948
if (unlikely(in_atomic()))
949949
printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
950950
current->comm, task_pid_nr(current),

‎kernel/irq/handle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
6060
* device interrupt, so no irq storm is lurking. If the
6161
* RUNTHREAD bit is already set, nothing to do.
6262
*/
63-
if (test_bit(IRQTF_DIED, &action->thread_flags) ||
63+
if ((action->thread->flags & PF_EXITING) ||
6464
test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))
6565
return;
6666

‎kernel/irq/internals.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ extern bool noirqdebug;
2020
/*
2121
* Bits used by threaded handlers:
2222
* IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
23-
* IRQTF_DIED - handler thread died
2423
* IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
2524
* IRQTF_AFFINITY - irq thread is requested to adjust affinity
2625
* IRQTF_FORCED_THREAD - irq action is force threaded
2726
*/
2827
enum {
2928
IRQTF_RUNTHREAD,
30-
IRQTF_DIED,
3129
IRQTF_WARNED,
3230
IRQTF_AFFINITY,
3331
IRQTF_FORCED_THREAD,

‎kernel/irq/manage.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -845,17 +845,8 @@ void exit_irq_thread(void)
845845

846846
desc = irq_to_desc(action->irq);
847847

848-
/*
849-
* Prevent a stale desc->threads_oneshot. Must be called
850-
* before setting the IRQTF_DIED flag.
851-
*/
848+
/* Prevent a stale desc->threads_oneshot */
852849
irq_finalize_oneshot(desc, action, true);
853-
854-
/*
855-
* Set the THREAD DIED flag to prevent further wakeups of the
856-
* soon to be gone threaded handler.
857-
*/
858-
set_bit(IRQTF_DIED, &action->flags);
859850
}
860851

861852
static void irq_setup_forced_threading(struct irqaction *new)

0 commit comments

Comments
 (0)