Sergey Senozhatsky
1c0891295a
lib/ratelimit.c: use deferred printk() version
...
commit 656d61ce9666209c4c4a13c71902d3ee70d1ff6f upstream.
printk_ratelimit() invokes ___ratelimit() which may invoke a normal
printk() (pr_warn() in this particular case) to warn about suppressed
output. Given that printk_ratelimit() may be called from anywhere, that
pr_warn() is dangerous - it may end up deadlocking the system. Fix
___ratelimit() by using deferred printk().
Sasha reported the following lockdep error:
: Unregister pv shared memory for cpu 8
: select_fallback_rq: 3 callbacks suppressed
: process 8583 (trinity-c78) no longer affine to cpu8
:
: ======================================================
: WARNING: possible circular locking dependency detected
: 4.14.0-rc2-next-20170927+ #252 Not tainted
: ------------------------------------------------------
: migration/8/62 is trying to acquire lock:
: (&port_lock_key){-.-.}, at: serial8250_console_write()
:
: but task is already holding lock:
: (&rq->lock){-.-.}, at: sched_cpu_dying()
:
: which lock already depends on the new lock.
:
:
: the existing dependency chain (in reverse order) is:
:
: -> #3 (&rq->lock){-.-.}:
: __lock_acquire()
: lock_acquire()
: _raw_spin_lock()
: task_fork_fair()
: sched_fork()
: copy_process.part.31()
: _do_fork()
: kernel_thread()
: rest_init()
: start_kernel()
: x86_64_start_reservations()
: x86_64_start_kernel()
: verify_cpu()
:
: -> #2 (&p->pi_lock){-.-.}:
: __lock_acquire()
: lock_acquire()
: _raw_spin_lock_irqsave()
: try_to_wake_up()
: default_wake_function()
: woken_wake_function()
: __wake_up_common()
: __wake_up_common_lock()
: __wake_up()
: tty_wakeup()
: tty_port_default_wakeup()
: tty_port_tty_wakeup()
: uart_write_wakeup()
: serial8250_tx_chars()
: serial8250_handle_irq.part.25()
: serial8250_default_handle_irq()
: serial8250_interrupt()
: __handle_irq_event_percpu()
: handle_irq_event_percpu()
: handle_irq_event()
: handle_level_irq()
: handle_irq()
: do_IRQ()
: ret_from_intr()
: native_safe_halt()
: default_idle()
: arch_cpu_idle()
: default_idle_call()
: do_idle()
: cpu_startup_entry()
: rest_init()
: start_kernel()
: x86_64_start_reservations()
: x86_64_start_kernel()
: verify_cpu()
:
: -> #1 (&tty->write_wait){-.-.}:
: __lock_acquire()
: lock_acquire()
: _raw_spin_lock_irqsave()
: __wake_up_common_lock()
: __wake_up()
: tty_wakeup()
: tty_port_default_wakeup()
: tty_port_tty_wakeup()
: uart_write_wakeup()
: serial8250_tx_chars()
: serial8250_handle_irq.part.25()
: serial8250_default_handle_irq()
: serial8250_interrupt()
: __handle_irq_event_percpu()
: handle_irq_event_percpu()
: handle_irq_event()
: handle_level_irq()
: handle_irq()
: do_IRQ()
: ret_from_intr()
: native_safe_halt()
: default_idle()
: arch_cpu_idle()
: default_idle_call()
: do_idle()
: cpu_startup_entry()
: rest_init()
: start_kernel()
: x86_64_start_reservations()
: x86_64_start_kernel()
: verify_cpu()
:
: -> #0 (&port_lock_key){-.-.}:
: check_prev_add()
: __lock_acquire()
: lock_acquire()
: _raw_spin_lock_irqsave()
: serial8250_console_write()
: univ8250_console_write()
: console_unlock()
: vprintk_emit()
: vprintk_default()
: vprintk_func()
: printk()
: ___ratelimit()
: __printk_ratelimit()
: select_fallback_rq()
: sched_cpu_dying()
: cpuhp_invoke_callback()
: take_cpu_down()
: multi_cpu_stop()
: cpu_stopper_thread()
: smpboot_thread_fn()
: kthread()
: ret_from_fork()
:
: other info that might help us debug this:
:
: Chain exists of:
: &port_lock_key --> &p->pi_lock --> &rq->lock
:
: Possible unsafe locking scenario:
:
: CPU0 CPU1
: ---- ----
: lock(&rq->lock);
: lock(&p->pi_lock);
: lock(&rq->lock);
: lock(&port_lock_key);
:
: *** DEADLOCK ***
:
: 4 locks held by migration/8/62:
: #0 : (&p->pi_lock){-.-.}, at: sched_cpu_dying()
: #1 : (&rq->lock){-.-.}, at: sched_cpu_dying()
: #2 : (printk_ratelimit_state.lock){....}, at: ___ratelimit()
: #3 : (console_lock){+.+.}, at: vprintk_emit()
:
: stack backtrace:
: CPU: 8 PID: 62 Comm: migration/8 Not tainted 4.14.0-rc2-next-20170927+ #252
: Call Trace:
: dump_stack()
: print_circular_bug()
: check_prev_add()
: ? add_lock_to_list.isra.26()
: ? check_usage()
: ? kvm_clock_read()
: ? kvm_sched_clock_read()
: ? sched_clock()
: ? check_preemption_disabled()
: __lock_acquire()
: ? __lock_acquire()
: ? add_lock_to_list.isra.26()
: ? debug_check_no_locks_freed()
: ? memcpy()
: lock_acquire()
: ? serial8250_console_write()
: _raw_spin_lock_irqsave()
: ? serial8250_console_write()
: serial8250_console_write()
: ? serial8250_start_tx()
: ? lock_acquire()
: ? memcpy()
: univ8250_console_write()
: console_unlock()
: ? __down_trylock_console_sem()
: vprintk_emit()
: vprintk_default()
: vprintk_func()
: printk()
: ? show_regs_print_info()
: ? lock_acquire()
: ___ratelimit()
: __printk_ratelimit()
: select_fallback_rq()
: sched_cpu_dying()
: ? sched_cpu_starting()
: ? rcutree_dying_cpu()
: ? sched_cpu_starting()
: cpuhp_invoke_callback()
: ? cpu_disable_common()
: take_cpu_down()
: ? trace_hardirqs_off_caller()
: ? cpuhp_invoke_callback()
: multi_cpu_stop()
: ? __this_cpu_preempt_check()
: ? cpu_stop_queue_work()
: cpu_stopper_thread()
: ? cpu_stop_create()
: smpboot_thread_fn()
: ? sort_range()
: ? schedule()
: ? __kthread_parkme()
: kthread()
: ? sort_range()
: ? kthread_create_on_node()
: ret_from_fork()
: process 9121 (trinity-c78) no longer affine to cpu8
: smpboot: CPU 8 is now offline
Link: http://lkml.kernel.org/r/20170928120405.18273-1-sergey.senozhatsky@gmail.com
Fixes: 6b1d174b0c27b ("ratelimit: extend to print suppressed messages on release")
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Borislav Petkov <bp@suse.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-12 11:51:19 +02:00
..
2016-03-17 21:38:27 -07:00
2014-10-09 11:35:48 +03:00
2017-09-02 07:07:54 +02:00
2014-09-28 11:08:01 +02:00
2017-09-07 08:35:40 +02:00
2016-10-07 09:45:43 -07:00
2014-06-04 16:54:18 -07:00
2015-09-10 13:29:01 -07:00
2014-08-06 18:01:24 -07:00
2016-05-17 09:33:39 -07:00
2016-04-06 14:06:48 +01:00
2016-10-07 18:46:30 -07:00
locking/atomic: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()
2016-06-16 10:48:32 +02:00
2014-12-13 12:42:51 -08:00
2016-10-11 15:06:30 -07:00
2014-12-22 16:43:06 +00:00
2015-11-23 09:44:58 +01:00
2016-03-17 15:09:34 -07:00
2013-06-19 17:54:06 +02:00
2016-07-03 00:57:23 -04:00
2016-03-13 23:55:13 -04:00
2014-04-03 16:21:12 -07:00
2017-06-29 13:00:28 +02:00
2014-03-20 10:11:35 -04:00
2015-05-27 15:22:15 +02:00
2016-09-19 21:44:31 +02:00
2017-07-21 07:42:23 +02:00
2014-05-16 14:26:52 -04:00
2016-08-02 19:35:08 -04:00
2015-05-26 15:26:43 +02:00
2015-05-30 22:42:24 -07:00
2015-06-11 15:08:32 +02:00
2013-06-26 12:10:56 +02:00
2016-11-30 16:32:52 -08:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-07-17 16:39:54 -07:00
2016-02-07 23:17:59 -08:00
2016-05-31 16:42:00 +08:00
2015-11-16 14:42:12 -05:00
2016-10-06 17:13:54 -07:00
2016-08-04 08:50:07 -04:00
2016-02-05 18:10:40 -08:00
2016-08-04 08:50:07 -04:00
2015-02-12 18:54:15 -08:00
2016-06-08 11:04:19 +02:00
2016-02-24 14:57:26 +00:00
2015-10-23 17:55:10 +09:00
2014-04-30 19:49:37 +01:00
2015-04-17 09:03:54 -04:00
2014-01-21 23:17:20 -08:00
2016-02-15 11:18:23 +01:00
2016-05-20 17:58:30 -07:00
2015-02-13 21:21:35 -08:00
2016-10-27 18:43:43 -07:00
2014-08-06 18:01:25 -07:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2016-06-08 15:01:02 +02:00
2015-11-06 17:50:42 -08:00
2014-05-05 09:09:14 +02:00
2015-02-12 18:54:15 -08:00
2016-01-20 17:09:18 -08:00
2014-04-07 16:36:11 -07:00
2015-11-05 16:34:48 -08:00
2016-08-02 19:35:07 -04:00
2015-04-14 16:49:04 -07:00
2017-04-21 09:31:21 +02:00
2016-10-15 10:03:15 -07:00
2015-11-06 17:50:42 -08:00
2016-01-16 11:17:27 -08:00
2016-10-07 21:38:00 -07:00
2017-08-11 08:49:36 -07:00
2016-07-28 16:07:41 -07:00
2016-05-23 17:04:14 -07:00
2016-09-20 14:26:08 +02:00
2014-08-08 15:57:25 -07:00
2016-02-07 22:18:47 -08:00
2015-02-12 18:54:15 -08:00
2016-02-09 17:36:34 -08:00
2016-10-11 15:06:30 -07:00
2015-03-31 09:45:50 -06:00
2017-06-24 07:11:17 +02:00
2016-03-09 15:43:42 -08:00
2015-06-16 14:12:35 -04:00
2015-11-06 17:50:42 -08:00
2016-11-25 07:12:19 +01:00
2015-08-12 11:59:04 +02:00
2015-11-25 09:22:02 -07:00
2016-10-11 15:06:32 -07:00
2015-02-12 18:54:15 -08:00
2014-06-25 17:45:43 -07:00
2015-12-03 11:49:23 -05:00
2016-04-23 20:13:24 -04:00
2016-10-07 18:46:30 -07:00
2016-05-19 19:12:14 -07:00
2015-10-08 05:26:36 -07:00
2014-01-23 16:36:55 -08:00
2015-09-08 14:35:59 -07:00
2016-05-19 19:12:14 -07:00
2015-11-06 17:50:42 -08:00
2013-11-13 12:09:11 +09:00
2016-08-11 13:52:23 -04:00
2015-02-12 18:54:16 -08:00
2016-12-09 10:41:42 -08:00
2016-10-15 10:03:15 -07:00
2017-10-12 11:51:19 +02:00
2014-01-23 16:37:03 -08:00
2016-07-06 10:51:14 +01:00
2014-01-21 23:17:20 -08:00
2016-09-20 04:43:36 -04:00
2016-09-19 08:19:40 -06:00
2016-02-08 10:15:17 -08:00
2015-12-23 14:27:20 -05:00
2016-04-15 16:53:14 -04:00
2015-08-24 14:28:01 -06:00
2015-03-23 22:12:08 -04:00
2015-09-08 15:35:28 -07:00
2014-04-07 16:36:14 -07:00
2015-06-25 17:00:40 -07:00
2016-11-11 08:12:37 -08:00
2015-02-12 18:54:16 -08:00
2016-04-21 10:47:26 +10:00
2016-03-17 15:09:34 -07:00
2016-10-11 15:06:30 -07:00
2016-08-08 13:02:01 -07:00
2017-07-05 14:40:26 +02:00
2017-04-08 09:30:35 +02:00
2016-02-19 22:54:09 -05:00
2017-05-14 14:00:21 +02:00
2016-01-07 13:44:22 -07:00
2016-09-01 17:52:01 -07:00
2016-01-20 17:09:18 -08:00
2016-11-30 16:32:52 -08:00
2014-01-23 16:36:57 -08:00
2016-03-15 16:55:16 -07:00
2016-08-08 12:52:42 -07:00
2015-08-03 11:51:12 +02:00
2016-02-09 10:27:29 +01:00
2017-06-14 15:06:05 +02:00
2016-05-30 15:26:57 -07:00
2015-09-10 13:29:01 -07:00
2016-02-03 08:28:43 -08:00
2014-10-14 02:18:14 +02:00
2015-04-22 17:06:49 +02:00
2016-08-02 17:31:41 -04:00
2016-01-20 17:09:18 -08:00
2016-09-09 16:08:46 +01:00
2016-05-30 15:26:57 -07:00
2016-05-20 17:58:30 -07:00
2016-09-21 00:22:59 -04:00