Re: [PATCH] printk: Remember the message level for multi-line output

Nick Andrew
2008-04-12T16:42:36Z

On Sun, Apr 13, 2008 at 02:18:54AM +1000, Nick Andrew wrote:
> - static int log_level_unknown = 1;
> + static int new_text_line = 1;

Further to the previous patch, maintaining the state of being in the
middle of an output line across calls to printk() opens up the
possibility of log corruption when calling code uses printk() to
output fragments of a line. This seems to happen a lot in the
codebase, for example (from arch/blackfin/kernel/traps.c):

printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack);
for (i = 0; i < kstack_depth_to_print; i++) {
if (stack + 1 > endstack)
break;
if (i % 8 == 0)
printk("\n" KERN_NOTICE " ");
printk(" %08lx", *stack++);
}
printk("\n");

The caller should be building complete output lines, at a minimum.
Or, to maintain the convenient coding, there would need to be an
intermediate function which buffers the partial lines until the
caller issues a flush call.

Nick.