Re: [PATCH v3 3/4] sched: reduce sched slice for SCHED_IDLE entities

From: Josh Don
Date: Mon Aug 23 2021 - 13:40:32 EST


On Mon, Aug 23, 2021 at 3:08 AM Vincent Guittot
<vincent.guittot@xxxxxxxxxx> wrote:
>
> On Fri, 20 Aug 2021 at 03:04, Josh Don <joshdon@xxxxxxxxxx> wrote:
> >
> > @@ -684,12 +696,13 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > for_each_sched_entity(se) {
> > struct load_weight *load;
> > struct load_weight lw;
> > + struct cfs_rq *qcfs_rq;
> >
> > - cfs_rq = cfs_rq_of(se);
> > - load = &cfs_rq->load;
> > + qcfs_rq = cfs_rq_of(se);
> > + load = &qcfs_rq->load;
> >
> > if (unlikely(!se->on_rq)) {
> > - lw = cfs_rq->load;
> > + lw = qcfs_rq->load;
> >
> > update_load_add(&lw, se->load.weight);
> > load = &lw;
> > @@ -697,8 +710,14 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > slice = __calc_delta(slice, se->load.weight, load);
> > }
> >
> > - if (sched_feat(BASE_SLICE))
> > - slice = max(slice, (u64)sysctl_sched_min_granularity);
> > + if (sched_feat(BASE_SLICE)) {
> > + if (se_is_idle(init_se) && !sched_idle_cfs_rq(cfs_rq))
>
> Like for place_entity, we should probably not dynamically switch
> between the 2 values below depending on the presence or not of non
> sched idle tasks and always use sysctl_sched_idle_min_granularity

My reasoning here is that sched_slice is something we reasonably
expect to change as tasks enqueue/dequeue, and unlike place_entity()
it does not create fairness issues by messing with vruntime.
Additionally, it would be preferable to use the larger min granularity
on a cpu running only idle tasks.