RE: [RFC PATCH v2 08/23] sched/topology: Introduce a per-CPU tasks NUMA preferred counter

From: Jianyong Wu

Date: Tue Sep 01 2026 - 04:47:15 EST


Hi Peter,

> -----Original Message-----
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Sent: Monday, August 31, 2026 9:24 PM
> To: Jianyong Wu <wujianyong@xxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>; Juri Lelli <juri.lelli@xxxxxxxxxx>;
> Vincent Guittot <vincent.guittot@xxxxxxxxxx>; Chen Yu
> <yu.c.chen@xxxxxxxxx>; Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>; Dietmar
> Eggemann <dietmar.eggemann@xxxxxxx>; Steven Rostedt
> <rostedt@xxxxxxxxxxx>; Ben Segall <bsegall@xxxxxxxxxx>; Mel Gorman
> <mgorman@xxxxxxx>; Valentin Schneider <vschneid@xxxxxxxxxx>; K
> Prateek Nayak <kprateek.nayak@xxxxxxx>; Shrikanth Hegde
> <sshegde@xxxxxxxxxxxxx>; Phil Auld <pauld@xxxxxxxxxx>; Andrew
> Morton <akpm@xxxxxxxxxxxxxxxxxxxx>; David Hildenbrand
> <david@xxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx;
> jianyong.wu@xxxxxxxxxxx; Yuan Zhong <zhongyuan@xxxxxxxx>; Huangsj
> <huangsj@xxxxxxxx>; Fengyu Wang <wangfengyu@xxxxxxxx>; Zhiwei Ying
> <yingzhiwei@xxxxxxxx>; justin.he@xxxxxxx
> Subject: Re: [RFC PATCH v2 08/23] sched/topology: Introduce a per-CPU
> tasks NUMA preferred counter
>
> On Thu, Aug 27, 2026 at 08:28:01PM +0800, Jianyong Wu wrote:
> > Like the existed task LLC preferred counter, sd->llc_counts, introduce
> > sd->numa_counts to denotes the task number that prefer each NUMA
> node in
> > a certain rq.
> >
>
> To what purpose? Is not the node occupancy the direct sum of its
> constituent llc occupancy?

numa_counts is used by the affinity score in patch 12. It holds, for each
NUMA node, the number of tasks on this rq whose preferred LLC falls in
that node.

You're right that numerically it equals the per-node sum of llc_counts.
The reason to keep it is granularity: NUMA-level load balance scores at
node granularity (numa_counts[node] * distance_delta), while NODE-level
balancing scores at LLC granularity (llc_counts[llc] * ...). Maintaining
the node aggregate costs only a single llc_to_node() lookup (an O(1)
array read) plus one increment in enqueue/dequeue, whereas recomputing
the per-node sum would have to walk every LLC of a node each time the
NUMA-level score is evaluated.

Thanks
Jianyong