Skip to content

Commit d362082

Browse files
rostedtgregkh
authored andcommitted
printk: Optimize if statement logic where newline exists
In reviewing Kay's fix up patch: "printk: Have printk() never buffer its data", I found two if statements that could be combined and optimized. Put together the two 'cont.len && cont.owner == current' if statements into a single one, and check if we need to call cont_add(). This also removes the unneeded double cont_flush() calls. Link: http://lkml.kernel.org/r/1340869133.876.10.camel@mop Signed-off-by: Steven Rostedt <[email protected]> Cc: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 084681d commit d362082

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

kernel/printk.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,15 +1496,14 @@ asmlinkage int vprintk_emit(int facility, int level,
14961496
bool stored = false;
14971497

14981498
/*
1499-
* Flush the conflicting buffer. An earlier newline was missing,
1500-
* or we race with a continuation line from an interrupt.
1499+
* If an earlier newline was missing and it was the same task,
1500+
* either merge it with the current buffer and flush, or if
1501+
* there was a race with interrupts (prefix == true) then just
1502+
* flush it out and store this line separately.
15011503
*/
1502-
if (cont.len && prefix && cont.owner == current)
1503-
cont_flush();
1504-
1505-
/* Merge with our buffer if possible; flush it in any case */
15061504
if (cont.len && cont.owner == current) {
1507-
stored = cont_add(facility, level, text, text_len);
1505+
if (!prefix)
1506+
stored = cont_add(facility, level, text, text_len);
15081507
cont_flush();
15091508
}
15101509

0 commit comments

Comments
 (0)