* [PATCH v2] xen/arm/efi: merge neighboring banks
@ 2025-03-27 23:16 Stefano Stabellini
2025-03-27 23:29 ` Volodymyr Babchuk
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Stabellini @ 2025-03-27 23:16 UTC (permalink / raw)
To: xen-devel
Cc: julien, sstabellini, bertrand.marquis, michal.orzel,
Volodymyr_Babchuk, Stefano Stabellini
When booting from U-Boot bootefi, there can be a high number of
neighboring RAM banks. See for example:
(XEN) RAM: 0000000000000000 - 0000000000bfffff
(XEN) RAM: 0000000000c00000 - 0000000000c00fff
(XEN) RAM: 0000000000c01000 - 0000000000dfffff
(XEN) RAM: 0000000000e00000 - 000000000279dfff
(XEN) RAM: 000000000279e000 - 00000000029fffff
(XEN) RAM: 0000000002a00000 - 0000000008379fff
(XEN) RAM: 000000000837a000 - 00000000083fffff
(XEN) RAM: 0000000008400000 - 0000000008518fff
(XEN) RAM: 0000000008519000 - 00000000085fffff
(XEN) RAM: 0000000008600000 - 0000000008613fff
(XEN) RAM: 0000000008614000 - 00000000097fffff
(XEN) RAM: 0000000009800000 - 00000000098a7fff
(XEN) RAM: 00000000098a8000 - 0000000009dfffff
(XEN) RAM: 0000000009e00000 - 0000000009ea7fff
(XEN) RAM: 0000000009ea8000 - 000000001fffffff
(XEN) RAM: 0000000020000000 - 000000002007ffff
(XEN) RAM: 0000000020080000 - 0000000077b17fff
(XEN) RAM: 0000000077b19000 - 0000000077b2bfff
(XEN) RAM: 0000000077b2c000 - 0000000077c8dfff
(XEN) RAM: 0000000077c8e000 - 0000000077c91fff
(XEN) RAM: 0000000077ca7000 - 0000000077caafff
(XEN) RAM: 0000000077cac000 - 0000000077caefff
(XEN) RAM: 0000000077cd0000 - 0000000077cd2fff
(XEN) RAM: 0000000077cd4000 - 0000000077cd7fff
(XEN) RAM: 0000000077cd8000 - 000000007bd07fff
(XEN) RAM: 000000007bd09000 - 000000007fd5ffff
(XEN) RAM: 000000007fd70000 - 000000007fefffff
(XEN) RAM: 0000000800000000 - 000000087fffffff
Xen does not currently support boot modules that span multiple banks: at
least one of the regions get freed twice. The first time from
setup_mm->populate_boot_allocator, then again from
discard_initial_modules->fw_unreserved_regions. With a high number of
banks, it can be difficult to arrange the boot modules in a way that
avoids spanning across multiple banks.
This small patch merges neighboring regions, to make dealing with them
more efficient, and to make it easier to load boot modules.
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
Changes in v2:
- remove unneeded check for duplicates
- unsigned int instead of int
- add parenthesis
---
xen/arch/arm/efi/efi-boot.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index a80a5a7ab3..8b8ef5dcfb 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -163,6 +163,16 @@ static bool __init meminfo_add_bank(struct membanks *mem,
struct membank *bank;
paddr_t start = desc->PhysicalStart;
paddr_t size = desc->NumberOfPages * EFI_PAGE_SIZE;
+ unsigned int j;
+
+ for ( j = 0; j < mem->nr_banks; j++ )
+ {
+ if ( (mem->bank[j].start + mem->bank[j].size) == start )
+ {
+ mem->bank[j].size += size;
+ return true;
+ }
+ }
if ( mem->nr_banks >= mem->max_banks )
return false;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] xen/arm/efi: merge neighboring banks
2025-03-27 23:16 [PATCH v2] xen/arm/efi: merge neighboring banks Stefano Stabellini
@ 2025-03-27 23:29 ` Volodymyr Babchuk
2025-03-28 21:32 ` Stefano Stabellini
0 siblings, 1 reply; 3+ messages in thread
From: Volodymyr Babchuk @ 2025-03-27 23:29 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel@lists.xenproject.org, julien@xen.org,
sstabellini@kernel.org, bertrand.marquis@arm.com,
michal.orzel@amd.com
Hi Stefano,
Stefano Stabellini <stefano.stabellini@amd.com> writes:
> When booting from U-Boot bootefi, there can be a high number of
> neighboring RAM banks. See for example:
>
> (XEN) RAM: 0000000000000000 - 0000000000bfffff
> (XEN) RAM: 0000000000c00000 - 0000000000c00fff
> (XEN) RAM: 0000000000c01000 - 0000000000dfffff
> (XEN) RAM: 0000000000e00000 - 000000000279dfff
> (XEN) RAM: 000000000279e000 - 00000000029fffff
> (XEN) RAM: 0000000002a00000 - 0000000008379fff
> (XEN) RAM: 000000000837a000 - 00000000083fffff
> (XEN) RAM: 0000000008400000 - 0000000008518fff
> (XEN) RAM: 0000000008519000 - 00000000085fffff
> (XEN) RAM: 0000000008600000 - 0000000008613fff
> (XEN) RAM: 0000000008614000 - 00000000097fffff
> (XEN) RAM: 0000000009800000 - 00000000098a7fff
> (XEN) RAM: 00000000098a8000 - 0000000009dfffff
> (XEN) RAM: 0000000009e00000 - 0000000009ea7fff
> (XEN) RAM: 0000000009ea8000 - 000000001fffffff
> (XEN) RAM: 0000000020000000 - 000000002007ffff
> (XEN) RAM: 0000000020080000 - 0000000077b17fff
> (XEN) RAM: 0000000077b19000 - 0000000077b2bfff
> (XEN) RAM: 0000000077b2c000 - 0000000077c8dfff
> (XEN) RAM: 0000000077c8e000 - 0000000077c91fff
> (XEN) RAM: 0000000077ca7000 - 0000000077caafff
> (XEN) RAM: 0000000077cac000 - 0000000077caefff
> (XEN) RAM: 0000000077cd0000 - 0000000077cd2fff
> (XEN) RAM: 0000000077cd4000 - 0000000077cd7fff
> (XEN) RAM: 0000000077cd8000 - 000000007bd07fff
> (XEN) RAM: 000000007bd09000 - 000000007fd5ffff
> (XEN) RAM: 000000007fd70000 - 000000007fefffff
> (XEN) RAM: 0000000800000000 - 000000087fffffff
>
> Xen does not currently support boot modules that span multiple banks: at
> least one of the regions get freed twice. The first time from
> setup_mm->populate_boot_allocator, then again from
> discard_initial_modules->fw_unreserved_regions. With a high number of
> banks, it can be difficult to arrange the boot modules in a way that
> avoids spanning across multiple banks.
>
> This small patch merges neighboring regions, to make dealing with them
> more efficient, and to make it easier to load boot modules.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> ---
> Changes in v2:
> - remove unneeded check for duplicates
> - unsigned int instead of int
> - add parenthesis
> ---
> xen/arch/arm/efi/efi-boot.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
> index a80a5a7ab3..8b8ef5dcfb 100644
> --- a/xen/arch/arm/efi/efi-boot.h
> +++ b/xen/arch/arm/efi/efi-boot.h
> @@ -163,6 +163,16 @@ static bool __init meminfo_add_bank(struct membanks *mem,
> struct membank *bank;
> paddr_t start = desc->PhysicalStart;
> paddr_t size = desc->NumberOfPages * EFI_PAGE_SIZE;
> + unsigned int j;
> +
> + for ( j = 0; j < mem->nr_banks; j++ )
> + {
> + if ( (mem->bank[j].start + mem->bank[j].size) == start )
> + {
> + mem->bank[j].size += size;
> + return true;
> + }
> + }
>
> if ( mem->nr_banks >= mem->max_banks )
> return false;
It didn't got into diff context, but there is this check below:
#ifdef CONFIG_ACPI
if ( check_reserved_regions_overlap(start, size, false) )
return false;
#endif
Your patch will skip it.
--
WBR, Volodymyr
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] xen/arm/efi: merge neighboring banks
2025-03-27 23:29 ` Volodymyr Babchuk
@ 2025-03-28 21:32 ` Stefano Stabellini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2025-03-28 21:32 UTC (permalink / raw)
To: Volodymyr Babchuk
Cc: Stefano Stabellini, xen-devel@lists.xenproject.org,
julien@xen.org, sstabellini@kernel.org, bertrand.marquis@arm.com,
michal.orzel@amd.com
On Thu, 27 Mar 2025, Volodymyr Babchuk wrote:
> Hi Stefano,
>
> Stefano Stabellini <stefano.stabellini@amd.com> writes:
>
> > When booting from U-Boot bootefi, there can be a high number of
> > neighboring RAM banks. See for example:
> >
> > (XEN) RAM: 0000000000000000 - 0000000000bfffff
> > (XEN) RAM: 0000000000c00000 - 0000000000c00fff
> > (XEN) RAM: 0000000000c01000 - 0000000000dfffff
> > (XEN) RAM: 0000000000e00000 - 000000000279dfff
> > (XEN) RAM: 000000000279e000 - 00000000029fffff
> > (XEN) RAM: 0000000002a00000 - 0000000008379fff
> > (XEN) RAM: 000000000837a000 - 00000000083fffff
> > (XEN) RAM: 0000000008400000 - 0000000008518fff
> > (XEN) RAM: 0000000008519000 - 00000000085fffff
> > (XEN) RAM: 0000000008600000 - 0000000008613fff
> > (XEN) RAM: 0000000008614000 - 00000000097fffff
> > (XEN) RAM: 0000000009800000 - 00000000098a7fff
> > (XEN) RAM: 00000000098a8000 - 0000000009dfffff
> > (XEN) RAM: 0000000009e00000 - 0000000009ea7fff
> > (XEN) RAM: 0000000009ea8000 - 000000001fffffff
> > (XEN) RAM: 0000000020000000 - 000000002007ffff
> > (XEN) RAM: 0000000020080000 - 0000000077b17fff
> > (XEN) RAM: 0000000077b19000 - 0000000077b2bfff
> > (XEN) RAM: 0000000077b2c000 - 0000000077c8dfff
> > (XEN) RAM: 0000000077c8e000 - 0000000077c91fff
> > (XEN) RAM: 0000000077ca7000 - 0000000077caafff
> > (XEN) RAM: 0000000077cac000 - 0000000077caefff
> > (XEN) RAM: 0000000077cd0000 - 0000000077cd2fff
> > (XEN) RAM: 0000000077cd4000 - 0000000077cd7fff
> > (XEN) RAM: 0000000077cd8000 - 000000007bd07fff
> > (XEN) RAM: 000000007bd09000 - 000000007fd5ffff
> > (XEN) RAM: 000000007fd70000 - 000000007fefffff
> > (XEN) RAM: 0000000800000000 - 000000087fffffff
> >
> > Xen does not currently support boot modules that span multiple banks: at
> > least one of the regions get freed twice. The first time from
> > setup_mm->populate_boot_allocator, then again from
> > discard_initial_modules->fw_unreserved_regions. With a high number of
> > banks, it can be difficult to arrange the boot modules in a way that
> > avoids spanning across multiple banks.
> >
> > This small patch merges neighboring regions, to make dealing with them
> > more efficient, and to make it easier to load boot modules.
> >
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> > ---
> > Changes in v2:
> > - remove unneeded check for duplicates
> > - unsigned int instead of int
> > - add parenthesis
> > ---
> > xen/arch/arm/efi/efi-boot.h | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
> > index a80a5a7ab3..8b8ef5dcfb 100644
> > --- a/xen/arch/arm/efi/efi-boot.h
> > +++ b/xen/arch/arm/efi/efi-boot.h
> > @@ -163,6 +163,16 @@ static bool __init meminfo_add_bank(struct membanks *mem,
> > struct membank *bank;
> > paddr_t start = desc->PhysicalStart;
> > paddr_t size = desc->NumberOfPages * EFI_PAGE_SIZE;
> > + unsigned int j;
> > +
> > + for ( j = 0; j < mem->nr_banks; j++ )
> > + {
> > + if ( (mem->bank[j].start + mem->bank[j].size) == start )
> > + {
> > + mem->bank[j].size += size;
> > + return true;
> > + }
> > + }
> >
> > if ( mem->nr_banks >= mem->max_banks )
> > return false;
>
> It didn't got into diff context, but there is this check below:
>
> #ifdef CONFIG_ACPI
> if ( check_reserved_regions_overlap(start, size, false) )
> return false;
> #endif
>
> Your patch will skip it.
You are right, this new hunk should be added after that check. I'l
resend.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-28 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-27 23:16 [PATCH v2] xen/arm/efi: merge neighboring banks Stefano Stabellini
2025-03-27 23:29 ` Volodymyr Babchuk
2025-03-28 21:32 ` Stefano Stabellini
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.