From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751696AbdBBPUt (ORCPT ); Thu, 2 Feb 2017 10:20:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:35267 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbdBBPUs (ORCPT ); Thu, 2 Feb 2017 10:20:48 -0500 Date: Thu, 2 Feb 2017 16:20:02 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Peter Zijlstra , Jan Kara , Ross Zwisler , Sergey Senozhatsky , Ross Zwisler , Andrew Morton , Linus Torvalds , Tejun Heo , Calvin Owens , Steven Rostedt , Ingo Molnar , Andy Lutomirski , Peter Hurley , LKML Subject: Re: [PATCHv7 6/8] printk: use printk_safe buffers in printk Message-ID: <20170202152002.GE23754@pathway.suse.cz> References: <20161227141611.940-1-sergey.senozhatsky@gmail.com> <20161227141611.940-7-sergey.senozhatsky@gmail.com> <20170201090625.GC11567@quack2.suse.cz> <20170201093739.GT6515@twins.programming.kicks-ass.net> <20170201153910.GL6620@pathway.suse.cz> <20170202021134.GC1954@jagdpanzerIV.localdomain> <20170202090722.GW6515@twins.programming.kicks-ass.net> <20170202100348.GA364@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170202100348.GA364@jagdpanzerIV.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2017-02-02 19:03:48, Sergey Senozhatsky wrote: > On (02/02/17 10:07), Peter Zijlstra wrote: > > On Thu, Feb 02, 2017 at 11:11:34AM +0900, Sergey Senozhatsky wrote: > > > On (02/01/17 16:39), Petr Mladek wrote: > > > [..] > > > > I guess that you are talking about the introduction of > > > > #define SCHED_WARN_ON(x) WARN_ONCE(x, #x) > > > > > > my guess would be that Jan was talking about printk_deferred() patch. > > > it's on my TODO list. > > > > > > I want to entirely remove console_sem and scheduler out of printk() path. > > > that's the only way to make printk() deadlock safe. > > > > And useless.. if you never get around to the 'later' part where you > > print the content. This way you still mostly get the output. > > well, I wouldn't say that printk_deferred() has less chances. I see your > point, of course. but with printk_deferred() we, at least, will have messages > in logbuf (or printk_safe buffers), so they can appear in crash dump, for > instance. that "later" part can be sysrq, for example, or panic->flush_on_panic(), > etc. if "normal" printk->queue irq_work doesn't work. > > needless to say, that in this particular case (WARN from sched), if the > first printk() out of N printk()-s, which sched core calls to dump_stack(), > deadlocks, then we got nothing to print/dump. An always deferred printk() or another deferred ways are future work. We should try to find a good solution, definitely. The question is what to do with this patch. We need to change things step by step. The printk_safe patchset is one of them and looks almost ready. The lockdep warnings are correct and help to find locations where scheduler warnings might cause a deadlock. One solution would be to keep lockdep as is in this patch. It means to hide existing risk until we have some reasonable printk_deferred() solution. Another solution would to keep this patch as is and implement WARN*_DEFERRED() variants that would either use printk_safe_enter()/exit() as the currently usable deferred and lockless solution. Or they could just disable lockdep and hide the report for now. These deferred variants should be used on all locations reported by lockdep where we want to accept the risk. We will at least know where the potential risk is and could find a proper solution later. Note that I do not like hiding problems but they were hidden before this patchset as well. I am just looking for the best way forward. > > And no, its not the only way, see my printk->early_printk patches. early > > serial console only does a loop over outb, impossible to mess that up. > > certainly :) Yup. I still would like to get Peter's patches in. They are in the queue. Best Regards, Petr