Skip to contentSkip to conversation

init: fix msleep() is not accurate

PATCH In review Yejune Deng 2 participants 2 messages Dec 11, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: fix msleep() is not accurate

See Documentation/timers/timers-howto.rst, msleep() is not for (1ms - 20ms),use usleep_range() instead.

---
 init/do_mounts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/do_mounts.c +1 -1
index a78e44e..e007b47 100644
@@ -606,7 +606,7 @@ void __init prepare_namespace(void)
 			saved_root_name);
 		while (driver_probe_done() != 0 ||
 			(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
-			msleep(5);
+			usleep_range(5000, 6000);
 		async_synchronize_full();
 	}
 
Signature · 1 line
1.9.1
#1 lore raw

Am Fri, Dec 11, 2020 at 11:24:12AM +0800 schrieb Yejune Deng:

Quoted 2 lines

See Documentation/timers/timers-howto.rst, msleep() is not for (1ms - 20ms),use usleep_range() instead.

While technically correct, this branch is only taken if the "rootwait" kernel parameter is passed -- and as the kernel is looping here, it does not really hurt if the msleep(5) takes a bit longer than advertised.

Thanks,
Dominik