fix-up schedule_timeout() usage
Subsystems (24)
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
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
@@ -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 }
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.
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_SECdefined anywhere in the tree, so the ifndef isn't needed. Nor is the one forUSEC_PER_SEC, come to that. I'll kill them.
Yup, that's fine by me. Thanks!
-Nish
PATCH 2/32 fs: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -2868,8 +2868,7 @@ static void let_transaction_grow(structstruct 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
@@ -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
@@ -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
@@ -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
@@ -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);
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.
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
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.
Re: [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanHi,
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.c2005-08-10 15:03:33.000000000 -0700fs/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
Re: [-mm PATCH 2/32] fs: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanThe 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
PATCH 3/32 kernel: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -48,8 +48,7 @@ static long compat_nanosleep_restart(strif (!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(strreturn -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_sigserecalc_sigpending ();spin_unlock_irq (¤t->sighand->siglock); - current->state =TASK_INTERRUPTIBLE ; - timeout =schedule_timeout (timeout); + timeout =schedule_timeout_interruptible (timeout);spin_lock_irq (¤t->sighand->siglock); sig =dequeue_signal (current, &s, &info);
kernel/signal.c +1 -2
@@ -2228,8 +2228,7 @@ sys_rt_sigtimedwait(const sigset_t __userecalc_sigpending ();spin_unlock_irq (¤t->sighand->siglock); - current->state =TASK_INTERRUPTIBLE ; - timeout =schedule_timeout (timeout); + timeout =schedule_timeout_interruptible (timeout);try_to_freeze ();spin_lock_irq (¤t->sighand->siglock);
kernel/timer.c +6 -12
@@ -1199,8 +1199,7 @@ static long __sched nanosleep_restart(stif (!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 timreturn -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); }
PATCH 4/32 mm: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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]
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 filethread_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
@@ -225,7 +225,7 @@ int dccp_sendmsg(struct kiocb *iocb, strif (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
@@ -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
@@ -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(sspin_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
@@ -1167,8 +1167,7 @@ svc_recv(struct svc_serv *serv, struct swhile (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
PATCH 15/32 drivers/acpi: fix-up schedule_timeout() usage
In reply to a message not in the archiveDescription: 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
@@ -315,8 +315,7 @@ acpi_status acpi_os_remove_interrupt_hanvoid 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
PATCH 6/32 sound: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -109,8 +109,7 @@ void snd_seq_instr_list_free(snd_seq_kinspin_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_seqwhile (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
@@ -39,8 +39,7 @@ void snd_use_lock_sync_helper(snd_use_losnd_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
@@ -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
@@ -302,8 +302,7 @@ static void snd_cs8427_reset(snd_i2c_devsnd_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
@@ -243,8 +243,7 @@ static void snd_ad1848_mce_down(ad1848_tsnd_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_tsnd_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 soundsunsigned 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 soundunsigned 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
@@ -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_waoutb (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
@@ -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, ac97do {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, ac97do {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
@@ -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
@@ -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
@@ -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
@@ -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 instatic 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
@@ -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
@@ -1303,8 +1303,7 @@ static int __devinit snd_fm801_create(sndo {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(sndo {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
@@ -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
@@ -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
@@ -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
@@ -2075,8 +2075,7 @@ static void snd_m3_ac97_reset(m3_t *chipoutw (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 *chipoutw (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
@@ -451,8 +451,7 @@ static int mixart_sync_nonblock_events(msnd_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
@@ -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
@@ -1893,8 +1893,7 @@ static int snd_via82xx_chip_init(via82xxpci_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
@@ -966,8 +966,7 @@ static int snd_via82xx_chip_init(via82xxpci_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
@@ -92,7 +92,7 @@ static int snd_ymfpci_codec_ready(ymfpciif ((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_tinit_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
@@ -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
PATCH 11/32 mips: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -1035,8 +1029,7 @@ bad: asmlinkage int irix_sginap(int ticks) { - current->state =TASK_INTERRUPTIBLE ; -schedule_timeout (ticks); +schedule_timeout_interruptible (ticks);return 0 ; }
PATCH 12/32 ppc: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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 = {
PATCH 14/32 um: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -58,10 +58,8 @@ static ssize_t rng_dev_read (struct fileif (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
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.Signed-off-by Nishanth Aravamudan <[email protected]>
-------------------------------------------------------
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
PATCH 17/32 drivers/cdrom: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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? */
PATCH 19/32 drivers/dlm: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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 ; }
PATCH 23/32 drivers/macintosh: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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:
PATCH 24/32 drivers/md: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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);
PATCH 26/32 message: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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
@@ -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(sosm_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_contif (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_controllerreturn -ETIMEDOUT ; } -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (1 ); +schedule_timeout_uninterruptible (1 ); }#ifdef DEBUG
PATCH 28/32 drivers/sbus: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -295,8 +295,7 @@ static unsigned short get_pins(unsignedstatic 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
@@ -81,8 +81,7 @@ int vfc_pcf8584_init(struct vfc_dev *devvoid 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)
PATCH 29/32 drivers/scsi: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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
@@ -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
@@ -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
@@ -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 *inodreturn -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,uprintk (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(adptprintk (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(adptprintk (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
@@ -883,8 +883,7 @@ __lpfc_abort_handler(struct scsi_cmnd *cwhile (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_cmnif (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
@@ -599,10 +599,7 @@ static int __init NCR5380_probe_irq(struNCR5380_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
@@ -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(strosst_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
@@ -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 );
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.Signed-off-by Nishanth Aravamudan <[email protected]>---
drivers/scsi/osst.c | 9 +++------diff -urpN
2.6.13-rc5-mm1/drivers/scsi/osst.c2.6.13-rc5-mm1-dev/drivers/scsi/osst.c
---2.6.13-rc5-mm1/drivers/scsi/osst.c2005-08-07 10:05:21.000000000
-0700
+++2.6.13-rc5-mm1-dev/drivers/scsi/osst.c2005-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.
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.Signed-off-by Nishanth Aravamudan <[email protected]>---
drivers/scsi/osst.c | 9 +++------diff -urpN
2.6.13-rc5-mm1/drivers/scsi/osst.c2.6.13-rc5-mm1-dev/drivers/scsi/osst.c
---2.6.13-rc5-mm1/drivers/scsi/osst.c2005-08-07 10:05:21.000000000
-0700
+++2.6.13-rc5-mm1-dev/drivers/scsi/osst.c2005-08-12
13:42:13.000000000 -0700drivers/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
PATCH 30/32 serial: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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 ttwhile (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))
PATCH 31/32 telephony: fix-up schedule_timeout() usage
In reply to Nishanth AravamudanDescription: 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
@@ -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 ) {