diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-03-21 18:01:05 (GMT) |
---|---|---|
committer | Emil Medve <Emilian.Medve@Freescale.com> | 2013-05-26 07:14:10 (GMT) |
commit | 37f5d14f2fa93527d2f1dfe838dc60c0387062a6 (patch) | |
tree | df1183563219f150c293230a9c91013f20f6adeb /kernel | |
parent | 7a28736272655101534f93c95c8bf13575e9d4bb (diff) | |
download | linux-fsl-qoriq-37f5d14f2fa93527d2f1dfe838dc60c0387062a6.tar.xz |
HACK: printk: drop the logbuf_lock more often
The lock is hold with irgs off. The latency drops 500us+ on my arm bugs
with a "full" buffer after executing "dmesg" on the shell.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/printk.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 2609082..6d52c34 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -1072,6 +1072,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear) { char *text; int len = 0; + int attempts = 0; text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL); if (!text) @@ -1083,7 +1084,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear) u64 seq; u32 idx; enum log_flags prev; - + int num_msg; +try_again: + attempts++; + if (attempts > 10) { + len = -EBUSY; + goto out; + } + num_msg = 0; if (clear_seq < log_first_seq) { /* messages are gone, move to first available one */ clear_seq = log_first_seq; @@ -1104,6 +1112,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear) prev = msg->flags; idx = log_next(idx); seq++; + num_msg++; + if (num_msg > 5) { + num_msg = 0; + raw_spin_unlock_irq(&logbuf_lock); + raw_spin_lock_irq(&logbuf_lock); + if (clear_seq < log_first_seq) + goto try_again; + } } /* move first record forward until length fits into the buffer */ @@ -1117,6 +1133,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear) prev = msg->flags; idx = log_next(idx); seq++; + num_msg++; + if (num_msg > 5) { + num_msg = 0; + raw_spin_unlock_irq(&logbuf_lock); + raw_spin_lock_irq(&logbuf_lock); + if (clear_seq < log_first_seq) + goto try_again; + } } /* last message fitting into this dump */ @@ -1158,6 +1182,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear) clear_seq = log_next_seq; clear_idx = log_next_idx; } +out: raw_spin_unlock_irq(&logbuf_lock); kfree(text); |