linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: 20230519105321.333-1-ssawgyw@gmail.com,
	Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, tsahu@linux.ibm.com,
	ssawgyw@gmail.com, Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: Re: [PATCH] memblock: update numa node of memblk reserved type
Date: Wed, 24 May 2023 10:29:36 +0530	[thread overview]
Message-ID: <03cdccc3-8b8a-d972-bbad-d60966e59ca9@arm.com> (raw)
In-Reply-To: <20230523115708.195597-1-wangkefeng.wang@huawei.com>



On 5/23/23 17:27, Kefeng Wang wrote:
> The numa node of memblk reserved type is wrong, it could update
> according to the numa node information from memblk memory type,
> let's fix it.

Indeed it's wrong at present and can be verified from sysfs file
(/sys/kernel/debug/memblock/reserved) accessed in user space.

> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/memblock.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index a50447d970ef..45a0781cda31 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1922,6 +1922,28 @@ phys_addr_t __init_memblock memblock_get_current_limit(void)
>  	return memblock.current_limit;
>  }
>  
> +static void __init_memblock memblock_reserved_update_node(void)
> +{
> +	struct memblock_region *rgn;
> +	phys_addr_t base, end, size;
> +	int ret;
> +
> +	if (!IS_ENABLED(CONFIG_NUMA))
> +		return;
> +
> +	for_each_mem_region(rgn) {
> +		base = rgn->base;
> +		size = rgn->size;
> +		end = base + size - 1;
> +
> +		ret = memblock_set_node(base, size, &memblock.reserved,
> +					memblock_get_region_node(rgn));
> +		if (ret)
> +			pr_err("memblock: Failed to update reserved [%pa-%pa] node",
> +			       &base, &end);
> +	}
> +}
> +
>  static void __init_memblock memblock_dump(struct memblock_type *type)
>  {
>  	phys_addr_t base, end, size;
> @@ -1955,6 +1977,7 @@ static void __init_memblock __memblock_dump_all(void)
>  		&memblock.memory.total_size,
>  		&memblock.reserved.total_size);
>  
> +	memblock_reserved_update_node();

__memblock_dump_all() gets called only when memblock_debug is enabled.
This helper should be called directly inside memblock_dump_all() right
at the beginning, regardless of memblock_debug.

diff --git a/mm/memblock.c b/mm/memblock.c
index 804fae92d56f..008c4e86d7f3 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1954,7 +1954,6 @@ static void __init_memblock __memblock_dump_all(void)
                &memblock.memory.total_size,
                &memblock.reserved.total_size);
 
-       memblock_reserved_update_node();
        memblock_dump(&memblock.memory);
        memblock_dump(&memblock.reserved);
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
@@ -1964,6 +1963,8 @@ static void __init_memblock __memblock_dump_all(void)
 
 void __init_memblock memblock_dump_all(void)
 {
+       memblock_reserved_update_node();
+
        if (memblock_debug)
                __memblock_dump_all();
 }

>  	memblock_dump(&memblock.memory);
>  	memblock_dump(&memblock.reserved);
>  #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
> @@ -2196,6 +2219,8 @@ static int memblock_debug_show(struct seq_file *m, void *private)
>  	unsigned int count = ARRAY_SIZE(flagname);
>  	phys_addr_t end;
>  
> +	memblock_reserved_update_node();
> +

This is redundant, should be dropped. Reserved memblock ranges need not
be scanned, each time the sysfs file is accessed from user space.

>  	for (i = 0; i < type->cnt; i++) {
>  		reg = &type->regions[i];
>  		end = reg->base + reg->size - 1;


  reply	other threads:[~2023-05-24  4:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 11:57 Kefeng Wang
2023-05-24  4:59 ` Anshuman Khandual [this message]
2023-05-24  6:47   ` Kefeng Wang
2023-05-24 15:33     ` Mike Rapoport
2023-05-25  1:28       ` Kefeng Wang

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=03cdccc3-8b8a-d972-bbad-d60966e59ca9@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=20230519105321.333-1-ssawgyw@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    --cc=ssawgyw@gmail.com \
    --cc=tsahu@linux.ibm.com \
    --cc=wangkefeng.wang@huawei.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