Skip to contentSkip to conversation

iopoll: Use fsleep() instead of usleep_range()

PATCH In review Andy Shevchenko 1 participant 2 messages May 2, 2025 – Jun 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iopoll: Use fsleep() instead of usleep_range()

Use fsleep() instead of usleep_range() to improve small time delays by avoiding the timer use. With this, use slightly bigger initial delays then was passed to usleep_range().

---
 include/linux/iopoll.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/iopoll.h +2 -2
index 91324c331a4b..fca50f117fae 100644
@@ -41,7 +41,7 @@
 	ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
 	might_sleep_if((__sleep_us) != 0); \
 	if (sleep_before_read && __sleep_us) \
-		usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
+		fsleep((__sleep_us >> 1) + 1); \
 	for (;;) { \
 		(val) = op(args); \
 		if (cond) \
@@ -52,7 +52,7 @@
 			break; \
 		} \
 		if (__sleep_us) \
-			usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
+			fsleep((__sleep_us >> 1) + 1); \
 		cpu_relax(); \
 	} \
 	(cond) ? 0 : -ETIMEDOUT; \
Signature · 1 line
2.47.2
#1 lore raw
Quoted 3 lines · Andy Shevchenko

Use fsleep() instead of usleep_range() to improve small time delays by avoiding the timer use. With this, use slightly bigger initial delays then was passed to usleep_range().

Any comments anybody?

Signature · 2 lines
With Best Regards,
Andy Shevchenko