[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201023121134.GF32486@alley>
Date: Fri, 23 Oct 2020 14:11:34 +0200
From: Petr Mladek <pmladek@...e.com>
To: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Steven Rostedt <rostedt@...dmis.org>,
John Ogness <john.ogness@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Guenter Roeck <linux@...ck-us.net>,
Shreyas Joshi <shreyas.joshi@...mp.com>,
shreyasjoshi15@...il.com,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [RFC 1/2] printk: Add kernel parameter: mute_console
On Fri 2020-10-23 09:33:34, Sergey Senozhatsky wrote:
> On (20/10/22 13:42), Petr Mladek wrote:
> > +static bool mute_console;
> > +
> > +static int __init mute_console_setup(char *str)
> > +{
> > + mute_console = true;
> > + pr_info("All consoles muted.\n");
> > +
> > + return 0;
> > +}
>
> First of all, thanks a lot for picking this up and for the patch set!
>
> I've several thoughts and comments below.
>
> > static bool suppress_message_printing(int level)
> > {
> > - return (level >= console_loglevel && !ignore_loglevel);
> > + if (unlikely(mute_console))
> > + return true;
> > +
> > + if (unlikely(ignore_loglevel))
> > + return false;
> > +
> > + return (level >= console_loglevel);
> > }
>
> This is one way of doing it. Another one is to clear CON_ENABLED bit
> from all consoles (upon registration), one upside of this is that we
> will signal user-space that consoles are disabled/muted (by removing
> the E flag from /proc/consoles).
Hmm, CON_ENABLED is used by suspend/resume code unconditionaly. We
would need another flag to define the state after resume.
Well, it is true that CON_ENABLED has the same effect. Messages are
not printed to the console. So, introducing another variable is
likely overkill.
> Thinking more about it. We are still relying on the fact that there is
> anything registered as console driver, which is not necessarily the case,
> we can have NULL console drivers list. So how about having a dummy struct
> console in printk, with NOP read/write and NOP tty_driver and NOP
> tty_operations. So that when init calls filp_open("/dev/console") and
> we can't give tty anything but NULL, we'd just give tty back the dummy
> NOP device.
Yup, this seems to be the best solution.
Best Regards,
Petr
Powered by blists - more mailing lists