linux-stable/kernel/printk
John Ogness 195cb7826a printk: use atomic updates for klogd work
[ Upstream commit 2ba3673d70 ]

The per-cpu @printk_pending variable can be updated from
sleepable contexts, such as:

  get_random_bytes()
    warn_unseeded_randomness()
      printk_deferred()
        defer_console_output()

and can be updated from interrupt contexts, such as:

  handle_irq_event_percpu()
    __irq_wake_thread()
      wake_up_process()
        try_to_wake_up()
          select_task_rq()
            select_fallback_rq()
              printk_deferred()
                defer_console_output()

and can be updated from NMI contexts, such as:

  vprintk()
    if (in_nmi()) defer_console_output()

Therefore the atomic variant of the updating functions must be used.

Replace __this_cpu_xchg() with this_cpu_xchg().
Replace __this_cpu_or() with this_cpu_or().

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/87iltld4ue.fsf@jogness.linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:22:48 +02:00
..
braille.c printk: Replace strncmp() with str_has_prefix() 2019-08-16 09:54:08 +02:00
braille.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
console_cmdline.h printk: Fix preferred console selection with multiple matches 2020-02-18 09:34:42 +01:00
index.c printk/index: Fix -Wunused-function warning 2021-08-27 16:42:44 +02:00
internal.h Merge branch 'rework/printk_safe-removal' into for-linus 2021-08-30 16:36:10 +02:00
Makefile printk: Userspace format indexing support 2021-07-19 11:57:48 +02:00
printk.c printk: use atomic updates for klogd work 2022-06-09 10:22:48 +02:00
printk_ringbuffer.c Merge branch 'printk-rework' into for-linus 2021-01-21 16:06:21 +01:00
printk_ringbuffer.h printk: rectify kernel-doc for prb_rec_init_wr() 2021-01-26 11:17:51 +01:00
printk_safe.c printk: remove NMI tracking 2021-07-26 15:09:44 +02:00