Re: [PATCH 6/8] sched/eevdf: Add per cpu cached min_slice
From: Vincent Guittot
Date: Tue Sep 22 2026 - 10:26:50 EST
On Tue, 22 Sept 2026 at 12:17, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Mon, Sep 21, 2026 at 05:22:36PM +0200, Vincent Guittot wrote:
> > In order to use min_slice during cpu selection, update a cached value when
> > needed after en/dequeing a new task. This cached value includes current
> > task.
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > ---
> > kernel/sched/fair.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 739a3af60520..a01a88dde811 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -1089,6 +1089,21 @@ static inline bool min_vruntime_update(struct sched_entity *se, bool exit)
> > RB_DECLARE_CALLBACKS(static, min_vruntime_cb, struct sched_entity,
> > run_node, min_vruntime, min_vruntime_update);
> >
> > +static DEFINE_PER_CPU(u64, rq_min_slice) = INT_MAX;
>
> Would it not be better to place this in struct rq, near data that is
> already accessed in select_idle_siblings()? This more or less guarantees
> a cache miss.
Yes, probably.
>
> > +static u64 get_rq_min_slice(struct rq *rq)
> > +{
> > + return READ_ONCE(per_cpu(rq_min_slice, cpu_of(rq)));
> > +}
> > +
> > +static void __update_rq_min_slice(struct rq *rq)
> > +{
> > + u64 min = cfs_rq_min_slice(&rq->cfs);
> > +
> > + if (min != get_rq_min_slice(rq))
> > + WRITE_ONCE(per_cpu(rq_min_slice, cpu_of(rq)), min);
> > +}
> > +
> > /*
> > * Enqueue an entity into the rb-tree:
> > */