* [PATCH] arm64: Use correct method to calculate nomap region boundaries @ 2021-10-22 7:06 Huacai Chen 2021-10-27 8:35 ` Huacai Chen ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Huacai Chen @ 2021-10-22 7:06 UTC (permalink / raw) To: Catalin Marinas, Will Deacon, Arnd Bergmann Cc: linux-arm-kernel, Huacai Chen, Jiaxun Yang, Huacai Chen Nomap regions are treated as "reserved". When region boundaries are not page aligned, we usually increase the "reserved" regions rather than decrease them. So, we should use memblock_region_reserved_base_pfn()/ memblock_region_reserved_end_pfn() instead of memblock_region_memory_ base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> --- arch/arm64/kernel/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index be5f85b0a24d..1e86d4c5ef8c 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) if (memblock_is_nomap(region)) { res->name = "reserved"; res->flags = IORESOURCE_MEM; + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; } else { res->name = "System RAM"; res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; } - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; request_resource(&iomem_resource, res); -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-10-22 7:06 [PATCH] arm64: Use correct method to calculate nomap region boundaries Huacai Chen @ 2021-10-27 8:35 ` Huacai Chen 2021-11-01 1:53 ` Guo Ren 2021-12-02 10:08 ` Will Deacon 2022-01-05 18:20 ` Catalin Marinas 2 siblings, 1 reply; 11+ messages in thread From: Huacai Chen @ 2021-10-27 8:35 UTC (permalink / raw) To: Huacai Chen, guoren Cc: Catalin Marinas, Will Deacon, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang Ping? On Fri, Oct 22, 2021 at 3:07 PM Huacai Chen <chenhuacai@loongson.cn> wrote: > > Nomap regions are treated as "reserved". When region boundaries are not > page aligned, we usually increase the "reserved" regions rather than > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > --- > arch/arm64/kernel/setup.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > index be5f85b0a24d..1e86d4c5ef8c 100644 > --- a/arch/arm64/kernel/setup.c > +++ b/arch/arm64/kernel/setup.c > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > if (memblock_is_nomap(region)) { > res->name = "reserved"; > res->flags = IORESOURCE_MEM; > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > } else { > res->name = "System RAM"; > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > } > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > request_resource(&iomem_resource, res); > > -- > 2.27.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-10-27 8:35 ` Huacai Chen @ 2021-11-01 1:53 ` Guo Ren 2021-11-07 10:10 ` Huacai Chen 0 siblings, 1 reply; 11+ messages in thread From: Guo Ren @ 2021-11-01 1:53 UTC (permalink / raw) To: Huacai Chen Cc: Huacai Chen, Catalin Marinas, Will Deacon, Arnd Bergmann, Linux ARM, Jiaxun Yang The real reserved memory have been initialized before in for_each_reserved_mem_region loop. If memblock_is_nomap still uses memblock_region_reserved, than it would cause overlap with reserved_mem_region. nomap_region: PFN_DOWN <-> PFN_UP reserved_region: PFN_DOWN <-> PFN_UP We would get overlapped reserved_mem_region. On Wed, Oct 27, 2021 at 4:35 PM Huacai Chen <chenhuacai@gmail.com> wrote: > > Ping? > > On Fri, Oct 22, 2021 at 3:07 PM Huacai Chen <chenhuacai@loongson.cn> wrote: > > > > Nomap regions are treated as "reserved". When region boundaries are not > > page aligned, we usually increase the "reserved" regions rather than > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > --- > > arch/arm64/kernel/setup.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > --- a/arch/arm64/kernel/setup.c > > +++ b/arch/arm64/kernel/setup.c > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > if (memblock_is_nomap(region)) { > > res->name = "reserved"; > > res->flags = IORESOURCE_MEM; > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > } else { > > res->name = "System RAM"; > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > } > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > request_resource(&iomem_resource, res); > > > > -- > > 2.27.0 > > -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-11-01 1:53 ` Guo Ren @ 2021-11-07 10:10 ` Huacai Chen 0 siblings, 0 replies; 11+ messages in thread From: Huacai Chen @ 2021-11-07 10:10 UTC (permalink / raw) To: Guo Ren Cc: Huacai Chen, Catalin Marinas, Will Deacon, Arnd Bergmann, Linux ARM, Jiaxun Yang Hi, Ren, On Mon, Nov 1, 2021 at 9:53 AM Guo Ren <guoren@kernel.org> wrote: > > The real reserved memory have been initialized before in > for_each_reserved_mem_region loop. If memblock_is_nomap still uses > memblock_region_reserved, than it would cause overlap with > reserved_mem_region. > > nomap_region: PFN_DOWN <-> PFN_UP > reserved_region: PFN_DOWN <-> PFN_UP > > We would get overlapped reserved_mem_region. Nomap regions are subsets of memory regions. And memory regions are already "decreased" to page-aligned regions. So, nomap regions will not exceed memory regions and overlap with reserved regions. In fact, unaligned nomap regions come from memblock_mark_nomap() with unaligned size. Huacai > > On Wed, Oct 27, 2021 at 4:35 PM Huacai Chen <chenhuacai@gmail.com> wrote: > > > > Ping? > > > > On Fri, Oct 22, 2021 at 3:07 PM Huacai Chen <chenhuacai@loongson.cn> wrote: > > > > > > Nomap regions are treated as "reserved". When region boundaries are not > > > page aligned, we usually increase the "reserved" regions rather than > > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > > --- > > > arch/arm64/kernel/setup.c | 6 ++++-- > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > > --- a/arch/arm64/kernel/setup.c > > > +++ b/arch/arm64/kernel/setup.c > > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > > if (memblock_is_nomap(region)) { > > > res->name = "reserved"; > > > res->flags = IORESOURCE_MEM; > > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > > } else { > > > res->name = "System RAM"; > > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > } > > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > > request_resource(&iomem_resource, res); > > > > > > -- > > > 2.27.0 > > > > > > > -- > Best Regards > Guo Ren > > ML: https://lore.kernel.org/linux-csky/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-10-22 7:06 [PATCH] arm64: Use correct method to calculate nomap region boundaries Huacai Chen 2021-10-27 8:35 ` Huacai Chen @ 2021-12-02 10:08 ` Will Deacon 2021-12-06 4:46 ` Huacai Chen 2022-01-05 18:20 ` Catalin Marinas 2 siblings, 1 reply; 11+ messages in thread From: Will Deacon @ 2021-12-02 10:08 UTC (permalink / raw) To: Huacai Chen Cc: Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Huacai Chen, Jiaxun Yang, ardb On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > Nomap regions are treated as "reserved". When region boundaries are not > page aligned, we usually increase the "reserved" regions rather than > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > --- > arch/arm64/kernel/setup.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > index be5f85b0a24d..1e86d4c5ef8c 100644 > --- a/arch/arm64/kernel/setup.c > +++ b/arch/arm64/kernel/setup.c > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > if (memblock_is_nomap(region)) { > res->name = "reserved"; > res->flags = IORESOURCE_MEM; > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > } else { > res->name = "System RAM"; > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > } > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; Under which circumstances would the nomap regions not be page-aligned? That sounds like something we should prevent, rather than work around here. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-12-02 10:08 ` Will Deacon @ 2021-12-06 4:46 ` Huacai Chen 2021-12-13 19:07 ` Will Deacon 0 siblings, 1 reply; 11+ messages in thread From: Huacai Chen @ 2021-12-06 4:46 UTC (permalink / raw) To: Will Deacon Cc: Huacai Chen, Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang, Ard Biesheuvel Hi, Will On Thu, Dec 2, 2021 at 6:08 PM Will Deacon <will@kernel.org> wrote: > > On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > > Nomap regions are treated as "reserved". When region boundaries are not > > page aligned, we usually increase the "reserved" regions rather than > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > --- > > arch/arm64/kernel/setup.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > --- a/arch/arm64/kernel/setup.c > > +++ b/arch/arm64/kernel/setup.c > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > if (memblock_is_nomap(region)) { > > res->name = "reserved"; > > res->flags = IORESOURCE_MEM; > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > } else { > > res->name = "System RAM"; > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > } > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > Under which circumstances would the nomap regions not be page-aligned? That > sounds like something we should prevent, rather than work around here. In this call path: acpi_table_upgrade --> arch_reserve_mem_area --> memblock_mark_nomap The nomap region is not page-aligned. Huacai > > Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-12-06 4:46 ` Huacai Chen @ 2021-12-13 19:07 ` Will Deacon 2021-12-14 0:50 ` Huacai Chen 0 siblings, 1 reply; 11+ messages in thread From: Will Deacon @ 2021-12-13 19:07 UTC (permalink / raw) To: Huacai Chen Cc: Huacai Chen, Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang, Ard Biesheuvel, mark.rutland On Mon, Dec 06, 2021 at 12:46:27PM +0800, Huacai Chen wrote: > On Thu, Dec 2, 2021 at 6:08 PM Will Deacon <will@kernel.org> wrote: > > On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > > > Nomap regions are treated as "reserved". When region boundaries are not > > > page aligned, we usually increase the "reserved" regions rather than > > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > > --- > > > arch/arm64/kernel/setup.c | 6 ++++-- > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > > --- a/arch/arm64/kernel/setup.c > > > +++ b/arch/arm64/kernel/setup.c > > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > > if (memblock_is_nomap(region)) { > > > res->name = "reserved"; > > > res->flags = IORESOURCE_MEM; > > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > > } else { > > > res->name = "System RAM"; > > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > } > > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > Under which circumstances would the nomap regions not be page-aligned? That > > sounds like something we should prevent, rather than work around here. > > In this call path: > acpi_table_upgrade --> arch_reserve_mem_area --> memblock_mark_nomap > The nomap region is not page-aligned. Fair enough, then I think this patch is probably doing the right thing. However, Ard and Mark had some concerns about the new behaviour wrt adjacent nomap regions where the page containing the overlap would be reported twice. Is this a problem? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-12-13 19:07 ` Will Deacon @ 2021-12-14 0:50 ` Huacai Chen 2021-12-14 14:11 ` Will Deacon 0 siblings, 1 reply; 11+ messages in thread From: Huacai Chen @ 2021-12-14 0:50 UTC (permalink / raw) To: Will Deacon Cc: Huacai Chen, Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang, Ard Biesheuvel, Mark Rutland Hi, Will, On Tue, Dec 14, 2021 at 3:07 AM Will Deacon <will@kernel.org> wrote: > > On Mon, Dec 06, 2021 at 12:46:27PM +0800, Huacai Chen wrote: > > On Thu, Dec 2, 2021 at 6:08 PM Will Deacon <will@kernel.org> wrote: > > > On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > > > > Nomap regions are treated as "reserved". When region boundaries are not > > > > page aligned, we usually increase the "reserved" regions rather than > > > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > > > --- > > > > arch/arm64/kernel/setup.c | 6 ++++-- > > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > > > --- a/arch/arm64/kernel/setup.c > > > > +++ b/arch/arm64/kernel/setup.c > > > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > > > if (memblock_is_nomap(region)) { > > > > res->name = "reserved"; > > > > res->flags = IORESOURCE_MEM; > > > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > > > } else { > > > > res->name = "System RAM"; > > > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > } > > > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > > Under which circumstances would the nomap regions not be page-aligned? That > > > sounds like something we should prevent, rather than work around here. > > > > In this call path: > > acpi_table_upgrade --> arch_reserve_mem_area --> memblock_mark_nomap > > The nomap region is not page-aligned. > > Fair enough, then I think this patch is probably doing the right thing. > However, Ard and Mark had some concerns about the new behaviour wrt > adjacent nomap regions where the page containing the overlap would be > reported twice. Is this a problem? Seems no problem, in most cases, memblock_mark_nomap() --> memblock_merge_regions() --> memblock_merge_regions(), adjacent intesected regions will be merged. Then the only problem is two or more small regions not intersected but in a single page, I think this is hardly happen.. But, even if this actually happens, I think it can be handle by the later request_resource() and small regions will not be reported more than once. Huacai > > Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-12-14 0:50 ` Huacai Chen @ 2021-12-14 14:11 ` Will Deacon 2021-12-15 0:31 ` Huacai Chen 0 siblings, 1 reply; 11+ messages in thread From: Will Deacon @ 2021-12-14 14:11 UTC (permalink / raw) To: Huacai Chen Cc: Huacai Chen, Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang, Ard Biesheuvel, Mark Rutland On Tue, Dec 14, 2021 at 08:50:14AM +0800, Huacai Chen wrote: > Hi, Will, > > On Tue, Dec 14, 2021 at 3:07 AM Will Deacon <will@kernel.org> wrote: > > > > On Mon, Dec 06, 2021 at 12:46:27PM +0800, Huacai Chen wrote: > > > On Thu, Dec 2, 2021 at 6:08 PM Will Deacon <will@kernel.org> wrote: > > > > On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > > > > > Nomap regions are treated as "reserved". When region boundaries are not > > > > > page aligned, we usually increase the "reserved" regions rather than > > > > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > > > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > > > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > > > > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > > > > --- > > > > > arch/arm64/kernel/setup.c | 6 ++++-- > > > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > > > > --- a/arch/arm64/kernel/setup.c > > > > > +++ b/arch/arm64/kernel/setup.c > > > > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > > > > if (memblock_is_nomap(region)) { > > > > > res->name = "reserved"; > > > > > res->flags = IORESOURCE_MEM; > > > > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > > > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > > > > } else { > > > > > res->name = "System RAM"; > > > > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > } > > > > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > > > > Under which circumstances would the nomap regions not be page-aligned? That > > > > sounds like something we should prevent, rather than work around here. > > > > > > In this call path: > > > acpi_table_upgrade --> arch_reserve_mem_area --> memblock_mark_nomap > > > The nomap region is not page-aligned. > > > > Fair enough, then I think this patch is probably doing the right thing. > > However, Ard and Mark had some concerns about the new behaviour wrt > > adjacent nomap regions where the page containing the overlap would be > > reported twice. Is this a problem? > Seems no problem, in most cases, memblock_mark_nomap() --> > memblock_merge_regions() --> memblock_merge_regions(), adjacent > intesected regions will be merged. Then the only problem is two or > more small regions not intersected but in a single page, I think this > is hardly happen.. What happens _today_ if we run into that case? Does end get rounded down below start? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-12-14 14:11 ` Will Deacon @ 2021-12-15 0:31 ` Huacai Chen 0 siblings, 0 replies; 11+ messages in thread From: Huacai Chen @ 2021-12-15 0:31 UTC (permalink / raw) To: Will Deacon Cc: Huacai Chen, Catalin Marinas, Arnd Bergmann, linux-arm-kernel, Jiaxun Yang, Ard Biesheuvel, Mark Rutland Hi, Will, On Tue, Dec 14, 2021 at 10:11 PM Will Deacon <will@kernel.org> wrote: > > On Tue, Dec 14, 2021 at 08:50:14AM +0800, Huacai Chen wrote: > > Hi, Will, > > > > On Tue, Dec 14, 2021 at 3:07 AM Will Deacon <will@kernel.org> wrote: > > > > > > On Mon, Dec 06, 2021 at 12:46:27PM +0800, Huacai Chen wrote: > > > > On Thu, Dec 2, 2021 at 6:08 PM Will Deacon <will@kernel.org> wrote: > > > > > On Fri, Oct 22, 2021 at 03:06:46PM +0800, Huacai Chen wrote: > > > > > > Nomap regions are treated as "reserved". When region boundaries are not > > > > > > page aligned, we usually increase the "reserved" regions rather than > > > > > > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > > > > > > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > > > > > > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > > > > > > > > > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > > > > > > --- > > > > > > arch/arm64/kernel/setup.c | 6 ++++-- > > > > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > > > > index be5f85b0a24d..1e86d4c5ef8c 100644 > > > > > > --- a/arch/arm64/kernel/setup.c > > > > > > +++ b/arch/arm64/kernel/setup.c > > > > > > @@ -232,12 +232,14 @@ static void __init request_standard_resources(void) > > > > > > if (memblock_is_nomap(region)) { > > > > > > res->name = "reserved"; > > > > > > res->flags = IORESOURCE_MEM; > > > > > > + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); > > > > > > + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; > > > > > > } else { > > > > > > res->name = "System RAM"; > > > > > > res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > > > > + res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > > > + res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > > } > > > > > > - res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); > > > > > > - res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; > > > > > > > > > > Under which circumstances would the nomap regions not be page-aligned? That > > > > > sounds like something we should prevent, rather than work around here. > > > > > > > > In this call path: > > > > acpi_table_upgrade --> arch_reserve_mem_area --> memblock_mark_nomap > > > > The nomap region is not page-aligned. > > > > > > Fair enough, then I think this patch is probably doing the right thing. > > > However, Ard and Mark had some concerns about the new behaviour wrt > > > adjacent nomap regions where the page containing the overlap would be > > > reported twice. Is this a problem? > > Seems no problem, in most cases, memblock_mark_nomap() --> > > memblock_merge_regions() --> memblock_merge_regions(), adjacent > > intesected regions will be merged. Then the only problem is two or > > more small regions not intersected but in a single page, I think this > > is hardly happen.. > > What happens _today_ if we run into that case? Does end get rounded down > below start? Yes, the "end" will be below "start", and the small regions disappear in /proc/iomem. Huacai > > Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] arm64: Use correct method to calculate nomap region boundaries 2021-10-22 7:06 [PATCH] arm64: Use correct method to calculate nomap region boundaries Huacai Chen 2021-10-27 8:35 ` Huacai Chen 2021-12-02 10:08 ` Will Deacon @ 2022-01-05 18:20 ` Catalin Marinas 2 siblings, 0 replies; 11+ messages in thread From: Catalin Marinas @ 2022-01-05 18:20 UTC (permalink / raw) To: Huacai Chen, Will Deacon, Arnd Bergmann Cc: linux-arm-kernel, Huacai Chen, Jiaxun Yang On Fri, 22 Oct 2021 15:06:46 +0800, Huacai Chen wrote: > Nomap regions are treated as "reserved". When region boundaries are not > page aligned, we usually increase the "reserved" regions rather than > decrease them. So, we should use memblock_region_reserved_base_pfn()/ > memblock_region_reserved_end_pfn() instead of memblock_region_memory_ > base_pfn()/memblock_region_memory_base_pfn() to calculate boundaries. > > > [...] Applied to arm64 (for-next/misc), thanks! [1/1] arm64: Use correct method to calculate nomap region boundaries https://git.kernel.org/arm64/c/daa149dd8cd4 -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-01-05 18:21 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-22 7:06 [PATCH] arm64: Use correct method to calculate nomap region boundaries Huacai Chen 2021-10-27 8:35 ` Huacai Chen 2021-11-01 1:53 ` Guo Ren 2021-11-07 10:10 ` Huacai Chen 2021-12-02 10:08 ` Will Deacon 2021-12-06 4:46 ` Huacai Chen 2021-12-13 19:07 ` Will Deacon 2021-12-14 0:50 ` Huacai Chen 2021-12-14 14:11 ` Will Deacon 2021-12-15 0:31 ` Huacai Chen 2022-01-05 18:20 ` Catalin Marinas
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.