<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Nishanth Aravamudan &lt;nacc@us.ibm.com&gt;

Use schedule_timeout_{,un}interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.  Also use
human-time conversion functions instead of hard-coded division to avoid
rounding issues.

(akpm: this patch relies on other stuff in -mm, please don't apply)

Signed-off-by: Nishanth Aravamudan &lt;nacc@us.ibm.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 net/core/pktgen.c            |   13 +++++--------
 net/ipv4/ipconfig.c          |    5 ++---
 net/irda/ircomm/ircomm_tty.c |    9 +++------
 net/sunrpc/svcsock.c         |    3 +--
 4 files changed, 11 insertions(+), 19 deletions(-)

diff -puN net/core/pktgen.c~net-fix-up-schedule_timeout-usage net/core/pktgen.c
--- devel/net/core/pktgen.c~net-fix-up-schedule_timeout-usage	2005-08-30 18:46:21.000000000 -0700
+++ devel-akpm/net/core/pktgen.c	2005-08-30 18:46:21.000000000 -0700
@@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file
 		thread_lock();
 		t-&gt;control |= T_REMDEV;
 		thread_unlock();
-		current-&gt;state = TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/8);  /* Propagate thread-&gt;control  */
+		schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread-&gt;control  */
 		ret = count;
                 sprintf(pg_result, "OK: rem_device_all");
 		goto out;
@@ -1716,10 +1715,9 @@ static void spin(struct pktgen_dev *pkt_
 	printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now));
 	while (now &lt; spin_until_us) {
 		/* TODO: optimise sleeping behavior */
-		if (spin_until_us - now &gt; (1000000/HZ)+1) {
-			current-&gt;state = TASK_INTERRUPTIBLE;
-			schedule_timeout(1);
-		} else if (spin_until_us - now &gt; 100) {
+		if (spin_until_us - now &gt; jiffies_to_usecs(1)+1)
+			schedule_timeout_interruptible(1);
+		else if (spin_until_us - now &gt; 100) {
 			do_softirq();
 			if (!pkt_dev-&gt;running)
 				return;
@@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void)
 	}
 	thread_unlock();
 
-	current-&gt;state = TASK_INTERRUPTIBLE;
-	schedule_timeout(HZ/8);  /* Propagate thread-&gt;control  */
+	schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread-&gt;control  */
 			
 	pktgen_wait_all_threads_run();
 }
diff -puN net/ipv4/ipconfig.c~net-fix-up-schedule_timeout-usage net/ipv4/ipconfig.c
--- devel/net/ipv4/ipconfig.c~net-fix-up-schedule_timeout-usage	2005-08-30 18:46:21.000000000 -0700
+++ devel-akpm/net/ipv4/ipconfig.c	2005-08-30 18:46:21.000000000 -0700
@@ -1102,10 +1102,9 @@ static int __init ic_dynamic(void)
 #endif
 
 		jiff = jiffies + (d-&gt;next ? CONF_INTER_TIMEOUT : timeout);
-		while (time_before(jiffies, jiff) &amp;&amp; !ic_got_reply) {
+		while (time_before(jiffies, jiff) &amp;&amp; !ic_got_reply)
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
-		}
+			schedule_timeout_uninterruptible(1);
 #ifdef IPCONFIG_DHCP
 		/* DHCP isn't done until we get a DHCPACK. */
 		if ((ic_got_reply &amp; IC_BOOTP)
diff -puN net/irda/ircomm/ircomm_tty.c~net-fix-up-schedule_timeout-usage net/irda/ircomm/ircomm_tty.c
--- devel/net/irda/ircomm/ircomm_tty.c~net-fix-up-schedule_timeout-usage	2005-08-30 18:46:21.000000000 -0700
+++ devel-akpm/net/irda/ircomm/ircomm_tty.c	2005-08-30 18:46:21.000000000 -0700
@@ -567,10 +567,8 @@ static void ircomm_tty_close(struct tty_
 	self-&gt;tty = NULL;
 
 	if (self-&gt;blocked_open) {
-		if (self-&gt;close_delay) {
-			current-&gt;state = TASK_INTERRUPTIBLE;
-			schedule_timeout(self-&gt;close_delay);
-		}
+		if (self-&gt;close_delay)
+			schedule_timeout_interruptible(self-&gt;close_delay);
 		wake_up_interruptible(&amp;self-&gt;open_wait);
 	}
 
@@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(s
 	spin_lock_irqsave(&amp;self-&gt;spinlock, flags);
 	while (self-&gt;tx_skb &amp;&amp; self-&gt;tx_skb-&gt;len) {
 		spin_unlock_irqrestore(&amp;self-&gt;spinlock, flags);
-		current-&gt;state = TASK_INTERRUPTIBLE;
-		schedule_timeout(poll_time);
+		schedule_timeout_interruptible(poll_time);
 		spin_lock_irqsave(&amp;self-&gt;spinlock, flags);
 		if (signal_pending(current))
 			break;
diff -puN net/sunrpc/svcsock.c~net-fix-up-schedule_timeout-usage net/sunrpc/svcsock.c
--- devel/net/sunrpc/svcsock.c~net-fix-up-schedule_timeout-usage	2005-08-30 18:46:21.000000000 -0700
+++ devel-akpm/net/sunrpc/svcsock.c	2005-08-30 18:46:21.000000000 -0700
@@ -1167,8 +1167,7 @@ svc_recv(struct svc_serv *serv, struct s
 	while (rqstp-&gt;rq_arghi &lt; pages) {
 		struct page *p = alloc_page(GFP_KERNEL);
 		if (!p) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/2);
+			schedule_timeout_uninterruptible(msecs_to_jiffies(500);
 			continue;
 		}
 		rqstp-&gt;rq_argpages[rqstp-&gt;rq_arghi++] = p;
_
</pre></body></html>