From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750996AbdBBDxd (ORCPT ); Wed, 1 Feb 2017 22:53:33 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34435 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdBBDxb (ORCPT ); Wed, 1 Feb 2017 22:53:31 -0500 Date: Thu, 2 Feb 2017 12:53:47 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Andrew Morton , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Thomas Gleixner , Sebastian Andrzej Siewior , Ingo Molnar Subject: Re: [PATCH] printk: use console_trylock() in console_cpu_notify() Message-ID: <20170202035347.GE1954@jagdpanzerIV.localdomain> References: <20170121104729.8585-1-sergey.senozhatsky@gmail.com> <20170125150236.GF6620@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170125150236.GF6620@pathway.suse.cz> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, thanks for taking a look, Petr. On (01/25/17 16:02), Petr Mladek wrote: [..] > > Signed-off-by: Sergey Senozhatsky > > --- > > kernel/printk/printk.c | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index 7180088cbb23..772eb16436ce 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -2028,15 +2028,16 @@ void resume_console(void) > > * @cpu: unused > > * > > * If printk() is called from a CPU that is not online yet, the messages > > - * will be spooled but will not show up on the console. This function is > > - * called when a new CPU comes online (or fails to come up), and ensures > > - * that any such output gets printed. > > + * will be printed on the console only if there are CON_ANYTIME consoles. > > + * This function is called when a new CPU comes online (or fails to come > > + * up) or goes offline. > > */ > > static int console_cpu_notify(unsigned int cpu) > > { > > if (!cpuhp_tasks_frozen) { > > - console_lock(); > > - console_unlock(); > > + /* If trylock fails, someone else is doing the printing */ > > + if (console_trylock()) > > + console_unlock(); > > } > > return 0; > > } > > Rather theoretically, the other owner of console_sem might be > on a CPU that is going online/offline and will refuse to print > the messages. hm, if console_sem is locked by CPU that is going offline then console_cpu_notify() will deadlock in console_lock(). if I understood your point correctly. > All in all. The change looks fine to me because it most likely > improves the performance[1] and does not affect the reliability > that much. yeah, I think so. > But we should revisit this notifier after adding the async printk > patchset. It will allow to defer the console handling to > another CPU and work even for going CPUs. ok, may be. > I add some people working on CPU hotplug into CC to get their > opinion. thanks. > [1] https://lkml.kernel.org/r/20170119120744.GB435@tigerII.localdomain -ss