linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 1/2] mm/memblock: use NUMA_NO_NODE instead of MAX_NUMNODES as default node_id
Date: Thu, 9 Mar 2017 11:44:15 +0800	[thread overview]
Message-ID: <20170309034415.GA16588@WeideMacBook-Pro.local> (raw)
In-Reply-To: <20170127015922.36249-1-richard.weiyang@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4454 bytes --]

Hello, everyone,

By deeper thinking, I am willing to split these two patches into two patch
set, since they are trying to address two different things.

The first one [Patch 1] is trying to use NUMA_NO_NODE as the default node_id in
memblock_region.

Current implementation use MAX_NUMNODES as the default nid in several
situations:

    * when it adds a range from e820 to memblock 
    * when it returns an allocated range, it sets nid to MAX_NUMNODES 
    * on x86 before initialize the numa info, it set all nid to MAX_NUMNODES

The usage of MAX_NUMNODES here is not accurate, and NUMA_NO_NODE should be
used here.

When looking at the allocation procedure of memblock, it translate
MAX_NUMNODES to NUMA_NO_NODE and mentioned MAX_NUMNODES is deprecated. So I
think it is reasonable to do this refactor here.

The second one [Patch 2] is trying to address similar issue in
for_each_mem_pfn_range(). The patch here is the first step. I have searched
out all related functions and relpaces MAX_NUMNODES with NUMA_NO_NODE. While
the warning here will still be seen when just this patch applies. While after
all patches applied, we won't see the warning again.

Hmm... it looks like some dirty work, while I still think it worth the efforts
to use the correct macro.

Willing to get some feedback :-)


On Fri, Jan 27, 2017 at 09:59:21AM +0800, Wei Yang wrote:
>According to commit <b115423357e0> ('mm/memblock: switch to use
>NUMA_NO_NODE instead of MAX_NUMNODES'), MAX_NUMNODES is not preferred as an
>node_id indicator.
>
>This patch use NUMA_NO_NODE as the default node_id for memblock.
>
>Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>---
> arch/x86/mm/numa.c | 6 +++---
> mm/memblock.c      | 8 ++++----
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
>index 3f35b48d1d9d..4366242356c5 100644
>--- a/arch/x86/mm/numa.c
>+++ b/arch/x86/mm/numa.c
>@@ -506,7 +506,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
> 	 *   reserve specific pages for Sandy Bridge graphics. ]
> 	 */
> 	for_each_memblock(reserved, mb_region) {
>-		if (mb_region->nid != MAX_NUMNODES)
>+		if (mb_region->nid != NUMA_NO_NODE)
> 			node_set(mb_region->nid, reserved_nodemask);
> 	}
> 
>@@ -633,9 +633,9 @@ static int __init numa_init(int (*init_func)(void))
> 	nodes_clear(node_online_map);
> 	memset(&numa_meminfo, 0, sizeof(numa_meminfo));
> 	WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory,
>-				  MAX_NUMNODES));
>+				  NUMA_NO_NODE));
> 	WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved,
>-				  MAX_NUMNODES));
>+				  NUMA_NO_NODE));
> 	/* In case that parsing SRAT failed. */
> 	WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX));
> 	numa_reset_distance();
>diff --git a/mm/memblock.c b/mm/memblock.c
>index d0f2c9632187..7d27566cee11 100644
>--- a/mm/memblock.c
>+++ b/mm/memblock.c
>@@ -292,7 +292,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
> 		type->regions[0].base = 0;
> 		type->regions[0].size = 0;
> 		type->regions[0].flags = 0;
>-		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
>+		memblock_set_region_node(&type->regions[0], NUMA_NO_NODE);
> 	}
> }
> 
>@@ -616,7 +616,7 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)
> 		     (unsigned long long)base + size - 1,
> 		     0UL, (void *)_RET_IP_);
> 
>-	return memblock_add_range(&memblock.memory, base, size, MAX_NUMNODES, 0);
>+	return memblock_add_range(&memblock.memory, base, size, NUMA_NO_NODE, 0);
> }
> 
> /**
>@@ -734,7 +734,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
> 		     (unsigned long long)base + size - 1,
> 		     0UL, (void *)_RET_IP_);
> 
>-	return memblock_add_range(&memblock.reserved, base, size, MAX_NUMNODES, 0);
>+	return memblock_add_range(&memblock.reserved, base, size, NUMA_NO_NODE, 0);
> }
> 
> /**
>@@ -1684,7 +1684,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type, char *name
> 		size = rgn->size;
> 		flags = rgn->flags;
> #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
>-		if (memblock_get_region_node(rgn) != MAX_NUMNODES)
>+		if (memblock_get_region_node(rgn) != NUMA_NO_NODE)
> 			snprintf(nid_buf, sizeof(nid_buf), " on node %d",
> 				 memblock_get_region_node(rgn));
> #endif
>-- 
>2.11.0

-- 
Wei Yang
Help you, Help me

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2017-03-09  3:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27  1:59 [PATCH 1/2] mm/memblock: use NUMA_NO_NODE instead of MAX_NUMNODES as default node_id Wei Yang
2017-01-27  1:59 ` [PATCH 2/2] mm/memblock: switch to use NUMA_NO_NODE instead of MAX_NUMNODES in for_each_mem_pfn_range() Wei Yang
2017-02-03  1:44   ` [lkp-robot] [mm/memblock] cc4a913fa5: WARNING:at_mm/memblock.c:#__next_mem_pfn_range kernel test robot
2017-02-04 16:27     ` Wei Yang
2017-02-06  1:46       ` Ye Xiaolong
2017-02-06 15:12         ` Wei Yang
2017-02-04 16:45     ` Wei Yang
2017-02-28  7:00 ` [PATCH 1/2] mm/memblock: use NUMA_NO_NODE instead of MAX_NUMNODES as default node_id Wei Yang
2017-03-09  3:44 ` Wei Yang [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=20170309034415.GA16588@WeideMacBook-Pro.local \
    --to=richard.weiyang@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).