From 8e96d0d3854487eeb610ae1be353d439175159f5 Mon Sep 17 00:00:00 2001 From: Jiamin Ma Date: Fri, 3 Nov 2017 16:49:20 +0800 Subject: [PATCH] printk: a fix for log output disordering PD#154008: the log output is in disorder The defination for a continues line in printk is much more strict from 3.14 to 4.9: in kernel 3.14, if the first fragment does not end with CR, and the next fragment does not start with LOG_PREFIX(KERN_ALERT, KERN_ERR and so on), then they are in a continues line eg. pr_err("foo "); printk("bar\n") or pr_err("foo "); pr_cont("bar\n"); both are printing a continues line in kernel 4.9, if only the first fragment does not end with CR, and the next fragment start with LOG_CONT, then they are in a continues line eg. pr_err("foo "); printk("bar\n"); are not printing a continues line and pr_err("foo "); pr_cont("bar\n"); are printing a continues line but in the code path of crash info dumping in kernel 4.9.y, not all of the continues line printing has been switched to the 4.9 way(aka. calling pr_cont). Only in kernel 4.13.y all of that has been updated. so in this commit, we lose the definition of continues line back to 3.14 way to sovle current issue, and need to revert it when we sync with upstream kernel 4.13.y Change-Id: I64403d3a18531ceb832b41d96dff4b79a6d7fb5a Signed-off-by: Jiamin Ma --- kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 931cb084bdb1..486bd14893c4 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1755,6 +1755,8 @@ static size_t cont_print_text(char *text, size_t size) return textlen; } +#define AML_LOSE_CONTLINE_DEF 1 + static size_t log_output(int facility, int level, enum log_flags lflags, const char *dict, size_t dictlen, char *text, size_t text_len) { /* @@ -1762,7 +1764,11 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c * write from the same process, try to add it to the buffer. */ if (cont.len) { +#if (AML_LOSE_CONTLINE_DEF == 1) + if (cont.owner == current && !(lflags & LOG_PREFIX)) { +#else if (cont.owner == current && (lflags & LOG_CONT)) { +#endif if (cont_add(facility, level, lflags, text, text_len)) return text_len; }