aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 791dd08c692f..089d8b12ab76 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2119,6 +2119,17 @@ static void pull_task(struct rq *src_rq, struct task_struct *p,
2119} 2119}
2120 2120
2121/* 2121/*
2122 * Is this task likely cache-hot:
2123 */
2124static inline int
2125task_hot(struct task_struct *p, unsigned long long now, struct sched_domain *sd)
2126{
2127 s64 delta = now - p->se.exec_start;
2128
2129 return delta < (long long)sysctl_sched_migration_cost;
2130}
2131
2132/*
2122 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu? 2133 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
2123 */ 2134 */
2124static 2135static
@@ -2139,6 +2150,22 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
2139 if (task_running(rq, p)) 2150 if (task_running(rq, p))
2140 return 0; 2151 return 0;
2141 2152
2153 /*
2154 * Aggressive migration if:
2155 * 1) task is cache cold, or
2156 * 2) too many balance attempts have failed.
2157 */
2158
2159 if (sd->nr_balance_failed > sd->cache_nice_tries) {
2160#ifdef CONFIG_SCHEDSTATS
2161 if (task_hot(p, rq->clock, sd))
2162 schedstat_inc(sd, lb_hot_gained[idle]);
2163#endif
2164 return 1;
2165 }
2166
2167 if (task_hot(p, rq->clock, sd))
2168 return 0;
2142 return 1; 2169 return 1;
2143} 2170}
2144 2171