Re: [PATCH 00/11] nodemask: switch to runtime nr_node_ids
From: Yury Norov
Date: Sat Nov 28 2026 - 22:02:01 EST
On Sat, Nov 28, 2026 at 03:40:39PM -0800, Andrew Morton wrote:
From: Yury Norov <ynorov@xxxxxxxxxx>
To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx,
Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>,
David Hildenbrand <david@xxxxxxxxxx>,
Gregory Price <gourry@xxxxxxxxxx>, Zi Yan <ziy@xxxxxxxxxx>,
Joshua Hahn <joshua.hahnjy@xxxxxxxxx>, Rakie Kim <rakie.kim@xxxxxx>,
Ying Huang <ying.huang@xxxxxxxxxxxxxxxxx>,
Muchun Song <muchun.song@xxxxxxxxx>,
Oscar Salvador <osalvador@xxxxxxx>,
Johannes Weiner <hannes@xxxxxxxxxxx>,
Kairui Song <kasong@xxxxxxxxxxx>,
Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>,
"Rafael J. Wysocki" <rafael@xxxxxxxxxx>,
Len Brown <lenb@xxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>,
Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Mel Gorman <mgorman@xxxxxxx>,
Steven Rostedt <rostedt@xxxxxxxxxxx>,
Masami Hiramatsu <mhiramat@xxxxxxxxxx>,
Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>,
linux-mips@xxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx,
linux-block@xxxxxxxxxxxxxxx, linux-trace-kernel@xxxxxxxxxxxxxxx,
"Liam R. Howlett" <liam@xxxxxxxxxxxxx>,
Axel Rasmussen <axelrasmussen@xxxxxxxxxx>,
Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>,
Baoquan He <baoquan.he@xxxxxxxxx>, Barry Song <baohua@xxxxxxxxxx>,
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>,
Lorenzo Stoakes <ljs@xxxxxxxxxx>, Michal Hocko <mhocko@xxxxxxxx>,
Mike Rapoport <rppt@xxxxxxxxxx>, Qi Zheng <qi.zheng@xxxxxxxxx>,
Shakeel Butt <shakeel.butt@xxxxxxxxx>,
Suren Baghdasaryan <surenb@xxxxxxxxxx>,
Vlastimil Babka <vbabka@xxxxxxxxxx>, Wei Xu <weixugc@xxxxxxxxxx>,
Yuanchu Xie <yuanchu@xxxxxxxxxx>, Yury Norov <yury.norov@xxxxxxxxx>
Bcc:
Subject: Re: [PATCH 00/11] nodemask: switch to runtime nr_node_ids
Message-ID: <awuQdcugLFR1NK_5@yury>
Reply-To:
In-Reply-To: <20261128154039.e898002e7af1e8af883c6c8a@xxxxxxxxxxxxxxxxxxxx>
On Sat, Nov 28, 2026 at 03:40:39PM -0800, Andrew Morton wrote:
> On Fri, 27 Nov 2026 18:01:17 -0500 Yury Norov <ynorov@xxxxxxxxxx> wrote:
>
> > Nodemasks have a compile-time capacity of MAX_NUMNODES, and
> > nr_node_ids describes the runtime node ID usage.
> >
> > Modern distros, like my Ubuntu, default MAX_NUMNODES to 1024, while the
> > actual number of nodes is typically smaller. All nodemask functions
> > currently refer to the MAX_NUMNODES, which adds a substantial overhead
> > on every traversing operation.
> >
>
> Thanks Yury, this is a worthy effort!
Thanks Andrew, I'm glad you like this.
> First thought: mainline Linux defaults x86_64 MAX_NUMNODES to 64. But
> 99.9% of our users say "well that's crap, let's use X instead".
I guess, 99% of our users don't even know that MAX_NUMNODES exists. I
think they don't care, and they shouldn't.
The real problem is that those major distros configure their kernels
without common sense check. Even consumer oriented Ubuntu tunes the
kernel knobs to full max where possible for no good reason.
That's how we end up with the NR_CPUS == 8K and MAX_NUMNODES == 1K. In
real life, if systems incorporating that many CPUS and memory nodes ever
exist, they will likely run highly customized version of Linux, not
something like stock Ubuntu or Fedora.
So, in my opinion the mainline Linux makes better choice for an average
setup than the distros do.
> The below is unreliable and very approximate, but my LLM's scouring
> turned up the following guesstimates:
>
> Who MAX_NUMNODES
> RHEL 1024
> SUSE 1024
> Oracle 1024
> Ubuntu 1024
> Debian 1024
> Fedora 1024
> AWS ~1024
> Google ~64
> Microsoft ~1024
> Meta ~64-1024
> Tencent ~1024
Yeah...
It's another interesting topic to estimate the bloat in kernels
delivered to end users, comparing to what we've got in defconfig.
> I suggest that we change mainline's default so what-we're-testing
> better represents what-they're-using. This somewhat offtopic, but
> wdyt? Would such a change affect this patchset?
The patchset would not be affected. It switches to runtime number
of nodes, which, to some extent, helps to mitigate insanely high
MAX_NUMNODES bloat. The small/large nodemask sizes machinery borrowed
from cpumasks allows the users who configure their MAX_NUMNODES to
reasonably small values to have the API optimized at compile time.
I would suggest another experiment. Let's on the system boot print a
message like:
The kernel is configured to support for up to 1024 NUMA nodes, while
the actual number of nodes on this system is 2. This leaves 99.8% of
the allocated resources unused. Please consider reconfiguring.
We can show it, say, at 90% rate or higher, and wait until this will start
showing up in the people's boot logs. :)
> > This series switches the kernel to runtime length of nodemasks, which
> > also saves up to 8K of .text for minimal config, and accelerates basic
> > nodemask operations ~4x if MAX_NUMNODES == 1024 and nr_node_ids == 2.
>
> I'm saddened by how many instances of MAX_NUMNODES remain in the tree!
> I'd love to see that become zero. But that would involve using
> alloca() or its equivalents. I think alloc() is neat but I've always
> lost that fight (LT), never really understood why.
>
> Series looks nice, applies cleanly for me. Sashiko said a thing
> (https://sashiko.dev/#/patchset/20261127230128.111933-1-ynorov@xxxxxxxxxx).
> I'll continue to monitor, see what reviewers have to say (please).
Thanks for the feedback. Now waiting for more comments. Then will send v2
if needed or take it with bitmap-for-next (or with your -mm if you prefer).
Thanks,
Yury