Skip to content

Commit 23e7b2a

Browse files
Chuansheng-Liugregkh
authored andcommitted
genirq: Remove racy waitqueue_active check
commit c685689 upstream. We hit one rare case below: T1 calling disable_irq(), but hanging at synchronize_irq() always; The corresponding irq thread is in sleeping state; And all CPUs are in idle state; After analysis, we found there is one possible scenerio which causes T1 is waiting there forever: CPU0 CPU1 synchronize_irq() wait_event() spin_lock() atomic_dec_and_test(&threads_active) insert the __wait into queue spin_unlock() if(waitqueue_active) atomic_read(&threads_active) wake_up() Here after inserted the __wait into queue on CPU0, and before test if queue is empty on CPU1, there is no barrier, it maybe cause it is not visible for CPU1 immediately, although CPU0 has updated the queue list. It is similar for CPU0 atomic_read() threads_active also. So we'd need one smp_mb() before waitqueue_active.that, but removing the waitqueue_active() check solves it as wel l and it makes things simple and clear. Signed-off-by: Chuansheng Liu <[email protected]> Cc: Xiaoming Wang <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ccc59a7 commit 23e7b2a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/irq/manage.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,7 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,
802802

803803
static void wake_threads_waitq(struct irq_desc *desc)
804804
{
805-
if (atomic_dec_and_test(&desc->threads_active) &&
806-
waitqueue_active(&desc->wait_for_threads))
805+
if (atomic_dec_and_test(&desc->threads_active))
807806
wake_up(&desc->wait_for_threads);
808807
}
809808

0 commit comments

Comments
 (0)