Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304097
b: refs/heads/master
c: 649e6ee
h: refs/heads/master
i:
  304095: e111b60
v: v3
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed May 10, 2012
1 parent fb761d0 commit 18e8972
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c5d5ca51abd728c8de3be43ffd6bb00f977bfcd
refs/heads/master: 649e6ee33f73ba1c4f2492c6de9aff2254b540cb
43 changes: 26 additions & 17 deletions trunk/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,22 @@ static bool printk_time;
#endif
module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);

static size_t prepend_timestamp(unsigned long long t, char *buf)
{
unsigned long rem_ns;

if (!printk_time)
return 0;

if (!buf)
return 15;

rem_ns = do_div(t, 1000000000);

return sprintf(buf, "[%5lu.%06lu] ",
(unsigned long) t, rem_ns / 1000);
}

static int syslog_print_line(u32 idx, char *text, size_t size)
{
struct log *msg;
Expand All @@ -800,25 +816,15 @@ static int syslog_print_line(u32 idx, char *text, size_t size)
len++;
if (msg->level > 99)
len++;

if (printk_time)
len += 15;
len += prepend_timestamp(0, NULL);

len += msg->text_len;
len++;
return len;
}

len = sprintf(text, "<%u>", msg->level);

if (printk_time) {
unsigned long long t = msg->ts_nsec;
unsigned long rem_ns = do_div(t, 1000000000);

len += sprintf(text + len, "[%5lu.%06lu] ",
(unsigned long) t, rem_ns / 1000);
}

len += prepend_timestamp(msg->ts_nsec, text + len);
if (len + msg->text_len > size)
return -EINVAL;
memcpy(text + len, log_text(msg), msg->text_len);
Expand Down Expand Up @@ -1741,7 +1747,7 @@ void console_unlock(void)
for (;;) {
struct log *msg;
static char text[LOG_LINE_MAX];
size_t len;
size_t len, l;
int level;

raw_spin_lock_irqsave(&logbuf_lock, flags);
Expand All @@ -1761,10 +1767,13 @@ void console_unlock(void)

msg = log_from_idx(console_idx);
level = msg->level & 7;
len = msg->text_len;
if (len+1 >= sizeof(text))
len = sizeof(text)-1;
memcpy(text, log_text(msg), len);

len = prepend_timestamp(msg->ts_nsec, text);
l = msg->text_len;
if (len + l + 1 >= sizeof(text))
l = sizeof(text) - len - 1;
memcpy(text + len, log_text(msg), l);
len += l;
text[len++] = '\n';

console_idx = log_next(console_idx);
Expand Down
16 changes: 10 additions & 6 deletions trunk/lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ config PRINTK_TIME
bool "Show timing information on printks"
depends on PRINTK
help
Selecting this option causes timing information to be
included in printk output. This allows you to measure
the interval between kernel operations, including bootup
operations. This is useful for identifying long delays
in kernel startup. Or add printk.time=1 at boot-time.
See Documentation/kernel-parameters.txt
Selecting this option causes time stamps of the printk()
messages to be added to the output of the syslog() system
call and at the console.

The timestamp is always recorded internally, and exported
to /dev/kmsg. This flag just specifies if the timestamp should
be included, not that the timestamp is recorded.

The behavior is also controlled by the kernel command line
parameter printk.time=1. See Documentation/kernel-parameters.txt

config DEFAULT_MESSAGE_LOGLEVEL
int "Default message log level (1-7)"
Expand Down

0 comments on commit 18e8972

Please sign in to comment.