aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/wait.h16
-rw-r--r--kernel/sched.c71
2 files changed, 49 insertions, 38 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index e820d00e1383..0e686280450b 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -366,15 +366,15 @@ static inline void remove_wait_queue_locked(wait_queue_head_t *q,
366 366
367/* 367/*
368 * These are the old interfaces to sleep waiting for an event. 368 * These are the old interfaces to sleep waiting for an event.
369 * They are racy. DO NOT use them, use the wait_event* interfaces above. 369 * They are racy. DO NOT use them, use the wait_event* interfaces above.
370 * We plan to remove these interfaces during 2.7. 370 * We plan to remove these interfaces.
371 */ 371 */
372extern void FASTCALL(sleep_on(wait_queue_head_t *q)); 372extern void sleep_on(wait_queue_head_t *q);
373extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q, 373extern long sleep_on_timeout(wait_queue_head_t *q,
374 signed long timeout)); 374 signed long timeout);
375extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q)); 375extern void interruptible_sleep_on(wait_queue_head_t *q);
376extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q, 376extern long interruptible_sleep_on_timeout(wait_queue_head_t *q,
377 signed long timeout)); 377 signed long timeout);
378 378
379/* 379/*
380 * Waitqueues which are removed from the waitqueue_head at wakeup time 380 * Waitqueues which are removed from the waitqueue_head at wakeup time
diff --git a/kernel/sched.c b/kernel/sched.c
index ef6b6bb3e0b2..0e3caf742ae3 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3699,74 +3699,85 @@ out:
3699} 3699}
3700EXPORT_SYMBOL(wait_for_completion_interruptible_timeout); 3700EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
3701 3701
3702 3702static inline void
3703#define SLEEP_ON_VAR \ 3703sleep_on_head(wait_queue_head_t *q, wait_queue_t *wait, unsigned long *flags)
3704 unsigned long flags; \ 3704{
3705 wait_queue_t wait; \ 3705 spin_lock_irqsave(&q->lock, *flags);
3706 init_waitqueue_entry(&wait, current); 3706 __add_wait_queue(q, wait);
3707
3708#define SLEEP_ON_HEAD \
3709 spin_lock_irqsave(&q->lock,flags); \
3710 __add_wait_queue(q, &wait); \
3711 spin_unlock(&q->lock); 3707 spin_unlock(&q->lock);
3708}
3712 3709
3713#define SLEEP_ON_TAIL \ 3710static inline void
3714 spin_lock_irq(&q->lock); \ 3711sleep_on_tail(wait_queue_head_t *q, wait_queue_t *wait, unsigned long *flags)
3715 __remove_wait_queue(q, &wait); \ 3712{
3716 spin_unlock_irqrestore(&q->lock, flags); 3713 spin_lock_irq(&q->lock);
3714 __remove_wait_queue(q, wait);
3715 spin_unlock_irqrestore(&q->lock, *flags);
3716}
3717 3717
3718void fastcall __sched interruptible_sleep_on(wait_queue_head_t *q) 3718void __sched interruptible_sleep_on(wait_queue_head_t *q)
3719{ 3719{
3720 SLEEP_ON_VAR 3720 unsigned long flags;
3721 wait_queue_t wait;
3722
3723 init_waitqueue_entry(&wait, current);
3721 3724
3722 current->state = TASK_INTERRUPTIBLE; 3725 current->state = TASK_INTERRUPTIBLE;
3723 3726
3724 SLEEP_ON_HEAD 3727 sleep_on_head(q, &wait, &flags);
3725 schedule(); 3728 schedule();
3726 SLEEP_ON_TAIL 3729 sleep_on_tail(q, &wait, &flags);
3727} 3730}
3728EXPORT_SYMBOL(interruptible_sleep_on); 3731EXPORT_SYMBOL(interruptible_sleep_on);
3729 3732
3730long fastcall __sched 3733long __sched
3731interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout) 3734interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
3732{ 3735{
3733 SLEEP_ON_VAR 3736 unsigned long flags;
3737 wait_queue_t wait;
3738
3739 init_waitqueue_entry(&wait, current);
3734 3740
3735 current->state = TASK_INTERRUPTIBLE; 3741 current->state = TASK_INTERRUPTIBLE;
3736 3742
3737 SLEEP_ON_HEAD 3743 sleep_on_head(q, &wait, &flags);
3738 timeout = schedule_timeout(timeout); 3744 timeout = schedule_timeout(timeout);
3739 SLEEP_ON_TAIL 3745 sleep_on_tail(q, &wait, &flags);
3740 3746
3741 return timeout; 3747 return timeout;
3742} 3748}
3743EXPORT_SYMBOL(interruptible_sleep_on_timeout); 3749EXPORT_SYMBOL(interruptible_sleep_on_timeout);
3744 3750
3745void fastcall __sched sleep_on(wait_queue_head_t *q) 3751void __sched sleep_on(wait_queue_head_t *q)
3746{ 3752{
3747 SLEEP_ON_VAR 3753 unsigned long flags;
3754 wait_queue_t wait;
3755
3756 init_waitqueue_entry(&wait, current);
3748 3757
3749 current->state = TASK_UNINTERRUPTIBLE; 3758 current->state = TASK_UNINTERRUPTIBLE;
3750 3759
3751 SLEEP_ON_HEAD 3760 sleep_on_head(q, &wait, &flags);
3752 schedule(); 3761 schedule();
3753 SLEEP_ON_TAIL 3762 sleep_on_tail(q, &wait, &flags);
3754} 3763}
3755EXPORT_SYMBOL(sleep_on); 3764EXPORT_SYMBOL(sleep_on);
3756 3765
3757long fastcall __sched sleep_on_timeout(wait_queue_head_t *q, long timeout) 3766long __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
3758{ 3767{
3759 SLEEP_ON_VAR 3768 unsigned long flags;
3769 wait_queue_t wait;
3770
3771 init_waitqueue_entry(&wait, current);
3760 3772
3761 current->state = TASK_UNINTERRUPTIBLE; 3773 current->state = TASK_UNINTERRUPTIBLE;
3762 3774
3763 SLEEP_ON_HEAD 3775 sleep_on_head(q, &wait, &flags);
3764 timeout = schedule_timeout(timeout); 3776 timeout = schedule_timeout(timeout);
3765 SLEEP_ON_TAIL 3777 sleep_on_tail(q, &wait, &flags);
3766 3778
3767 return timeout; 3779 return timeout;
3768} 3780}
3769
3770EXPORT_SYMBOL(sleep_on_timeout); 3781EXPORT_SYMBOL(sleep_on_timeout);
3771 3782
3772#ifdef CONFIG_RT_MUTEXES 3783#ifdef CONFIG_RT_MUTEXES