Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755268AbbFLO2J (ORCPT ); Fri, 12 Jun 2015 10:28:09 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39531 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753387AbbFLO2H (ORCPT ); Fri, 12 Jun 2015 10:28:07 -0400 Date: Fri, 12 Jun 2015 16:28:05 +0200 From: Petr Mladek To: Peter Zijlstra Cc: Steven Rostedt , linux-kernel@vger.kernel.org, jkosina@suse.cz, paulmck@linux.vnet.ibm.com, Ingo Molnar , Thomas Gleixner Subject: Re: [RFC][PATCH] printk: Fixup the nmi printk mess Message-ID: <20150612142805.GI9409@pathway.suse.cz> References: <20150610125509.GO19282@twins.programming.kicks-ass.net> <20150610143155.GD9409@pathway.suse.cz> <20150610152917.GI3644@twins.programming.kicks-ass.net> <20150610192304.GY18673@twins.programming.kicks-ass.net> <20150611145547.GA3234@dhcp128.suse.cz> <20150612120037.GR3644@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150612120037.GR3644@twins.programming.kicks-ass.net> 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 Content-Length: 1921 Lines: 50 On Fri 2015-06-12 14:00:37, Peter Zijlstra wrote: > On Thu, Jun 11, 2015 at 04:55:47PM +0200, Petr Mladek wrote: > > > + * 'Consume' this chunk, avoids concurrent callers printing the same > > > + * stuff. > > > + */ > > > + if (atomic_cmpxchg(&s->read, i, len) != i) > > > + goto again; > > > > I think that this is racy: > > Indeed. I'll think a bit on that. > > > I think that ordering CPUs is not worth it. I would go back to the > > first solution, add the @lock there, and double check races with > > seq_buf(). > > You mean, provide printk_nmi_flush() but completely screw concurrency? > And basically reserve it for a last ditch effort for getting crap out? This looks much easier to me. We could call this only when the system is going down. Another possibility would be to ignore this race because it is rather theoretical and it better to print some mess than nothing. I wonder what Andrew thinks about it. I really admired the atomic operations in the 2nd patch but I was also scared by them. Note that I have already had two attempts to make printk() safe in NMI. The first one was too precise, too complicated, and thus rejected, see https://lkml.org/lkml/2014/6/10/388. The second one was rather defensive and quite simple. It has not been completely rejected but there is still some resistance to accept non-trivial code for handling printk() in NMI, see https://lkml.org/lkml/2015/5/29/699 I hope that your approach has a chance if we do not make it too complicated. The big plus is that it generalizes the already used solution for arch_trigger_all_cpu_backtrace() and the 1st variant was rather easy but quite functional. Best Regards, Petr -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/