2020-09-04 20:10:21 +00:00
|
|
|
From a39b767fed2c7ee3b6a58b23e3996e8a189377f1 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <a39b767fed2c7ee3b6a58b23e3996e8a189377f1.1599166691.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
|
|
|
References: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Date: Thu, 21 Mar 2013 19:01:05 +0100
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 208/333] printk: Drop the logbuf_lock more often
|
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.142-rt63.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
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(+)
|
2018-08-27 14:32:32 +00:00
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
|
2020-08-28 04:53:35 +00:00
|
|
|
index c5fbc51e61ed..4ac542763a09 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/printk/printk.c
|
|
|
|
+++ b/kernel/printk/printk.c
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -1455,12 +1455,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;
|
2018-08-27 14:32:32 +00:00
|
|
|
+ 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-08-27 14:32:32 +00:00
|
|
|
|
2018-10-30 12:40:05 +00:00
|
|
|
logbuf_lock_irq();
|
|
|
|
+
|
2018-08-27 14:32:32 +00:00
|
|
|
+try_again:
|
2018-10-30 12:40:05 +00:00
|
|
|
+ attempts++;
|
|
|
|
+ if (attempts > 10) {
|
|
|
|
+ len = -EBUSY;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+ num_msg = 0;
|
2018-08-27 14:32:32 +00:00
|
|
|
+
|
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.
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -1473,6 +1484,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-08-27 14:32:32 +00:00
|
|
|
|
2018-10-30 12:40:05 +00:00
|
|
|
/* move first record forward until length fits into the buffer */
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -1484,6 +1503,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-08-27 14:32:32 +00:00
|
|
|
|
2018-10-30 12:40:05 +00:00
|
|
|
/* last message fitting into this dump */
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -1521,6 +1548,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
|
2018-08-27 14:32:32 +00:00
|
|
|
clear_seq = log_next_seq;
|
|
|
|
clear_idx = log_next_idx;
|
|
|
|
}
|
|
|
|
+out:
|
|
|
|
logbuf_unlock_irq();
|
|
|
|
|
|
|
|
kfree(text);
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|