Subject: sched: fair: limit max slice From: Peter Zijlstra To keep the inter-group interference to a minimum, limit the max slice length. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar --- kernel/sched_fair.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) Index: linux/kernel/sched_fair.c =================================================================== --- linux.orig/kernel/sched_fair.c +++ linux/kernel/sched_fair.c @@ -625,7 +625,20 @@ static inline u64 __sched_period(unsigne */ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { - return calc_delta_weight(__sched_period(cfs_rq->nr_running), se); + u64 slice = calc_delta_weight(__sched_period(cfs_rq->nr_running), se); + +#ifdef CONFIG_FAIR_GROUP_SCHED + /* + * Limit the max slice length when there is contention (strictly + * speaking we only need to do this when there are tasks of more + * than a single group). This avoids very longs slices of a lightly + * loaded group delaying tasks from another group. + */ + if (rq_of(cfs_rq)->cfs_root.nr_queued) + slice = min_t(u64, slice, sysctl_sched_min_granularity); +#endif + + return slice; } /*