mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	[PATCH] kernel: fix-up schedule_timeout() usage
Use schedule_timeout_{,un}interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
			
			
This commit is contained in:
		
							parent
							
								
									041e0e3b19
								
							
						
					
					
						commit
						75bcc8c5e1
					
				
					 3 changed files with 10 additions and 20 deletions
				
			
		| 
						 | 
					@ -48,8 +48,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
 | 
				
			||||||
	if (!time_after(expire, now))
 | 
						if (!time_after(expire, now))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	current->state = TASK_INTERRUPTIBLE;
 | 
						expire = schedule_timeout_interruptible(expire - now);
 | 
				
			||||||
	expire = schedule_timeout(expire - now);
 | 
					 | 
				
			||||||
	if (expire == 0)
 | 
						if (expire == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,8 +81,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
 | 
						expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
 | 
				
			||||||
	current->state = TASK_INTERRUPTIBLE;
 | 
						expire = schedule_timeout_interruptible(expire);
 | 
				
			||||||
	expire = schedule_timeout(expire);
 | 
					 | 
				
			||||||
	if (expire == 0)
 | 
						if (expire == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -795,8 +793,7 @@ compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese,
 | 
				
			||||||
			recalc_sigpending();
 | 
								recalc_sigpending();
 | 
				
			||||||
			spin_unlock_irq(¤t->sighand->siglock);
 | 
								spin_unlock_irq(¤t->sighand->siglock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			current->state = TASK_INTERRUPTIBLE;
 | 
								timeout = schedule_timeout_interruptible(timeout);
 | 
				
			||||||
			timeout = schedule_timeout(timeout);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			spin_lock_irq(¤t->sighand->siglock);
 | 
								spin_lock_irq(¤t->sighand->siglock);
 | 
				
			||||||
			sig = dequeue_signal(current, &s, &info);
 | 
								sig = dequeue_signal(current, &s, &info);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2221,8 +2221,7 @@ sys_rt_sigtimedwait(const sigset_t __user *uthese,
 | 
				
			||||||
			recalc_sigpending();
 | 
								recalc_sigpending();
 | 
				
			||||||
			spin_unlock_irq(¤t->sighand->siglock);
 | 
								spin_unlock_irq(¤t->sighand->siglock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			current->state = TASK_INTERRUPTIBLE;
 | 
								timeout = schedule_timeout_interruptible(timeout);
 | 
				
			||||||
			timeout = schedule_timeout(timeout);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try_to_freeze();
 | 
								try_to_freeze();
 | 
				
			||||||
			spin_lock_irq(¤t->sighand->siglock);
 | 
								spin_lock_irq(¤t->sighand->siglock);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1184,8 +1184,7 @@ static long __sched nanosleep_restart(struct restart_block *restart)
 | 
				
			||||||
	if (!time_after(expire, now))
 | 
						if (!time_after(expire, now))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	current->state = TASK_INTERRUPTIBLE;
 | 
						expire = schedule_timeout_interruptible(expire - now);
 | 
				
			||||||
	expire = schedule_timeout(expire - now);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = 0;
 | 
						ret = 0;
 | 
				
			||||||
	if (expire) {
 | 
						if (expire) {
 | 
				
			||||||
| 
						 | 
					@ -1213,8 +1212,7 @@ asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __us
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
 | 
						expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
 | 
				
			||||||
	current->state = TASK_INTERRUPTIBLE;
 | 
						expire = schedule_timeout_interruptible(expire);
 | 
				
			||||||
	expire = schedule_timeout(expire);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = 0;
 | 
						ret = 0;
 | 
				
			||||||
	if (expire) {
 | 
						if (expire) {
 | 
				
			||||||
| 
						 | 
					@ -1612,10 +1610,8 @@ void msleep(unsigned int msecs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 | 
						unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (timeout) {
 | 
						while (timeout)
 | 
				
			||||||
		set_current_state(TASK_UNINTERRUPTIBLE);
 | 
							timeout = schedule_timeout_uninterruptible(timeout);
 | 
				
			||||||
		timeout = schedule_timeout(timeout);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPORT_SYMBOL(msleep);
 | 
					EXPORT_SYMBOL(msleep);
 | 
				
			||||||
| 
						 | 
					@ -1628,10 +1624,8 @@ unsigned long msleep_interruptible(unsigned int msecs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 | 
						unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (timeout && !signal_pending(current)) {
 | 
						while (timeout && !signal_pending(current))
 | 
				
			||||||
		set_current_state(TASK_INTERRUPTIBLE);
 | 
							timeout = schedule_timeout_interruptible(timeout);
 | 
				
			||||||
		timeout = schedule_timeout(timeout);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return jiffies_to_msecs(timeout);
 | 
						return jiffies_to_msecs(timeout);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue