freenode
Kernel & Low-Level

Kernel nodemask speedup collides with distro NUMA bloat

A proposal to walk only the nodes a machine actually has draws praise, skepticism, and a fight over who ships 1024-node kernels.

Yury Norov has posted a kernel series that would stop nodemask operations from always scanning the compile-time maximum number of NUMA nodes, and instead use the count the running system actually has. On the kernels most people boot, that gap is large: Ubuntu and the other major distributions compile for 1024 nodes, while a typical machine has far fewer. Norov says basic operations are about four times faster when the kernel is built for 1024 nodes and only two exist, and that a minimal configuration sheds up to 8KB of text.

Nodemasks are bitmaps the memory-management and scheduler code uses to say which nodes a task, policy, or migration may touch. Today those walks are bounded by MAX_NUMNODES, a constant baked in at build time, not by nr_node_ids, the runtime figure. A naive switch to the runtime value would, Norov writes, also throw away compile-time bitmap optimizations on kernels that already set a small maximum, so the series picks a small compile-time size, a large one, or the precise runtime count depending on the operation. It also keeps userspace-facing masks at full width, rejects migrate_pages source IDs past the live node count, and clears unused bits before they leak into scheduler traces.

Andrew Morton called the work worthy and used it to reopen a wider complaint. Mainline x86_64 still defaults MAX_NUMNODES to 64, but his survey of vendor kernels put RHEL, SUSE, Oracle, Ubuntu, Debian, Fedora, and several cloud builds at 1024, with Google and Meta sometimes much lower. He asked whether mainline should raise its default so what developers test looks like what users run. The same pattern shows up in NR_CPUS: mainline 64, most of those vendors 8192. Morton put the obvious per-task cost at about a kilobyte; Norov pointed at an older measurement of roughly 8KB per supported CPU and said he would remeasure.

Norov floated a boot message that would tell an operator the kernel was built for 1024 nodes, the machine has two, and 99.8 percent of that capacity is unused. Morton liked the provocation. Linus Torvalds did not share Morton's assumption that distributors had thought this through: "Their configurations and complete random noise." Some, he said, used to flip on a maximum-SMP option and stop there. Norov agreed, and suggested distributors ship a kernel and then rebuild it against the machine's actual config. He said he would estimate the wasted memory before anyone adds a shout to the boot log.

Memory-management maintainers were cooler about taking the series itself. Lorenzo Stoakes said the cover letter does not show a real workload hitting these paths, and that 8KB of text is not a reason to merge. He asked what users would see change, whether hot-added CPUs or CXL memory could break assumptions about the node count, and what was tested. With review time already consumed by a wave of machine-generated fixes, he was unsure the mm tree should take non-fixes this late. David Hildenbrand said the churn is small enough that it might still fit, with no promise. Joshua Hahn liked the speedup but asked about the other half of the waste: static arrays sized to MAX_NUMNODES in the page allocator, mempolicy, and hugetlb code, which this series does not shrink.

Norov said he will not push it into late release candidates. He plans to carry it in linux-next for wider testing and send it when the merge window opens, and he agreed not to merge mm changes without mm signoff.