Re: [PATCH v3 09/21] sched/cache: Count tasks prefering destination LLC in a sched group

From: Peter Zijlstra

Date: Fri Feb 20 2026 - 08:47:43 EST


On Fri, Feb 20, 2026 at 01:52:48PM +0100, Peter Zijlstra wrote:
> On Tue, Feb 10, 2026 at 02:18:49PM -0800, Tim Chen wrote:
>
> > @@ -11034,6 +11037,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> > {
> > int i, nr_running, local_group, sd_flags = env->sd->flags;
> > bool balancing_at_rd = !env->sd->parent;
> > +#ifdef CONFIG_SCHED_CACHE
> > + int dst_llc = llc_id(env->dst_cpu);
> > +#endif
> >
> > memset(sgs, 0, sizeof(*sgs));
> >
> > @@ -11054,6 +11060,15 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> > if (cpu_overutilized(i))
> > *sg_overutilized = 1;
> >
> > +#ifdef CONFIG_SCHED_CACHE
> > + if (sched_cache_enabled() && llc_id(i) != dst_llc) {
>
> If you write that like:
>
> if (sched_cache_enabled && llc_id(i) != llc_id(env->dst_cpu))
>
> You can get rid of that dst_llc variable, but more importantly its
> ifdeffery.

Ah, you're perhaps wanting to not re-load on the dst_llc usage below? Do
the compilers DTRT when you mark llc_id() as __pure?

> > + struct sched_domain *sd_tmp = rcu_dereference(rq->sd);
> > +
> > + if (valid_llc_buf(sd_tmp, dst_llc))
> > + sgs->nr_pref_dst_llc += sd_tmp->pf[dst_llc];
> > + }
> > +#endif
>
>