public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: nerdopolis <bluescreen_avenger@verizon.net>
To: pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de,
	senozhatsky@chromium.org, gregkh@linuxfoundation.org,
	tglx@linutronix.de, tony@atomide.com,
	linux-kernel@vger.kernel.org,
	Bagas Sanjaya <bagasdotme@gmail.com>
Subject: Re: VT-less kernels, and /dev/console on x86
Date: Sat, 17 Aug 2024 22:31:17 -0400	[thread overview]
Message-ID: <4805768.rnE6jSC6OK@nerdopolis2> (raw)
In-Reply-To: <ZsFJSYI3EVjC8p5W@archie.me>

On Saturday, August 17, 2024 9:07:21 PM EDT Bagas Sanjaya wrote:
> On Sat, Aug 17, 2024 at 08:09:20PM -0400, nerdopolis wrote:
> > Hi
> > 
> > I originally brought this up on linux-serial, but I think it makes more sense
> > that it's part of how printk console device selection works. Without VTs, while
> > most software is able to handle the situation, some userspace programs expect
> > /dev/console to still be responsive. Namely systemd. It calls isatty() against
> > /dev/console, and since /dev/console on VT-less systems currently defaults to
> > /dev/ttyS0, and when /dev/ttyS0 is disconnected, the ioctl's fail, and it
> > refuses to write log messages to it.
> > 
> > There doesn't seem to be a mailing list for printk, so I had to use
> > get_maintainer.pl. Hopefully this is correct
> > 
> > 
> > After some grepping and guessing and testing, and playing around Something like
> > diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
> > index a45d423ad10f..f94a4632aab0 100644
> > --- a/drivers/tty/Kconfig
> > +++ b/drivers/tty/Kconfig
> > @@ -384,9 +384,12 @@ config NULL_TTY
> >  
> >           In order to use this driver, you should redirect the console to this
> >           TTY, or boot the kernel with console=ttynull.
> > -
> >           If unsure, say N.
> >  
> > +config NULL_TTY_CONSOLE
> > +        bool "Supports /dev/ttynull as a console automatically"
> > +        depends on NULL_TTY && !VT_CONSOLE
> > +
> >  config VCC
> >         tristate "Sun Virtual Console Concentrator"
> >         depends on SUN_LDOMS
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index dddb15f48d59..c1554a789de8 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -3712,6 +3712,11 @@ void __init console_init(void)
> >         initcall_t call;
> >         initcall_entry_t *ce;
> >  
> > +#ifdef CONFIG_NULL_TTY_CONSOLE
> > +       if (!strstr(boot_command_line, "console="))
> > +               add_preferred_console("ttynull", 0, NULL);
> > +#endif
> > +
> >         /* Setup the default TTY line discipline. */
> >         n_tty_init();
> >  
> > 
> > 
> > 
> > seems to work, it conflicts with CONFIG_VT_CONSOLE since it is effectively
> > redundant, it is optional, so that it doesn't cause any changes to
> > configurations, that historically had CONFIG_VT_CONSOLE turned off in the past,
> > and for bootloader configs, it won't change any behavior if the kernel command
> > line has a console device specified
> > 
> > With ttynull as the console device, isatty() no longer fails on /dev/console,
> > systemd writes the log messages fine to /dev/console, and when Plymouth calls
> > TIOCCONS on its PTY, it is able to get the log messages.
> 
> Then what does /dev/ttynull do other than just to satisfy systemd? I expect
> it to be like /dev/null, though.
> 
> Confused...
> 
> 
/dev/ttynull is the fake tty device that was added in ~2019, I guess it's kind
of like /dev/null, but certain terminal related IOCTLs work against it too,
like TCGETS, which is the probe isatty() uses.

https://lore.kernel.org/all/20190403113327.3628-1-vincent.whitchurch@axis.com/
the original thread for the addition of the ttynull driver explains it better
than I can.

The issue came up here https://github.com/systemd/systemd/pull/33690 before I
knew about the existence of this driver. I was getting the nice status messages
from systemd appearing on Plymouth when the QEMU had a virtual console attached
to /dev/ttyS0, but on real hardware, I was not seeing these status messages.


The thought is that when distributions eventually decide to go VT-less they are
not going to want to change the kernel boot options in the bootloader config to
force console=ttynull, and might want this to happen automatically.




  reply	other threads:[~2024-08-18  3:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2669238.7s5MMGUR32.ref@nerdopolis2>
2024-08-18  0:09 ` VT-less kernels, and /dev/console on x86 nerdopolis
2024-08-18  1:07   ` Bagas Sanjaya
2024-08-18  2:31     ` nerdopolis [this message]
2024-08-18  5:12       ` Greg KH
2024-08-18 14:33         ` nerdopolis
2024-08-18  5:12   ` Greg KH
2024-08-18 12:33     ` nerdopolis
2024-08-18 14:30       ` nerdopolis
2024-08-19 15:09         ` Steven Rostedt
2024-08-19 15:50           ` nerdopolis
2024-08-20 13:29             ` Petr Mladek
2024-08-21 17:12               ` nerdopolis
2024-08-22 10:05                 ` Petr Mladek
2024-08-22 12:49                   ` nerdopolis
2024-08-27 12:53                     ` nerdopolis
2024-08-27 13:46                       ` Willy Tarreau
2024-09-12 16:48                         ` nerdopolis
2024-09-12 17:25                           ` Willy Tarreau
2024-09-12 18:46                             ` nerdopolis
2024-09-13  2:22                               ` nerdopolis
2024-09-17 12:54                               ` nerdopolis
2024-10-15 13:26                             ` nerdopolis
2024-09-12 12:29               ` nerdopolis
2024-09-12 13:27                 ` Petr Mladek
2024-10-09  9:24   ` Bernd Petrovitsch
2024-10-09 17:49     ` nerdopolis

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=4805768.rnE6jSC6OK@nerdopolis2 \
    --to=bluescreen_avenger@verizon.net \
    --cc=bagasdotme@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.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