Re: [PATCH 07/19] sched/fair: Track LLC-preferred tasks per runqueue
From: K Prateek Nayak
Date: Wed Oct 29 2025 - 00:00:34 EST
Hello Chenyu,
On 10/28/2025 8:45 PM, Chen, Yu C wrote:
>> 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?
>>
>
> I suppose what you mean is to avoid the race condition between
> enabling sched_cache and EQ/DE_LLC, similar to uclamp:
>
> enqueue(taskA)
> // sched_cache gets enabled
> enqueue(taskB)
> dequeue(taskA)
> // Must not decrement rq->llc_pref for taskA
> dequeue(taskB)
Yup! We can have
enqueue(p)
account_llc_enqueue(p)
if (sched_cache_enabled())
p->se.llc_sched_active = true;
rq->nr_llc_running += (p->preferred_llc != -1);
rq->nr_pref_llc_running += (p->preferred_llc == task_llc(p));
...
dequeue(p)
account_llc_dequeue(p)
if (p->se.llc_sched_active)
rq->nr_llc_running -= (p->preferred_llc != -1);
rq->nr_pref_llc_running -= (p->preferred_llc == task_llc(p));
We can also have a single bit for "llc_sched_active" in the
task_struct next to the "sched_task_hot" bit instead of using the
hole in sched_entity after "sched_delayed"
--
Thanks and Regards,
Prateek