Skip to content

Commit

Permalink
genirq: Remove racy waitqueue_active check
Browse files Browse the repository at this point in the history
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 <chuansheng.liu@intel.com>
Cc: Xiaoming Wang <xiaoming.wang@intel.com>
Link: http://lkml.kernel.org/r/1393212590-32543-1-git-send-email-chuansheng.liu@intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  • Loading branch information
Chuansheng-Liu authored and Jiri Slaby committed Mar 22, 2014
1 parent c4b97b0 commit f81d190
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,7 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,

static void wake_threads_waitq(struct irq_desc *desc)
{
if (atomic_dec_and_test(&desc->threads_active) &&
waitqueue_active(&desc->wait_for_threads))
if (atomic_dec_and_test(&desc->threads_active))
wake_up(&desc->wait_for_threads);
}

Expand Down

0 comments on commit f81d190

Please sign in to comment.