Skip to contentSkip to conversation

net/e1000_osdep: replace schedule_timeout() with msleep()

PATCH New [email protected] 1 participant 1 message Sep 1, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/16 net/e1000_osdep: replace schedule_timeout() with msleep()

Quoted 16 lines · Matthew Wilcox

Review

Quoted 11 lines · Nishanth Aravamudan

I would appreciate any comments from the janitor@sternweltens list.

Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time.

(quoted diff) +1 -2
 			} else { \
-				set_current_state(TASK_UNINTERRUPTIBLE); \
-				schedule_timeout((x * HZ)/1000 + 2); \
+				msleep(x); \
 			} } while(0)

Looks much better than the previous code. It's actually possible to do better, though. Simply change to:

Quoted 4 lines

#define msec_delay(x) msleep(x)

If msleep() ends up scheduling, the bad attempt to sleep will be caught by schedule(). There's no need to do the check in the driver.

Thanks for the tip and here is this change:

---

 linux-2.6.9-rc1-bk7-max/drivers/net/e1000/e1000_osdep.h |    8 +-------
 1 files changed, 1 insertion(+), 7 deletions(-)
drivers/net/e1000/e1000_osdep.h renamed from drivers/net/e1000/e1000_osdep.h~msleep-drivers_net_e1000_osdep +1 -7
diff -puN drivers/net/e1000/e1000_osdep.h~msleep-drivers_net_e1000_osdep drivers/net/e1000/e1000_osdep.h
@@ -42,13 +42,7 @@
 #include <linux/sched.h>
 
 #ifndef msec_delay
-#define msec_delay(x)	do { if(in_interrupt()) { \
-				/* Don't mdelay in interrupt context! */ \
-	                	BUG(); \
-			} else { \
-				set_current_state(TASK_UNINTERRUPTIBLE); \
-				schedule_timeout((x * HZ)/1000 + 2); \
-			} } while(0)
+#define msec_delay(x)	msleep(x)
 #endif
 
 #define PCI_COMMAND_REGISTER   PCI_COMMAND

_