[PATCH 5/6] printk: Minimize time zero output

From: Mike Travis
Date: Fri Feb 18 2011 - 21:47:54 EST


Reduce the length for time zero messages by only printing "[0] ".

v2: updated to apply to x86-tip

Signed-off-by: Mike Travis <travis@xxxxxxx>
Reviewed-by: Jack Steiner <steiner@xxxxxxx>
Reviewed-by: Robin Holt <holt@xxxxxxx>
---
kernel/printk.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

--- linux.orig/kernel/printk.c
+++ linux/kernel/printk.c
@@ -735,9 +735,14 @@ static inline int printk_emit_time(void)
unsigned long microsec_rem;

t = cpu_clock(printk_cpu);
- microsec_rem = do_div(t, 1000000000) / 1000;
- tlen = sprintf(tbuf, "[%5lu.%06lu] ", (unsigned long)t, microsec_rem);
-
+ if (likely(t)) {
+ microsec_rem = do_div(t, 1000000000) / 1000;
+ tlen = sprintf(tbuf, "[%5lu.%06lu] ",
+ (unsigned long)t, microsec_rem);
+ } else {
+ /* reduce byte count in log when time is zero */
+ tlen = sprintf(tbuf, "[0] ");
+ }
for (tp = tbuf; tp < tbuf + tlen; tp++)
emit_log_char(*tp);


--
--
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/