Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/numa: Avoid migrating task to CPU-less node

In a typical memory tiering system, there's no CPU in slow (PMEM) NUMA
nodes. But if the number of the hint page faults on a PMEM node is
the max for a task, The current NUMA balancing policy may try to place
the task on the PMEM node instead of DRAM node. This is unreasonable,
because there's no CPU in PMEM NUMA nodes. To fix this, CPU-less
nodes are ignored when searching the migration target node for a task
in this patch.

To test the patch, we run a workload that accesses more memory in PMEM
node than memory in DRAM node. Without the patch, the PMEM node will
be chosen as preferred node in task_numa_placement(). While the DRAM
node will be chosen instead with the patch.

Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220214121553.582248-2-ying.huang@intel.com

authored by

Huang Ying and committed by
Peter Zijlstra
5c7b1aaf 0fb3978b

+20 -5
+20 -5
kernel/sched/fair.c
··· 1989 1989 */ 1990 1990 ng = deref_curr_numa_group(p); 1991 1991 if (env.best_cpu == -1 || (ng && ng->active_nodes > 1)) { 1992 - for_each_online_node(nid) { 1992 + for_each_node_state(nid, N_CPU) { 1993 1993 if (nid == env.src_nid || nid == p->numa_preferred_nid) 1994 1994 continue; 1995 1995 ··· 2087 2087 unsigned long faults, max_faults = 0; 2088 2088 int nid, active_nodes = 0; 2089 2089 2090 - for_each_online_node(nid) { 2090 + for_each_node_state(nid, N_CPU) { 2091 2091 faults = group_faults_cpu(numa_group, nid); 2092 2092 if (faults > max_faults) 2093 2093 max_faults = faults; 2094 2094 } 2095 2095 2096 - for_each_online_node(nid) { 2096 + for_each_node_state(nid, N_CPU) { 2097 2097 faults = group_faults_cpu(numa_group, nid); 2098 2098 if (faults * ACTIVE_NODE_FRACTION > max_faults) 2099 2099 active_nodes++; ··· 2247 2247 2248 2248 dist = sched_max_numa_distance; 2249 2249 2250 - for_each_online_node(node) { 2250 + for_each_node_state(node, N_CPU) { 2251 2251 score = group_weight(p, node, dist); 2252 2252 if (score > max_score) { 2253 2253 max_score = score; ··· 2266 2266 * inside the highest scoring group of nodes. The nodemask tricks 2267 2267 * keep the complexity of the search down. 2268 2268 */ 2269 - nodes = node_online_map; 2269 + nodes = node_states[N_CPU]; 2270 2270 for (dist = sched_max_numa_distance; dist > LOCAL_DISTANCE; dist--) { 2271 2271 unsigned long max_faults = 0; 2272 2272 nodemask_t max_group = NODE_MASK_NONE; ··· 2403 2403 max_faults = group_faults; 2404 2404 max_nid = nid; 2405 2405 } 2406 + } 2407 + 2408 + /* Cannot migrate task to CPU-less node */ 2409 + if (!node_state(max_nid, N_CPU)) { 2410 + int near_nid = max_nid; 2411 + int distance, near_distance = INT_MAX; 2412 + 2413 + for_each_node_state(nid, N_CPU) { 2414 + distance = node_distance(max_nid, nid); 2415 + if (distance < near_distance) { 2416 + near_nid = nid; 2417 + near_distance = distance; 2418 + } 2419 + } 2420 + max_nid = near_nid; 2406 2421 } 2407 2422 2408 2423 if (ng) {