* [PATCH] arm64: mm: Correct the update of max_pfn
@ 2025-03-21 7:00 Zhenhua Huang
2025-03-21 16:40 ` Catalin Marinas
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Zhenhua Huang @ 2025-03-21 7:00 UTC (permalink / raw)
To: anshuman.khandual, catalin.marinas, david, will, ryan.roberts,
mark.rutland, ardb, quic_zhenhuah, yangyicong, joey.gouly,
quic_cgoldswo, quic_sudaraja, akpm
Cc: linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: mm: Correct the update of max_pfn
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn Zhenhua Huang
@ 2025-03-21 16:40 ` Catalin Marinas
2025-03-22 5:18 ` David Hildenbrand
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-03-21 16:40 UTC (permalink / raw)
To: Zhenhua Huang
Cc: anshuman.khandual, david, will, ryan.roberts, mark.rutland, ardb,
yangyicong, joey.gouly, quic_cgoldswo, quic_sudaraja, akpm,
linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
On Fri, Mar 21, 2025 at 03:00:19PM +0800, 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;
> }
I think this makes sense and also matches what x86 does. I'll queue it
at -rc1 as a fix.
Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: mm: Correct the update of max_pfn
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn Zhenhua Huang
2025-03-21 16:40 ` Catalin Marinas
@ 2025-03-22 5:18 ` David Hildenbrand
2025-03-24 4:19 ` Anshuman Khandual
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2025-03-22 5:18 UTC (permalink / raw)
To: Zhenhua Huang, anshuman.khandual, catalin.marinas, will,
ryan.roberts, mark.rutland, ardb, yangyicong, joey.gouly,
quic_cgoldswo, quic_sudaraja, akpm
Cc: linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
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;
> }
>
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: mm: Correct the update of max_pfn
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn 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
2025-03-28 20:08 ` Catalin Marinas
4 siblings, 0 replies; 6+ messages in thread
From: Anshuman Khandual @ 2025-03-24 4:19 UTC (permalink / raw)
To: Zhenhua Huang, catalin.marinas, david, will, ryan.roberts,
mark.rutland, ardb, yangyicong, joey.gouly, quic_cgoldswo,
quic_sudaraja, akpm
Cc: linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
On 3/21/25 12:30, 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;
> }
>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: mm: Correct the update of max_pfn
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn Zhenhua Huang
` (2 preceding siblings ...)
2025-03-24 4:19 ` Anshuman Khandual
@ 2025-03-25 19:22 ` David Hildenbrand
2025-03-28 20:08 ` Catalin Marinas
4 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2025-03-25 19:22 UTC (permalink / raw)
To: Zhenhua Huang, anshuman.khandual, catalin.marinas, will,
ryan.roberts, mark.rutland, ardb, yangyicong, joey.gouly,
quic_cgoldswo, quic_sudaraja, akpm
Cc: linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: mm: Correct the update of max_pfn
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn Zhenhua Huang
` (3 preceding siblings ...)
2025-03-25 19:22 ` David Hildenbrand
@ 2025-03-28 20:08 ` Catalin Marinas
4 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-03-28 20:08 UTC (permalink / raw)
To: anshuman.khandual, david, will, ryan.roberts, mark.rutland, ardb,
yangyicong, joey.gouly, quic_cgoldswo, quic_sudaraja, akpm,
Zhenhua Huang
Cc: linux-mm, linux-arm-kernel, linux-kernel, quic_tingweiz
On Fri, 21 Mar 2025 15:00:19 +0800, 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.
>
> [...]
Applied to arm64 (for-next/core), thanks!
[1/1] arm64: mm: Correct the update of max_pfn
https://git.kernel.org/arm64/c/89f43e1ce6f6
--
Catalin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-28 20:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 7:00 [PATCH] arm64: mm: Correct the update of max_pfn 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
2025-03-28 20:08 ` Catalin Marinas
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).