printk: convert @syslog_lock to mutex
authorJohn Ogness <john.ogness@linutronix.de>
Thu, 15 Jul 2021 19:33:58 +0000 (21:39 +0206)
committerPetr Mladek <pmladek@suse.com>
Mon, 26 Jul 2021 13:09:50 +0000 (15:09 +0200)
commitb371cbb584d843bc4194d0cd4ce5ecd19b0cf55f
tree295158c7c7df8e7149f5aa6ce55ac961de1d43e2
parent85e3e7fbbb720b9897fba9a99659e31cbd1c082e
printk: convert @syslog_lock to mutex

@syslog_lock was a raw_spin_lock to simplify the transition of
removing @logbuf_lock and the safe buffers. With that transition
complete, and since all uses of @syslog_lock are within sleepable
contexts, @syslog_lock can become a mutex.

Note that until now register_console() would disable interrupts
using irqsave, which implies that it may be called with interrupts
disabled. And indeed, there is one possible call chain on parisc
where this happens:

handle_interruption(code=1) /* High-priority machine check (HPMC) */
  pdc_console_restart()
    pdc_console_init_force()
      register_console()

However, register_console() calls console_lock(), which might sleep.
So it has never been allowed to call register_console() from an
atomic context and the above call chain is a bug.

Note that the removal of read_syslog_seq_irq() is slightly changing
the behavior of SYSLOG_ACTION_READ by testing against a possibly
outdated @seq value. However, the value of @seq could have changed
after the test, so it is not a new window. A follow-up commit closes
this window.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210715193359.25946-6-john.ogness@linutronix.de
kernel/printk/printk.c