xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: julien.grall@arm.com, sstabellini@kernel.org, xen-devel@lists.xen.org
Subject: Re: [PATCH V4] xen/arm: domain_build: allocate lowmem for dom0 as much as possible
Date: Sat, 8 Oct 2016 10:25:25 +0800	[thread overview]
Message-ID: <20161008022523.GA15741@linux-7smt.suse> (raw)
In-Reply-To: <1474599334-30709-1-git-send-email-peng.fan@nxp.com>

Hi Stefano, Julien

Any comments on this v4 patch?

Thanks,
Peng
On Fri, Sep 23, 2016 at 10:55:34AM +0800, Peng Fan wrote:
>On AArch64 SoCs, some IPs may only have the capability to access
>32 bits address space. The physical memory assigned for Dom0 maybe
>not in 4GB address space, then the IPs will not work properly.
>So need to allocate memory under 4GB for Dom0.
>
>There is no restriction that how much lowmem needs to be allocated for
>Dom0 ,so allocate lowmem as much as possible for Dom0.
>
>This patch does not affect 32-bit domain, because Variable "lowmem" is
>set to true at the beginning. If failed to allocate bank0 under 4GB,
>need to panic for 32-bit domain, because 32-bit domain requires bank0
>be allocated under 4GB.
>
>For 64-bit domain, set "lowmem" to false, and continue allocating
>memory from above 4GB.
>
>Signed-off-by: Peng Fan <peng.fan@nxp.com>
>Cc: Stefano Stabellini <sstabellini@kernel.org>
>Cc: Julien Grall <julien.grall@arm.com>
>---
>
>This patch is to resolve the issue mentioned in
>https://lists.xen.org/archives/html/xen-devel/2016-09/msg00235.html
>
> Tested results:
> (XEN) Allocating 1:1 mappings totalling 2048MB for dom0:
> (XEN) BANK[0] 0x00000088000000-0x000000f8000000 (1792MB)
> (XEN) BANK[1] 0x000009e0000000-0x000009f0000000 (256MB)
> 1792M allocated in 4GB address space.
>
>V4:
> Address comments in V3: https://lists.xen.org/archives/html/xen-devel/2016-09/msg02499.html
> Drop uneccessary check when failed to allocate memory under 4GB
> Refine comments according to Julien's suggestion in V3.
> Keep "bits <= (lowmem ? 32 : PADDR_BITS)", but not changed to "bits <= 32"
>
>V3:
> Add more commit log
> Add more comments
> Add back panic if failed to allocate bank0 under 4GB for 32-bit domain.
>
>V2:
> Remove the bootargs dom0_lowmem introduced in V1.
> Following "https://lists.xenproject.org/archives/html/xen-devel/2016-09/msg01459.html"
> to allocate as much as possible lowmem.
>
> xen/arch/arm/domain_build.c | 33 ++++++++++++++++++++++-----------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
>diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>index 35ab08d..6b5ac8d 100644
>--- a/xen/arch/arm/domain_build.c
>+++ b/xen/arch/arm/domain_build.c
>@@ -195,9 +195,9 @@ fail:
>  *    bank. Partly this is just easier for us to deal with, but also
>  *    the ramdisk and DTB must be placed within a certain proximity of
>  *    the kernel within RAM.
>- * 3. For 32-bit dom0 we want to place as much of the RAM as we
>- *    reasonably can below 4GB, so that it can be used by non-LPAE
>- *    enabled kernels.
>+ * 3. For dom0 we want to place as much of the RAM as we reasonably can
>+ *    below 4GB, so that it can be used by non-LPAE enabled kernels (32-bit)
>+ *    or when a device assigned to dom0 can only do 32-bit DMA access.
>  * 4. For 32-bit dom0 the kernel must be located below 4GB.
>  * 5. We want to have a few largers banks rather than many smaller ones.
>  *
>@@ -230,7 +230,8 @@ fail:
>  * we give up.
>  *
>  * For 32-bit domain we require that the initial allocation for the
>- * first bank is under 4G. Then for the subsequent allocations we
>+ * first bank is under 4G. For 64-bit domain, the first bank is preferred
>+ * to be allocated under 4G. Then for the subsequent allocations we
>  * initially allocate memory only from below 4GB. Once that runs out
>  * (as described above) we allow higher allocations and continue until
>  * that runs out (or we have allocated sufficient dom0 memory).
>@@ -244,7 +245,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
>     unsigned int order = get_11_allocation_size(kinfo->unassigned_mem);
>     int i;
> 
>-    bool_t lowmem = is_32bit_domain(d);
>+    bool_t lowmem = true;
>     unsigned int bits;
> 
>     /*
>@@ -269,20 +270,30 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
>         {
>             pg = alloc_domheap_pages(d, order, MEMF_bits(bits));
>             if ( pg != NULL )
>+            {
>+                if ( !insert_11_bank(d, kinfo, pg, order) )
>+                    BUG(); /* Cannot fail for first bank */
>+
>                 goto got_bank0;
>+            }
>         }
>         order--;
>     }
> 
>-    panic("Unable to allocate first memory bank");
>-
>- got_bank0:
>+    /* Failed to allocate bank0 under 4GB */
>+    if ( is_32bit_domain(d) )
>+        panic("Unable to allocate first memory bank.");
> 
>-    if ( !insert_11_bank(d, kinfo, pg, order) )
>-        BUG(); /* Cannot fail for first bank */
>+    /* Try to allocate memory from above 4GB */
>+    printk(XENLOG_INFO "No bank has been allocated below 4GB.\n");
>+    lowmem = false;
> 
>-    /* Now allocate more memory and fill in additional banks */
>+ got_bank0:
> 
>+    /*
>+     * If we failed to allocate bank0 under 4GB, continue allocating
>+     * memory from above 4GB and fill in banks.
>+     */
>     order = get_11_allocation_size(kinfo->unassigned_mem);
>     while ( kinfo->unassigned_mem && kinfo->mem.nr_banks < NR_MEM_BANKS )
>     {
>-- 
>2.6.6
>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-10-08  2:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-23  2:55 [PATCH V4] xen/arm: domain_build: allocate lowmem for dom0 as much as possible Peng Fan
2016-10-08  2:25 ` Peng Fan [this message]
2016-11-01 14:42 ` Julien Grall
2016-11-01 18:12   ` Stefano Stabellini
2016-11-10  8:30   ` Peng Fan
2016-11-10 13:01     ` Julien Grall
2016-11-11  1:10       ` Peng Fan
2016-11-11  1:41       ` Wei Liu
2016-11-11 11:35 ` Andrii Anisov
2016-11-11 11:59   ` Julien Grall
2016-11-11 14:24     ` Andrii Anisov
2016-11-11 14:39       ` Andrii Anisov
2016-11-11 16:02       ` Julien Grall
2016-11-11 19:27         ` Stefano Stabellini
2016-11-14  8:54           ` Andrii Anisov
2016-11-14  9:11           ` Andrii Anisov
2016-11-14 20:30             ` Julien Grall
2016-11-16 14:49               ` Andrii Anisov
2016-11-14  9:25         ` Andrii Anisov
2016-11-14  9:43         ` Andrii Anisov
2016-11-14 23:28           ` Stefano Stabellini
2016-11-16 15:28             ` Andrii Anisov
2016-11-17 17:21               ` Stefano Stabellini
2016-11-18 18:00                 ` Stefano Stabellini
2016-11-21 11:04                 ` Andrii Anisov
2016-11-21 17:52                   ` Stefano Stabellini
2016-11-11 19:25       ` Stefano Stabellini

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=20161008022523.GA15741@linux-7smt.suse \
    --to=van.freenix@gmail.com \
    --cc=julien.grall@arm.com \
    --cc=peng.fan@nxp.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.org \
    /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;
as well as URLs for NNTP newsgroup(s).