Skip to contentSkip to conversation

fix-up schedule_timeout() usage

PATCH In review Nishanth Aravamudan 8 participants 30 messages Aug 15, 2005 – Aug 18, 2005 1 message not in the archive

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

cover fix-up schedule_timeout() usage

Hello Andrew,

Sorry for the lack of a combined To:/Cc: list, but it would have been excessive if I included everyone (I won't send all of the patches to LKML, unless there is no other list entry in MAINTAINERS - I think that is only 9 out of the 32 patches :)

Andrew recently added schedule_timeout_interruptible() and schedule_timeout_uninterruptible() to the -mm tree, as schedule_timeout() called without the state set results in an immediate return; thus, it makes little sense to ever call it that way. Almost all the kernel invocations of schedule_timeout(), additionally, follow:

	set_current_state(TASK_{,UN}INTERRUPTIBLE);
	schedule_timeout(some_value_in_jiffies);

Andrew pointed out that creating non-inline wrappers for this common usage should reduce the kernel size. The following 32 patches (split up by directory/subsystem) convert the schedule_timeout() callers in 2.6.13-rc5-mm1, where appropriate.

Here's the list of patches as I split them up:

01/32: include/
02/32: fs/
03/32: kernel/
04/32: mm/
05/32: net/
06/32: sound/
07/32: arch/alpha
08/32: arch/i386
09/32: arch/ia64
10/32: arch/m68k
11/32: arch/mips
12/32: arch/ppc
13/32: arch/ppc64
14/32: arch/um
15/32: drivers/acpi
16/32: drivers/block
17/32: drivers/cdrom
18/32: drivers/char
19/32: drivers/dlm
20/32: drivers/net
21/32: drivers/ieee1394
22/32: drivers/isdn
23/32: drivers/macintosh
24/32: drivers/md
25/32: drivers/media
26/32: drivers/message
27/32: drivers/parport
28/32: drivers/sbus
29/32: drivers/scsi
30/32: drivers/serial
31/32: drivers/telephony
32/32: drivers/usb

Thanks,
Nish

#1 lore raw

PATCH 1/32 include: update jiffies/{m,u}secs conversion functions

Description: Clarify the human-time units to jiffies conversion functions by using the constants in time.h. This makes many of the subsequent patches direct copies of the current code.

---

 include/linux/jiffies.h |   40 ++++++++++++++++++++--------------------
 include/linux/time.h    |    4 ++++
 2 files changed, 24 insertions(+), 20 deletions(-)
include/linux/time.h +4 -0
@@ -28,6 +28,10 @@ struct timezone {
 #ifdef __KERNEL__
 
 /* Parameters used to convert the timespec values */
+#ifndef MSEC_PER_SEC
+#define MSEC_PER_SEC (1000L)
+#endif
+
 #ifndef USEC_PER_SEC
 #define USEC_PER_SEC (1000000L)
 #endif
include/linux/jiffies.h +20 -20
diff -urpN 2.6.13-rc5-mm1/include/linux/jiffies.h 2.6.13-rc5-mm1-dev/include/linux/jiffies.h
@@ -254,23 +254,23 @@ static inline u64 get_jiffies_64(void)
  */
 static inline unsigned int jiffies_to_msecs(const unsigned long j)
 {
-#if HZ <= 1000 && !(1000 % HZ)
-	return (1000 / HZ) * j;
-#elif HZ > 1000 && !(HZ % 1000)
-	return (j + (HZ / 1000) - 1)/(HZ / 1000);
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+	return (MSEC_PER_SEC / HZ) * j;
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+	return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
 #else
-	return (j * 1000) / HZ;
+	return (j * MSEC_PER_SEC) / HZ;
 #endif
 }
 
 static inline unsigned int jiffies_to_usecs(const unsigned long j)
 {
-#if HZ <= 1000000 && !(1000000 % HZ)
-	return (1000000 / HZ) * j;
-#elif HZ > 1000000 && !(HZ % 1000000)
-	return (j + (HZ / 1000000) - 1)/(HZ / 1000000);
+#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
+	return (USEC_PER_SEC / HZ) * j;
+#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
+	return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC);
 #else
-	return (j * 1000000) / HZ;
+	return (j * USEC_PER_SEC) / HZ;
 #endif
 }
 
@@ -278,12 +278,12 @@ static inline unsigned long msecs_to_jif
 {
 	if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
 		return MAX_JIFFY_OFFSET;
-#if HZ <= 1000 && !(1000 % HZ)
-	return (m + (1000 / HZ) - 1) / (1000 / HZ);
-#elif HZ > 1000 && !(HZ % 1000)
-	return m * (HZ / 1000);
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+	return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+	return m * (HZ / MSEC_PER_SEC);
 #else
-	return (m * HZ + 999) / 1000;
+	return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;
 #endif
 }
 
@@ -291,12 +291,12 @@ static inline unsigned long usecs_to_jif
 {
 	if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
 		return MAX_JIFFY_OFFSET;
-#if HZ <= 1000000 && !(1000000 % HZ)
-	return (u + (1000000 / HZ) - 1) / (1000000 / HZ);
-#elif HZ > 1000000 && !(HZ % 1000000)
-	return u * (HZ / 1000000);
+#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
+	return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ);
+#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
+	return u * (HZ / USEC_PER_SEC);
 #else
-	return (u * HZ + 999999) / 1000000;
+	return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC;
 #endif
 }
 
#2 lore raw

Re: [-mm PATCH 1/32] include: update jiffies/{m,u}secs conversion functions

Quoted 7 lines · Nishanth Aravamudan

Description: Clarify the human-time units to jiffies conversion functions by using the constants in time.h. This makes many of the subsequent patches direct copies of the current code.

/* Parameters used to convert the timespec values */

include/linux/time.h struct timezone { · line 37

Quoted 7 lines
include/linux/time.h +4 -0
+#ifndef MSEC_PER_SEC
+#define MSEC_PER_SEC (1000L)
+#endif
+
 #ifndef USEC_PER_SEC
 #define USEC_PER_SEC (1000000L)
 #endif

Bah. There's no MSEC_PER_SEC defined anywhere in the tree, so the ifndef isn't needed. Nor is the one for USEC_PER_SEC, come to that. I'll kill them.

#3 lore raw

Re: [-mm PATCH 1/32] include: update jiffies/{m,u}secs conversion functions

Quoted 7 lines · Andrew Morton
Quoted 6 lines · Nishanth Aravamudan

Description: Clarify the human-time units to jiffies conversion functions by using the constants in time.h. This makes many of the subsequent patches direct copies of the current code.

Quoted 12 lines

include/linux/time.h struct timezone { · line 37

Quoted 8 lines

/* Parameters used to convert the timespec values */

include/linux/time.h +4 -0
+#ifndef MSEC_PER_SEC
+#define MSEC_PER_SEC (1000L)
+#endif
+
 #ifndef USEC_PER_SEC
 #define USEC_PER_SEC (1000000L)
 #endif

Bah. There's no MSEC_PER_SEC defined anywhere in the tree, so the ifndef isn't needed. Nor is the one for USEC_PER_SEC, come to that. I'll kill them.

Yup, that's fine by me. Thanks!

-Nish

#4 lore raw

PATCH 2/32 fs: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use helper functions to convert between human time units and jiffies rather than constant HZ division to avoid rounding errors.

---

 fs/cifs/cifsfs.c             |    7 ++-----
 fs/cifs/connect.c            |    6 ++----
 fs/jbd/transaction.c         |    3 +--
 fs/lockd/clntproc.c          |    3 +--
 fs/nfs/nfs3proc.c            |    3 +--
 fs/nfs/nfs4proc.c            |   12 ++++--------
 fs/reiserfs/journal.c        |    3 +--
 fs/smbfs/proc.c              |    3 +--
 fs/xfs/linux-2.6/time.h      |    3 +--
 fs/xfs/linux-2.6/xfs_buf.c   |    6 +++---
 fs/xfs/linux-2.6/xfs_super.c |   12 ++++++------
 11 files changed, 23 insertions(+), 38 deletions(-)
fs/cifs/cifsfs.c +2 -5
diff -urpN 2.6.13-rc5-mm1/fs/cifs/cifsfs.c 2.6.13-rc5-mm1-dev/fs/cifs/cifsfs.c
@@ -781,14 +781,11 @@ static int cifs_oplock_thread(void * dum
 
 	oplockThread = current;
 	do {
-		set_current_state(TASK_INTERRUPTIBLE);
-		
-		schedule_timeout(1*HZ);  
+		schedule_timeout_interruptible(1*HZ);  
 		spin_lock(&GlobalMid_Lock);
 		if(list_empty(&GlobalOplock_Q)) {
 			spin_unlock(&GlobalMid_Lock);
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(39*HZ);
+			schedule_timeout_interruptible(39*HZ);
 		} else {
 			oplock_item = list_entry(GlobalOplock_Q.next, 
 				struct oplock_q_entry, qhead);
fs/cifs/connect.c +2 -4
diff -urpN 2.6.13-rc5-mm1/fs/cifs/connect.c 2.6.13-rc5-mm1-dev/fs/cifs/connect.c
@@ -3215,10 +3215,8 @@ cifs_umount(struct super_block *sb, stru
 	}
 	
 	cifs_sb->tcon = NULL;
-	if (ses) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ / 2);
-	}
+	if (ses)
+		schedule_timeout_interruptible(msecs_to_jiffies(500));
 	if (ses)
 		sesInfoFree(ses);
 
fs/jbd/transaction.c +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/jbd/transaction.c 2.6.13-rc5-mm1-dev/fs/jbd/transaction.c
@@ -1340,8 +1340,7 @@ int journal_stop(handle_t *handle)
 	if (handle->h_sync) {
 		do {
 			old_handle_count = transaction->t_handle_count;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (old_handle_count != transaction->t_handle_count);
 	}
 
fs/lockd/clntproc.c +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/lockd/clntproc.c 2.6.13-rc5-mm1-dev/fs/lockd/clntproc.c
@@ -299,8 +299,7 @@ nlmclnt_alloc_call(void)
 			return call;
 		}
 		printk("nlmclnt_alloc_call: failed, waiting for memory\n");
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(5*HZ);
+		schedule_timeout_interruptible(5*HZ);
 	}
 	return NULL;
 }
fs/nfs/nfs3proc.c +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/nfs/nfs3proc.c 2.6.13-rc5-mm1-dev/fs/nfs/nfs3proc.c
@@ -34,8 +34,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, 
 		res = rpc_call_sync(clnt, msg, flags);
 		if (res != -EJUKEBOX)
 			break;
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(NFS_JUKEBOX_RETRY_TIME);
+		schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME);
 		res = -ERESTARTSYS;
 	} while (!signalled());
 	rpc_clnt_sigunmask(clnt, &oldset);
fs/nfs/nfs4proc.c +4 -8
diff -urpN 2.6.13-rc5-mm1/fs/nfs/nfs4proc.c 2.6.13-rc5-mm1-dev/fs/nfs/nfs4proc.c
@@ -2412,14 +2412,11 @@ static int nfs4_delay(struct rpc_clnt *c
 		*timeout = NFS4_POLL_RETRY_MAX;
 	rpc_clnt_sigmask(clnt, &oldset);
 	if (clnt->cl_intr) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(*timeout);
+		schedule_timeout_interruptible(*timeout);
 		if (signalled())
 			res = -ERESTARTSYS;
-	} else {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(*timeout);
-	}
+	} else
+		schedule_timeout_uninterruptible(*timeout);
 	rpc_clnt_sigunmask(clnt, &oldset);
 	*timeout <<= 1;
 	return res;
@@ -2572,8 +2569,7 @@ int nfs4_proc_delegreturn(struct inode *
 static unsigned long
 nfs4_set_lock_task_retry(unsigned long timeout)
 {
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(timeout);
+	schedule_timeout_interruptible(timeout);
 	timeout <<= 1;
 	if (timeout > NFS4_LOCK_MAXTIMEOUT)
 		return NFS4_LOCK_MAXTIMEOUT;
fs/reiserfs/journal.c +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/reiserfs/journal.c 2.6.13-rc5-mm1-dev/fs/reiserfs/journal.c
@@ -2868,8 +2868,7 @@ static void let_transaction_grow(struct 
 	struct reiserfs_journal *journal = SB_JOURNAL(sb);
 	unsigned long bcount = journal->j_bcount;
 	while (1) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 		journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
 		while ((atomic_read(&journal->j_wcount) > 0 ||
 			atomic_read(&journal->j_jlock)) &&
fs/smbfs/proc.c +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/smbfs/proc.c 2.6.13-rc5-mm1-dev/fs/smbfs/proc.c
@@ -2397,8 +2397,7 @@ smb_proc_readdir_long(struct file *filp,
 		if (req->rq_rcls == ERRSRV && req->rq_err == ERRerror) {
 			/* a damn Win95 bug - sometimes it clags if you 
 			   ask it too fast */
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(HZ/5);
+			schedule_timeout_interruptible(msecs_to_jiffies(200));
 			continue;
                 }
 
fs/xfs/linux-2.6/time.h +1 -2
diff -urpN 2.6.13-rc5-mm1/fs/xfs/linux-2.6/time.h 2.6.13-rc5-mm1-dev/fs/xfs/linux-2.6/time.h
@@ -39,8 +39,7 @@ typedef struct timespec timespec_t;
 
 static inline void delay(long ticks)
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(ticks);
+	schedule_timeout_uninterruptible(ticks);
 }
 
 static inline void nanotime(struct timespec *tvp)
fs/xfs/linux-2.6/xfs_buf.c +3 -3
diff -urpN 2.6.13-rc5-mm1/fs/xfs/linux-2.6/xfs_buf.c 2.6.13-rc5-mm1-dev/fs/xfs/linux-2.6/xfs_buf.c
@@ -1778,10 +1778,10 @@ xfsbufd(
 			xfsbufd_force_sleep = 0;
 		}
 
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100);
+		schedule_timeout_interruptible
+			(xfs_buf_timer_centisecs * msecs_to_jiffies(10));
 
-		age = (xfs_buf_age_centisecs * HZ) / 100;
+		age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
 		spin_lock(&pbd_delwrite_lock);
 		list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
 			PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
fs/xfs/linux-2.6/xfs_super.c +6 -6
diff -urpN 2.6.13-rc5-mm1/fs/xfs/linux-2.6/xfs_super.c 2.6.13-rc5-mm1-dev/fs/xfs/linux-2.6/xfs_super.c
@@ -416,7 +416,7 @@ xfs_flush_inode(
 
 	igrab(inode);
 	xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work);
-	delay(HZ/2);
+	delay(msecs_to_jiffies(500));
 }
 
 /*
@@ -441,7 +441,7 @@ xfs_flush_device(
 
 	igrab(inode);
 	xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work);
-	delay(HZ/2);
+	delay(msecs_to_jiffies(500));
 	xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
 }
 
@@ -478,10 +478,9 @@ xfssyncd(
 	wake_up(&vfsp->vfs_wait_sync_task);
 
 	INIT_LIST_HEAD(&tmp);
-	timeleft = (xfs_syncd_centisecs * HZ) / 100;
+	timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
 	for (;;) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		timeleft = schedule_timeout(timeleft);
+		timeleft = schedule_timeout_interruptible(timeleft);
 		/* swsusp */
 		try_to_freeze();
 		if (vfsp->vfs_flag & VFS_UMOUNT)
@@ -495,7 +494,8 @@ xfssyncd(
 		 */
 		if (!timeleft || list_empty(&vfsp->vfs_sync_list)) {
 			if (!timeleft)
-				timeleft = (xfs_syncd_centisecs * HZ) / 100;
+				timeleft = xfs_syncd_centisecs *
+							msecs_to_jiffies(10);
 			INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list);
 			list_add_tail(&vfsp->vfs_sync_work.w_list,
 					&vfsp->vfs_sync_list);
#5 lore raw

Re: [xfs-masters] [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage

Quoted 4 lines · Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use helper functions to convert between human time units and jiffies rather than constant HZ division to avoid rounding errors.

The XFS changes are still wrong for the same rason as last time, we actually do want the daemons to do work if they're woken earlier using wake_up_process.

#6 lore raw

Re: [xfs-masters] [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage

Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use helper functions to convert between human time units and jiffies rather than constant HZ division to avoid rounding errors.

The XFS changes are still wrong for the same rason as last time, we actually do want the daemons to do work if they're woken earlier using wake_up_process.

Hrm, I got dropped from the Cc list...? No worries, I'm subscribed in two places :)

I think your reference to "last time" is the KJ patches which probably used msleep{,_interruptible}() instead of schedule_timeout(). This patchset, in contrast, should result in *no* functional changes (beyond some more precisie conversions, where appropriate). schedule_timeout_interruptible(some_value), for instance is nothing more than:

	set_current_state(TASK_INTERRUPTIBLE);
	schedule_timeout(some_value);

Just in the form of a combine function call. No loops like msleep() & co.

Is the patch still a problem?

Thanks,
Nish

#7 lore raw

Re: [xfs-masters] [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage

Quoted 2 lines · Nishanth Aravamudan

Hrm, I got dropped from the Cc list...? No worries, I'm subscribed in two places :)

I didn't do that manually, must haven some mail header thing.

Quoted 6 lines

I think your reference to "last time" is the KJ patches which probably used msleep{,_interruptible}() instead of schedule_timeout(). This patchset, in contrast, should result in *no* functional changes (beyond some more precisie conversions, where appropriate). schedule_timeout_interruptible(some_value), for instance is nothing more than:

Quoted 7 lines
	set_current_state(TASK_INTERRUPTIBLE);
	schedule_timeout(some_value);

Just in the form of a combine function call. No loops like msleep() & co.

Is the patch still a problem?

No, it's fine. Sorry for the noise.

#8 lore raw

Re: [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Hi,

fs/jbd/transaction.c int journal_stop(handle_t *handle) · line 1340

Quoted 8 lines · Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

+++ 2.6.13-rc5-mm1-dev/fs/jbd/transaction.c 2005-08-10 15:03:33.000000000 -0700

fs/jbd/transaction.c +1 -2
@@ -1340,8 +1340,7 @@ int journal_stop(handle_t *handle)
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);

This chunk at least is fine.

--Stephen

#9 lore raw

Re: [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

The cifs ones look fine with me.

Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench at-sign us dot ibm dot com

#10 lore raw

PATCH 3/32 kernel: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 kernel/compat.c |    9 +++------
 kernel/signal.c |    3 +--
 kernel/timer.c  |   18 ++++++------------
 3 files changed, 10 insertions(+), 20 deletions(-)
kernel/compat.c +3 -6
diff -urpN 2.6.13-rc5-mm1/kernel/compat.c 2.6.13-rc5-mm1-dev/kernel/compat.c
@@ -48,8 +48,7 @@ static long compat_nanosleep_restart(str
 	if (!time_after(expire, now))
 		return 0;
 
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire - now);
+	expire = schedule_timeout_interruptible(expire - now);
 	if (expire == 0)
 		return 0;
 
@@ -82,8 +81,7 @@ asmlinkage long compat_sys_nanosleep(str
 		return -EINVAL;
 
 	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire);
+	expire = schedule_timeout_interruptible(expire);
 	if (expire == 0)
 		return 0;
 
@@ -795,8 +793,7 @@ compat_sys_rt_sigtimedwait (compat_sigse
 			recalc_sigpending();
 			spin_unlock_irq(&current->sighand->siglock);
 
-			current->state = TASK_INTERRUPTIBLE;
-			timeout = schedule_timeout(timeout);
+			timeout = schedule_timeout_interruptible(timeout);
 
 			spin_lock_irq(&current->sighand->siglock);
 			sig = dequeue_signal(current, &s, &info);
kernel/signal.c +1 -2
diff -urpN 2.6.13-rc5-mm1/kernel/signal.c 2.6.13-rc5-mm1-dev/kernel/signal.c
@@ -2228,8 +2228,7 @@ sys_rt_sigtimedwait(const sigset_t __use
 			recalc_sigpending();
 			spin_unlock_irq(&current->sighand->siglock);
 
-			current->state = TASK_INTERRUPTIBLE;
-			timeout = schedule_timeout(timeout);
+			timeout = schedule_timeout_interruptible(timeout);
 
 			try_to_freeze();
 			spin_lock_irq(&current->sighand->siglock);
kernel/timer.c +6 -12
diff -urpN 2.6.13-rc5-mm1/kernel/timer.c 2.6.13-rc5-mm1-dev/kernel/timer.c
@@ -1199,8 +1199,7 @@ static long __sched nanosleep_restart(st
 	if (!time_after(expire, now))
 		return 0;
 
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire - now);
+	expire = schedule_timeout_interruptible(expire - now);
 
 	ret = 0;
 	if (expire) {
@@ -1228,8 +1227,7 @@ asmlinkage long sys_nanosleep(struct tim
 		return -EINVAL;
 
 	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
-	current->state = TASK_INTERRUPTIBLE;
-	expire = schedule_timeout(expire);
+	expire = schedule_timeout_interruptible(expire);
 
 	ret = 0;
 	if (expire) {
@@ -1627,10 +1625,8 @@ void msleep(unsigned int msecs)
 {
 	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 
-	while (timeout) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		timeout = schedule_timeout(timeout);
-	}
+	while (timeout)
+		timeout = schedule_timeout_uninterruptible(timeout);
 }
 
 EXPORT_SYMBOL(msleep);
@@ -1643,10 +1639,8 @@ unsigned long msleep_interruptible(unsig
 {
 	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 
-	while (timeout && !signal_pending(current)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		timeout = schedule_timeout(timeout);
-	}
+	while (timeout && !signal_pending(current))
+		timeout = schedule_timeout_interruptible(timeout);
 	return jiffies_to_msecs(timeout);
 }
 
#11 lore raw

PATCH 4/32 mm: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 mm/oom_kill.c |    3 +--
 mm/swapfile.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
mm/oom_kill.c +1 -2
diff -urpN 2.6.13-rc5-mm1/mm/oom_kill.c 2.6.13-rc5-mm1-dev/mm/oom_kill.c
@@ -290,6 +290,5 @@ retry:
 	 * Give "p" a good chance of killing itself before we
 	 * retry to allocate memory.
 	 */
-	__set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(1);
+	schedule_timeout_interruptible(1);
 }
mm/swapfile.c +1 -2
diff -urpN 2.6.13-rc5-mm1/mm/swapfile.c 2.6.13-rc5-mm1-dev/mm/swapfile.c
@@ -1151,8 +1151,7 @@ asmlinkage long sys_swapoff(const char _
 	p->highest_bit = 0;		/* cuts scans short */
 	while (p->flags >= SWP_SCANNING) {
 		spin_unlock(&swap_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 		spin_lock(&swap_lock);
 	}
 

A message that is not in the archive (sent off-list or not yet received): 20050815180514.GC2854-r/[email protected]

#13 lore raw

PATCH 5/32 net: fix-up schedule_timeout() usage

Description: 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.

---

 net/core/pktgen.c            |   13 +++++--------
 net/dccp/proto.c             |    2 +-
 net/ipv4/ipconfig.c          |    5 ++---
 net/irda/ircomm/ircomm_tty.c |    9 +++------
 net/sunrpc/svcsock.c         |    3 +--
 5 files changed, 12 insertions(+), 20 deletions(-)
net/core/pktgen.c +5 -8
@@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file
 		thread_lock();
 		t->control |= T_REMDEV;
 		thread_unlock();
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/8);  /* Propagate thread->control  */
+		schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread->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 < spin_until_us) {
 		/* TODO: optimise sleeping behavior */
-		if (spin_until_us - now > (1000000/HZ)+1) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(1);
-		} else if (spin_until_us - now > 100) {
+		if (spin_until_us - now > jiffies_to_usecs(1)+1)
+			schedule_timeout_interruptible(1);
+		else if (spin_until_us - now > 100) {
 			do_softirq();
 			if (!pkt_dev->running)
 				return;
@@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void)
 	}
 	thread_unlock();
 
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(HZ/8);  /* Propagate thread->control  */
+	schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread->control  */
 			
 	pktgen_wait_all_threads_run();
 }
net/dccp/proto.c +1 -1
diff -urpN 2.6.13-rc5-mm1/net/dccp/proto.c 2.6.13-rc5-mm1-dev/net/dccp/proto.c
@@ -225,7 +225,7 @@ int dccp_sendmsg(struct kiocb *iocb, str
 			if (delay > timeo)
 				goto out_discard;
 			release_sock(sk);
-			delay = schedule_timeout(delay);
+			delay = schedule_timeout_interruptible(delay);
 			lock_sock(sk);
 			timeo -= delay;
 			if (signal_pending(current))
net/ipv4/ipconfig.c +2 -3
diff -urpN 2.6.13-rc5-mm1/net/ipv4/ipconfig.c 2.6.13-rc5-mm1-dev/net/ipv4/ipconfig.c
@@ -1102,10 +1102,9 @@ static int __init ic_dynamic(void)
 #endif
 
 		jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
-		while (time_before(jiffies, jiff) && !ic_got_reply) {
+		while (time_before(jiffies, jiff) && !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 & IC_BOOTP)
net/irda/ircomm/ircomm_tty.c +3 -6
diff -urpN 2.6.13-rc5-mm1/net/irda/ircomm/ircomm_tty.c 2.6.13-rc5-mm1-dev/net/irda/ircomm/ircomm_tty.c
@@ -567,10 +567,8 @@ static void ircomm_tty_close(struct tty_
 	self->tty = NULL;
 
 	if (self->blocked_open) {
-		if (self->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(self->close_delay);
-		}
+		if (self->close_delay)
+			schedule_timeout_interruptible(self->close_delay);
 		wake_up_interruptible(&self->open_wait);
 	}
 
@@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(s
 	spin_lock_irqsave(&self->spinlock, flags);
 	while (self->tx_skb && self->tx_skb->len) {
 		spin_unlock_irqrestore(&self->spinlock, flags);
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(poll_time);
+		schedule_timeout_interruptible(poll_time);
 		spin_lock_irqsave(&self->spinlock, flags);
 		if (signal_pending(current))
 			break;
net/sunrpc/svcsock.c +1 -2
diff -urpN 2.6.13-rc5-mm1/net/sunrpc/svcsock.c 2.6.13-rc5-mm1-dev/net/sunrpc/svcsock.c
@@ -1167,8 +1167,7 @@ svc_recv(struct svc_serv *serv, struct s
 	while (rqstp->rq_arghi < 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->rq_argpages[rqstp->rq_arghi++] = p;

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

#14 lore raw

PATCH 15/32 drivers/acpi: fix-up schedule_timeout() usage

In reply to a message not in the archive

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use msecs_to_jiffies() instead of direct HZ division to avoid rounding errors.

---

 drivers/acpi/osl.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/acpi/osl.c +2 -4
diff -urpN 2.6.13-rc5-mm1/drivers/acpi/osl.c 2.6.13-rc5-mm1-dev/drivers/acpi/osl.c
@@ -315,8 +315,7 @@ acpi_status acpi_os_remove_interrupt_han
 
 void acpi_os_sleep(acpi_integer ms)
 {
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(((signed long)ms * HZ) / 1000);
+	schedule_timeout_interruptible(msecs_to_jiffies(ms));
 }
 
 EXPORT_SYMBOL(acpi_os_sleep);
@@ -866,8 +865,7 @@ acpi_status acpi_os_wait_semaphore(acpi_
 
 			ret = down_trylock(sem);
 			for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(1);
+				schedule_timeout_interruptible(1);
 				ret = down_trylock(sem);
 			}
 

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

#15 lore raw

PATCH 6/32 sound: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: 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.

---

 sound/core/seq/seq_instr.c            |   12 ++++--------
 sound/core/seq/seq_lock.c             |    3 +--
 sound/core/seq/seq_memory.c           |    3 +--
 sound/i2c/cs8427.c                    |    3 +--
 sound/isa/ad1848/ad1848_lib.c         |    6 ++----
 sound/isa/gus/gus_pcm.c               |    3 +--
 sound/isa/sb/emu8000.c                |    9 +++------
 sound/isa/sb/emu8000_patch.c          |    3 +--
 sound/isa/sb/emu8000_pcm.c            |    3 +--
 sound/isa/sscape.c                    |   17 ++---------------
 sound/isa/wavefront/wavefront_synth.c |    6 ++----
 sound/pci/ac97/ac97_codec.c           |   15 +++++----------
 sound/pci/ali5451/ali5451.c           |   12 ++++--------
 sound/pci/atiixp.c                    |    3 +--
 sound/pci/atiixp_modem.c              |    3 +--
 sound/pci/cs4281.c                    |    6 ++----
 sound/pci/ens1370.c                   |    3 +--
 sound/pci/fm801.c                     |    9 +++------
 sound/pci/ice1712/pontis.c            |    3 +--
 sound/pci/intel8x0.c                  |    3 +--
 sound/pci/intel8x0m.c                 |    3 +--
 sound/pci/maestro3.c                  |    9 +++------
 sound/pci/mixart/mixart.c             |    3 +--
 sound/pci/trident/trident_main.c      |    3 +--
 sound/pci/via82xx.c                   |    6 ++----
 sound/pci/via82xx_modem.c             |    6 ++----
 sound/pci/ymfpci/ymfpci_main.c        |    5 ++---
 sound/usb/usbaudio.c                  |    3 +--
 28 files changed, 51 insertions(+), 112 deletions(-)
sound/core/seq/seq_instr.c +4 -8
diff -urpN 2.6.13-rc5-mm1/sound/core/seq/seq_instr.c 2.6.13-rc5-mm1-dev/sound/core/seq/seq_instr.c
@@ -109,8 +109,7 @@ void snd_seq_instr_list_free(snd_seq_kin
 			spin_lock_irqsave(&list->lock, flags);
 			while (instr->use) {
 				spin_unlock_irqrestore(&list->lock, flags);
-				set_current_state(TASK_INTERRUPTIBLE);
-				schedule_timeout(1);
+				schedule_timeout_interruptible(1);
 				spin_lock_irqsave(&list->lock, flags);
 			}				
 			spin_unlock_irqrestore(&list->lock, flags);
@@ -199,10 +198,8 @@ int snd_seq_instr_list_free_cond(snd_seq
 		while (flist) {
 			instr = flist;
 			flist = instr->next;
-			while (instr->use) {
-				set_current_state(TASK_INTERRUPTIBLE);
-				schedule_timeout(1);
-			}				
+			while (instr->use)
+				schedule_timeout_interruptible(1);
 			if (snd_seq_instr_free(instr, atomic)<0)
 				snd_printk(KERN_WARNING "instrument free problem\n");
 			instr = next;
@@ -554,8 +551,7 @@ static int instr_free(snd_seq_kinstr_ops
 			instr->ops->notify(instr->ops->private_data, instr, SNDRV_SEQ_INSTR_NOTIFY_REMOVE);
 		while (instr->use) {
 			spin_unlock_irqrestore(&list->lock, flags);
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_interruptible(1);
 			spin_lock_irqsave(&list->lock, flags);
 		}				
 		spin_unlock_irqrestore(&list->lock, flags);
sound/core/seq/seq_lock.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/core/seq/seq_lock.c 2.6.13-rc5-mm1-dev/sound/core/seq/seq_lock.c
@@ -39,8 +39,7 @@ void snd_use_lock_sync_helper(snd_use_lo
 			snd_printk(KERN_WARNING "seq_lock: timeout [%d left] in %s:%d\n", atomic_read(lockp), file, line);
 			break;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 		max_count--;
 	}
 }
sound/core/seq/seq_memory.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/core/seq/seq_memory.c 2.6.13-rc5-mm1-dev/sound/core/seq/seq_memory.c
@@ -423,8 +423,7 @@ int snd_seq_pool_done(pool_t *pool)
 			snd_printk(KERN_WARNING "snd_seq_pool_done timeout: %d cells remain\n", atomic_read(&pool->counter));
 			break;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 		max_count--;
 	}
 	
sound/i2c/cs8427.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/i2c/cs8427.c 2.6.13-rc5-mm1-dev/sound/i2c/cs8427.c
@@ -302,8 +302,7 @@ static void snd_cs8427_reset(snd_i2c_dev
 		snd_i2c_unlock(cs8427->bus);
 		if (!(data & CS8427_UNLOCK))
 			break;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	snd_i2c_lock(cs8427->bus);
 	chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~CS8427_RXDMASK;
sound/isa/ad1848/ad1848_lib.c +2 -4
diff -urpN 2.6.13-rc5-mm1/sound/isa/ad1848/ad1848_lib.c 2.6.13-rc5-mm1-dev/sound/isa/ad1848/ad1848_lib.c
@@ -243,8 +243,7 @@ static void snd_ad1848_mce_down(ad1848_t
 			snd_printk("mce_down - auto calibration time out (2)\n");
 			return;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		time = schedule_timeout(time);
+		time = schedule_timeout_interruptible(time);
 		spin_lock_irqsave(&chip->reg_lock, flags);
 	}
 #if 0
@@ -257,8 +256,7 @@ static void snd_ad1848_mce_down(ad1848_t
 			snd_printk("mce_down - auto calibration time out (3)\n");
 			return;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		time = schedule_timeout(time);
+		time = schedule_timeout_interruptible(time);
 		spin_lock_irqsave(&chip->reg_lock, flags);
 	}
 	spin_unlock_irqrestore(&chip->reg_lock, flags);
sound/isa/gus/gus_pcm.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/isa/gus/gus_pcm.c 2.6.13-rc5-mm1-dev/sound/isa/gus/gus_pcm.c
@@ -333,8 +333,7 @@ static int snd_gf1_pcm_poke_block(snd_gu
 			}
 		}
 		if (count > 0 && !in_interrupt()) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_interruptible(1);
 			if (signal_pending(current))
 				return -EAGAIN;
 		}
sound/isa/sb/emu8000.c +3 -6
diff -urpN 2.6.13-rc5-mm1/sound/isa/sb/emu8000.c 2.6.13-rc5-mm1-dev/sound/isa/sb/emu8000.c
@@ -135,8 +135,7 @@ static void __init
 snd_emu8000_read_wait(emu8000_t *emu)
 {
 	while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 		if (signal_pending(current))
 			break;
 	}
@@ -148,8 +147,7 @@ static void __init
 snd_emu8000_write_wait(emu8000_t *emu)
 {
 	while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 		if (signal_pending(current))
 			break;
 	}
@@ -437,8 +435,7 @@ size_dram(emu8000_t *emu)
 	for (i = 0; i < 10000; i++) {
 		if ((EMU8000_SMALW_READ(emu) & 0x80000000) == 0)
 			break;
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 		if (signal_pending(current))
 			break;
 	}
sound/isa/sb/emu8000_patch.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/isa/sb/emu8000_patch.c 2.6.13-rc5-mm1-dev/sound/isa/sb/emu8000_patch.c
@@ -109,8 +109,7 @@ static void
 snd_emu8000_write_wait(emu8000_t *emu)
 {
 	while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 		if (signal_pending(current))
 			break;
 	}
sound/isa/sb/emu8000_pcm.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/isa/sb/emu8000_pcm.c 2.6.13-rc5-mm1-dev/sound/isa/sb/emu8000_pcm.c
@@ -117,8 +117,7 @@ snd_emu8000_write_wait(emu8000_t *emu, i
 {
 	while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
 		if (can_schedule) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_interruptible(1);
 			if (signal_pending(current))
 				break;
 		}
sound/isa/sscape.c +2 -15
diff -urpN 2.6.13-rc5-mm1/sound/isa/sscape.c 2.6.13-rc5-mm1-dev/sound/isa/sscape.c
@@ -344,19 +344,6 @@ static void soundscape_free(snd_card_t *
 }
 
 /*
- * Put this process into an idle wait-state for a certain number
- * of "jiffies". The process can almost certainly be rescheduled
- * while we're waiting, and so we must NOT be holding any spinlocks
- * when we call this function. If we are then we risk DEADLOCK in
- * SMP (Ha!) or pre-emptible kernels.
- */
-static inline void sleep(long jiffs, int state)
-{
-	set_current_state(state);
-	schedule_timeout(jiffs);
-}
-
-/*
  * Tell the SoundScape to begin a DMA tranfer using the given channel.
  * All locking issues are left to the caller.
  */
@@ -393,7 +380,7 @@ static int obp_startup_ack(struct sounds
 		unsigned long flags;
 		unsigned char x;
 
-		sleep(1, TASK_INTERRUPTIBLE);
+		schedule_timeout_interruptible(1);
 
 		spin_lock_irqsave(&s->lock, flags);
 		x = inb(HOST_DATA_IO(s->io_base));
@@ -420,7 +407,7 @@ static int host_startup_ack(struct sound
 		unsigned long flags;
 		unsigned char x;
 
-		sleep(1, TASK_INTERRUPTIBLE);
+		schedule_timeout_interruptible(1);
 
 		spin_lock_irqsave(&s->lock, flags);
 		x = inb(HOST_DATA_IO(s->io_base));
sound/isa/wavefront/wavefront_synth.c +2 -4
diff -urpN 2.6.13-rc5-mm1/sound/isa/wavefront/wavefront_synth.c 2.6.13-rc5-mm1-dev/sound/isa/wavefront/wavefront_synth.c
@@ -275,8 +275,7 @@ static int
 wavefront_sleep (int limit)
 
 {
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(limit);
+	schedule_timeout_interruptible(limit);
 
 	return signal_pending(current);
 }
@@ -1788,8 +1787,7 @@ wavefront_should_cause_interrupt (snd_wa
 	outb (val,port);
 	spin_unlock_irq(&dev->irq_lock);
 	while (1) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ((timeout = schedule_timeout(timeout)) == 0)
+		if ((timeout = schedule_timeout_interruptible(timeout)) == 0)
 			return;
 		if (dev->irq_ok)
 			return;
sound/pci/ac97/ac97_codec.c +5 -10
diff -urpN 2.6.13-rc5-mm1/sound/pci/ac97/ac97_codec.c 2.6.13-rc5-mm1-dev/sound/pci/ac97/ac97_codec.c
@@ -1756,8 +1756,7 @@ static int ac97_reset_wait(ac97_t *ac97,
 			if ((snd_ac97_read(ac97, AC97_REC_GAIN) & 0x7fff) == 0x0a05)
 				return 0;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_after_eq(end_time, jiffies));
 	return -ENODEV;
 }
@@ -2019,8 +2018,7 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97
 		do {
 			if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f)
 				goto __ready_ok;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after_eq(end_time, jiffies));
 		snd_printk(KERN_WARNING "AC'97 %d analog subsections not ready\n", ac97->num);
 	}
@@ -2052,8 +2050,7 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97
 		do {
 			if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp)
 				goto __ready_ok;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after_eq(end_time, jiffies));
 		snd_printk(KERN_WARNING "MC'97 %d converters and GPIO not ready (0x%x)\n", ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
 	}
@@ -2294,8 +2291,7 @@ void snd_ac97_resume(ac97_t *ac97)
 		do {
 			if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101)
 				break;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after_eq(end_time, jiffies));
 		/* FIXME: extra delay */
 		ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
@@ -2307,8 +2303,7 @@ void snd_ac97_resume(ac97_t *ac97)
 			unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
 			if (val != 0xffff && (val & 1) != 0)
 				break;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after_eq(end_time, jiffies));
 	}
 __reset_ready:
sound/pci/ali5451/ali5451.c +4 -8
diff -urpN 2.6.13-rc5-mm1/sound/pci/ali5451/ali5451.c 2.6.13-rc5-mm1-dev/sound/pci/ali5451/ali5451.c
@@ -404,10 +404,8 @@ static int snd_ali_codec_ready(	ali_t *c
 		res = snd_ali_5451_peek(codec,port);
 		if (! (res & 0x8000))
 			return 0;
-		if (sched) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
-		}
+		if (sched)
+			schedule_timeout_uninterruptible(1);
 	} while (time_after_eq(end_time, jiffies));
 	snd_ali_5451_poke(codec, port, res & ~0x8000);
 	snd_printdd("ali_codec_ready: codec is not ready.\n ");
@@ -427,10 +425,8 @@ static int snd_ali_stimer_ready(ali_t *c
 		dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
 		if (dwChk2 != dwChk1)
 			return 0;
-		if (sched) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
-		}
+		if (sched)
+			schedule_timeout_uninterruptible(1);
 	} while (time_after_eq(end_time, jiffies));
 	snd_printk("ali_stimer_read: stimer is not ready.\n");
 	return -EIO;
sound/pci/atiixp.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/atiixp.c 2.6.13-rc5-mm1-dev/sound/pci/atiixp.c
@@ -328,8 +328,7 @@ static int snd_atiixp_update_bits(atiixp
 
 /* delay for one tick */
 #define do_delay() do { \
-	set_current_state(TASK_UNINTERRUPTIBLE); \
-	schedule_timeout(1); \
+	schedule_timeout_uninterruptible(1); \
 } while (0)
 
 
sound/pci/atiixp_modem.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/atiixp_modem.c 2.6.13-rc5-mm1-dev/sound/pci/atiixp_modem.c
@@ -306,8 +306,7 @@ static int snd_atiixp_update_bits(atiixp
 
 /* delay for one tick */
 #define do_delay() do { \
-	set_current_state(TASK_UNINTERRUPTIBLE); \
-	schedule_timeout(1); \
+	schedule_timeout_uninterruptible(1); \
 } while (0)
 
 
sound/pci/cs4281.c +2 -4
diff -urpN 2.6.13-rc5-mm1/sound/pci/cs4281.c 2.6.13-rc5-mm1-dev/sound/pci/cs4281.c
@@ -534,8 +534,7 @@ static void snd_cs4281_delay(unsigned in
 			delay = 1;
 		end_time = jiffies + delay;
 		do {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after_eq(end_time, jiffies));
 	} else {
 		udelay(delay);
@@ -544,8 +543,7 @@ static void snd_cs4281_delay(unsigned in
 
 static inline void snd_cs4281_delay_long(void)
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(1);
+	schedule_timeout_uninterruptible(1);
 }
 
 static inline void snd_cs4281_pokeBA0(cs4281_t *chip, unsigned long offset, unsigned int val)
sound/pci/ens1370.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/ens1370.c 2.6.13-rc5-mm1-dev/sound/pci/ens1370.c
@@ -583,8 +583,7 @@ static void snd_es1370_codec_write(ak453
 			outw(ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
 			return;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_after(end_time, jiffies));
 	snd_printk("codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS)));
 }
sound/pci/fm801.c +3 -6
diff -urpN 2.6.13-rc5-mm1/sound/pci/fm801.c 2.6.13-rc5-mm1-dev/sound/pci/fm801.c
@@ -1303,8 +1303,7 @@ static int __devinit snd_fm801_create(sn
 	do {
 		if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8))
 			goto __ac97_secondary;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_after(timeout, jiffies));
 	snd_printk("Primary AC'97 codec not found\n");
 	snd_fm801_free(chip);
@@ -1329,8 +1328,7 @@ static int __devinit snd_fm801_create(sn
 					goto __ac97_ok;
 				}
 			}
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (time_after(timeout, jiffies));
 	}
 
@@ -1343,8 +1341,7 @@ static int __devinit snd_fm801_create(sn
 	do {
 		if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8))
 			goto __ac97_ok;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_after(timeout, jiffies));
 	snd_printk("Primary AC'97 codec not responding\n");
 	snd_fm801_free(chip);
sound/pci/ice1712/pontis.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/ice1712/pontis.c 2.6.13-rc5-mm1-dev/sound/pci/ice1712/pontis.c
@@ -794,8 +794,7 @@ static int __devinit pontis_init(ice1712
 	/* initialize WM8776 codec */
 	for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
 		wm_put(ice, wm_inits[i], wm_inits[i+1]);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(1);
+	schedule_timeout_uninterruptible(1);
 	for (i = 0; i < ARRAY_SIZE(wm_inits2); i += 2)
 		wm_put(ice, wm_inits2[i], wm_inits2[i+1]);
 
sound/pci/intel8x0.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/intel8x0.c 2.6.13-rc5-mm1-dev/sound/pci/intel8x0.c
@@ -2153,8 +2153,7 @@ static void do_ali_reset(intel8x0_t *chi
 }
 
 #define do_delay(chip) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(1);\
+	schedule_timeout_uninterruptible(1);\
 } while (0)
 
 static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing)
sound/pci/intel8x0m.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/intel8x0m.c 2.6.13-rc5-mm1-dev/sound/pci/intel8x0m.c
@@ -934,8 +934,7 @@ static int __devinit snd_intel8x0_mixer(
  */
 
 #define do_delay(chip) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(1);\
+	schedule_timeout_uninterruptible(1);\
 } while (0)
 
 static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
sound/pci/maestro3.c +3 -6
diff -urpN 2.6.13-rc5-mm1/sound/pci/maestro3.c 2.6.13-rc5-mm1-dev/sound/pci/maestro3.c
@@ -2075,8 +2075,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(0, io + GPIO_DATA);
 		outw(dir | GPO_PRIMARY_AC97, io + GPIO_DIRECTION);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay1 * HZ) / 1000);
+		schedule_timeout_uninterruptible(msecs_to_jiffies(delay1));
 
 		outw(GPO_PRIMARY_AC97, io + GPIO_DATA);
 		udelay(5);
@@ -2084,8 +2083,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(IO_SRAM_ENABLE | SERIAL_AC_LINK_ENABLE, io + RING_BUS_CTRL_A);
 		outw(~0, io + GPIO_MASK);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay2 * HZ) / 1000);
+		schedule_timeout_uninterruptible(msecs_to_jiffies(delay2));
 
 		if (! snd_m3_try_read_vendor(chip))
 			break;
@@ -2130,8 +2128,7 @@ static int __devinit snd_m3_mixer(m3_t *
 
 	/* seems ac97 PCM needs initialization.. hack hack.. */
 	snd_ac97_write(chip->ac97, AC97_PCM, 0x8000 | (15 << 8) | 15);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 10);
+	schedule_timeout_uninterruptible(msecs_to_jiffies(100));
 	snd_ac97_write(chip->ac97, AC97_PCM, 0);
 
 	memset(&id, 0, sizeof(id));
sound/pci/mixart/mixart.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/mixart/mixart.c 2.6.13-rc5-mm1-dev/sound/pci/mixart/mixart.c
@@ -451,8 +451,7 @@ static int mixart_sync_nonblock_events(m
 			snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
 			return -EBUSY;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	return 0;
 }
sound/pci/trident/trident_main.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/pci/trident/trident_main.c 2.6.13-rc5-mm1-dev/sound/pci/trident/trident_main.c
@@ -3206,8 +3206,7 @@ static inline void snd_trident_free_game
  */
 static inline void do_delay(trident_t *chip)
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(1);
+	schedule_timeout_uninterruptible(1);
 }
 
 /*
sound/pci/via82xx.c +2 -4
diff -urpN 2.6.13-rc5-mm1/sound/pci/via82xx.c 2.6.13-rc5-mm1-dev/sound/pci/via82xx.c
@@ -1893,8 +1893,7 @@ static int snd_via82xx_chip_init(via82xx
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -1913,8 +1912,7 @@ static int snd_via82xx_chip_init(via82xx
 			chip->ac97_secondary = 1;
 			goto __ac97_ok2;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
sound/pci/via82xx_modem.c +2 -4
diff -urpN 2.6.13-rc5-mm1/sound/pci/via82xx_modem.c 2.6.13-rc5-mm1-dev/sound/pci/via82xx_modem.c
@@ -966,8 +966,7 @@ static int snd_via82xx_chip_init(via82xx
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -985,8 +984,7 @@ static int snd_via82xx_chip_init(via82xx
 			chip->ac97_secondary = 1;
 			goto __ac97_ok2;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
sound/pci/ymfpci/ymfpci_main.c +2 -3
diff -urpN 2.6.13-rc5-mm1/sound/pci/ymfpci/ymfpci_main.c 2.6.13-rc5-mm1-dev/sound/pci/ymfpci/ymfpci_main.c
@@ -92,7 +92,7 @@ static int snd_ymfpci_codec_ready(ymfpci
 		if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0)
 			return 0;
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_before(jiffies, end_time));
 	snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));
 	return -EBUSY;
@@ -727,8 +727,7 @@ static void snd_ymfpci_irq_wait(ymfpci_t
 		init_waitqueue_entry(&wait, current);
 		add_wait_queue(&chip->interrupt_sleep, &wait);
 		atomic_inc(&chip->interrupt_sleep_count);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/20);
+		schedule_timeout_uninterruptible(msecs_to_jiffies(50));
 		remove_wait_queue(&chip->interrupt_sleep, &wait);
 	}
 }
sound/usb/usbaudio.c +1 -2
diff -urpN 2.6.13-rc5-mm1/sound/usb/usbaudio.c 2.6.13-rc5-mm1-dev/sound/usb/usbaudio.c
@@ -810,8 +810,7 @@ static int wait_clear_urbs(snd_usb_subst
 		}
 		if (! alive)
 			break;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (time_before(jiffies, end_time));
 	if (alive)
 		snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

#16 lore raw

PATCH 11/32 mips: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also, replace custom timespectojiffies() function with globally availabe timespec_to_jiffies().

---

 arch/mips/kernel/irixsig.c |   17 ++---------------
 arch/mips/kernel/sysirix.c |    3 +--
 2 files changed, 3 insertions(+), 17 deletions(-)
arch/mips/kernel/irixsig.c +2 -15
diff -urpN 2.6.13-rc5-mm1/arch/mips/kernel/irixsig.c 2.6.13-rc5-mm1-dev/arch/mips/kernel/irixsig.c
@@ -441,18 +441,6 @@ struct irix5_siginfo {
 	} stuff;
 };
 
-static inline unsigned long timespectojiffies(struct timespec *value)
-{
-	unsigned long sec = (unsigned) value->tv_sec;
-	long nsec = value->tv_nsec;
-
-	if (sec > (LONG_MAX / HZ))
-		return LONG_MAX;
-	nsec += 1000000000L / HZ - 1;
-	nsec /= 1000000000L / HZ;
-	return HZ * sec + nsec;
-}
-
 asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
 				struct timespec *tp)
 {
@@ -490,14 +478,13 @@ asmlinkage int irix_sigpoll_sys(unsigned
 			error = -EINVAL;
 			goto out;
 		}
-		expire = timespectojiffies(tp)+(tp->tv_sec||tp->tv_nsec);
+		expire = timespec_to_jiffies(tp) + (tp->tv_sec||tp->tv_nsec);
 	}
 
 	while(1) {
 		long tmp = 0;
 
-		current->state = TASK_INTERRUPTIBLE;
-		expire = schedule_timeout(expire);
+		expire = schedule_timeout_interruptible(expire);
 
 		for (i=0; i<=4; i++)
 			tmp |= (current->pending.signal.sig[i] & kset.sig[i]);
arch/mips/kernel/sysirix.c +1 -2
diff -urpN 2.6.13-rc5-mm1/arch/mips/kernel/sysirix.c 2.6.13-rc5-mm1-dev/arch/mips/kernel/sysirix.c
@@ -1035,8 +1029,7 @@ bad:
 
 asmlinkage int irix_sginap(int ticks)
 {
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(ticks);
+	schedule_timeout_interruptible(ticks);
 	return 0;
 }
 
#17 lore raw

PATCH 12/32 ppc: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use human-time conversion functions instead of hard-coded HZ division to avoid rounding errors.

---

 arch/ppc/4xx_io/serial_sicc.c |   17 +++++++----------
 arch/ppc/8260_io/fcc_enet.c   |    3 +--
 2 files changed, 8 insertions(+), 12 deletions(-)
arch/ppc/4xx_io/serial_sicc.c +7 -10
diff -urpN 2.6.13-rc5-mm1/arch/ppc/4xx_io/serial_sicc.c 2.6.13-rc5-mm1-dev/arch/ppc/4xx_io/serial_sicc.c
@@ -1145,8 +1145,8 @@ static int set_serial_info(struct SICC_i
     info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) |
                (info->flags & ASYNC_INTERNAL_FLAGS));
     state->custom_divisor = new_serial.custom_divisor;
-    state->close_delay = new_serial.close_delay * HZ / 100;
-    state->closing_wait = new_serial.closing_wait * HZ / 100;
+    state->close_delay = msecs_to_jiffies(10 * new_serial.close_delay);
+    state->closing_wait = msecs_to_jiffies(10 * new_serial.closing_wait);
     info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
     port->fifosize = new_serial.xmit_fifo_size;
 
@@ -1465,10 +1465,8 @@ static void siccuart_close(struct tty_st
     info->event = 0;
     info->tty = NULL;
     if (info->blocked_open) {
-        if (info->state->close_delay) {
-            set_current_state(TASK_INTERRUPTIBLE);
-            schedule_timeout(info->state->close_delay);
-        }
+        if (info->state->close_delay)
+            schedule_timeout_interruptible(info->state->close_delay);
         wake_up_interruptible(&info->open_wait);
     }
     info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -1496,7 +1494,7 @@ static void siccuart_wait_until_sent(str
      * Note: we have to use pretty tight timings here to satisfy
      * the NIST-PCTS.
      */
-    char_time = (info->timeout - HZ/50) / info->port->fifosize;
+    char_time = (info->timeout - msecs_to_jiffies(20)) / info->port->fifosize;
     char_time = char_time / 5;
     if (char_time == 0)
         char_time = 1;
@@ -1521,8 +1519,7 @@ static void siccuart_wait_until_sent(str
            tty->index, jiffies,
            expire, char_time);
     while ((readb(info->port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != _LSR_TX_ALL) {
-        set_current_state(TASK_INTERRUPTIBLE);
-        schedule_timeout(char_time);
+        schedule_timeout_interruptible(char_time);
         if (signal_pending(current))
             break;
         if (timeout && time_after(jiffies, expire))
@@ -1773,7 +1770,7 @@ int __init siccuart_init(void)
     for (i = 0; i < SERIAL_SICC_NR; i++) {
         struct SICC_state *state = sicc_state + i;
         state->line     = i;
-        state->close_delay  = 5 * HZ / 10;
+        state->close_delay  = msecs_to_jiffies(500);
         state->closing_wait = 30 * HZ;
 	spin_lock_init(&state->sicc_lock);
     }
arch/ppc/8260_io/fcc_enet.c +1 -2
diff -urpN 2.6.13-rc5-mm1/arch/ppc/8260_io/fcc_enet.c 2.6.13-rc5-mm1-dev/arch/ppc/8260_io/fcc_enet.c
@@ -1309,8 +1309,7 @@ static void mii_dm9161_wait(uint mii_reg
 
 	/* Davicom takes a bit to come up after a reset,
 	 * so wait here for a bit */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(timeout);
+	schedule_timeout_uninterruptible(timeout);
 }
 
 static phy_info_t phy_info_dm9161 = {
#18 lore raw

PATCH 14/32 um: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 arch/um/drivers/random.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/um/drivers/random.c +2 -4
diff -urpN 2.6.13-rc5-mm1/arch/um/drivers/random.c 2.6.13-rc5-mm1-dev/arch/um/drivers/random.c
@@ -58,10 +58,8 @@ static ssize_t rng_dev_read (struct file
                         if (filp->f_flags & O_NONBLOCK)
                                 return ret ? : -EAGAIN;
 
-                        if(need_resched()){
-                                current->state = TASK_INTERRUPTIBLE;
-                                schedule_timeout(1);
-                        }
+                        if(need_resched())
+                                schedule_timeout_interruptible(1);
                 }
                 else return n;
 		if (signal_pending (current))

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Acked-by on v1 14/32
#19 lore raw

Re: [uml-devel] [-mm PATCH 14/32] um: fix-up schedule_timeout() usage

Quoted 4 lines · Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#20 lore raw

PATCH 17/32 drivers/cdrom: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_{un,}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/cdrom/sbpcd.c     |    3 +--
 drivers/cdrom/sonycd535.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/cdrom/sbpcd.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/cdrom/sbpcd.c 2.6.13-rc5-mm1-dev/drivers/cdrom/sbpcd.c
@@ -827,8 +827,7 @@ static void mark_timeout_audio(u_long i)
 static void sbp_sleep(u_int time)
 {
 	sti();
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(time);
+	schedule_interruptible_timeout(time);
 	sti();
 }
 /*==========================================================================*/
drivers/cdrom/sonycd535.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/cdrom/sonycd535.c 2.6.13-rc5-mm1-dev/drivers/cdrom/sonycd535.c
@@ -1478,8 +1477,7 @@ static int __init sony535_init(void)
 	/* look for the CD-ROM, follows the procedure in the DOS driver */
 	inb(select_unit_reg);
 	/* wait for 40 18 Hz ticks (reverse-engineered from DOS driver) */
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout((HZ+17)*40/18);
+	schedule_timeout_interruptible((HZ+17)*40/18);
 	inb(result_reg);
 
 	outb(0, read_status_reg);	/* does a reset? */
#21 lore raw

PATCH 19/32 drivers/dlm: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/dlm/lockspace.c |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)
drivers/dlm/lockspace.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/dlm/lockspace.c 2.6.13-rc5-mm1-dev/drivers/dlm/lockspace.c
@@ -54,8 +54,7 @@ static int dlm_scand(void *data)
 	while (!kthread_should_stop()) {
 		list_for_each_entry(ls, &lslist, ls_list)
 			dlm_scan_rsbs(ls);
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(dlm_config.scan_secs * HZ);
+		schedule_timeout_interruptible(dlm_config.scan_secs * HZ);
 	}
 	return 0;
 }
#22 lore raw

PATCH 23/32 drivers/macintosh: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 arch/m68k/atari/time.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/macintosh/therm_pm72.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/macintosh/therm_pm72.c 2.6.13-rc5-mm1-dev/drivers/macintosh/therm_pm72.c
@@ -1678,10 +1678,9 @@ static int main_control_loop(void *x)
 		}
 
 		// FIXME: Deal with signals
-		set_current_state(TASK_INTERRUPTIBLE);
 		elapsed = jiffies - start;
 		if (elapsed < HZ)
-			schedule_timeout(HZ - elapsed);
+			schedule_timeout_interruptible(HZ - elapsed);
 	}
 
  out:
#23 lore raw

PATCH 24/32 drivers/md: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/md/raid5.c     |    3 +--
 drivers/md/raid6main.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/md/raid5.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/md/raid5.c 2.6.13-rc5-mm1-dev/drivers/md/raid5.c
@@ -1522,8 +1522,7 @@ static sector_t sync_request(mddev_t *md
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access 
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	spin_lock(&sh->lock);	
 	set_bit(STRIPE_SYNCING, &sh->state);
drivers/md/raid6main.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/md/raid6main.c 2.6.13-rc5-mm1-dev/drivers/md/raid6main.c
@@ -1681,8 +1681,7 @@ static sector_t sync_request(mddev_t *md
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	spin_lock(&sh->lock);
 	set_bit(STRIPE_SYNCING, &sh->state);
#24 lore raw

PATCH 26/32 message: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/message/fusion/mptlan.c   |   10 ++++------
 drivers/message/fusion/mptscsih.c |    6 ++----
 drivers/message/i2o/iop.c         |   15 +++++----------
 3 files changed, 11 insertions(+), 20 deletions(-)
drivers/message/fusion/mptlan.c +4 -6
diff -urpN 2.6.13-rc5-mm1/drivers/message/fusion/mptlan.c 2.6.13-rc5-mm1-dev/drivers/message/fusion/mptlan.c
@@ -506,7 +506,7 @@ mpt_lan_close(struct net_device *dev)
 {
 	struct mpt_lan_priv *priv = netdev_priv(dev);
 	MPT_ADAPTER *mpt_dev = priv->mpt_dev;
-	unsigned int timeout;
+	unsigned long timeout;
 	int i;
 
 	dlprintk((KERN_INFO MYNAM ": mpt_lan_close called\n"));
@@ -521,11 +521,9 @@ mpt_lan_close(struct net_device *dev)
 
 	mpt_lan_reset(dev);
 
-	timeout = 2 * HZ;
-	while (atomic_read(&priv->buckets_out) && --timeout) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	timeout = jiffies + 2 * HZ;
+	while (atomic_read(&priv->buckets_out) && time_before(jiffies, timeout))
+		schedule_timeout_interruptible(1);
 
 	for (i = 0; i < priv->max_buckets_out; i++) {
 		if (priv->RcvCtl[i].skb != NULL) {
drivers/message/fusion/mptscsih.c +2 -4
diff -urpN 2.6.13-rc5-mm1/drivers/message/fusion/mptscsih.c 2.6.13-rc5-mm1-dev/drivers/message/fusion/mptscsih.c
@@ -974,10 +974,8 @@ mptscsih_remove(struct pci_dev *pdev)
 	spin_lock_irqsave(&dvtaskQ_lock, flags);
 	if (dvtaskQ_active) {
 		spin_unlock_irqrestore(&dvtaskQ_lock, flags);
-		while(dvtaskQ_active && --count) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
-		}
+		while(dvtaskQ_active && --count)
+			schedule_timeout_interruptible(1);
 	} else {
 		spin_unlock_irqrestore(&dvtaskQ_lock, flags);
 	}
drivers/message/i2o/iop.c +5 -10
diff -urpN 2.6.13-rc5-mm1/drivers/message/i2o/iop.c 2.6.13-rc5-mm1-dev/drivers/message/i2o/iop.c
@@ -92,8 +92,7 @@ u32 i2o_msg_get_wait(struct i2o_controll
 				  c->name);
 			return I2O_QUEUE_EMPTY;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	return m;
@@ -484,8 +483,7 @@ static int i2o_iop_init_outbound_queue(s
 			osm_warn("%s: Timeout Initializing\n", c->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	m = c->out_queue.phys;
@@ -547,8 +545,7 @@ static int i2o_iop_reset(struct i2o_cont
 		if (time_after(jiffies, timeout))
 			break;
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	switch (*status) {
@@ -576,8 +573,7 @@ static int i2o_iop_reset(struct i2o_cont
 				rc = -ETIMEDOUT;
 				goto exit;
 			}
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 
 			m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
 		}
@@ -987,8 +983,7 @@ int i2o_status_get(struct i2o_controller
 			return -ETIMEDOUT;
 		}
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 #ifdef DEBUG
#25 lore raw

PATCH 28/32 drivers/sbus: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/sbus/char/bpp.c     |    3 +--
 drivers/sbus/char/vfc_i2c.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/sbus/char/bpp.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/sbus/char/bpp.c 2.6.13-rc5-mm1-dev/drivers/sbus/char/bpp.c
@@ -295,8 +295,7 @@ static unsigned short get_pins(unsigned 
 
 static void snooze(unsigned long snooze_time, unsigned minor)
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(snooze_time + 1);
+	schedule_timeout_uninterruptible(snooze_time + 1);
 }
 
 static int wait_for(unsigned short set, unsigned short clr,
drivers/sbus/char/vfc_i2c.c +1 -2
diff -urpN 2.6.13-rc5-mm1/drivers/sbus/char/vfc_i2c.c 2.6.13-rc5-mm1-dev/drivers/sbus/char/vfc_i2c.c
@@ -81,8 +81,7 @@ int vfc_pcf8584_init(struct vfc_dev *dev
 
 void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs) 
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(usecs_to_jiffies(usecs));
+	schedule_timeout_uninterruptible(usecs_to_jiffies(usecs));
 }
 
 void inline vfc_i2c_delay(struct vfc_dev *dev) 
#26 lore raw

PATCH 29/32 drivers/scsi: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/scsi/NCR5380.c        |    5 +----
 drivers/scsi/aacraid/rkt.c    |    6 ++----
 drivers/scsi/aacraid/rx.c     |    6 ++----
 drivers/scsi/aacraid/sa.c     |    6 ++----
 drivers/scsi/dpt_i2o.c        |   34 +++++++++++-----------------------
 drivers/scsi/lpfc/lpfc_scsi.c |   12 ++++--------
 drivers/scsi/osst.c           |    9 +++------
 drivers/scsi/qla2xxx/qla_os.c |   11 ++++-------
 8 files changed, 29 insertions(+), 60 deletions(-)
drivers/scsi/aacraid/rkt.c +2 -4
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/aacraid/rkt.c 2.6.13-rc5-mm1-dev/drivers/scsi/aacraid/rkt.c
@@ -166,8 +166,7 @@ static int rkt_sync_cmd(struct aac_dev *
 		/*
 		 *	Yield the processor in case we are slow 
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (ok != 1) {
 		/*
@@ -410,8 +409,7 @@ int aac_rkt_init(struct aac_dev *dev)
 					dev->name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (request_irq(dev->scsi_host_ptr->irq, aac_rkt_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 
 	{
drivers/scsi/aacraid/rx.c +2 -4
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/aacraid/rx.c 2.6.13-rc5-mm1-dev/drivers/scsi/aacraid/rx.c
@@ -166,8 +166,7 @@ static int rx_sync_cmd(struct aac_dev *d
 		/*
 		 *	Yield the processor in case we are slow 
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (ok != 1) {
 		/*
@@ -410,8 +409,7 @@ int aac_rx_init(struct aac_dev *dev)
 					dev->name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (request_irq(dev->scsi_host_ptr->irq, aac_rx_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 
 	{
drivers/scsi/aacraid/sa.c +2 -4
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/aacraid/sa.c 2.6.13-rc5-mm1-dev/drivers/scsi/aacraid/sa.c
@@ -189,8 +189,7 @@ static int sa_sync_cmd(struct aac_dev *d
 			ok = 1;
 			break;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if (ok != 1)
@@ -347,8 +346,7 @@ int aac_sa_init(struct aac_dev *dev)
 					name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if (request_irq(dev->scsi_host_ptr->irq, aac_sa_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev ) < 0) {
drivers/scsi/dpt_i2o.c +11 -23
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/dpt_i2o.c 2.6.13-rc5-mm1-dev/drivers/scsi/dpt_i2o.c
@@ -1211,8 +1211,7 @@ static s32 adpt_i2o_post_this(adpt_hba* 
 			printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m == EMPTY_QUEUE);
 		
 	msg = pHba->msg_addr_virt + m;
@@ -1287,8 +1286,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 			printk(KERN_WARNING"Timeout waiting for message!\n");
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (m == EMPTY_QUEUE);
 
 	status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32);
@@ -1320,8 +1318,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 			return -ETIMEDOUT;
 		}
 		rmb();
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if(*status == 0x01 /*I2O_EXEC_IOP_RESET_IN_PROGRESS*/) {
@@ -1338,8 +1335,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 				printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
 				return -ETIMEDOUT;
 			}
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (m == EMPTY_QUEUE);
 		// Flush the offset
 		adpt_send_nop(pHba, m);
@@ -1910,11 +1906,8 @@ static int adpt_ioctl(struct inode *inod
 		return -ENXIO;
 	}
 
-	while((volatile u32) pHba->state & DPTI_STATE_RESET ) {
-		set_task_state(current,TASK_UNINTERRUPTIBLE);
-		schedule_timeout(2);
-
-	}
+	while((volatile u32) pHba->state & DPTI_STATE_RESET )
+		schedule_timeout_uninterruptible(2);
 
 	switch (cmd) {
 	// TODO: handle 3 cases
@@ -2628,8 +2621,7 @@ static s32 adpt_send_nop(adpt_hba*pHba,u
 			printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name);
 			return 2;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	msg = (u32 __iomem *)(pHba->msg_addr_virt + m);
 	writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]);
@@ -2663,8 +2655,7 @@ static s32 adpt_i2o_init_outbound_q(adpt
 			printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m == EMPTY_QUEUE);
 
 	msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
@@ -2702,8 +2693,7 @@ static s32 adpt_i2o_init_outbound_q(adpt
 			printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (1);
 
 	// If the command was successful, fill the fifo with our reply
@@ -2781,8 +2771,7 @@ static s32 adpt_i2o_status_get(adpt_hba*
 					pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m==EMPTY_QUEUE);
 
 	
@@ -2809,8 +2798,7 @@ static s32 adpt_i2o_status_get(adpt_hba*
 			return -ETIMEDOUT;
 		}
 		rmb();
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	// Set up our number of outbound and inbound messages
drivers/scsi/lpfc/lpfc_scsi.c +4 -8
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc5-mm1-dev/drivers/scsi/lpfc/lpfc_scsi.c
@@ -883,8 +883,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -950,8 +949,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			schedule_timeout_uninterruptible(msecs_to_jiffies(500));
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1009,8 +1007,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1108,8 +1105,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
drivers/scsi/NCR5380.c +1 -4
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/NCR5380.c 2.6.13-rc5-mm1-dev/drivers/scsi/NCR5380.c
@@ -599,10 +599,7 @@ static int __init NCR5380_probe_irq(stru
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
 
 	while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
-	{
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+		schedule_timeout_uninterruptible(1);
 	
 	NCR5380_write(SELECT_ENABLE_REG, 0);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
drivers/scsi/osst.c +3 -6
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/osst.c 2.6.13-rc5-mm1-dev/drivers/scsi/osst.c
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp, aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			schedule_timeout_interruptible(HZ / OSST_POLL_PER_SEC);
 
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
 			memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(str
 			osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
 			flag = 0;
 			attempts--;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ / 10);
+			schedule_timeout_interruptible(msecs_to_jiffies(100));
 		}
 		if (osst_get_frame_position(STp, aSRpnt) < 0) {		/* additional write error */
 #if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(str
 			debugging = 0;
 		}
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ / 10);
+		schedule_timeout_interruptible(msecs_to_jiffies(100));
 	}
 	printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name);
 #if DEBUG
drivers/scsi/qla2xxx/qla_os.c +4 -7
diff -urpN 2.6.13-rc5-mm1/drivers/scsi/qla2xxx/qla_os.c 2.6.13-rc5-mm1-dev/drivers/scsi/qla2xxx/qla_os.c
@@ -1944,10 +1944,8 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 
 	/* Make sure all other threads are stopped. */
 	wtime = 60 * HZ;
-	while (ha->dpc_wait && wtime) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		wtime = schedule_timeout(wtime);
-	}
+	while (ha->dpc_wait && wtime)
+		wtime = schedule_timeout_interruptible(wtime);
 
 	/* free ioctl memory */
 	qla2x00_free_ioctl_mem(ha);
@@ -2478,13 +2476,12 @@ qla2x00_timer(scsi_qla_host_t *ha)
 int
 qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
 {
-	const unsigned int step = HZ/10;
+	const unsigned int step = msecs_to_jiffies(100);
 
 	do {
 		if (!down_trylock(sema))
 			return 0;
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(step))
+		if (schedule_timeout_interruptible(step))
 			break;
 	} while ((timeout -= step) > 0);
 
#27 lore raw

Re: [-mm PATCH 29/32] drivers/scsi: fix-up schedule_timeout() usage

Quoted 16 lines · Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/scsi/osst.c           |    9 +++------

diff -urpN 2.6.13-rc5-mm1/drivers/scsi/osst.c
2.6.13-rc5-mm1-dev/drivers/scsi/osst.c
--- 2.6.13-rc5-mm1/drivers/scsi/osst.c 2005-08-07 10:05:21.000000000
-0700
+++ 2.6.13-rc5-mm1-dev/drivers/scsi/osst.c 2005-08-12
13:42:13.000000000 -0700

drivers/scsi/osst.c static int osst_recover_wait_frame(struc · line 866

Quoted 7 lines
drivers/scsi/osst.c +1 -2
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp,
 aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			schedule_timeout_interruptible(HZ /

OSST_POLL_PER_SEC);

Others have suggested using msleep in osst instead of schedule, which I think is
more appropriate.

Regards, Willem Riede.

#28 lore raw

Re: [-mm PATCH 29/32] drivers/scsi: fix-up schedule_timeout() usage

Quoted 26 lines · Willem Riede
Quoted 16 lines · Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/scsi/osst.c           |    9 +++------

diff -urpN 2.6.13-rc5-mm1/drivers/scsi/osst.c
2.6.13-rc5-mm1-dev/drivers/scsi/osst.c
--- 2.6.13-rc5-mm1/drivers/scsi/osst.c 2005-08-07 10:05:21.000000000
-0700
+++ 2.6.13-rc5-mm1-dev/drivers/scsi/osst.c 2005-08-12
13:42:13.000000000 -0700

drivers/scsi/osst.c static int osst_recover_wait_frame(struc · line 866

Quoted 7 lines
drivers/scsi/osst.c +1 -2
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp,
 aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			schedule_timeout_interruptible(HZ /

OSST_POLL_PER_SEC);

Quoted 3 lines

Others have suggested using msleep in osst instead of schedule, which I think is
more appropriate.

That's my fault, you are right, a patch for msleep() usage in OSST already exists in the latest -KJ patchset and covers all these changes. I tried to avoid collisions between existing changes in -KJ and these new ones in -MM, but must have missed this one.

Thanks,
Nish

#29 lore raw

PATCH 30/32 serial: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/serial/crisv10.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/serial/crisv10.c +3 -6
diff -urpN 2.6.13-rc5-mm1/drivers/serial/crisv10.c 2.6.13-rc5-mm1-dev/drivers/serial/crisv10.c
@@ -4417,10 +4417,8 @@ rs_close(struct tty_struct *tty, struct 
 	info->event = 0;
 	info->tty = 0;
 	if (info->blocked_open) {
-		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
-		}
+		if (info->close_delay)
+			schedule_timeout_interruptible(info->close_delay);
 		wake_up_interruptible(&info->open_wait);
 	}
 	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -4470,8 +4468,7 @@ static void rs_wait_until_sent(struct tt
 	while (info->xmit.head != info->xmit.tail || /* More in send queue */
 	       (*info->ostatusadr & 0x007f) ||  /* more in FIFO */
 	       (elapsed_usec < 2*info->char_time_usec)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_interruptible(1);
 		if (signal_pending(current))
 			break;
 		if (timeout && time_after(jiffies, orig_jiffies + timeout))
#30 lore raw

PATCH 31/32 telephony: fix-up schedule_timeout() usage

In reply to Nishanth Aravamudan

Description: Use schedule_timeout_uninterruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size.

---

 drivers/telephony/ixj.c |   54 ++++++++++++++++--------------------------------
 1 files changed, 18 insertions(+), 36 deletions(-)
drivers/telephony/ixj.c +18 -36
diff -urpN 2.6.13-rc5-mm1/drivers/telephony/ixj.c 2.6.13-rc5-mm1-dev/drivers/telephony/ixj.c
@@ -2071,8 +2071,7 @@ static int ixj_ring(IXJ *j)
 				j->flags.ringing = 0;
 				return 1;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_interruptible(1);
 			if (signal_pending(current))
 				break;
 		}
@@ -2086,8 +2085,7 @@ static int ixj_ring(IXJ *j)
 					return 1;
 				}
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_interruptible(1);
 			if (signal_pending(current))
 				break;
 		}
@@ -2153,10 +2151,8 @@ static int ixj_release(struct inode *ino
 	 *    Set up locks to ensure that only one process is talking to the DSP at a time.
 	 *    This is necessary to keep the DSP from locking up.
 	 */
-	while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
+		schedule_timeout_interruptible(1);
 	if (ixjdebug & 0x0002)
 		printk(KERN_INFO "Closing board %d\n", NUM(inode));
 
@@ -3286,14 +3282,10 @@ static void ixj_write_cidcw(IXJ *j)
 	ixj_play_tone(j, 23);
 
 	clear_bit(j->board, &j->busyflags);
-	while(j->tone_state) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
-	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while(j->tone_state)
+		schedule_timeout_interruptible(1);
+	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+		schedule_timeout_interruptible(1);
 	if(ixjdebug & 0x0200) {
 		printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
 	}
@@ -3313,14 +3305,10 @@ static void ixj_write_cidcw(IXJ *j)
 	ixj_play_tone(j, 24);
 
 	clear_bit(j->board, &j->busyflags);
-	while(j->tone_state) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
-	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while(j->tone_state)
+		schedule_timeout_interruptible(1);
+	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+		schedule_timeout_interruptible(1);
 	if(ixjdebug & 0x0200) {
 		printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
 	}
@@ -3328,14 +3316,10 @@ static void ixj_write_cidcw(IXJ *j)
 	j->cidcw_wait = jiffies + ((50 * hertz) / 100);
 
 	clear_bit(j->board, &j->busyflags);
-	while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
-	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait))
+		schedule_timeout_interruptible(1);
+	while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+		schedule_timeout_interruptible(1);
 	j->cidcw_wait = 0;
 	if(!j->flags.cidcw_ack) {
 		if(ixjdebug & 0x0200) {
@@ -6110,10 +6094,8 @@ static int ixj_ioctl(struct inode *inode
 	 *    Set up locks to ensure that only one process is talking to the DSP at a time.
 	 *    This is necessary to keep the DSP from locking up.
 	 */
-	while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
+		schedule_timeout_interruptible(1);
 	if (ixjdebug & 0x0040)
 		printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
 	if (minor >= IXJMAX) {