Re: [PATCH v9 1/2] sched/cache: Reduce the overhead of task_cache_work by only scan the visisted cpus
From: Chen, Yu C
Date: Tue Aug 11 2026 - 03:46:47 EST
Hi Gengkun,
On 8/11/2026 10:27 AM, Luo Gengkun wrote:
I did a further study on this and have two minor questions:
@@ -1711,6 +1722,9 @@ void account_mm_sched(struct rq *rq, struct task_struct *p, s64 delta_exec)
pcpu_sched->runtime += delta_exec;
rq->cpu_runtime += delta_exec;
epoch = rq->cpu_epoch;
+ pcpu_sched->epoch_last_visit = epoch;
+ if (!cpumask_test_cpu(cpu_of(rq), mm->sc_stat.visited_cpus))
+ cpumask_set_cpu(cpu_of(rq), mm->sc_stat.visited_cpus);
visited_cpus bits are only cleared inside fraction_mm_sched(), which is
reachable in task_cache_work() - but that loop is skipped when invalid_llc_nr()
returns true for any single-threaded process. As a result, single-threaded
processes keep setting bits in account_mm_sched() without using them.
Maybe a gate would be useful:
if (get_nr_threads(p) > 1 &&
!cpumask_test_cpu(cpu_of(rq), mm->sc_stat.visited_cpus))
cpumask_set_cpu(cpu_of(rq), mm->sc_stat.visited_cpus);
[ ... ]
@@ -1866,7 +1835,18 @@ static void task_cache_work(struct callback_head *work)
scoped_guard (cpus_read_lock) {
guard(rcu)();
- get_scan_cpumasks(cpus, p);
I'm thinking of if this could bring cross-node bouncing. Is it doable
to honor the result from NUMA preference:
get_scan_cpumasks(cpus, p);
cpumask_and(cpus, cpus, mm->sc_stat.visited_cpus);
thanks,
Chenyu