From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680AbcLLP6Q (ORCPT ); Mon, 12 Dec 2016 10:58:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:44559 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752125AbcLLP6P (ORCPT ); Mon, 12 Dec 2016 10:58:15 -0500 Date: Mon, 12 Dec 2016 16:58:10 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Andrew Morton , Jan Kara , Tejun Heo , Calvin Owens , Thomas Gleixner , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Linus Torvalds , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCHv5 5/7] printk: report lost messages in printk safe/nmi contexts Message-ID: <20161212155810.GD2441@pathway.suse.cz> References: <20161201135546.15549-1-sergey.senozhatsky@gmail.com> <20161201135546.15549-6-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161201135546.15549-6-sergey.senozhatsky@gmail.com> 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 2016-12-01 22:55:44, Sergey Senozhatsky wrote: > Account lost messages in pritk-safe and printk-safe-nmi > contexts and report those numbers during printk_safe_flush(). > > Signed-off-by: Sergey Senozhatsky > --- > --- a/kernel/printk/printk_safe.c > +++ b/kernel/printk/printk_safe.c > @@ -211,6 +242,9 @@ static void __printk_safe_flush(struct irq_work *work) > if (atomic_cmpxchg(&s->len, len, 0) != len) > goto more; > > + report_nmi_message_lost(); > + report_safe_message_lost(); The great thing about this solution is that we print this message in the right order (after the messages that fit into the buffer). But not really because we report lost messages from both buffers and from all CPUs here. The perfect solution would be to remember the number of lost messages in struct printk_safe_seq_buf. Then we might bump the value directly in printk_safe_log_store() instead of returning the ugly -ENOSPC. Also we could use an universal message (no "NMI" or "printk-safe") because it could be printed right after flushing the messages that fit the buffer. This solution is good enough and still better than the previous one, so Reviewed-by: Petr Mladek But if you would want to change it to the "perfect" one, it would be appreciated ;-) It will be even more straightforward and less code. In this, case I would do the change in an earlier patch to make it more straightforward. But we could also do this later (in another patchset). Best Regards, Petr