mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
sched: add avg_overlap decay
Impact: more precise avg_overlap metric - better load-balancing avg_overlap is used to measure the runtime overlap of the waker and wakee. However, when a process changes behaviour, eg a pipe becomes un-congested and we don't need to go to sleep after a wakeup for a while, the avg_overlap value grows stale. When running we use the avg runtime between preemption as a measure for avg_overlap since the amount of runtime can be correlated to cache footprint. The longer we run, the less likely we'll be wanting to be migrated to another CPU. Signed-off-by: Mike Galbraith <efault@gmx.de> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1236709131.25234.576.camel@laptop> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
57310a98a3
commit
df1c99d416
1 changed files with 23 additions and 1 deletions
|
@ -4620,6 +4620,28 @@ static inline void schedule_debug(struct task_struct *prev)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void put_prev_task(struct rq *rq, struct task_struct *prev)
|
||||||
|
{
|
||||||
|
if (prev->state == TASK_RUNNING) {
|
||||||
|
u64 runtime = prev->se.sum_exec_runtime;
|
||||||
|
|
||||||
|
runtime -= prev->se.prev_sum_exec_runtime;
|
||||||
|
runtime = min_t(u64, runtime, 2*sysctl_sched_migration_cost);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In order to avoid avg_overlap growing stale when we are
|
||||||
|
* indeed overlapping and hence not getting put to sleep, grow
|
||||||
|
* the avg_overlap on preemption.
|
||||||
|
*
|
||||||
|
* We use the average preemption runtime because that
|
||||||
|
* correlates to the amount of cache footprint a task can
|
||||||
|
* build up.
|
||||||
|
*/
|
||||||
|
update_avg(&prev->se.avg_overlap, runtime);
|
||||||
|
}
|
||||||
|
prev->sched_class->put_prev_task(rq, prev);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pick up the highest-prio task:
|
* Pick up the highest-prio task:
|
||||||
*/
|
*/
|
||||||
|
@ -4698,7 +4720,7 @@ asmlinkage void __sched schedule(void)
|
||||||
if (unlikely(!rq->nr_running))
|
if (unlikely(!rq->nr_running))
|
||||||
idle_balance(cpu, rq);
|
idle_balance(cpu, rq);
|
||||||
|
|
||||||
prev->sched_class->put_prev_task(rq, prev);
|
put_prev_task(rq, prev);
|
||||||
next = pick_next_task(rq);
|
next = pick_next_task(rq);
|
||||||
|
|
||||||
if (likely(prev != next)) {
|
if (likely(prev != next)) {
|
||||||
|
|
Loading…
Reference in a new issue