Linux Trace Kernel
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	David Hildenbrand <david@kernel.org>,
	Gregory Price <gourry@gourry.net>, Zi Yan <ziy@nvidia.com>,
	Joshua Hahn <joshua.hahnjy@gmail.com>,
	Rakie Kim <rakie.kim@sk.com>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Kairui Song <kasong@tencent.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Peter Zijlstra <peterz@infradead.org>,
	Mel Gorman <mgorman@suse.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-mips@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	"Liam R. Howlett" <liam@infradead.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Baoquan He <baoquan.he@linux.dev>, Barry Song <baohua@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Mike Rapoport <rppt@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Suren Baghdasaryan <surenb@google.com>,
	Vlastimil Babka <vbabka@kernel.org>, Wei Xu <weixugc@google.com>,
	Yuanchu Xie <yuanchu@google.com>,
	Yury Norov <yury.norov@gmail.com>
Subject: Re: [PATCH 00/11] nodemask: switch to runtime nr_node_ids
Date: Sat, 28 Nov 2026 22:01:46 -0500	[thread overview]
Message-ID: <awuVms9ASXmn3Get@yury> (raw)
In-Reply-To: <20261128154039.e898002e7af1e8af883c6c8a@linux-foundation.org>

On Sat, Nov 28, 2026 at 03:40:39PM -0800, Andrew Morton wrote:

From: Yury Norov <ynorov@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	David Hildenbrand <david@kernel.org>,
	Gregory Price <gourry@gourry.net>, Zi Yan <ziy@nvidia.com>,
	Joshua Hahn <joshua.hahnjy@gmail.com>, Rakie Kim <rakie.kim@sk.com>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Kairui Song <kasong@tencent.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Peter Zijlstra <peterz@infradead.org>, Mel Gorman <mgorman@suse.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-mips@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	"Liam R. Howlett" <liam@infradead.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Baoquan He <baoquan.he@linux.dev>, Barry Song <baohua@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Mike Rapoport <rppt@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Suren Baghdasaryan <surenb@google.com>,
	Vlastimil Babka <vbabka@kernel.org>, Wei Xu <weixugc@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Yury Norov <yury.norov@gmail.com>
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@linux-foundation.org>

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@nvidia.com> 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@nvidia.com).
> 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

      reply	other threads:[~2026-11-29  3:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 23:01 [PATCH 00/11] nodemask: switch to runtime nr_node_ids Yury Norov
2026-11-27 23:01 ` [PATCH 01/11] nodemask: add 'small' and 'large' compile-time sizes Yury Norov
2026-11-27 23:01 ` [PATCH 02/11] nodemask: pass nodemask length to node search functions Yury Norov
2026-11-27 23:01 ` [PATCH 03/11] mm/mempolicy: reject migrate_pages source IDs beyond nr_node_ids Yury Norov
2026-11-27 23:01 ` [PATCH 04/11] mm/mempolicy: preserve full-width userspace nodemasks Yury Norov
2026-11-27 23:01 ` [PATCH 05/11] mm: switch to runtime nodemask length Yury Norov
2026-11-27 23:01 ` [PATCH 06/11] MIPS: IP27: switch nmi_dump " Yury Norov
2026-11-27 23:01 ` [PATCH 07/11] ACPI: NUMA: switch acpi_map_pxm_to_node " Yury Norov
2026-11-27 23:01 ` [PATCH 08/11] mtip32xx: switch next_online_node() " Yury Norov
2026-11-27 23:01 ` [PATCH 09/11] nodemask: add nodes_copy_and_extend() Yury Norov
2026-11-27 23:01 ` [PATCH 10/11] sched/numa: bound cpuset trace masks by nr_node_ids Yury Norov
2026-11-28 23:02   ` sashiko-bot
2026-11-27 23:01 ` [PATCH 11/11] nodemask: add cpumask-style operation size bounds Yury Norov
2026-11-28 23:40 ` [PATCH 00/11] nodemask: switch to runtime nr_node_ids Andrew Morton
2026-11-29  3:01   ` Yury Norov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awuVms9ASXmn3Get@yury \
    --to=ynorov@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kasong@tencent.com \
    --cc=lenb@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=ljs@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mgorman@suse.de \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    --cc=peterz@infradead.org \
    --cc=qi.zheng@linux.dev \
    --cc=rafael@kernel.org \
    --cc=rakie.kim@sk.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=ying.huang@linux.alibaba.com \
    --cc=yuanchu@google.com \
    --cc=yury.norov@gmail.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox