Revert "printk: add cpu info into kernel log"
authorsunyue5 <sunyue5@motorola.com>
Fri, 11 Oct 2019 05:55:48 +0000 (13:55 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:32:12 +0000 (17:32 +0800)
Change-Id: I20b58073db759906e2892e14373148a51e2aef99
Signed-off-by: sunyue5 <sunyue5@motorola.com>
Reviewed-on: https://gerrit.mot.com/1435441
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Zonghua Liu <a17671@motorola.com>
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

kernel/printk/printk.c

index 932f2cced8e99f22dc749c2fef60c88196f7179f..ed1f9c6432bfb02d93dd057c8908eceb5a9d9228 100755 (executable)
@@ -359,10 +359,10 @@ struct printk_log {
        u8 facility;            /* syslog facility */
        u8 flags:5;             /* internal record flags */
        u8 level:3;             /* syslog level */
-       u8 cpu;                 /* cpu id */
 #ifdef CONFIG_PRINTK_PROCESS
        char process[16];       /* process name */
        pid_t pid;              /* process id */
+       u8 cpu;                 /* cpu id */
        u8 in_interrupt;        /* interrupt context */
 #endif
 }
@@ -572,10 +572,11 @@ static size_t print_process(const struct printk_log *msg, char *buf)
                return 0;
 
        if (!buf)
-               return snprintf(NULL, 0, "%c[%15s:%5d] ", ' ', " ", 0);
+               return snprintf(NULL, 0, "%c[%1d:%15s:%5d] ", ' ', 0, " ", 0);
 
-       return sprintf(buf, "%c[%15s:%5d] ",
+       return sprintf(buf, "%c[%1d:%15s:%5d] ",
                        msg->in_interrupt ? 'I' : ' ',
+                       msg->cpu,
                        msg->process,
                        msg->pid);
 }
@@ -732,12 +733,12 @@ static int log_store(int facility, int level,
        memset(log_dict(msg) + dict_len, 0, pad_len);
        msg->len = size;
 
-       msg->cpu = smp_processor_id();
 #ifdef CONFIG_PRINTK_PROCESS
        if (printk_process) {
                strncpy(msg->process, current->comm, sizeof(msg->process) - 1);
                msg->process[sizeof(msg->process) - 1] = '\0';
                msg->pid = task_pid_nr(current);
+               msg->cpu = smp_processor_id();
                msg->in_interrupt = in_interrupt() ? 1 : 0;
        }
 #endif
@@ -1329,7 +1330,7 @@ static inline void boot_delay_msec(int level)
 static bool printk_time = IS_ENABLED(CONFIG_PRINTK_TIME);
 module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
 
-static size_t print_time(u64 ts, char *buf, u8 cpu)
+static size_t print_time(u64 ts, char *buf)
 {
        unsigned long rem_nsec;
 
@@ -1339,10 +1340,10 @@ static size_t print_time(u64 ts, char *buf, u8 cpu)
        rem_nsec = do_div(ts, 1000000000);
 
        if (!buf)
-               return snprintf(NULL, 0, "[%5lu.000000,%u] ", (unsigned long)ts, cpu);
+               return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
 
-       return sprintf(buf, "[%5lu.%06lu,%u] ",
-                      (unsigned long)ts, rem_nsec / 1000,cpu);
+       return sprintf(buf, "[%5lu.%06lu] ",
+                      (unsigned long)ts, rem_nsec / 1000);
 }
 
 static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
@@ -1364,8 +1365,7 @@ static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
                }
        }
 
-        len += print_time(msg->ts_nsec, buf ? buf + len : NULL,
-                        msg->cpu);
+       len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
 #ifndef CONFIG_PRINTK_UTC_TIME
        len += print_process(msg, buf ? buf + len : NULL);
 #endif