Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1551033img; Wed, 27 Feb 2019 01:03:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IbT0HUmzbBkM0z1/rXR4rCI4OoZStWJgMRVY3Up/ZaaB9BzjcFv25wwGk6nQjoiurO5KIKC X-Received: by 2002:a17:902:b708:: with SMTP id d8mr1029696pls.322.1551258216176; Wed, 27 Feb 2019 01:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551258216; cv=none; d=google.com; s=arc-20160816; b=vzKNCAFvEwvGOiB5ePWzsLmoTV4m9uQHGsNNgQlAPaAPotum3tU9VP9QZKE/XqtXt2 eBPouWgfoxTltwQSsA3hFCY70ApUz+Obvji8bB0jrFO9P50rFlQrbykgokmiwT4t002N x8MzRPV+TBqQCfclXSgYgCbIubQD+Und1Fuzf2lj2hovyiwVkcAAHWb0XEqo6ITwy/kg uQt7dtdBsOnC6XBTXhA1s5DkSPAXu6nDVAu6/6JuNcQQ1NpUE5x2oQmmtBLKdfaXocIy vXu+PBJPrFznDSe7NmEz5+iPl8QSJeCFOnVGsltcSPzcgKSkVbSbWWhMu2dwgskCZ9Y2 bqVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ikpNdKhyF9htQ28W7/VsGKEW8L/wPU0M9wUiwY4jrE0=; b=yHnlkRY6zQ6dJgZyrXHrzo9kG8rl3AI4n3jQUp6OHzY1/HcCbGiu9tDCJwgHhA1YBS XE8oBysQCnnHpzX4EF9SuRvcXxwOVrwDYFOHmI8lM1YPPvlhpHsSyvkMsqEbA4Kljpfd ChrDReS3/t7/s2g6yOc+whJo2AYYyuDFzoXIJpFdirxAHgMCPkPooUIE1xNqyigZ2qmT b5R1/3GIBWnBUgQIngKtQ3cJq2kP/8tVj49XjY+tWPbzQWKIVOs8ZTYHQiNpI/I7DKjj 2FhXiO/syLauimNUkRob0+Gi8/nq3LlzOKpVMI9YhQ6bewVBT2/DQLyRRzGGJncpyEhn 3NZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si15142115pfj.186.2019.02.27.01.03.18; Wed, 27 Feb 2019 01:03:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729558AbfB0JCx (ORCPT + 99 others); Wed, 27 Feb 2019 04:02:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:55806 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726932AbfB0JCx (ORCPT ); Wed, 27 Feb 2019 04:02:53 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0DB0EAEBD; Wed, 27 Feb 2019 09:02:51 +0000 (UTC) Date: Wed, 27 Feb 2019 10:02:49 +0100 From: Petr Mladek To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 15/25] printk: print history for new consoles Message-ID: <20190227090249.fzigc7r237emlg6k@pathway.suse.cz> References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-16-john.ogness@linutronix.de> <20190226145837.wl54fr7rn2ii5oxc@pathway.suse.cz> <87o96yziau.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o96yziau.fsf@linutronix.de> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2019-02-26 16:22:01, John Ogness wrote: > On 2019-02-26, Petr Mladek wrote: > >> When new consoles register, they currently print how many messages > >> they have missed. However, many (or all) of those messages may still > >> be in the ring buffer. Add functionality to print as much of the > >> history as available. This is a clean replacement of the old > >> exclusive console hack. > >> > >> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > >> index 897219f34cab..6c875abd7b17 100644 > >> --- a/kernel/printk/printk.c > >> +++ b/kernel/printk/printk.c > >> @@ -1524,6 +1595,10 @@ static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len, > >> for_each_console(con) { > >> if (!(con->flags & CON_ENABLED)) > >> continue; > >> + if (!con->wrote_history) { > >> + printk_write_history(con, seq); > > > > This looks like an alien. The code is supposed to write one message > > from the given buffer. And some huge job is well hidden there. > > This is a very simple implementation of a printk kthread. It probably > makes more sense to have a printk kthread per console. That would allow > fast consoles to not be penalized by slow consoles. Due to the > per-console seq tracking, the code would already support it. I mean that your patch does the reply on a very hidden location. I think that a cleaned design would be to implement something like: void console_check_and_reply(void) { struct console *con; if (!console_drivers) return; for_each_console(con) { if (con->flags & CON_PRINTBUFFER) { printk_write_history(con, console_seq); con->flags &= ~CON_PRINTBUFFER; } } } Then there is no recursion. Also you are much more flexible. You could call this on any reasonable place. For example, you could call this in the printk_kthread right after taking console_lock and before processing new messages. Regarding the per-console kthread. It would make sense if we stop handling all consoles synchronously. For example, when we push messages to fast consoles immediately and offload the work for slow consoles. Anyway, we first need to make the offload reliable enough. It is not acceptable to always offload all messages. We have been there last few years. We must keep a high chance to see the messages. Any warning might be important when it causes the system to die. Nobody knows what message is such an important. > > In addition, the code is actually recursive. It will become > > clear when it is deduplicated as suggested above. We should > > avoid it when it is not necessary. Note that recursive code > > is always more prone to mistakes and it is harder to think of. > > Agreed. > > > I guess that the motivation is to do everything from the printk > > kthread. Is it really necessary? register_console() takes > > console_lock(). It has to be sleepable context by definition. > > It is not necessary. It is desired. Why should _any_ task be punished > with console writing? That is what the printk kthread is for. I do not know about any acceptable solution without punishing the tasks. But we might find a better compromise between the punishment and reliability. Best Regards, Petr