netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: netdev@oss.sgi.com
Subject: [PATCH] ipconfig schedule fix
Date: Tue, 23 Nov 2004 23:50:35 +0100	[thread overview]
Message-ID: <aec7e5c3041123145030b75d14@mail.gmail.com> (raw)

[-- 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

             reply	other threads:[~2004-11-23 22:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-23 22:50 Magnus Damm [this message]
2004-11-23 23:18 ` [PATCH] ipconfig schedule fix 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aec7e5c3041123145030b75d14@mail.gmail.com \
    --to=magnus.damm@gmail.com \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).