Re: [RFC PATCH v2 07/23] sched/cache: Prioritize preferred NUMA node selection over LLC selection

From: Peter Zijlstra

Date: Mon Aug 31 2026 - 09:42:53 EST


On Thu, Aug 27, 2026 at 08:28:00PM +0800, Jianyong Wu wrote:
> In the current implementation, the preferred LLC is selected based on the
> LLC with the largest running time of the thread group. However, the
> preferred LLC may be prone to frequent migration when the workload
> spreads across the entire system, especially when the number of CPUs
> sharing an LLC is small. A better approach is to first select a preferred
> NUMA node in the same way, and then select the preferred LLC within that
> preferred NUMA node.

Hmm, if we're going to look at nodes, should we not also consider the
numa balancing preferred node, and perhaps priorize an llc inside that
nore, rather than the occupancy wise busiest node?


> - a_occ += occ;
> - if (occ > m_occ) {
> - m_occ = occ;
> - m_cpu = i;
> + a_occ += occ;
> + if (occ > m_occ) {
> + m_occ = occ;
> + m_cpu = i;
> + }
> +
> + cur = rcu_dereference_all(cpu_rq(i)->curr);
> + if (cur && !(cur->flags & (PF_EXITING | PF_KTHREAD)) &&
> + cur->mm == mm)
> + nr_running++;
> }

This level of indenting seems to suggest perhaps breaking things out
into a helper function?