linux/debian/patches-rt/0209-printk-Drop-the-logbuf...

80 lines
2.2 KiB
Diff
Raw Normal View History

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 21 Mar 2013 19:01:05 +0100
2019-11-25 00:04:39 +00:00
Subject: [PATCH 209/290] printk: Drop the logbuf_lock more often
Origin: https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=3bfadd9fc97cf1d7877b7d67316d67a96e82f182
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>
---
2019-04-08 23:49:20 +00:00
kernel/printk/printk.c | 28 ++++++++++++++++++++++++++++
2018-10-30 12:40:05 +00:00
1 file changed, 28 insertions(+)
2019-04-08 23:49:20 +00:00
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
2019-11-25 00:04:39 +00:00
index 1935cf91db0c..3b0f90ace2f1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
2019-04-08 23:49:20 +00:00
@@ -1420,12 +1420,23 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
2018-10-30 12:40:05 +00:00
u64 next_seq;
u64 seq;
u32 idx;
+ int attempts = 0;
+ int num_msg;
text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
if (!text)
2018-10-30 12:40:05 +00:00
return -ENOMEM;
2018-10-30 12:40:05 +00:00
logbuf_lock_irq();
+
+try_again:
2018-10-30 12:40:05 +00:00
+ attempts++;
+ if (attempts > 10) {
+ len = -EBUSY;
+ goto out;
+ }
+ num_msg = 0;
+
2018-10-30 12:40:05 +00:00
/*
* Find first record that fits, including all following records,
* into the user-provided buffer for this dump.
2019-04-08 23:49:20 +00:00
@@ -1438,6 +1449,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
2018-10-30 12:40:05 +00:00
len += msg_print_text(msg, true, NULL, 0);
idx = log_next(idx);
seq++;
+ num_msg++;
+ if (num_msg > 5) {
+ num_msg = 0;
+ logbuf_unlock_irq();
+ logbuf_lock_irq();
+ if (clear_seq < log_first_seq)
+ goto try_again;
+ }
}
2018-10-30 12:40:05 +00:00
/* move first record forward until length fits into the buffer */
2019-04-08 23:49:20 +00:00
@@ -1449,6 +1468,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
2018-10-30 12:40:05 +00:00
len -= msg_print_text(msg, true, NULL, 0);
idx = log_next(idx);
seq++;
+ num_msg++;
+ if (num_msg > 5) {
+ num_msg = 0;
+ logbuf_unlock_irq();
+ logbuf_lock_irq();
+ if (clear_seq < log_first_seq)
+ goto try_again;
+ }
}
2018-10-30 12:40:05 +00:00
/* last message fitting into this dump */
2019-04-08 23:49:20 +00:00
@@ -1486,6 +1513,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
clear_seq = log_next_seq;
clear_idx = log_next_idx;
}
+out:
logbuf_unlock_irq();
kfree(text);