public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] printk: use console_trylock() in console_cpu_notify()
Date: Thu, 2 Feb 2017 17:56:41 +0100	[thread overview]
Message-ID: <20170202165641.GK23754@pathway.suse.cz> (raw)
In-Reply-To: <20170202035347.GE1954@jagdpanzerIV.localdomain>

On Thu 2017-02-02 12:53:47, Sergey Senozhatsky wrote:
> Hello,
> 
> thanks for taking a look, Petr.
> 
> On (01/25/17 16:02), Petr Mladek wrote:
> [..]
> > > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > > ---
> > >  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.

No, it will not deadlock. I guess that it will just do nothing.

console_unlock() would probably return at the beginning because
can_use_console() would return false because cpu_online()
would return false.

I am not sure about it. It is not easy for me to find
in which cpu_online() state the notifiers are called.

If the console really is not usable, we should rather
defer the console work to another CPU.

Best Regards,
Petr

  reply	other threads:[~2017-02-02 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-21 10:47 [PATCH] printk: use console_trylock() in console_cpu_notify() Sergey Senozhatsky
2017-01-25 15:02 ` Petr Mladek
2017-02-02  3:53   ` Sergey Senozhatsky
2017-02-02 16:56     ` Petr Mladek [this message]
2017-03-23 16:26   ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170202165641.GK23754@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox