[PATCH v4 3/5] sched/cache: Drive cache task tick from execution context

From: Hui Su

Date: Wed Sep 09 2026 - 05:49:28 EST


Cache-aware scheduling accounts CPU runtime to the mm of the task actually
executing. update_se() passes rq->curr to account_mm_sched() for this
purpose.

With proxy execution, task_tick_cache() still runs for the scheduling
context in rq->donor. When a fair task executes on behalf of an RT or
deadline donor, its mm runtime advances but its cache scan epoch is not
driven. This can cause account_mm_sched() to invalidate the mm's preferred
LLC.

Run task_tick_cache() from the fair execution-context section of
task_tick_fair(), alongside NUMA tick handling, so cache work and runtime
accounting refer to the same task and mm.

Fixes: df0d98475954 ("sched/cache: Introduce infrastructure for cache-aware load balancing")
Suggested-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
Signed-off-by: Hui Su <sh_def@xxxxxxx>
---
kernel/sched/fair.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a8c7a9a29ace..43d558289856 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -15086,13 +15086,15 @@ static void task_tick_fair(struct rq *rq, int queued)
return;

/* Update state owned by the execution context. */
- if (curr->sched_class == &fair_sched_class &&
- static_branch_unlikely(&sched_numa_balancing))
- task_tick_numa(rq, curr);
+ if (curr->sched_class == &fair_sched_class) {
+ if (static_branch_unlikely(&sched_numa_balancing))
+ task_tick_numa(rq, curr);

- if (donor->sched_class == &fair_sched_class) {
- task_tick_cache(rq, donor);
+ task_tick_cache(rq, curr);
+ }

+ /* Update state owned by the scheduling context. */
+ if (donor->sched_class == &fair_sched_class) {
update_misfit_status(donor, rq);
check_update_overutilized_status(task_rq(donor));

--
2.55.0