summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2023-11-02 13:00:34 +0100
committerPetr Mladek <pmladek@suse.com>2023-11-02 13:00:34 +0100
commit86098bcddeb10ae7975d701c3440d912bd2ebe12 (patch)
treecacbd669b36f01ed11f8a13d597c039c3656815d
parentadb982ad4b9d691f707061fbe90eff80d391a0ef (diff)
parent29fda1ad2a64a62e1c51d61207396e2de1c67362 (diff)
Merge branch 'rework/misc-cleanups' into for-linus
-rw-r--r--kernel/printk/printk.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a8fab94f4c04..95689eccf0fb 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3727,7 +3727,8 @@ late_initcall(printk_late_init);
/* If @con is specified, only wait for that console. Otherwise wait for all. */
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress)
{
- int remaining = timeout_ms;
+ unsigned long timeout_jiffies = msecs_to_jiffies(timeout_ms);
+ unsigned long remaining_jiffies = timeout_jiffies;
struct console *c;
u64 last_diff = 0;
u64 printk_seq;
@@ -3744,6 +3745,9 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
console_unlock();
for (;;) {
+ unsigned long begin_jiffies;
+ unsigned long slept_jiffies;
+
diff = 0;
/*
@@ -3772,24 +3776,20 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
console_srcu_read_unlock(cookie);
if (diff != last_diff && reset_on_progress)
- remaining = timeout_ms;
+ remaining_jiffies = timeout_jiffies;
console_unlock();
/* Note: @diff is 0 if there are no usable consoles. */
- if (diff == 0 || remaining == 0)
+ if (diff == 0 || remaining_jiffies == 0)
break;
- if (remaining < 0) {
- /* no timeout limit */
- msleep(100);
- } else if (remaining < 100) {
- msleep(remaining);
- remaining = 0;
- } else {
- msleep(100);
- remaining -= 100;
- }
+ /* msleep(1) might sleep much longer. Check time by jiffies. */
+ begin_jiffies = jiffies;
+ msleep(1);
+ slept_jiffies = jiffies - begin_jiffies;
+
+ remaining_jiffies -= min(slept_jiffies, remaining_jiffies);
last_diff = diff;
}