Commit 2b56f065 authored by Thomas Gleixner's avatar Thomas Gleixner

sched: implement wake functions for the priority boosting code

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 53e9ba17
......@@ -1969,6 +1969,9 @@ extern void do_timer(unsigned long ticks);
extern int wake_up_state(struct task_struct *tsk, unsigned int state);
extern int wake_up_process(struct task_struct *tsk);
extern int wake_up_process_mutex(struct task_struct * tsk);
extern int wake_up_process_sync(struct task_struct * tsk);
extern int wake_up_process_mutex_sync(struct task_struct * tsk);
extern void wake_up_new_task(struct task_struct *tsk,
unsigned long clone_flags);
#ifdef CONFIG_SMP
......
......@@ -2415,7 +2415,8 @@ void task_oncpu_function_call(struct task_struct *p,
*
* returns failure only if the task is already active.
*/
static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
static int
try_to_wake_up(struct task_struct *p, unsigned int state, int sync, int mutex)
{
int cpu, orig_cpu, this_cpu, success = 0;
unsigned long flags;
......@@ -2524,6 +2525,9 @@ out_running:
trace_sched_wakeup(rq, p, success);
check_preempt_curr(rq, p, sync);
if (mutex)
p->state = TASK_RUNNING_MUTEX;
else
p->state = TASK_RUNNING;
#ifdef CONFIG_SMP
if (p->sched_class->task_wake_up)
......@@ -2548,13 +2552,31 @@ out:
*/
int wake_up_process(struct task_struct *p)
{
return try_to_wake_up(p, TASK_ALL, 0);
return try_to_wake_up(p, TASK_ALL, 0, 0);
}
EXPORT_SYMBOL(wake_up_process);
int wake_up_process_sync(struct task_struct * p)
{
return try_to_wake_up(p, TASK_ALL, 1, 0);
}
EXPORT_SYMBOL(wake_up_process_sync);
int wake_up_process_mutex(struct task_struct * p)
{
return try_to_wake_up(p, TASK_ALL, 0, 1);
}
EXPORT_SYMBOL(wake_up_process_mutex);
int wake_up_process_mutex_sync(struct task_struct * p)
{
return try_to_wake_up(p, TASK_ALL, 1, 1);
}
EXPORT_SYMBOL(wake_up_process_mutex_sync);
int wake_up_state(struct task_struct *p, unsigned int state)
{
return try_to_wake_up(p, state, 0);
return try_to_wake_up(p, state | TASK_RUNNING_MUTEX, 0, 0);
}
/*
......@@ -5358,7 +5380,8 @@ need_resched_nonpreemptible:
update_rq_clock(rq);
clear_tsk_need_resched(prev);
if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
if ((prev->state & ~TASK_RUNNING_MUTEX) &&
!(preempt_count() & PREEMPT_ACTIVE)) {
if (unlikely(signal_pending_state(prev->state, prev)))
prev->state = TASK_RUNNING;
else
......@@ -5410,7 +5433,7 @@ need_resched:
}
EXPORT_SYMBOL(schedule);
#ifdef CONFIG_SMP
#if defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_RT)
/*
* Look out! "owner" is an entirely speculative pointer
* access and not reliable.
......@@ -5557,7 +5580,8 @@ asmlinkage void __sched preempt_schedule_irq(void)
int default_wake_function(wait_queue_t *curr, unsigned mode, int sync,
void *key)
{
return try_to_wake_up(curr->private, mode, sync);
return try_to_wake_up(curr->private, mode | TASK_RUNNING_MUTEX,
sync, 0);
}
EXPORT_SYMBOL(default_wake_function);
......@@ -5600,7 +5624,7 @@ void __wake_up(wait_queue_head_t *q, unsigned int mode,
unsigned long flags;
spin_lock_irqsave(&q->lock, flags);
__wake_up_common(q, mode, nr_exclusive, 0, key);
__wake_up_common(q, mode, nr_exclusive, 1, key);
spin_unlock_irqrestore(&q->lock, flags);
}
EXPORT_SYMBOL(__wake_up);
......@@ -5680,7 +5704,7 @@ void complete(struct completion *x)
spin_lock_irqsave(&x->wait.lock, flags);
x->done++;
__wake_up_common(&x->wait, TASK_NORMAL, 1, 0, NULL);
__wake_up_common(&x->wait, TASK_NORMAL, 1, 1, NULL);
spin_unlock_irqrestore(&x->wait.lock, flags);
}
EXPORT_SYMBOL(complete);
......@@ -5700,7 +5724,7 @@ void complete_all(struct completion *x)
spin_lock_irqsave(&x->wait.lock, flags);
x->done += UINT_MAX/2;
__wake_up_common(&x->wait, TASK_NORMAL, 0, 0, NULL);
__wake_up_common(&x->wait, TASK_NORMAL, 0, 1, NULL);
spin_unlock_irqrestore(&x->wait.lock, flags);
}
EXPORT_SYMBOL(complete_all);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment