public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCHv2 3/4] printk: factor out register_console() code
Date: Thu, 23 May 2019 15:51:44 +0900	[thread overview]
Message-ID: <20190523065144.GA18333@jagdpanzerIV> (raw)
In-Reply-To: <20190515143631.vuhbda6btucrkskx@pathway.suse.cz>

Hello,

On (05/15/19 16:36), Petr Mladek wrote:
[..]
> >  
> >  	console_unlock();
> >  	console_sysfs_notify();
> > +	console_lock();
> 
> I have got an idea how to get rid of this weirdness:
>
> 1. The check for bcon seems to be just an optimization. There is not need
>    to remove boot consoles when there are none.
> 
> 2. The condition (newcon->flags & (CON_CONSDEV|CON_BOOT)) == CON_CONSDEV)
>    is valid only when the preferred console was really added.
> 
> Therefore we could move the code to a separate function, e.g.
> 
> void unregister_boot_consoles(void)
> {
> 	struct console *bcon;
> 
> 	console_lock();
> 	for_each_console(bcon)
> 		if (bcon->flags & CON_BOOT)
> 			__unregister_console(bcon);
> 	}
> 	console_unlock();
> 	console_sysfs_notify();
> }
> 
> Then we could do something like:
> 
> void register_console(struct console *newcon)
> {
> 	bool newcon_is_preferred = false;
> 
> 	console_lock();
> 	__register_console(newcon);
> 	if ((newcon->flags & (CON_CONSDEV|CON_BOOT)) == CON_CONSDEV)
> 		newcon_is_preferred = true;
> 	console_unlock();
> 	console_sysfs_notify();
> 
> 	/*
> 	 * By unregistering the bootconsoles after we enable the real console
> 	 * we get the "console xxx enabled" message on all the consoles -
> 	 * boot consoles, real consoles, etc - this is to ensure that end
> 	 * users know there might be something in the kernel's log buffer that
> 	 * went to the bootconsole (that they do not see on the real console)
> 	 */
> 	if (newcon_is_preferred && !keep_bootcon)
> 		unregister_boot_consoles();
> }
> 
> How does that sound?

Hmm, may be I'm missing something. I think that the 'weirdness'
is still needed. This

	console_lock();
	__unregister_console(bcon);  // pr_info("%sconsole disabled\n")
	console_unlock();

is going to change the visible behaviour - we need to show
pr_info("%sconsole [%s%d] disabled\n") on all consoles, especially
on the console which we are disabling. Who knows, maybe that's the
last remaining properly working console. Doing __unregister_console()
under console_sem will end up in a lost/missing message on bcon (or
on any other console we are unregistering).

	-ss

  reply	other threads:[~2019-05-23  6:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  5:32 [PATCHv2 0/4] Access console drivers list under console_sem Sergey Senozhatsky
2019-04-26  5:32 ` [PATCHv2 1/4] printk: factor out __unregister_console() code Sergey Senozhatsky
2019-05-15 13:34   ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 2/4] printk: remove invalid register_console() comment Sergey Senozhatsky
2019-05-15 13:38   ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 3/4] printk: factor out register_console() code Sergey Senozhatsky
2019-05-15 14:36   ` Petr Mladek
2019-05-23  6:51     ` Sergey Senozhatsky [this message]
2019-05-27 11:42       ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 4/4] printk: make sure we always print console disabled message Sergey Senozhatsky
2019-04-26  5:44   ` Sergey Senozhatsky
2019-05-15 14:47     ` Petr Mladek
2019-05-23  6:59       ` Sergey Senozhatsky
2019-05-27 12:45         ` 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=20190523065144.GA18333@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    /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