Re: [PATCH] add timing information to printk messages

From: Tim Bird
Date: Wed Mar 09 2005 - 19:10:31 EST


Tony Luck wrote:
> Setting CONFIG_PRINTK_TIME=y I see (the "<NUL>" pieces are actually
> each a single ASCII '\0' character):

Tony,

Can you try the patch below? (inspired by a patch from Tom Zanussi -
gotta give credit where credit is due... :-)

This solves the problem for me but I'd like independent confirmation.

BTW, this also fixes a problem with the return value for printk,
which is supposed to be the actual amount printed. This was incorrect
in the printk-times=y case, but also in the '=n' case where a log-level
tag is inserted by printk automatically. This looks like a longstanding
bug. (Although I doubt a very important one, since no one appears
to ever look at the printk return value.)

Thanks,
-- Tim

Fix for null character processing with printk-times option on:
---------------------------------
diff -pruN printk-1/kernel/printk.c printk-fix1/kernel/printk.c
--- printk-1/kernel/printk.c 2005-03-09 15:42:04.550944124 -0800
+++ printk-fix1/kernel/printk.c 2005-03-09 15:36:18.928567360 -0800
@@ -579,6 +579,7 @@ asmlinkage int vprintk(const char *fmt,
p[1] <= '7' && p[2] == '>') {
loglev_char = p[1];
p += 3;
+ printed_len += 3;
} else {
loglev_char = default_message_loglevel
+ '0';
@@ -593,6 +594,7 @@ asmlinkage int vprintk(const char *fmt,

for (tp = tbuf; tp < tbuf + tlen; tp++)
emit_log_char (*tp);
+ printed_len += tlen - 3;
} else {
if (p[0] != '<' || p[1] < '0' ||
p[1] > '7' || p[2] != '>') {
@@ -601,8 +603,11 @@ asmlinkage int vprintk(const char *fmt,
+ '0');
emit_log_char('>');
}
+ printed_len += 3;
}
log_level_unknown = 0;
+ if (!*p)
+ break;
}
emit_log_char(*p);
if (*p == '\n')
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/