LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] Preempt realtime printk syslog
@ 2008-02-16  3:45 Min Zhang
  0 siblings, 0 replies; only message in thread
From: Min Zhang @ 2008-02-16  3:45 UTC (permalink / raw)
  To: linux-kernel

Add 50s timeout in do_syslog to poll printk from non-preemptible
section. printk is missing from syslog if from non-preemptible
section, because on PREEMPT_RT kernels, printk doesn't wake up syslogd
from non-preemptible section; see release_console_sem in
kernel/printk.c.

Tested by printk in module_init and insmod that kernel module. The
printk is in non-preemptive context because modules are loaded from
inside a realtime priority thread in a preemptive realtime kernel.

Signed-off-by: Min Zhang <mzhang@mvista.com>

Index: rt-2.6/kernel/printk.c
===================================================================
--- rt-2.6.orig/kernel/printk.c
+++ rt-2.6/kernel/printk.c
@@ -116,6 +116,12 @@ static int preferred_console = -1;
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
 
+/* minimum time in jiffies between messages */
+int printk_ratelimit_jiffies = 5 * HZ;
+
+/* number of messages we send before ratelimiting */
+int printk_ratelimit_burst = 10;
+
 #ifdef CONFIG_PRINTK
 
 static char __log_buf[__LOG_BUF_LEN];
@@ -313,10 +319,26 @@ int do_syslog(int type, char __user *buf
 			error = -EFAULT;
 			goto out;
 		}
+#ifdef CONFIG_PREEMPT_RT
+ 		/*
+ 		 * On PREEMPT_RT kernels release_console_sem wakes us only if
+ 		 * in preemptible section, so timeout to poll for printk from
+ 		 * non-preemptible sections.
+ 		 */
+ 		i = printk_ratelimit_burst * printk_ratelimit_jiffies;
+ 		error = wait_event_interruptible_timeout(log_wait,
+ 							 (log_start - log_end),
+ 							 i);
+ 		if (error < 0)
+ 			goto out;
+ 		else
+ 			error = 0;
+#else
 		error = wait_event_interruptible(log_wait,
 							(log_start - log_end));
 		if (error)
 			goto out;
+#endif
 		i = 0;
 		spin_lock_irq(&logbuf_lock);
 		while (!error && (log_start != log_end) && i < len) {
@@ -1272,12 +1294,6 @@ int __printk_ratelimit(int ratelimit_jif
 }
 EXPORT_SYMBOL(__printk_ratelimit);
 
-/* minimum time in jiffies between messages */
-int printk_ratelimit_jiffies = 5 * HZ;
-
-/* number of messages we send before ratelimiting */
-int printk_ratelimit_burst = 10;
-
 int printk_ratelimit(void)
 {
 	return __printk_ratelimit(printk_ratelimit_jiffies,



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-16  3:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-16  3:45 [PATCH 2/2] Preempt realtime printk syslog Min Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).