Re: [PATCH] printk: fix one circular lockdep warning about console_lock

From: Jane Li
Date: Fri Feb 14 2014 - 02:43:27 EST


On 02/12/2014 05:19 AM, Andrew Morton wrote:

There are three locks involved in two sequence:
a) pm suspend:
console_lock (@suspend_console())
cpu_add_remove_lock (@disable_nonboot_cpus())
cpu_hotplug.lock (@_cpu_down())
But but but. suspend_console() releases console_sem again.

Console_lock does not refer to console_sem but console_lock_dep_map. Its name is console_lock. Suspend_console() does not release console_lock_dep_map.

So the
sequence is actually

down(&console_sem) (@suspend_console())

acquire(&console_lock_dep_map) (&suspend_console())

up(&console_sem) (@suspend_console())
cpu_add_remove_lock (@disable_nonboot_cpus())
cpu_hotplug.lock (@_cpu_down())

So console_sem *doesn't* nest outside cpu_add_remove_lock and
cpu_hotplug.lock.

Add console_lock in the sequence.


b) Plug-out CPUx:
cpu_add_remove_lock (@(cpu_down())
cpu_hotplug.lock (@_cpu_down())
console_lock (@console_cpu_notify()) => Lockdeps prints warning log.

There should be not real deadlock, as flag of console_suspended can
protect this.
console_lock() does down(&console_sem) *before* testing
console_suspended, so I don't understand this sentence - a more
detailed description would help.

After suspend_console(), console_sem is unlocked, but console_lock_dep_map has been acquired.


Best Regards,
Jane

--
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/