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.

Merge tag 'sched_ext-for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext

Pull sched_ext fixes from Tejun Heo:
"Two fixes in the built-in idle selection helpers:

- Fix prev_cpu handling to guarantee that idle selection never
returns a CPU that's not allowed

- Skip cross-node search when !NUMA which could lead to infinite
looping due to a bug in NUMA iterator"

* tag 'sched_ext-for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext:
sched_ext: idle: Skip cross-node search with !CONFIG_NUMA
sched_ext: idle: Properly handle invalid prev_cpu during idle selection

+19 -18
+19 -18
kernel/sched/ext_idle.c
··· 138 138 goto retry; 139 139 } 140 140 141 + #ifdef CONFIG_NUMA 141 142 /* 142 143 * Tracks nodes that have not yet been visited when searching for an idle 143 144 * CPU across all available nodes. ··· 187 186 188 187 return cpu; 189 188 } 189 + #else 190 + static inline s32 191 + pick_idle_cpu_from_online_nodes(const struct cpumask *cpus_allowed, int node, u64 flags) 192 + { 193 + return -EBUSY; 194 + } 195 + #endif 190 196 191 197 /* 192 198 * Find an idle CPU in the system, starting from @node. ··· 455 447 const struct cpumask *llc_cpus = NULL, *numa_cpus = NULL; 456 448 const struct cpumask *allowed = cpus_allowed ?: p->cpus_ptr; 457 449 int node = scx_cpu_node_if_enabled(prev_cpu); 450 + bool is_prev_allowed; 458 451 s32 cpu; 459 452 460 453 preempt_disable(); 454 + 455 + /* 456 + * Check whether @prev_cpu is still within the allowed set. If not, 457 + * we can still try selecting a nearby CPU. 458 + */ 459 + is_prev_allowed = cpumask_test_cpu(prev_cpu, allowed); 461 460 462 461 /* 463 462 * Determine the subset of CPUs usable by @p within @cpus_allowed. ··· 478 463 allowed = local_cpus; 479 464 } else { 480 465 cpu = -EBUSY; 481 - goto out_enable; 482 - } 483 - 484 - /* 485 - * If @prev_cpu is not in the allowed CPUs, skip topology 486 - * optimizations and try to pick any idle CPU usable by the 487 - * task. 488 - * 489 - * If %SCX_OPS_BUILTIN_IDLE_PER_NODE is enabled, prioritize 490 - * the current node, as it may optimize some waker->wakee 491 - * workloads. 492 - */ 493 - if (!cpumask_test_cpu(prev_cpu, allowed)) { 494 - node = scx_cpu_node_if_enabled(smp_processor_id()); 495 - cpu = scx_pick_idle_cpu(allowed, node, flags); 496 466 goto out_enable; 497 467 } 498 468 } ··· 525 525 * then avoid a migration. 526 526 */ 527 527 cpu = smp_processor_id(); 528 - if (cpus_share_cache(cpu, prev_cpu) && 528 + if (is_prev_allowed && cpus_share_cache(cpu, prev_cpu) && 529 529 scx_idle_test_and_clear_cpu(prev_cpu)) { 530 530 cpu = prev_cpu; 531 531 goto out_unlock; ··· 562 562 /* 563 563 * Keep using @prev_cpu if it's part of a fully idle core. 564 564 */ 565 - if (cpumask_test_cpu(prev_cpu, idle_cpumask(node)->smt) && 565 + if (is_prev_allowed && 566 + cpumask_test_cpu(prev_cpu, idle_cpumask(node)->smt) && 566 567 scx_idle_test_and_clear_cpu(prev_cpu)) { 567 568 cpu = prev_cpu; 568 569 goto out_unlock; ··· 612 611 /* 613 612 * Use @prev_cpu if it's idle. 614 613 */ 615 - if (scx_idle_test_and_clear_cpu(prev_cpu)) { 614 + if (is_prev_allowed && scx_idle_test_and_clear_cpu(prev_cpu)) { 616 615 cpu = prev_cpu; 617 616 goto out_unlock; 618 617 }