aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2009-12-08 11:06:43 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2009-12-08 12:44:50 -0500
commit8e305c54a9f1ed0c0c181b40487aae13791b6e4f (patch)
tree6678e9e18d2e52c0856a8bade02032031a2c365d
parentcaf11fefeae129a338f09da8cdfa986db5b26105 (diff)
Hook up printk() with sched_trace.c.
-rw-r--r--kernel/printk.c11
-rw-r--r--litmus/sched_trace.c9
2 files changed, 19 insertions, 1 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 89011bf8c106..4423a5542eef 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -54,6 +54,13 @@ int console_printk[4] = {
54 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ 54 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
55}; 55};
56 56
57/* divert printk() messages when we have a LITMUS^RT
58 * debug listener
59 */
60#include <litmus/litmus.h>
61int trace_override = 0;
62int trace_recurse = 0;
63
57/* 64/*
58 * Low level drivers may need that to know if they can schedule in 65 * Low level drivers may need that to know if they can schedule in
59 * their unblank() callback or not. So let's export it. 66 * their unblank() callback or not. So let's export it.
@@ -652,6 +659,8 @@ asmlinkage int vprintk(const char *fmt, va_list args)
652 659
653 /* Emit the output into the temporary buffer */ 660 /* Emit the output into the temporary buffer */
654 printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args); 661 printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
662 if (trace_override && !trace_recurse)
663 TRACE("%s", printk_buf);
655 664
656 /* 665 /*
657 * Copy the output into log_buf. If the caller didn't provide 666 * Copy the output into log_buf. If the caller didn't provide
@@ -932,7 +941,7 @@ int is_console_locked(void)
932 941
933void wake_up_klogd(void) 942void wake_up_klogd(void)
934{ 943{
935 if (!oops_in_progress && waitqueue_active(&log_wait)) 944 if (!trace_override && !oops_in_progress && waitqueue_active(&log_wait))
936 wake_up_interruptible(&log_wait); 945 wake_up_interruptible(&log_wait);
937} 946}
938 947
diff --git a/litmus/sched_trace.c b/litmus/sched_trace.c
index 8581c03bb137..9ee6f02a61d8 100644
--- a/litmus/sched_trace.c
+++ b/litmus/sched_trace.c
@@ -301,6 +301,10 @@ static ssize_t log_read(struct file *filp, char __user *to, size_t len,
301 301
302 302
303 303
304/* in kernel/printk.c */
305extern int trace_override;
306extern int trace_recurse;
307
304 308
305/* log_open - open the global log message ring buffer. 309/* log_open - open the global log message ring buffer.
306 */ 310 */
@@ -330,6 +334,7 @@ static int log_open(struct inode *in, struct file *filp)
330 printk(KERN_DEBUG "sched_trace buf: from 0x%p to 0x%p length: %x\n", 334 printk(KERN_DEBUG "sched_trace buf: from 0x%p to 0x%p length: %x\n",
331 buf->buf.buf, buf->buf.end, 335 buf->buf.buf, buf->buf.end,
332 (unsigned int) (buf->buf.end - buf->buf.buf)); 336 (unsigned int) (buf->buf.end - buf->buf.buf));
337 trace_override++;
333 out_unlock: 338 out_unlock:
334 up(&buf->reader_mutex); 339 up(&buf->reader_mutex);
335 out: 340 out:
@@ -353,6 +358,7 @@ static int log_release(struct inode *in, struct file *filp)
353 error = rb_free_buf(&buf->buf); 358 error = rb_free_buf(&buf->buf);
354 } 359 }
355 360
361 trace_override--;
356 up(&buf->reader_mutex); 362 up(&buf->reader_mutex);
357 out: 363 out:
358 return error; 364 return error;
@@ -490,9 +496,12 @@ void dump_trace_buffer(int max)
490 int len; 496 int len;
491 int count = 0; 497 int count = 0;
492 498
499 /* potential but very unlikely race... */
500 trace_recurse = 1;
493 while ((max == 0 || count++ < max) && 501 while ((max == 0 || count++ < max) &&
494 (len = rb_get(&log_buffer.buf, line, sizeof(line) - 1)) > 0) { 502 (len = rb_get(&log_buffer.buf, line, sizeof(line) - 1)) > 0) {
495 line[len] = '\0'; 503 line[len] = '\0';
496 printk("%s", line); 504 printk("%s", line);
497 } 505 }
506 trace_recurse = 0;
498} 507}