printk: get caller_id/timestamp after migration disable
authorJohn Ogness <john.ogness@linutronix.de>
Thu, 21 Apr 2022 21:22:41 +0000 (23:28 +0206)
committerPetr Mladek <pmladek@suse.com>
Fri, 22 Apr 2022 19:30:57 +0000 (21:30 +0200)
Currently the local CPU timestamp and caller_id for the record are
collected while migration is enabled. Since this information is
CPU-specific, it should be collected with migration disabled.

Migration is disabled immediately after collecting this information
anyway, so just move the information collection to after the
migration disabling.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220421212250.565456-7-john.ogness@linutronix.de
kernel/printk/printk.c

index 7bb148a1debb6ba94e36c670ffffef13b5cd4d15..82ad3d3d0d4ad06afbf2035876d55b68d4574d98 100644 (file)
@@ -2063,7 +2063,7 @@ static inline void printk_delay(void)
 static inline u32 printk_caller_id(void)
 {
        return in_task() ? task_pid_nr(current) :
-               0x80000000 + raw_smp_processor_id();
+               0x80000000 + smp_processor_id();
 }
 
 /**
@@ -2145,7 +2145,6 @@ int vprintk_store(int facility, int level,
                  const struct dev_printk_info *dev_info,
                  const char *fmt, va_list args)
 {
-       const u32 caller_id = printk_caller_id();
        struct prb_reserved_entry e;
        enum printk_info_flags flags = 0;
        struct printk_record r;
@@ -2155,10 +2154,14 @@ int vprintk_store(int facility, int level,
        u8 *recursion_ptr;
        u16 reserve_size;
        va_list args2;
+       u32 caller_id;
        u16 text_len;
        int ret = 0;
        u64 ts_nsec;
 
+       if (!printk_enter_irqsave(recursion_ptr, irqflags))
+               return 0;
+
        /*
         * Since the duration of printk() can vary depending on the message
         * and state of the ringbuffer, grab the timestamp now so that it is
@@ -2167,8 +2170,7 @@ int vprintk_store(int facility, int level,
         */
        ts_nsec = local_clock();
 
-       if (!printk_enter_irqsave(recursion_ptr, irqflags))
-               return 0;
+       caller_id = printk_caller_id();
 
        /*
         * The sprintf needs to come first since the syslog prefix might be