Skip to content

Commit f1adad7

Browse files
author
Linus Torvalds
committed
Revert "[PATCH] sched: fix interactive task starvation"
This reverts commit 5ce74ab (and its dependent commit 8a5bc07), because of audio underruns. Reported by Rene Herman <[email protected]>, who also pinpointed the exact cause of the underruns: "Audio underruns galore, with only ogg123 and firefox (browsing the GIT tree online is also a nice trigger by the way). If I back it out, everything is fine for me again." Cc: Rene Herman <[email protected]> Cc: Mike Galbraith <[email protected]> Acked-by: Con Kolivas <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c9d20af commit f1adad7

File tree

1 file changed

+18
-44
lines changed

1 file changed

+18
-44
lines changed

kernel/sched.c

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -664,56 +664,14 @@ static int effective_prio(task_t *p)
664664
return prio;
665665
}
666666

667-
/*
668-
* We place interactive tasks back into the active array, if possible.
669-
*
670-
* To guarantee that this does not starve expired tasks we ignore the
671-
* interactivity of a task if the first expired task had to wait more
672-
* than a 'reasonable' amount of time. This deadline timeout is
673-
* load-dependent, as the frequency of array switched decreases with
674-
* increasing number of running tasks. We also ignore the interactivity
675-
* if a better static_prio task has expired, and switch periodically
676-
* regardless, to ensure that highly interactive tasks do not starve
677-
* the less fortunate for unreasonably long periods.
678-
*/
679-
static inline int expired_starving(runqueue_t *rq)
680-
{
681-
int limit;
682-
683-
/*
684-
* Arrays were recently switched, all is well
685-
*/
686-
if (!rq->expired_timestamp)
687-
return 0;
688-
689-
limit = STARVATION_LIMIT * rq->nr_running;
690-
691-
/*
692-
* It's time to switch arrays
693-
*/
694-
if (jiffies - rq->expired_timestamp >= limit)
695-
return 1;
696-
697-
/*
698-
* There's a better selection in the expired array
699-
*/
700-
if (rq->curr->static_prio > rq->best_expired_prio)
701-
return 1;
702-
703-
/*
704-
* All is well
705-
*/
706-
return 0;
707-
}
708-
709667
/*
710668
* __activate_task - move a task to the runqueue.
711669
*/
712670
static void __activate_task(task_t *p, runqueue_t *rq)
713671
{
714672
prio_array_t *target = rq->active;
715673

716-
if (unlikely(batch_task(p) || (expired_starving(rq) && !rt_task(p))))
674+
if (batch_task(p))
717675
target = rq->expired;
718676
enqueue_task(p, target);
719677
rq->nr_running++;
@@ -2531,6 +2489,22 @@ unsigned long long current_sched_time(const task_t *tsk)
25312489
return ns;
25322490
}
25332491

2492+
/*
2493+
* We place interactive tasks back into the active array, if possible.
2494+
*
2495+
* To guarantee that this does not starve expired tasks we ignore the
2496+
* interactivity of a task if the first expired task had to wait more
2497+
* than a 'reasonable' amount of time. This deadline timeout is
2498+
* load-dependent, as the frequency of array switched decreases with
2499+
* increasing number of running tasks. We also ignore the interactivity
2500+
* if a better static_prio task has expired:
2501+
*/
2502+
#define EXPIRED_STARVING(rq) \
2503+
((STARVATION_LIMIT && ((rq)->expired_timestamp && \
2504+
(jiffies - (rq)->expired_timestamp >= \
2505+
STARVATION_LIMIT * ((rq)->nr_running) + 1))) || \
2506+
((rq)->curr->static_prio > (rq)->best_expired_prio))
2507+
25342508
/*
25352509
* Account user cpu time to a process.
25362510
* @p: the process that the cpu time gets accounted to
@@ -2666,7 +2640,7 @@ void scheduler_tick(void)
26662640

26672641
if (!rq->expired_timestamp)
26682642
rq->expired_timestamp = jiffies;
2669-
if (!TASK_INTERACTIVE(p) || expired_starving(rq)) {
2643+
if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
26702644
enqueue_task(p, rq->expired);
26712645
if (p->static_prio < rq->best_expired_prio)
26722646
rq->best_expired_prio = p->static_prio;

0 commit comments

Comments
 (0)