mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
printk: use console_trylock() in console_cpu_notify()
There is no need to always call blocking console_lock() in console_cpu_notify(), it's quite possible that console_sem can be locked by other CPU on the system, either already printing or soon to begin printing the messages. console_lock() in this case can simply block CPU hotplug for unknown period of time (console_unlock() is time unbound). Not that hotplug is very fast, but still, with other CPUs being online and doing printk() console_cpu_notify() can stuck. Use console_trylock() instead and opt-out if console_sem is already acquired from another CPU, since that CPU will do the printing for us. Link: http://lkml.kernel.org/r/[email protected] Cc: Steven Rostedt <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: [email protected] Signed-off-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Petr Mladek <[email protected]>
This commit is contained in:
1 parent
7d91de7443
commit
64ca752dcb
1 file changed
+6
-5
@@ -2028,15 +2028,16 @@ void resume_console(void)
|
||||
* @cpu: unused
|
||||
*
|
||||
* If printk() is called from a CPU that is not online yet, the messages
|
||||
* will be spooled but will not show up on the console. This function is
|
||||
* called when a new CPU comes online (or fails to come up), and ensures
|
||||
* that any such output gets printed.
|
||||
* will be printed on the console only if there are CON_ANYTIME consoles.
|
||||
* This function is called when a new CPU comes online (or fails to come
|
||||
* up) or goes offline.
|
||||
*/
|
||||
static int console_cpu_notify(unsigned int cpu)
|
||||
{
|
||||
if (!cpuhp_tasks_frozen) {
|
||||
console_lock();
|
||||
console_unlock();
|
||||
/* If trylock fails, someone else is doing the printing */
|
||||
if (console_trylock())
|
||||
console_unlock();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user