printk: add cpu id in printk message

PD#138714: add cpu id in printk message

Change-Id: Ic3efb64b8675d2e03129c5a646f53e60fbf8c78d
Signed-off-by: Jianxin Pan <jianxin.pan@amlogic.com>
This commit is contained in:
Jianxin Pan
2017-01-20 17:50:55 +08:00
committed by Yun Cai
parent 39c7bcad55
commit 8cd9ca2e48

View File

@@ -338,6 +338,9 @@ struct printk_log {
u8 facility; /* syslog facility */
u8 flags:5; /* internal record flags */
u8 level:3; /* syslog level */
#ifdef CONFIG_AMLOGIC_DRIVER
int cpu;
#endif
}
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
__packed __aligned(4)
@@ -353,6 +356,9 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
#ifdef CONFIG_PRINTK
DECLARE_WAIT_QUEUE_HEAD(log_wait);
#ifdef CONFIG_AMLOGIC_DRIVER
static int current_cpu;
#endif
/* the next printk record to read by syslog(READ) or /proc/kmsg */
static u64 syslog_seq;
static u32 syslog_idx;
@@ -574,6 +580,9 @@ static int log_store(int facility, int level,
msg->facility = facility;
msg->level = level & 7;
msg->flags = flags & 0x1f;
#ifdef CONFIG_AMLOGIC_DRIVER
msg->cpu = smp_processor_id();
#endif
if (ts_nsec > 0)
msg->ts_nsec = ts_nsec;
else
@@ -1183,8 +1192,13 @@ static size_t print_time(u64 ts, char *buf)
if (!buf)
return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
#if defined(CONFIG_SMP) && defined(CONFIG_AMLOGIC_DRIVER)
return sprintf(buf, "[%5lu.%06lu@%d] ",
(unsigned long)ts, rem_nsec / 1000, current_cpu);
#else
return sprintf(buf, "[%5lu.%06lu] ",
(unsigned long)ts, rem_nsec / 1000);
#endif
}
static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
@@ -1205,7 +1219,9 @@ static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
len++;
}
}
#ifdef CONFIG_AMLOGIC_DRIVER
current_cpu = msg->cpu;
#endif
len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
return len;
}