Re: [PATCH printk v2 4/5] printk: Add per-console suspended state
From: Petr Mladek
Date: Thu Jul 13 2023 - 11:53:20 EST
On Mon 2023-07-10 15:51:23, John Ogness wrote:
> Currently the global @console_suspended is used to determine if
> consoles are in a suspended state. Its primary purpose is to allow
> usage of the console_lock when suspended without causing console
> printing. It is synchronized by the console_lock.
>
> Rather than relying on the console_lock to determine suspended
> state, make it an official per-console state that is set within
> console->flags. This allows the state to be queried via SRCU.
>
> Remove @console_suspended. Console printing will still be avoided
> when suspended because console_is_usable() returns false when
> the new suspended flag is set for that console.
>
> Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
Looks good to me:
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
I have double checked the history. suspend_console() was added
into v2.6.18-rc1 by the commit ("Add support for suspending and
resuming the whole console subsystem").
The above commit added "secondary_console_sem". It was taken
by acquire_console_sem() instead of the normal "console_sem"
when "console_suspended" was set. It means that the normal
"console_sem" really was not taken.
The "secondary_console_sem" was removed in v2.6.29-rc6 by the commit
("PM: Fix suspend_console and resume_console to use only one
semaphore"). It solved races between code taking "console_sem"
and code "secondary_console_sem". This commit kept the handling of
"console_locked". It was not set when console_suspended was set
even though "console_sem" was actually taken.
IMHO, it was a bug in the commit removing "secondary_console_sem".
But it probably never caused any issues.
Anyway, this patch makes "console_locked" handling sane. And if some
tty code relies on the insane logic then it should get fixed.
Best Regards,
Petr