Skip to content

Commit 86098bc

Browse files
committed
Merge branch 'rework/misc-cleanups' into for-linus
2 parents adb982a + 29fda1a commit 86098bc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

kernel/printk/printk.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,7 +3727,8 @@ late_initcall(printk_late_init);
37273727
/* If @con is specified, only wait for that console. Otherwise wait for all. */
37283728
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress)
37293729
{
3730-
int remaining = timeout_ms;
3730+
unsigned long timeout_jiffies = msecs_to_jiffies(timeout_ms);
3731+
unsigned long remaining_jiffies = timeout_jiffies;
37313732
struct console *c;
37323733
u64 last_diff = 0;
37333734
u64 printk_seq;
@@ -3744,6 +3745,9 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
37443745
console_unlock();
37453746

37463747
for (;;) {
3748+
unsigned long begin_jiffies;
3749+
unsigned long slept_jiffies;
3750+
37473751
diff = 0;
37483752

37493753
/*
@@ -3772,24 +3776,20 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
37723776
console_srcu_read_unlock(cookie);
37733777

37743778
if (diff != last_diff && reset_on_progress)
3775-
remaining = timeout_ms;
3779+
remaining_jiffies = timeout_jiffies;
37763780

37773781
console_unlock();
37783782

37793783
/* Note: @diff is 0 if there are no usable consoles. */
3780-
if (diff == 0 || remaining == 0)
3784+
if (diff == 0 || remaining_jiffies == 0)
37813785
break;
37823786

3783-
if (remaining < 0) {
3784-
/* no timeout limit */
3785-
msleep(100);
3786-
} else if (remaining < 100) {
3787-
msleep(remaining);
3788-
remaining = 0;
3789-
} else {
3790-
msleep(100);
3791-
remaining -= 100;
3792-
}
3787+
/* msleep(1) might sleep much longer. Check time by jiffies. */
3788+
begin_jiffies = jiffies;
3789+
msleep(1);
3790+
slept_jiffies = jiffies - begin_jiffies;
3791+
3792+
remaining_jiffies -= min(slept_jiffies, remaining_jiffies);
37933793

37943794
last_diff = diff;
37953795
}

0 commit comments

Comments
 (0)