Nodemask capacity grid: before / after

Before: fe906beea8b376065865573afe236fa27e47d958
After: 87d15eba092671b081d5bab31a58da7e22afc384

VM hardware versus compile-time capacities

The grid axes show configured NR_CPUS and MAX_NUMNODES limits. Runtime VM hardware stayed fixed as follows:

Kernel configurationvCPUsMemory nodes
SMP and NUMA enabled22
SMP enabled, NUMA disabled21
SMP disabled11

Every VM has 512 MiB RAM. Two-node VMs have 256 MiB per node; both vCPUs belong to node 0, and node 1 is memory-only. Guest NUMA is synthetic. These measurements exercise kernel NUMA policy and mask handling in KVM, rather than physical NUMA hardware placement.

Tested on x86_64/ KVM. Host vCPU threads are pinned to separate physical cores. Off-stack cpumasks are enabled for every SMP configuration through a shared Kconfig wrapper, with debug checks disabled; UP uses stack masks.

Performance cells show percentage reduction in time. Positive is faster.

Kernel results average four input patterns within each run, then summarize 20 run averages per variant across four boots (five per boot). Syscall tests summarize 100 runs across 20 boots per variant. Counterbalanced ABBA / BAAB ordering pairs neighboring before/after boots; the syscall rerun repeats this order five times.

In the performance grids, green with bold text means a statistically significant improvement; red with bold text means a statistically significant regression. Neutral cells with plain text did not meet the significance threshold. Positive percentages mean less elapsed time (better); negative percentages mean more (worse).

Significance uses a two-sided paired t-test on matched boot means: four pairs (df=3) for kernel tests and 20 pairs (df=19) for syscalls, with Holm-adjusted p < 0.05 across all 1,016 displayed comparisons. Hover over a cell for raw and adjusted p-values. Size-grid colors show growth or shrinkage directly and do not represent statistical tests.

Bloat-o-meter grand total: net change in bytes

The parenthesized net change from the first add/remove summary line of unmodified scripts/bloat-o-meter, with no flags.

Compile-time capacity cost: (KiB)

Before-kernel size increase relative to the kernel with NR_CPUS=1, MAX_NUMNODES=1. Uses the unmodified bloat-o-meter first-line net-change metric divided by 1024. The first increase includes enabling SMP/NUMA; dynamic per-task and per-CPU allocations are separate.

One additional CPU costs approximately 142 bytes. One additional node costs approximately 1.2–2.2 KiB, depending on the configured node capacity. These estimates describe static kernel size, and exclude the separate cost of enabling SMP/NUMA and dynamic allocations.

Estimated runtime mask memory: this host as workload reference

Total estimate for mask memory. On this local machine with 8 CPUs, one NUMA node and 2,009 tasks, the counted masks use approximately 4.20 MiB with NR_CPUS=8192 and MAX_NUMNODES=1024; task masks account for 4.17 MiB. Configuring the same workload for the actual 8 CPUs and one node reduces the estimate to 53.1 KiB, saving approximately 4.15 MiB (98.8%). These estimates cover counted mask payloads and exclude allocator overhead and objects whose live counts were not measured.

Memory componentBytes per additional CPU capacityBytes per additional node capacity
.text≈0≈14.0
.data≈46.2≈9.4
.bss≈34.1≈704.0
Runtime mask payload≈505.8 / ≈535*≈251.1
Total of listed components≈586.1≈978.5

* 535 bytes with CPUMASK_OFFSTACK disabled.

The host snapshot has 2,009 visible tasks (threads), 427 processes including 259 kernel-thread leaders, and approximately 168 userspace address spaces. Hardware: 8 possible/online CPUs and one NUMA node. The running kernel is configured for NR_CPUS=8192, MAX_NUMNODES=1024, with CPUSETS and CPUMASK_OFFSTACK enabled. The workload snapshot is separate from the benchmark VM topology described above.

Task masks alone consume 4.17 MiB. Every task embeds two 1024-byte CPU masks (affinity and nested TLB-flush batching) and one 128-byte node mask, totaling 2,176 bytes per task. Running-kernel BTF confirms all three fields. The series changes operation lengths; it does not reduce these persistent mask sizes.

Configuring the kernel for the actual 8 CPUs and 1 node

Mask memoryCurrent: NR_CPUS=8192, MAX_NUMNODES=1024Matching hardware: NR_CPUS=8, MAX_NUMNODES=1
Per task2,176 bytes24 bytes
All 2,009 visible tasks4.17 MiB47.1 KiB
All counted components4.20 MiB53.1 KiB

Matching the configured capacities to this host saves approximately 4.15 MiB of mask storage, a 98.8% reduction. This comparison keeps the same workload and enabled features, and excludes allocator rounding and uncounted objects.

ComponentObjectsMask bytes / objectTotal KiB
Task CPU affinity mask2,0091,0242,009.00
Task batched TLB-flush CPU mask2,0091,0242,009.00
Task allowed-node mask2,009128251.12
Cache sharing CPU masks281,02428.00
Address-space CPU/CID masks (estimate)168243.94
Top cpuset masks (estimate)14160.41
IRQ affinity masks (estimate)65241.52
x86 CPU topology masks8400.31
Node-to-CPU map180.01
Selected-components subtotal4,303.31

This subtotal is approximately 4.20 MiB of mask payload. It excludes object padding, slab rounding, pointer fields and allocator metadata. /proc excludes the eight idle tasks; their masks add 17.00 KiB. The top cpuset includes static masks already covered by image-size accounting, so this subtotal should not be added directly to the compile-time grid.

Allocated CPU masks are only 8 bytes on this host despite NR_CPUS=8192. In this tree, allocations use the configured CPU limit up to 256 CPUs and the runtime CPU-ID limit above 256; embedded masks always use NR_CPUS. With SCHED_MM_CID disabled, as in the benchmark kernels, address spaces need one CPU mask rather than the three CPU/CID bitmaps estimated here.

Additional allocations depend on workload: each non-default mempolicy embeds 256 bytes of node masks (two masks; union members share storage); each saved user-affinity mask requests at least 16 bytes; each additional cpuset has 416 bytes of mask backing storage. The 123 cgroups do not imply 123 cpusets: no child cpuset controller files were found. Default NULL memory policies allocate no policy object.

The subtotal omits masks in scheduler domains/groups, workqueues, networking, KVM and device-specific objects because their live object counts were not measured. Slab counters were unreadable. The readable NUMA maps showed no non-default VMA policies, but that does not establish zero policy objects. This is an estimate of the major counted components, rather than a measured system-wide allocation total.

NR_CPUSMAX_NUMNODESEmbedded mask bytes / taskTask masks for 2,009 tasks (KiB)
812447.09
64642447.09
25625696188.34
512512192376.69
8192102421764,269.12

Performance measurements

Cpumasks

Cpumasks before

Before kernels only, relative to the before kernel configured with NR_CPUS=1 and MAX_NUMNODES=1. Ratios are configuration time / reference time: 1× is unchanged, above 1× is slower, and below 1× is faster. Hover over a cell for both timings in ns/operation. As elsewhere, each mean averages the four input patterns within each of 20 runs. Colors and bold text mark significance using a two-sided Welch t-test on four boot means per configuration, with Holm correction across these 441 baseline comparisons. Runtime hardware follows the VM topology table above: the 1/1 reference has one vCPU and one node; SMP/NUMA configurations have two vCPUs and two nodes. These comparisons therefore include configuration and runtime-topology effects.

Cpumasks after

After kernels only, relative to the after kernel configured with NR_CPUS=1 and MAX_NUMNODES=1. Ratios are configuration time / reference time: 1× is unchanged, above 1× is slower, and below 1× is faster. Hover over a cell for both timings in ns/operation. As elsewhere, each mean averages the four input patterns within each of 20 runs. Colors and bold text mark significance using a two-sided Welch t-test on four boot means per configuration, with Holm correction across these 441 after-kernel baseline comparisons (a separate family from the before-kernel grid). Runtime hardware follows the VM topology table above: the 1/1 reference has one vCPU and one node; SMP/NUMA configurations have two vCPUs and two nodes. These comparisons therefore include configuration and runtime-topology effects.

Cpumasks before/after

Time reduction after the patches versus before (%); positive means faster.

Nodemasks

Nodemasks before

Before kernels only, relative to the before kernel configured with NR_CPUS=1 and MAX_NUMNODES=1. Ratios are configuration time / reference time: 1× is unchanged, above 1× is slower, and below 1× is faster. Hover over a cell for both timings in ns/operation. Each mean averages the four input patterns within each of 20 runs. Colors and bold text mark significance using a two-sided Welch t-test on four boot means per configuration, with Holm correction across these 504 nodemask comparisons (a separate family for each variant). Runtime hardware follows the VM topology table above, so these comparisons include configuration and runtime-topology effects.

Nodemasks after

After kernels only, relative to the after kernel configured with NR_CPUS=1 and MAX_NUMNODES=1. Ratios are configuration time / reference time: 1× is unchanged, above 1× is slower, and below 1× is faster. Hover over a cell for both timings in ns/operation. Each mean averages the four input patterns within each of 20 runs. Colors and bold text mark significance using a two-sided Welch t-test on four boot means per configuration, with Holm correction across these 504 nodemask comparisons (a separate family for each variant). Runtime hardware follows the VM topology table above, so these comparisons include configuration and runtime-topology effects.

Nodemasks before/after

Time reduction after the patches versus before (%); positive means faster.

set_mempolicy(MPOL_BIND): time reduction (%)

All 56 NUMA configurations use the fresh 100 measurements per variant across 20 matched boot pairs.