Commit 71c19018 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] setscheduler needs to force a reschedule

From: Robert Love <rml@tech9.net>

Basically, the problem is that setscheduler() does not set need_resched
when needed.  There are two basic cases where this is needed:

	- the task is running, but now it is no longer the highest
	  priority task on the rq
	- the task is not running, but now it is the highest
	  priority task on the rq

In either case, we need to set need_resched to invoke the scheduler.
parent dc0cf8b1
...@@ -1691,6 +1691,7 @@ static int setscheduler(pid_t pid, int policy, struct sched_param __user *param) ...@@ -1691,6 +1691,7 @@ static int setscheduler(pid_t pid, int policy, struct sched_param __user *param)
{ {
struct sched_param lp; struct sched_param lp;
int retval = -EINVAL; int retval = -EINVAL;
int oldprio;
prio_array_t *array; prio_array_t *array;
unsigned long flags; unsigned long flags;
runqueue_t *rq; runqueue_t *rq;
...@@ -1757,12 +1758,24 @@ static int setscheduler(pid_t pid, int policy, struct sched_param __user *param) ...@@ -1757,12 +1758,24 @@ static int setscheduler(pid_t pid, int policy, struct sched_param __user *param)
retval = 0; retval = 0;
p->policy = policy; p->policy = policy;
p->rt_priority = lp.sched_priority; p->rt_priority = lp.sched_priority;
oldprio = p->prio;
if (policy != SCHED_NORMAL) if (policy != SCHED_NORMAL)
p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority; p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority;
else else
p->prio = p->static_prio; p->prio = p->static_prio;
if (array) if (array) {
__activate_task(p, task_rq(p)); __activate_task(p, task_rq(p));
/*
* Reschedule if we are currently running on this runqueue and
* our priority decreased, or if we are not currently running on
* this runqueue and our priority is higher than the current's
*/
if (rq->curr == p) {
if (p->prio > oldprio)
resched_task(rq->curr);
} else if (p->prio < rq->curr->prio)
resched_task(rq->curr);
}
out_unlock: out_unlock:
task_rq_unlock(rq, &flags); task_rq_unlock(rq, &flags);
......
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