@@ -1294,7 +1294,7 @@ struct load_weight {
struct sched_avg {
u64 last_update_time, load_sum;
u32 util_sum, period_contrib;
- unsigned long load_avg, util_avg;
+ unsigned long load_avg, util_avg, util_peak;
};
#ifdef CONFIG_SCHEDSTATS
@@ -696,6 +696,7 @@ void init_entity_runnable_average(struct sched_entity *se)
* At this point, util_avg won't be used in select_task_rq_fair anyway
*/
sa->util_avg = 0;
+ sa->util_peak = 0;
sa->util_sum = 0;
/* when this task enqueue'ed, it will contribute to its cfs_rq's load_avg */
}
@@ -747,6 +748,7 @@ void post_init_entity_util_avg(struct sched_entity *se)
} else {
sa->util_avg = cap;
}
+ sa->util_peak = sa->util_avg;
sa->util_sum = sa->util_avg * LOAD_AVG_MAX;
}
@@ -3181,6 +3183,10 @@ dequeue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
max_t(long, cfs_rq->runnable_load_avg - se->avg.load_avg, 0);
cfs_rq->runnable_load_sum =
max_t(s64, cfs_rq->runnable_load_sum - se->avg.load_sum, 0);
+
+ /* Save peak PELT utilization for task to help wake-up decisions */
+ if (entity_is_task(se))
+ se->avg.util_peak = se->avg.util_avg;
}
#ifndef CONFIG_64BIT
@@ -5203,7 +5209,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p,
return 1;
}
-static inline int task_util(struct task_struct *p);
+static inline int task_util_peak(struct task_struct *p);
static int cpu_util_wake(int cpu, struct task_struct *p);
static unsigned long capacity_spare_wake(int cpu, struct task_struct *p)
@@ -5286,14 +5292,14 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p,
/*
* The cross-over point between using spare capacity or least load
* is too conservative for high utilization tasks on partially
- * utilized systems if we require spare_capacity > task_util(p),
+ * utilized systems if we require spare_capacity > task_util_peak(p),
* so we allow for some task stuffing by using
- * spare_capacity > task_util(p)/2.
+ * spare_capacity > task_util_peak(p)/2.
*/
- if (this_spare > task_util(p) / 2 &&
+ if (this_spare > task_util_peak(p) / 2 &&
imbalance*this_spare > 100*most_spare)
return NULL;
- else if (most_spare > task_util(p) / 2)
+ else if (most_spare > task_util_peak(p) / 2)
return most_spare_sg;
if (!idlest || 100*this_load < imbalance*min_load)
@@ -5628,6 +5634,11 @@ static inline int task_util(struct task_struct *p)
return p->se.avg.util_avg;
}
+static inline int task_util_peak(struct task_struct *p)
+{
+ return p->se.avg.util_peak;
+}
+
/*
* cpu_util_wake: Compute cpu utilization with any contributions from
* the waking task p removed.
@@ -5667,7 +5678,7 @@ static int wake_cap(struct task_struct *p, int cpu, int prev_cpu)
/* Bring task utilization in sync with prev_cpu */
sync_entity_load_avg(&p->se);
- return min_cap * 1024 < task_util(p) * capacity_margin;
+ return min_cap * 1024 < task_util_peak(p) * capacity_margin;
}
/*