From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752579AbdBAPwU (ORCPT ); Wed, 1 Feb 2017 10:52:20 -0500 Received: from mail.kernel.org ([198.145.29.136]:34678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbdBAPwS (ORCPT ); Wed, 1 Feb 2017 10:52:18 -0500 Date: Wed, 1 Feb 2017 10:52:13 -0500 From: Steven Rostedt To: Sergey Senozhatsky Cc: Andrew Morton , Petr Mladek , Linus Torvalds , Jan Kara , Tejun Heo , Calvin Owens , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter Hurley , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [PATCHv7 3/8] printk: introduce per-cpu safe_print seq buffer Message-ID: <20170201105213.351d1a01@gandalf.local.home> In-Reply-To: <20161227141611.940-4-sergey.senozhatsky@gmail.com> References: <20161227141611.940-1-sergey.senozhatsky@gmail.com> <20161227141611.940-4-sergey.senozhatsky@gmail.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Dec 2016 23:16:06 +0900 Sergey Senozhatsky wrote: > This patch extends the idea of NMI per-cpu buffers to regions > that may cause recursive printk() calls and possible deadlocks. > Namely, printk() can't handle printk calls from schedule code > or printk() calls from lock debugging code (spin_dump() for instance); > because those may be called with `sem->lock' already taken or any > other `critical' locks (p->pi_lock, etc.). An example of deadlock > can be > > vprintk_emit() > console_unlock() > up() << raw_spin_lock_irqsave(&sem->lock, flags); > wake_up_process() > try_to_wake_up() > ttwu_queue() > ttwu_activate() > activate_task() > enqueue_task() > enqueue_task_fair() > cfs_rq_of() > task_of() > WARN_ON_ONCE(!entity_is_task(se)) > vprintk_emit() > console_trylock() > down_trylock() > raw_spin_lock_irqsave(&sem->lock, flags) > ^^^^ deadlock > > and some other cases. > > Just like in NMI implementation, the solution uses a per-cpu > `printk_func' pointer to 'redirect' printk() calls to a 'safe' > callback, that store messages in a per-cpu buffer and flushes > them back to logbuf buffer later. > > Usage example: > > printk() > printk_safe_enter_irqsave(flags) > // > // any printk() call from here will endup in vprintk_safe(), > // that stores messages in a special per-CPU buffer. > // > printk_safe_exit_irqrestore(flags) > > The 'redirection' mechanism, though, has been reworked, as suggested > by Petr Mladek. Instead of using a per-cpu @print_func callback we now > keep a per-cpu printk-context variable and call either default or nmi > vprintk function depending on its value. printk_nmi_entrer/exit and > printk_safe_enter/exit, thus, just set/celar corresponding bits in > printk-context functions. > > The patch only adds printk_safe support, we don't use it yet. > > Signed-off-by: Sergey Senozhatsky /me does the actual reviewed-by now :-p Yes, I like this approach. I probably would have done it pretty much the same way. Reviewed-by: Steven Rostedt (VMware) -- Steve