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 <[EMAIL PROTECTED]>

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,


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to