Commit 8a5cfa2
committed
sched/fair: Get rid of sched_domains_curr_level hack for tl->cpumask()
JIRA: https://issues.redhat.com/browse/RHEL-118964
Conflicts: Minor context differences in topology.h
commit 661f951
Author: Peter Zijlstra <peterz@infradead.org>
Date: Mon Aug 25 12:02:44 2025 +0000
sched/fair: Get rid of sched_domains_curr_level hack for tl->cpumask()
Leon [1] and Vinicius [2] noted a topology_span_sane() warning during
their testing starting from v6.16-rc1. Debug that followed pointed to
the tl->mask() for the NODE domain being incorrectly resolved to that of
the highest NUMA domain.
tl->mask() for NODE is set to the sd_numa_mask() which depends on the
global "sched_domains_curr_level" hack. "sched_domains_curr_level" is
set to the "tl->numa_level" during tl traversal in build_sched_domains()
calling sd_init() but was not reset before topology_span_sane().
Since "tl->numa_level" still reflected the old value from
build_sched_domains(), topology_span_sane() for the NODE domain trips
when the span of the last NUMA domain overlaps.
Instead of replicating the "sched_domains_curr_level" hack, get rid of
it entirely and instead, pass the entire "sched_domain_topology_level"
object to tl->cpumask() function to prevent such mishap in the future.
sd_numa_mask() now directly references "tl->numa_level" instead of
relying on the global "sched_domains_curr_level" hack to index into
sched_domains_numa_masks[].
The original warning was reproducible on the following NUMA topology
reported by Leon:
$ sudo numactl -H
available: 5 nodes (0-4)
node 0 cpus: 0 1
node 0 size: 2927 MB
node 0 free: 1603 MB
node 1 cpus: 2 3
node 1 size: 3023 MB
node 1 free: 3008 MB
node 2 cpus: 4 5
node 2 size: 3023 MB
node 2 free: 3007 MB
node 3 cpus: 6 7
node 3 size: 3023 MB
node 3 free: 3002 MB
node 4 cpus: 8 9
node 4 size: 3022 MB
node 4 free: 2718 MB
node distances:
node 0 1 2 3 4
0: 10 39 38 37 36
1: 39 10 38 37 36
2: 38 38 10 37 36
3: 37 37 37 10 36
4: 36 36 36 36 10
The above topology can be mimicked using the following QEMU cmd that was
used to reproduce the warning and test the fix:
sudo qemu-system-x86_64 -enable-kvm -cpu host \
-m 20G -smp cpus=10,sockets=10 -machine q35 \
-object memory-backend-ram,size=4G,id=m0 \
-object memory-backend-ram,size=4G,id=m1 \
-object memory-backend-ram,size=4G,id=m2 \
-object memory-backend-ram,size=4G,id=m3 \
-object memory-backend-ram,size=4G,id=m4 \
-numa node,cpus=0-1,memdev=m0,nodeid=0 \
-numa node,cpus=2-3,memdev=m1,nodeid=1 \
-numa node,cpus=4-5,memdev=m2,nodeid=2 \
-numa node,cpus=6-7,memdev=m3,nodeid=3 \
-numa node,cpus=8-9,memdev=m4,nodeid=4 \
-numa dist,src=0,dst=1,val=39 \
-numa dist,src=0,dst=2,val=38 \
-numa dist,src=0,dst=3,val=37 \
-numa dist,src=0,dst=4,val=36 \
-numa dist,src=1,dst=0,val=39 \
-numa dist,src=1,dst=2,val=38 \
-numa dist,src=1,dst=3,val=37 \
-numa dist,src=1,dst=4,val=36 \
-numa dist,src=2,dst=0,val=38 \
-numa dist,src=2,dst=1,val=38 \
-numa dist,src=2,dst=3,val=37 \
-numa dist,src=2,dst=4,val=36 \
-numa dist,src=3,dst=0,val=37 \
-numa dist,src=3,dst=1,val=37 \
-numa dist,src=3,dst=2,val=37 \
-numa dist,src=3,dst=4,val=36 \
-numa dist,src=4,dst=0,val=36 \
-numa dist,src=4,dst=1,val=36 \
-numa dist,src=4,dst=2,val=36 \
-numa dist,src=4,dst=3,val=36 \
...
[ prateek: Moved common functions to include/linux/sched/topology.h,
reuse the common bits for s390 and ppc, commit message ]
Closes: https://lore.kernel.org/lkml/20250610110701.GA256154@unreal/ [1]
Fixes: ccf7412 ("sched/topology: Assert non-NUMA topology masks don't (partially) overlap") # ce29a7d, f55dac1
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reported-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Tested-by: Valentin Schneider <vschneid@redhat.com> # x86
Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com> # powerpc
Link: https://lore.kernel.org/lkml/a3de98387abad28592e6ab591f3ff6107fe01dc1.1755893468.git.tim.c.chen@linux.intel.com/ [2]
Signed-off-by: Phil Auld <pauld@redhat.com>1 parent 3a55f9d commit 8a5cfa2
File tree
8 files changed
+66
-53
lines changed- arch
- powerpc
- include/asm
- kernel
- s390/kernel
- x86/kernel
- include/linux
- sched
- kernel/sched
8 files changed
+66
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
856 | 860 | | |
857 | 861 | | |
858 | 862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | | - | |
| 1049 | + | |
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
| 1055 | + | |
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | 1069 | | |
1075 | 1070 | | |
1076 | 1071 | | |
| |||
1459 | 1454 | | |
1460 | 1455 | | |
1461 | 1456 | | |
1462 | | - | |
| 1457 | + | |
1463 | 1458 | | |
1464 | 1459 | | |
1465 | 1460 | | |
| |||
1549 | 1544 | | |
1550 | 1545 | | |
1551 | 1546 | | |
1552 | | - | |
| 1547 | + | |
1553 | 1548 | | |
1554 | 1549 | | |
1555 | 1550 | | |
| |||
1612 | 1607 | | |
1613 | 1608 | | |
1614 | 1609 | | |
1615 | | - | |
| 1610 | + | |
1616 | 1611 | | |
1617 | 1612 | | |
1618 | 1613 | | |
| |||
1714 | 1709 | | |
1715 | 1710 | | |
1716 | 1711 | | |
1717 | | - | |
| 1712 | + | |
1718 | 1713 | | |
1719 | | - | |
| 1714 | + | |
1720 | 1715 | | |
1721 | 1716 | | |
1722 | 1717 | | |
1723 | 1718 | | |
1724 | | - | |
| 1719 | + | |
1725 | 1720 | | |
1726 | 1721 | | |
1727 | 1722 | | |
1728 | 1723 | | |
1729 | | - | |
| 1724 | + | |
1730 | 1725 | | |
1731 | 1726 | | |
1732 | | - | |
| 1727 | + | |
1733 | 1728 | | |
1734 | 1729 | | |
1735 | 1730 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | 516 | | |
523 | 517 | | |
524 | 518 | | |
525 | 519 | | |
526 | 520 | | |
527 | | - | |
| 521 | + | |
528 | 522 | | |
529 | 523 | | |
530 | 524 | | |
531 | 525 | | |
532 | | - | |
| 526 | + | |
533 | 527 | | |
534 | 528 | | |
535 | 529 | | |
536 | 530 | | |
537 | 531 | | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
543 | 537 | | |
544 | 538 | | |
545 | 539 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
509 | 509 | | |
510 | | - | |
| 510 | + | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
514 | 514 | | |
515 | | - | |
| 515 | + | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
50 | 64 | | |
51 | 65 | | |
52 | 66 | | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
57 | 77 | | |
58 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
59 | 85 | | |
60 | 86 | | |
61 | 87 | | |
| |||
185 | 211 | | |
186 | 212 | | |
187 | 213 | | |
188 | | - | |
| 214 | + | |
189 | 215 | | |
190 | 216 | | |
191 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1604 | 1604 | | |
1605 | 1605 | | |
1606 | 1606 | | |
1607 | | - | |
1608 | 1607 | | |
1609 | 1608 | | |
1610 | 1609 | | |
| |||
1645 | 1644 | | |
1646 | 1645 | | |
1647 | 1646 | | |
1648 | | - | |
1649 | | - | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
| 1647 | + | |
1656 | 1648 | | |
1657 | 1649 | | |
1658 | 1650 | | |
| |||
1690 | 1682 | | |
1691 | 1683 | | |
1692 | 1684 | | |
1693 | | - | |
| 1685 | + | |
1694 | 1686 | | |
1695 | 1687 | | |
1696 | 1688 | | |
| |||
1750 | 1742 | | |
1751 | 1743 | | |
1752 | 1744 | | |
1753 | | - | |
| 1745 | + | |
1754 | 1746 | | |
1755 | 1747 | | |
1756 | 1748 | | |
1757 | | - | |
| 1749 | + | |
1758 | 1750 | | |
1759 | 1751 | | |
1760 | 1752 | | |
1761 | | - | |
| 1753 | + | |
1762 | 1754 | | |
1763 | | - | |
| 1755 | + | |
1764 | 1756 | | |
1765 | 1757 | | |
1766 | 1758 | | |
| |||
1782 | 1774 | | |
1783 | 1775 | | |
1784 | 1776 | | |
1785 | | - | |
| 1777 | + | |
1786 | 1778 | | |
1787 | | - | |
| 1779 | + | |
1788 | 1780 | | |
1789 | 1781 | | |
1790 | 1782 | | |
| |||
2423 | 2415 | | |
2424 | 2416 | | |
2425 | 2417 | | |
2426 | | - | |
| 2418 | + | |
2427 | 2419 | | |
2428 | 2420 | | |
2429 | 2421 | | |
2430 | 2422 | | |
2431 | 2423 | | |
2432 | 2424 | | |
2433 | 2425 | | |
2434 | | - | |
| 2426 | + | |
2435 | 2427 | | |
2436 | 2428 | | |
2437 | 2429 | | |
| |||
0 commit comments