netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipconfig schedule fix
@ 2004-11-23 22:50 Magnus Damm
  2004-11-23 23:18 ` David S. Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Magnus Damm @ 2004-11-23 22:50 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

Hi,

This simple patch makes the DHCP/BOOTP/RARP code sleep with
schedule_timeout() instead of hogging the cpu with cpu_relax() in a
loop. This comes handy when a guest kernel is booted inside QEMU.
Without the patch, the host operating system will consume cpu time
busy waiting.

Thanks,

/ magnus

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: linux-2.6.10-rc2-mm3-ipconfig_schedule.patch --]
[-- Type: text/x-patch; name="linux-2.6.10-rc2-mm3-ipconfig_schedule.patch", Size: 1293 bytes --]

--- linux-2.6.10-rc2-mm3/net/ipv4/ipconfig.c	2004-10-18 23:53:08.000000000 +0200
+++ linux-2.6.10-rc2-mm3-ipconfig_schedule/net/ipv4/ipconfig.c	2004-11-23 23:21:26.154463880 +0100
@@ -1102,8 +1102,8 @@
 
 		jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
 		while (time_before(jiffies, jiff) && !ic_got_reply) {
-			barrier();
-			cpu_relax();
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			schedule_timeout (1);
 		}
 #ifdef IPCONFIG_DHCP
 		/* DHCP isn't done until we get a DHCPACK. */
@@ -1245,7 +1245,6 @@
 
 static int __init ip_auto_config(void)
 {
-	unsigned long jiff;
 	u32 addr;
 
 #ifdef CONFIG_PROC_FS
@@ -1260,18 +1259,16 @@
  try_try_again:
 #endif
 	/* Give hardware a chance to settle */
-	jiff = jiffies + CONF_PRE_OPEN;
-	while (time_before(jiffies, jiff))
-		cpu_relax();
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout (CONF_PRE_OPEN);
 
 	/* Setup all network devices */
 	if (ic_open_devs() < 0)
 		return -1;
 
 	/* Give drivers a chance to settle */
-	jiff = jiffies + CONF_POST_OPEN;
-	while (time_before(jiffies, jiff))
-		cpu_relax();
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout (CONF_POST_OPEN);
 
 	/*
 	 * If the config information is insufficient (e.g., our IP address or

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-11-24  0:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-23 22:50 [PATCH] ipconfig schedule fix Magnus Damm
2004-11-23 23:18 ` David S. Miller
2004-11-23 23:42   ` Magnus Damm
2004-11-23 23:45     ` David S. Miller
2004-11-24  0:02       ` Magnus Damm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).