From: Nishanth Aravamudan Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. (akpm: this patch relies on other stuff in -mm, please don't apply) Signed-off-by: Nishanth Aravamudan Signed-off-by: Andrew Morton --- kernel/compat.c | 9 +++------ kernel/signal.c | 3 +-- kernel/timer.c | 18 ++++++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff -puN kernel/compat.c~kernel-fix-up-schedule_timeout-usage kernel/compat.c --- 25/kernel/compat.c~kernel-fix-up-schedule_timeout-usage Wed Aug 17 17:00:15 2005 +++ 25-akpm/kernel/compat.c Wed Aug 17 17:00:15 2005 @@ -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(¤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); diff -puN kernel/signal.c~kernel-fix-up-schedule_timeout-usage kernel/signal.c --- 25/kernel/signal.c~kernel-fix-up-schedule_timeout-usage Wed Aug 17 17:00:15 2005 +++ 25-akpm/kernel/signal.c Wed Aug 17 17:00:15 2005 @@ -2228,8 +2228,7 @@ sys_rt_sigtimedwait(const sigset_t __use recalc_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); diff -puN kernel/timer.c~kernel-fix-up-schedule_timeout-usage kernel/timer.c --- 25/kernel/timer.c~kernel-fix-up-schedule_timeout-usage Wed Aug 17 17:00:15 2005 +++ 25-akpm/kernel/timer.c Wed Aug 17 17:00:15 2005 @@ -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); } _