From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377AbcLNKvZ (ORCPT ); Wed, 14 Dec 2016 05:51:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:53602 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753100AbcLNKvY (ORCPT ); Wed, 14 Dec 2016 05:51:24 -0500 Date: Wed, 14 Dec 2016 11:51:20 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Sergey Senozhatsky , 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 Subject: Re: [RFC][PATCHv5 5/7] printk: report lost messages in printk safe/nmi contexts Message-ID: <20161214105120.GC16064@pathway.suse.cz> References: <20161201135546.15549-1-sergey.senozhatsky@gmail.com> <20161201135546.15549-6-sergey.senozhatsky@gmail.com> <20161212155810.GD2441@pathway.suse.cz> <20161213015237.GE415@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161213015237.GE415@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 Tue 2016-12-13 10:52:37, Sergey Senozhatsky wrote: > On (12/12/16 16:58), Petr Mladek wrote: > > On Thu 2016-12-01 22:55:44, Sergey Senozhatsky wrote: > [..] > > 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. > > ok, I can take a look. this won't grow the per-CPU buffers bigger, > but will shrink the actual message buffer size by sizeof(atomic), > not that dramatic. IMHO, the size is a negligible difference. If we are often getting on the edge of the buffers, we have problems anyway. > * unrelated, can be done later (if ever) * > > speaking of tha actual message buffer size, we, may be, can move > `struct irq_work' out of printk_safe_seq_buf. there is already > a printk-related per-CPU irq_work in place - wake_up_klogd_work. > so we may be can use it, instead of defining a bunch of new irq_works. > this will increase the printk-safe/nmi per-CPU message buffer size > by sizeof(irq_work). Interesting idea! I think that there is a space for more optimization. For example, we will not need to schedule the irq work if we are flushing the per-CPU buffers from irq work and we know that we will flush consoles or wake up the kthread right after that. Also I though about using a global "printk_pending" variable and queue the irqwork only when the given event was not already set. I would leave all this optimization for a later patchset. > > 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 "context" part probably can be dropped. both printk-safe and > printk-nmi per-CPU buffer sizes are controlled by a single .config > option anyway; user can't increase the printk-safe buffer size > without increasing the printk-nmi buffer size (in case if printk-safe > buffer is too small). I agree. Best Regards, Petr