Patch "printk: use atomic updates for klogd work" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    printk: use atomic updates for klogd work

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     printk-use-atomic-updates-for-klogd-work.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3b2511585cecde615d89127d71017635fc174d17
Author: John Ogness <john.ogness@xxxxxxxxxxxxx>
Date:   Fri Feb 11 12:29:37 2022 +0106

    printk: use atomic updates for klogd work
    
    [ Upstream commit 2ba3673d70178bf07fb75ff25c54bc478add4021 ]
    
    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@xxxxxxxxxxxxx>
    Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
    Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
    Link: https://lore.kernel.org/r/87iltld4ue.fsf@xxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7aeb13542ce7..e6a815a1cd76 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3215,7 +3215,7 @@ static DEFINE_PER_CPU(int, printk_pending);
 
 static void wake_up_klogd_work_func(struct irq_work *irq_work)
 {
-	int pending = __this_cpu_xchg(printk_pending, 0);
+	int pending = this_cpu_xchg(printk_pending, 0);
 
 	if (pending & PRINTK_PENDING_OUTPUT) {
 		/* If trylock fails, someone else is doing the printing */
@@ -3249,7 +3249,7 @@ void defer_console_output(void)
 		return;
 
 	preempt_disable();
-	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+	this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
 	irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
 	preempt_enable();
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux