Re: [PATCH]: Use stop_machine_run in the Intel RNG driver
From: Andrew Morton
Date: Thu Mar 01 2007 - 01:17:07 EST
On Tue, 27 Feb 2007 07:22:00 -0500 Prarit Bhargava <prarit@xxxxxxxxxx> wrote:
> Replace call_smp_function with stop_machine_run in the Intel RNG driver.
>
> CPU A has done read_lock(&lock)
> CPU B has done write_lock_irq(&lock) and is waiting for A to release the lock.
>
> A third CPU calls call_smp_function and issues the IPI. CPU A takes CPU C's
> IPI. CPU B is waiting with interrupts disabled and does not see the IPI.
> CPU C is stuck waiting for CPU B to respond to the IPI.
>
> Deadlock.
I think what you're describing here is just the standard old
smp_call_function() deadlock, rather than anything which is specific to
intel-rng, yes?
It is "well known" that you can't call smp_call_function() with local
interrupts disabled. In fact i386 will spit a warning if you try it.
intel-rng doesn't do that, but what it _does_ do is:
smp_call_function(..., wait = 0);
local_irq_disable();
so some CPUs will still be entering the IPI while this CPU has gone and
disabled interrupts, thus exposing us to the deadlock, yes?
In which case a suitable fix might be to make intel-rng spin until all the
other CPUs have entered intel_init_wait().
> The solution is to use stop_machine_run instead of call_smp_function
> (call_smp_function should not be called in situations where the CPUs may
> be suspended).
But that seems to be a nice change anyway. It took rather a lot of code
churn to do it, and it does find it necessary to export stop_machine_run()
to modules, but that seems OK too.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/