Linux block layer
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.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>,
	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: Wed, 2 Dec 2026 17:02:25 -0500	[thread overview]
Message-ID: <axCVcR5O9JY8cQUi@yury> (raw)
In-Reply-To: <axCEQ6dTrixtVh14@gremlin>

On Wed, Dec 02, 2026 at 08:50:25PM +0000, Lorenzo Stoakes (ARM) wrote:
> Yuri - you may have missed the below because it was sent as a follow up to
> original feedback, thanks.

I tried to answer this and some other questions, and summarized it in the
html here:

https://lore.kernel.org/all/aw8XThqaTZg_yJWR@yury/

I'll walk through your questions inplace.

Thanks,
Yury
 
> On Mon, Nov 30, 2026 at 12:20:00PM +0000, Lorenzo Stoakes (ARM) wrote:
> > On Mon, Nov 30, 2026 at 11:51:02AM +0000, Lorenzo Stoakes (ARM) wrote:
> > > On Fri, Nov 27, 2026 at 06:01:17PM -0500, Yury Norov 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.
> > > >
> > > > 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.
> >
> > Also, in general, this cover letter is pretty incomplete.
> >
> > What is the motivation here? Is it purely cleanup?

Cleanup, performance and consistency considerations - all are on the
table.

> I mean I don't think
> > anybody's hitting perf hot paths because of this? Or did you encounter something
> > in a real workload that was impacted somehow?

It's 4x faster in microbenchmark, and 5% faster in set_mempolicy(MPOL_BIND)
test.

> > 8K of .text being saved is also surely neither here nor there also?

It's 8K of kernel image, which means L1 cache memory almost
automatically. To me it's definitely 'here'.

> > I think if
> > it's a cleanup it should say so because 'saves 8K and speeds up operations
> > nobody cares about' isn't hugely motivating.

I'm OK if you consider it as a cleanup because it's a nice cleanup
after all. Some other people, including me, find the performance and
memory improvements significant.

'Nobody cares' is not a strong argument, can't address it.

> > What are the user-visible changes?

I tested the performance of the obvious target: set_mempolicy(MPOL_BIND),
and it's 5% faster. LMK if you have other tests in mind

The other user-visible change is on the ABI side. It was discussed in
the other subthread, here's the summary:

Consider a machine with MAX_NUMNODES == 1K and NR_CPUS == 8K. The
actual number of CPUs and nodes is 2.

Then when you pass cpulist "0-3:1/4" to the kernel, it will correctly
reject it because it refers non-possible CPUs. When you pass the same
as nodelist, the kernel would accept the request because it checks user
input against (quite random) MAX_NUMNODES, not nr_node_ids.

The worst part is that if you decide to trim MAX_NUMNODES to the
actual number of possible nodes on your machine, you'll have the same
nodelist rejected after reboot.

> > Is MAX_NUMNODES retained and used for something else? How do the configs change?

In kernel it's only used for nodemasks. Kernel config is unchanged.

It's not exposed to user via kernel headers, only with NODES_SHIFT
config. User can also check Mems_allowed in /proc/<pid>/status to
calculate the possible nodes.

Before c4f392a35c4f39ebb2c ("nodemask: reduce bitmap width to nr_node_ids
in __nodemask_pr_numnodes()") it printed the nodemask based on
MAX_NUMNODES. Now it's switched to nr_node_ids.

> > What testing did you do? I do worry about somebody somewhere making assumptions
> > about MAX_NR_NODES that this potentially breaks.

Check this for testing:

https://lore.kernel.org/all/aw8XThqaTZg_yJWR@yury/

I ran my AI against all popular distros and apps to check if they
refer MAX_NUMNODES, CONFIG_NODES_SHIFT or check /proc for
Mems_allowed.

Some container (Kubernetes IIRC) refers Mems_allowed, but it's already
switched, and nobody complained. Some apps have wrappers around cpuset
interface etc., but nobody explicitly makes requests based on
MAX_NUMNODES.

> > Also can hot-onlining CPUs or weird CXL stuff break anything here? Do the locks
> > suffice etc.?

nr_node_ids is set at system boot. Neither hotplug nor CXL can't
change it.

> > Asking claude to dig in it seems like it doesn't touch anything like that, also
> > probably worth saying that in the cover letter too.

Codex agreed.


  reply	other threads:[~2026-12-02 22:02 UTC|newest]

Thread overview: 43+ 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-12-01 10:01   ` David Hildenbrand (Arm)
2026-11-27 23:01 ` [PATCH 02/11] nodemask: pass nodemask length to node search functions Yury Norov
2026-12-01 10:02   ` David Hildenbrand (Arm)
2026-11-27 23:01 ` [PATCH 03/11] mm/mempolicy: reject migrate_pages source IDs beyond nr_node_ids Yury Norov
2026-11-30 19:44   ` Gregory Price (Meta)
2026-12-01 10:02     ` David Hildenbrand (Arm)
2026-12-01 20:45       ` Yury Norov
2026-11-27 23:01 ` [PATCH 04/11] mm/mempolicy: preserve full-width userspace nodemasks Yury Norov
2026-12-01 10:10   ` David Hildenbrand (Arm)
2026-12-01 21:05     ` Yury Norov
2026-11-27 23:01 ` [PATCH 05/11] mm: switch to runtime nodemask length Yury Norov
2026-12-01  9:57   ` David Hildenbrand (Arm)
2026-11-27 23:01 ` [PATCH 06/11] MIPS: IP27: switch nmi_dump " Yury Norov
2026-12-01  9:58   ` David Hildenbrand (Arm)
2026-11-27 23:01 ` [PATCH 07/11] ACPI: NUMA: switch acpi_map_pxm_to_node " Yury Norov
2026-12-01  9:58   ` David Hildenbrand (Arm)
2026-11-27 23:01 ` [PATCH 08/11] mtip32xx: switch next_online_node() " Yury Norov
2026-12-01  9:58   ` David Hildenbrand (Arm)
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-27 23:01 ` [PATCH 11/11] nodemask: add cpumask-style operation size bounds Yury Norov
2026-11-30 19:59   ` Gregory Price (Meta)
2026-12-02  0:01     ` 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
2026-11-29  4:20     ` Andrew Morton
2026-11-29  4:21       ` Linus Torvalds
2026-11-29 22:05       ` Yury Norov
2026-12-01 14:51       ` Gregory Price (Meta)
2026-12-01 15:03         ` Lorenzo Stoakes (ARM)
2026-11-30 11:51 ` Lorenzo Stoakes (ARM)
2026-11-30 12:17   ` David Hildenbrand (Arm)
2026-11-30 16:32     ` Yury Norov
2026-11-30 16:42       ` Lorenzo Stoakes (ARM)
2026-11-30 17:28         ` Yury Norov
2026-11-30 12:20   ` Lorenzo Stoakes (ARM)
2026-12-02 20:50     ` Lorenzo Stoakes (ARM)
2026-12-02 22:02       ` Yury Norov [this message]
2026-11-30 16:48 ` Joshua Hahn
2026-11-30 19:18   ` Joshua Hahn
2026-12-02  0:35     ` Yury Norov

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=axCVcR5O9JY8cQUi@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