From 8cd9ca2e48bc4cfcdf2463c00d11adc6537f79d4 Mon Sep 17 00:00:00 2001 From: Jianxin Pan Date: Fri, 20 Jan 2017 17:50:55 +0800 Subject: [PATCH] printk: add cpu id in printk message PD#138714: add cpu id in printk message Change-Id: Ic3efb64b8675d2e03129c5a646f53e60fbf8c78d Signed-off-by: Jianxin Pan --- kernel/printk/printk.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index f7a55e9ff2f7..c4435a887d7c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -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; }