History

printk() - do not merge continuation lines of different threads

This prevents the merging of printk() continuation lines of different threads, in the case they race against each other. It should properly isolate "atomic" single-line printk() users from continuation users, to make sure the single-line users will never be merged with the racy continuation ones.

Kay Sievers committed 14 years ago

Commit 5c5d5ca1 parent 7f3a7811 file · +10 −9Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/printk.c+10−9
@@ -1230,12 +1230,13 @@ asmlinkage int vprintk_emit(int facility, int level, · 1229 unmodified lines
12301230 static size_t buflen;
12311231 static int buflevel;
12321232 static char textbuf[LOG_LINE_MAX];
1233+ static struct task_struct *cont;
12331234 char *text = textbuf;
12341235 size_t textlen;
12351236 unsigned long flags;
12361237 int this_cpu;
12371238 bool newline = false;
1238− bool cont = false;
1239+ bool prefix = false;
12391240 int printed_len = 0;
12401241
12411242 boot_delay_msec();
@@ -1295,20 +1296,16 @@ asmlinkage int vprintk_emit(int facility, int level, · 53 unmodified lines
12951296 case '0' ... '7':
12961297 if (level == -1)
12971298 level = text[1] - '0';
1298− text += 3;
1299− textlen -= 3;
1300− break;
1301− case 'c': /* KERN_CONT */
1302− cont = true;
13031299 case 'd': /* KERN_DEFAULT */
1300+ prefix = true;
1301+ case 'c': /* KERN_CONT */
13041302 text += 3;
13051303 textlen -= 3;
1306− break;
13071304 }
13081305 }
13091306
1310− if (buflen && (!cont || dict)) {
1311− /* no continuation; flush existing buffer */
1307+ if (buflen && (prefix || dict || cont != current)) {
1308+ /* flush existing buffer */
13121309 log_store(facility, buflevel, NULL, 0, buf, buflen);
13131310 printed_len += buflen;
13141311 buflen = 0;
@@ -1342,6 +1339,10 @@ asmlinkage int vprintk_emit(int facility, int level, · 27 unmodified lines
13421339 dict, dictlen, text, textlen);
13431340 printed_len += textlen;
13441341 }
1342+ cont = NULL;
1343+ } else {
1344+ /* remember thread which filled the buffer */
1345+ cont = current;
13451346 }
13461347
13471348 /*