Re: [PATCH 07/19] sched/fair: Track LLC-preferred tasks per runqueue
From: Tim Chen
Date: Tue Oct 28 2025 - 13:06:30 EST
On Mon, 2025-10-27 at 11:34 +0530, K Prateek Nayak wrote:
> Hello Tim,
>
> On 10/11/2025 11:54 PM, Tim Chen wrote:
> > @@ -3999,6 +4038,7 @@ account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > struct rq *rq = rq_of(cfs_rq);
> >
> > account_numa_enqueue(rq, task_of(se));
> > + account_llc_enqueue(rq, task_of(se));
> > list_add(&se->group_node, &rq->cfs_tasks);
> > }
> > cfs_rq->nr_queued++;
> > @@ -4010,9 +4050,14 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > update_load_sub(&cfs_rq->load, se->load.weight);
> > if (entity_is_task(se)) {
> > account_numa_dequeue(rq_of(cfs_rq), task_of(se));
> > + account_llc_dequeue(rq_of(cfs_rq), task_of(se));
> > list_del_init(&se->group_node);
> > }
> > cfs_rq->nr_queued--;
> > +
> > + /* safeguard to clear the cache aware data */
> > + if (!parent_entity(se) && !cfs_rq->nr_queued)
> > + reset_llc_stats(rq_of(cfs_rq));
>
> Instead of relying on reset_llc_stats() hack, I think a better approach
> would be to have a "p->se.llc_sched_active" flag similar to how uclamp
> has "uc_se->active" and we set this in account_llc_enqueue() which will
> still check for sched_cache_enabled() but account_llc_dequeue() would
> only check for "p->se.llc_sched_active" to decrement the stats and then
> unset the flag.
>
> That way, we cannot have an imbalanced accounting. Thoughts?
With our current accounting method, we should not have imbalanced
accounting even if you turn on sched_cache after the
scheduler has started running (see my reply to Chen Yu's follow up).
That reset_llc_stats() hack
should not be needed as Peter pointed out.
We will change that check to warning under debug option.
Tim
>
> > }
> >