All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: rppt@kernel.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Sang-Heon Jeon <ekffu200098@gmail.com>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Danilo Krummrich <dakr@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>
Subject: [PATCH v2 1/9] mm: numa_memblks: set numa_nodes_parsed in numa_add_memblk()
Date: Fri,  3 Jul 2026 13:13:21 +0900	[thread overview]
Message-ID: <20260703041329.2797584-2-ekffu200098@gmail.com> (raw)
In-Reply-To: <20260703041329.2797584-1-ekffu200098@gmail.com>

Every existing numa_add_memblk() caller separately marks the new node in
numa_nodes_parsed with node_set().  Set the node in numa_add_memblk() itself
on a successful add, so this no longer depends on each caller.

numa_add_memblk_to() now returns -EINVAL for an out-of-range node id, so a
zero return implies @nid was valid.  No caller passes an invalid one, so
existing callers are unaffected.

The per-caller node_set() calls are removed in later patches.

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
 mm/numa_memblks.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index 3c3c4eac3514..9815192549c3 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -135,13 +135,20 @@ EXPORT_SYMBOL(__node_distance);
 static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
 				     struct numa_meminfo *mi)
 {
+	/* whine about and ignore invalid nid */
+	if (nid < 0 || nid >= MAX_NUMNODES) {
+		pr_warn("Warning: invalid memblk node id %d [mem %#010Lx-%#010Lx]\n",
+			nid, start, end - 1);
+		return -EINVAL;
+	}
+
 	/* ignore zero length blks */
 	if (start == end)
 		return 0;
 
 	/* whine about and ignore invalid blks */
-	if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
-		pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
+	if (start > end) {
+		pr_warn("Warning: invalid memblk node size %d [mem %#010Lx-%#010Lx]\n",
 			nid, start, end - 1);
 		return 0;
 	}
@@ -193,13 +200,20 @@ static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx,
  * @end: End address of the new memblk
  *
  * Add a new memblk to the default numa_meminfo.
+ * On success @nid is also set in numa_nodes_parsed.
  *
  * RETURNS:
  * 0 on success, -errno on failure.
  */
 int __init numa_add_memblk(int nid, u64 start, u64 end)
 {
-	return numa_add_memblk_to(nid, start, end, &numa_meminfo);
+	int ret;
+
+	ret = numa_add_memblk_to(nid, start, end, &numa_meminfo);
+	if (!ret)
+		node_set(nid, numa_nodes_parsed);
+
+	return ret;
 }
 
 /**
-- 
2.43.0



  reply	other threads:[~2026-07-03  4:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03  4:13 [PATCH v2 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
2026-07-03  4:13 ` Sang-Heon Jeon [this message]
2026-07-03  4:13 ` [PATCH v2 2/9] ACPI: NUMA: remove redundant numa_nodes_parsed node_set() Sang-Heon Jeon
2026-07-06 17:57   ` Rafael J. Wysocki (Intel)
2026-07-07  5:42     ` Mike Rapoport
2026-07-03  4:13 ` [PATCH v2 3/9] of/numa: " Sang-Heon Jeon
2026-07-03  4:27   ` sashiko-bot
2026-07-03  4:51     ` Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 4/9] x86/numa: " Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 5/9] arch_numa: " Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 6/9] LoongArch: " Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 7/9] mm: numa_memblks: remove redundant numa_nodemask_from_meminfo() Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 8/9] arch_numa: remove redundant node_possible_map assignment Sang-Heon Jeon
2026-07-03  4:13 ` [PATCH v2 9/9] mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo() Sang-Heon Jeon
2026-07-03  9:43 ` [PATCH v2 0/9] treewide, numa_memblks: remove redundant work during NUMA init Mike Rapoport

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=20260703041329.2797584-2-ekffu200098@gmail.com \
    --to=ekffu200098@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=chenhuacai@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rppt@kernel.org \
    --cc=saravanak@kernel.org \
    --cc=tglx@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.