Message ID | 20240202163433.786581-3-abrestic@rivosinc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 | expand |
On Fri, 2 Feb 2024 at 17:34, Andrew Bresticker <abrestic@rivosinc.com> wrote: > > Adding memblocks (even if nomap) for such regions unnecessarily consumes > resources by creating struct pages for memory that may never be used or, > in the case of soft-reserved regions, prevents the memory from later > being hotplugged in by dax_kmem. This is also consistent with how x86 > handles unusable memory found in the EFI memory map. > x86 doesn't care as much about memory vs device semantics as ARM does. This affects the output of memblock_is_[region_]memory(), so we'd have to double check that none of those uses get broken by this. If the soft reserved regions need to be omitted from memblock, we can deal with that separately perhaps, but changing it at this level seems inappropriate to me. > Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com> > --- > drivers/firmware/efi/efi-init.c | 12 +----------- > 1 file changed, 1 insertion(+), 11 deletions(-) > > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c > index d4987d013080..f05bacac89b7 100644 > --- a/drivers/firmware/efi/efi-init.c > +++ b/drivers/firmware/efi/efi-init.c > @@ -24,13 +24,6 @@ > > unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR; > > -static int __init is_memory(efi_memory_desc_t *md) > -{ > - if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)) > - return 1; > - return 0; > -} > - > /* > * Translate a EFI virtual address into a physical address: this is necessary, > * as some data members of the EFI system table are virtually remapped after > @@ -195,12 +188,9 @@ static __init void reserve_regions(void) > memrange_efi_to_native(&paddr, &npages); > size = npages << PAGE_SHIFT; > > - if (is_memory(md)) { > + if (is_usable_memory(md)) { > early_init_dt_add_memory_arch(paddr, size); > > - if (!is_usable_memory(md)) > - memblock_mark_nomap(paddr, size); > - > /* keep ACPI reclaim memory intact for kexec etc. */ > if (md->type == EFI_ACPI_RECLAIM_MEMORY) > memblock_reserve(paddr, size); > -- > 2.34.1 >
On Fri, Feb 2, 2024 at 11:45 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > On Fri, 2 Feb 2024 at 17:34, Andrew Bresticker <abrestic@rivosinc.com> wrote: > > > > Adding memblocks (even if nomap) for such regions unnecessarily consumes > > resources by creating struct pages for memory that may never be used or, > > in the case of soft-reserved regions, prevents the memory from later > > being hotplugged in by dax_kmem. This is also consistent with how x86 > > handles unusable memory found in the EFI memory map. > > > > x86 doesn't care as much about memory vs device semantics as ARM does. > > This affects the output of memblock_is_[region_]memory(), so we'd have > to double check that none of those uses get broken by this. > > If the soft reserved regions need to be omitted from memblock, we can > deal with that separately perhaps, but changing it at this level seems > inappropriate to me. Sure, I can constrain this to just the soft-reserved regions. -Andrew > > > > Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com> > > --- > > drivers/firmware/efi/efi-init.c | 12 +----------- > > 1 file changed, 1 insertion(+), 11 deletions(-) > > > > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c > > index d4987d013080..f05bacac89b7 100644 > > --- a/drivers/firmware/efi/efi-init.c > > +++ b/drivers/firmware/efi/efi-init.c > > @@ -24,13 +24,6 @@ > > > > unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR; > > > > -static int __init is_memory(efi_memory_desc_t *md) > > -{ > > - if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)) > > - return 1; > > - return 0; > > -} > > - > > /* > > * Translate a EFI virtual address into a physical address: this is necessary, > > * as some data members of the EFI system table are virtually remapped after > > @@ -195,12 +188,9 @@ static __init void reserve_regions(void) > > memrange_efi_to_native(&paddr, &npages); > > size = npages << PAGE_SHIFT; > > > > - if (is_memory(md)) { > > + if (is_usable_memory(md)) { > > early_init_dt_add_memory_arch(paddr, size); > > > > - if (!is_usable_memory(md)) > > - memblock_mark_nomap(paddr, size); > > - > > /* keep ACPI reclaim memory intact for kexec etc. */ > > if (md->type == EFI_ACPI_RECLAIM_MEMORY) > > memblock_reserve(paddr, size); > > -- > > 2.34.1 > >
diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index d4987d013080..f05bacac89b7 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -24,13 +24,6 @@ unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR; -static int __init is_memory(efi_memory_desc_t *md) -{ - if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)) - return 1; - return 0; -} - /* * Translate a EFI virtual address into a physical address: this is necessary, * as some data members of the EFI system table are virtually remapped after @@ -195,12 +188,9 @@ static __init void reserve_regions(void) memrange_efi_to_native(&paddr, &npages); size = npages << PAGE_SHIFT; - if (is_memory(md)) { + if (is_usable_memory(md)) { early_init_dt_add_memory_arch(paddr, size); - if (!is_usable_memory(md)) - memblock_mark_nomap(paddr, size); - /* keep ACPI reclaim memory intact for kexec etc. */ if (md->type == EFI_ACPI_RECLAIM_MEMORY) memblock_reserve(paddr, size);
Adding memblocks (even if nomap) for such regions unnecessarily consumes resources by creating struct pages for memory that may never be used or, in the case of soft-reserved regions, prevents the memory from later being hotplugged in by dax_kmem. This is also consistent with how x86 handles unusable memory found in the EFI memory map. Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com> --- drivers/firmware/efi/efi-init.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)