Mikael Pettersson <mikpe@xxxxxxxxx> wrote:Think about interrupts: they are permitted to acquire the tasklist_lock for read.
Andrew,
There is another locking problem with the per-process
performance counter inheritance changes I sent you.
I currently use task_lock(tsk) to synchronise accesses
to tsk->thread.perfctr, when that pointer could change.
The write_lock_irq(&tasklist_lock) in release_task() is
needed to prevent ->parent from changing while releasing the
child, but the parent's ->thread.perfctr must also be locked.
However, sched.h explicitly forbids holding task_lock()
simultaneously with write_lock_irq(&tasklist_lock). Ouch.
That's ghastly.
* Nests both inside and outside of read_lock(&tasklist_lock).
* It must not be nested with write_lock_irq(&tasklist_lock),
* neither inside nor outside.
Manfred, where did you discover the offending code?
Would be better to just sort out the locking, then take task_lock() insideIt probably works by chance in 2.4.
tasklist_lock. That was allegedly the rule in 2.4.