From: Yury Norov <ynorov@nvidia.com>
To: 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
Cc: Yury Norov <ynorov@nvidia.com>,
"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: [PATCH 05/11] mm: switch to runtime nodemask length
Date: Fri, 27 Nov 2026 18:01:22 -0500 [thread overview]
Message-ID: <20261127230128.111933-6-ynorov@nvidia.com> (raw)
In-Reply-To: <20261127230128.111933-1-ynorov@nvidia.com>
In preparation for switching nodemask API to runtime nr_node_ids,
update the boundary checking conditions.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
mm/hugetlb_internal.h | 2 +-
mm/mempolicy.c | 20 ++++++++++----------
mm/mmzone.c | 2 +-
mm/vmscan.c | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/mm/hugetlb_internal.h b/mm/hugetlb_internal.h
index 1d2f870deccf..bcdff7485c8d 100644
--- a/mm/hugetlb_internal.h
+++ b/mm/hugetlb_internal.h
@@ -31,7 +31,7 @@ static inline bool hstate_is_gigantic_no_runtime(struct hstate *h)
static inline int next_node_allowed(int nid, nodemask_t *nodes_allowed)
{
nid = next_node_in(nid, *nodes_allowed);
- VM_BUG_ON(nid >= MAX_NUMNODES);
+ VM_BUG_ON(nid >= nr_node_ids);
return nid;
}
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index ed8b20b27753..d64d3e70a82e 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1123,7 +1123,7 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
current->mempolicy = new;
if (new && (new->mode == MPOL_INTERLEAVE ||
new->mode == MPOL_WEIGHTED_INTERLEAVE)) {
- current->il_prev = MAX_NUMNODES-1;
+ current->il_prev = nr_node_ids - 1;
current->il_weight = 0;
}
task_unlock(current);
@@ -2141,7 +2141,7 @@ static unsigned int weighted_interleave_nodes(struct mempolicy *policy)
node = next_node_in(node, policy->nodes);
if (read_mems_allowed_retry(cpuset_mems_cookie))
goto retry;
- if (node == MAX_NUMNODES)
+ if (node >= nr_node_ids)
return node;
current->il_prev = node;
current->il_weight = get_il_weight(node);
@@ -2162,7 +2162,7 @@ static unsigned int interleave_nodes(struct mempolicy *policy)
nid = next_node_in(current->il_prev, policy->nodes);
} while (read_mems_allowed_retry(cpuset_mems_cookie));
- if (nid < MAX_NUMNODES)
+ if (nid < nr_node_ids)
current->il_prev = nid;
return nid;
}
@@ -2261,7 +2261,7 @@ static unsigned int weighted_interleave_nid(struct mempolicy *pol, pgoff_t ilx)
* Clamp this loop to a single pass (nnodes) to keep the walk
* bounded by node count.
*/
- while (target && nnodes-- && nid < MAX_NUMNODES) {
+ while (target && nnodes-- && nid < nr_node_ids) {
/* detect system default usage */
weight = table ? table[nid] : 1;
if (target < weight)
@@ -2272,7 +2272,7 @@ static unsigned int weighted_interleave_nid(struct mempolicy *pol, pgoff_t ilx)
rcu_read_unlock();
/* the mask emptied under the walk */
- if (nid >= MAX_NUMNODES)
+ if (nid >= nr_node_ids)
return numa_node_id();
return nid;
}
@@ -2295,11 +2295,11 @@ static unsigned int interleave_nid(struct mempolicy *pol, pgoff_t ilx)
nid = first_node(pol->nodes);
/* A concurrent cpuset rebind may cause us to see an empty nodemask */
- for (i = 0; i < target && nid < MAX_NUMNODES; i++)
+ for (i = 0; i < target && nid < nr_node_ids; i++)
nid = next_node_in(nid, pol->nodes);
/* the mask emptied under the walk */
- if (nid >= MAX_NUMNODES)
+ if (nid >= nr_node_ids)
return numa_node_id();
return nid;
}
@@ -2697,7 +2697,7 @@ static unsigned long alloc_pages_bulk_weighted_interleave(gfp_t gfp,
unsigned int weight_total = 0;
unsigned long rem_pages = nr_pages;
int nnodes, node;
- int resume_node = MAX_NUMNODES - 1;
+ int resume_node = nr_node_ids - 1;
u8 resume_weight = 0;
int prev_node;
int i;
@@ -2759,12 +2759,12 @@ static unsigned long alloc_pages_bulk_weighted_interleave(gfp_t gfp,
rounds = rem_pages / weight_total;
delta = rem_pages % weight_total;
resume_node = next_node_in(prev_node, pol->nodes);
- if (resume_node >= MAX_NUMNODES)
+ if (resume_node >= nr_node_ids)
goto out;
resume_weight = table ? table[resume_node] : 1;
for (i = 0; i < nnodes; i++) {
node = next_node_in(prev_node, pol->nodes);
- if (node >= MAX_NUMNODES)
+ if (node >= nr_node_ids)
break;
weight = table ? table[node] : 1;
node_pages = weight * rounds;
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 65880396f104..2c96341ad7e0 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -19,7 +19,7 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
{
int nid = next_online_node(pgdat->node_id);
- if (nid == MAX_NUMNODES)
+ if (nid >= nr_node_ids)
return NULL;
return NODE_DATA(nid);
}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6a1af9b92349..7d78181946b7 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5751,7 +5751,7 @@ static void *lru_gen_seq_next(struct seq_file *m, void *v, loff_t *pos)
++*pos;
nid = next_memory_node(nid);
- if (nid == MAX_NUMNODES) {
+ if (nid >= nr_node_ids) {
memcg = mem_cgroup_iter(NULL, memcg, NULL);
if (!memcg)
return NULL;
--
2.53.0
next prev parent reply other threads:[~2026-11-27 23:02 UTC|newest]
Thread overview: 12+ 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 ` Yury Norov [this message]
2026-11-27 23:01 ` [PATCH 06/11] MIPS: IP27: switch nmi_dump to runtime nodemask length 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-27 23:01 ` [PATCH 11/11] nodemask: add cpumask-style operation size bounds 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=20261127230128.111933-6-ynorov@nvidia.com \
--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