linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Zhenhua Huang <quic_zhenhuah@quicinc.com>,
	anshuman.khandual@arm.com, catalin.marinas@arm.com,
	will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com,
	ardb@kernel.org, yangyicong@hisilicon.com, joey.gouly@arm.com,
	quic_cgoldswo@quicinc.com, quic_sudaraja@quicinc.com,
	akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, quic_tingweiz@quicinc.com
Subject: Re: [PATCH] arm64: mm: Correct the update of max_pfn
Date: Tue, 25 Mar 2025 20:22:02 +0100	[thread overview]
Message-ID: <1767a68b-cb2e-425c-86bb-bc8e5289ee99@redhat.com> (raw)
In-Reply-To: <20250321070019.1271859-1-quic_zhenhuah@quicinc.com>

On 21.03.25 08:00, Zhenhua Huang wrote:
> Hotplugged memory can be smaller than the original memory. For example,
> on my target:
> 
> root@genericarmv8:~# cat /sys/kernel/debug/memblock/memory
>     0: 0x0000000064005000..0x0000000064023fff    0 NOMAP
>     1: 0x0000000064400000..0x00000000647fffff    0 NOMAP
>     2: 0x0000000068000000..0x000000006fffffff    0 DRV_MNG
>     3: 0x0000000088800000..0x0000000094ffefff    0 NONE
>     4: 0x0000000094fff000..0x0000000094ffffff    0 NOMAP
> max_pfn will affect read_page_owner. Therefore, it should first compare and
> then select the larger value for max_pfn.
> 
> Fixes: 8fac67ca236b ("arm64: mm: update max_pfn after memory hotplug")
> Signed-off-by: Zhenhua Huang <quic_zhenhuah@quicinc.com>
> ---
>   arch/arm64/mm/mmu.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 1dfe1a8efdbe..310ff75891ef 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1361,7 +1361,8 @@ int arch_add_memory(int nid, u64 start, u64 size,
>   		__remove_pgd_mapping(swapper_pg_dir,
>   				     __phys_to_virt(start), size);
>   	else {
> -		max_pfn = PFN_UP(start + size);
> +		/* Address of hotplugged memory can be smaller */
> +		max_pfn = max(max_pfn, PFN_UP(start + size));
>   		max_low_pfn = max_pfn;
>   	}
>   

Yes, that's the right thing to do. (I always wonder if these values 
should be atomically updated ...)

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



  parent reply	other threads:[~2025-03-25 19:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21  7:00 Zhenhua Huang
2025-03-21 16:40 ` Catalin Marinas
2025-03-22  5:18 ` David Hildenbrand
2025-03-24  4:19 ` Anshuman Khandual
2025-03-25 19:22 ` David Hildenbrand [this message]
2025-03-28 20:08 ` Catalin Marinas

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=1767a68b-cb2e-425c-86bb-bc8e5289ee99@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=quic_cgoldswo@quicinc.com \
    --cc=quic_sudaraja@quicinc.com \
    --cc=quic_tingweiz@quicinc.com \
    --cc=quic_zhenhuah@quicinc.com \
    --cc=ryan.roberts@arm.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.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