[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <84wm919z9i.fsf@jogness.linutronix.de>
Date: Tue, 24 Jun 2025 13:10:25 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Marcos Paulo de Souza <mpdesouza@...e.com>, Steven Rostedt
<rostedt@...dmis.org>, Sergey Senozhatsky <senozhatsky@...omium.org>, Greg
Kroah-Hartman <gregkh@...uxfoundation.org>, Jiri Slaby
<jirislaby@...nel.org>, Jason Wessel <jason.wessel@...driver.com>, Daniel
Thompson <danielt@...nel.org>, Douglas Anderson <dianders@...omium.org>,
Richard Weinberger <richard@....at>, Anton Ivanov
<anton.ivanov@...bridgegreys.com>, Johannes Berg
<johannes@...solutions.net>, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, kgdb-bugreport@...ts.sourceforge.net,
linux-um@...ts.infradead.org
Subject: Re: [PATCH 2/7] printk: Use consoles_suspended flag when
suspending/resuming all consoles
On 2025-06-24, Petr Mladek <pmladek@...e.com> wrote:
>> > Variant C:
>> > ==========
>> >
>> > Remove even @flags parameter from console_is_usable() and read both
>> > values there directly.
>> >
>> > Many callers read @flags only because they call console_is_usable().
>> > The change would simplify the code.
>> >
>> > But there are few exceptions:
>> >
>> > 2. Another exception is __pr_flush() where console_is_usable() is
>> > called twice with @use_atomic set "true" and "false".
>> >
>> > We would want to read "con->flags" only once here. A solution
>> > would be to add a parameter to check both con->write_atomic
>> > and con->write_thread in a single call.
>>
>> Or it could become a bitmask of printing types to check:
>>
>> #define ATOMIC_PRINTING 0x1
>> #define NONATOMIC_PRINTING 0x2
>>
>> and then __pr_flush() looks like:
>>
>> if (!console_is_usable(c, flags, ATOMIC_PRINTING|NONATOMIC_PRINTING)
>
> I like this. It will help even in all other cases when one mode is needed.
> I mean that, for example:
>
> console_is_usable(c, flags, ATOMIC_PRINTING)
>
> is more self-explaining than
>
> console_is_usable(c, flags, true)
After I wrote that suggestion, I decided that the naming is not
good. There is always confusion about what "atomic printing" means. For
that reason the parameter was changed to "use_atomic". Basically we are
specifying which callback to use and not the purpose. It is a bit tricky
because legacy consoles do not have an atomic callback, i.e. the
parameter only has meaning for nbcon consoles.
Perhaps these macros would be more suitable:
#define NBCON_USE_ATOMIC 0x1
#define NBCON_USE_THREAD 0x2
or
#define NBCON_USE_WRITE_ATOMIC 0x1
#define NBCON_USE_WRITE_THREAD 0x2
or
#define NBCON_ATOMIC_CB 0x1
#define NBCON_THREAD_CB 0x2
or
#define NBCON_ATOMIC_FUNC 0x1
#define NBCON_THREAD_FUNC 0x2
Hopefully that gives Petr enough ideas that he can come up with good
naming. ;-)
John
Powered by blists - more mailing lists