@@ -3727,7 +3727,8 @@ late_initcall(printk_late_init);
3727
3727
/* If @con is specified, only wait for that console. Otherwise wait for all. */
3728
3728
static bool __pr_flush (struct console * con , int timeout_ms , bool reset_on_progress )
3729
3729
{
3730
- int remaining = timeout_ms ;
3730
+ unsigned long timeout_jiffies = msecs_to_jiffies (timeout_ms );
3731
+ unsigned long remaining_jiffies = timeout_jiffies ;
3731
3732
struct console * c ;
3732
3733
u64 last_diff = 0 ;
3733
3734
u64 printk_seq ;
@@ -3744,6 +3745,9 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
3744
3745
console_unlock ();
3745
3746
3746
3747
for (;;) {
3748
+ unsigned long begin_jiffies ;
3749
+ unsigned long slept_jiffies ;
3750
+
3747
3751
diff = 0 ;
3748
3752
3749
3753
/*
@@ -3772,24 +3776,20 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
3772
3776
console_srcu_read_unlock (cookie );
3773
3777
3774
3778
if (diff != last_diff && reset_on_progress )
3775
- remaining = timeout_ms ;
3779
+ remaining_jiffies = timeout_jiffies ;
3776
3780
3777
3781
console_unlock ();
3778
3782
3779
3783
/* Note: @diff is 0 if there are no usable consoles. */
3780
- if (diff == 0 || remaining == 0 )
3784
+ if (diff == 0 || remaining_jiffies == 0 )
3781
3785
break ;
3782
3786
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 );
3793
3793
3794
3794
last_diff = diff ;
3795
3795
}
0 commit comments