All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Julien Grall <julien.grall@arm.com>
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	nd@arm.com, Stefano Stabellini <sstabellini@kernel.org>,
	andrii_anisov@epam.com, xen-devel@lists.xen.org
Subject: Re: [PATCH v4 10/23] xen/arm: introduce allocate_memory
Date: Fri, 19 Oct 2018 15:28:50 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1810191456160.31582@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <6be5efb4-72fe-95fa-9373-7d50b2c304f0@arm.com>

On Mon, 15 Oct 2018, Julien Grall wrote:
> Hi,
> 
> On 05/10/2018 19:47, Stefano Stabellini wrote:
> > Introduce an allocate_memory function able to allocate memory for DomUs
> > and map it at the right guest addresses, according to the guest memory
> > map: GUEST_RAM0_BASE and GUEST_RAM1_BASE.
> 
> Please add something along the line: "This is under #if 0 as not used for
> now".

I'll add


> > 
> > Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
> > ---
> > Changes in v4:
> > - move earlier, add #if 0
> > - introduce allocate_bank_memory, remove insert_bank
> > - allocate_bank_memory allocate memory and inserts the bank, while
> >    allocate_memory specifies where to do that
> > 
> > Changes in v3:
> > - new patch
> > ---
> >   xen/arch/arm/domain_build.c | 83
> > +++++++++++++++++++++++++++++++++++++++++++++
> >   1 file changed, 83 insertions(+)
> > 
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index 41f2f27..fddfd82 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -368,6 +368,89 @@ static void __init allocate_memory_11(struct domain *d,
> >       }
> >   }
> >   +#if 0
> > +static bool __init allocate_bank_memory(struct domain *d,
> > +                                        struct kernel_info *kinfo,
> > +                                        gfn_t sgfn,
> > +                                        unsigned int order)
> > +{
> > +    int res;
> > +    struct page_info *pg;
> > +    struct membank *bank;
> > +    paddr_t gaddr = gfn_to_gaddr(sgfn), size = pfn_to_paddr(1UL << order);
> 
> There is no need to have gaddr in a variable.

I'll remove it.


> > +
> > +    pg = alloc_domheap_pages(d, order, 0);
> 
> So here you impose the memory to be contiguously allocated for a given bank.
> There are quite a few case where you may not have enough memory to allocate
> contiguously.
> 
> So more likely you want to add loop in this code to allocate until order is
> reached.

This case is not handled today for dom0.


> > +    if ( !pg )
> > +        return false;
> > +
> > +    res = guest_physmap_add_page(d, sgfn, page_to_mfn(pg), order);
> > +    if ( res )
> > +    {
> > +        dprintk(XENLOG_ERR, "Failed map pages to DOMU: %d", res);
> > +        goto fail;
> > +    }
> > +
> > +    bank = &kinfo->mem.bank[kinfo->mem.nr_banks];
> > +    bank->start = gaddr;
> > +    bank->size = size;
> > +    kinfo->mem.nr_banks++;
> > +    kinfo->unassigned_mem -= size;
> 
> newline here.

OK

> > +    return true;
> > +
> > +fail:
> > +    free_domheap_pages(pg, order);
> > +    return false;
> > +}
> > +
> > +static void __init allocate_memory(struct domain *d, struct kernel_info
> > *kinfo)
> > +{
> > +    unsigned int order = get_allocation_size(kinfo->unassigned_mem);
> > +    unsigned int order_req;
> > +    int i;
> 
> unsigned.

OK

> 
> > +
> > +    dprintk(XENLOG_INFO, "Allocating mappings totalling %ldMB for
> > dom%d:\n",
> > +            /* Don't want format this as PRIpaddr (16 digit hex) */
> > +            (unsigned long)(kinfo->unassigned_mem >> 20), d->domain_id);
> > +
> > +    kinfo->mem.nr_banks = 0;
> > +
> > +    order = get_allocation_size(kinfo->unassigned_mem);
> > +    if ( order > get_order_from_bytes(GUEST_RAM0_SIZE) )
> > +        order_req = get_order_from_bytes(GUEST_RAM0_SIZE);
> > +    else
> > +        order_req = order;
> > +    if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM0_BASE),
> > order_req) )
> > +        goto fail;
> > +
> > +    order -= order_req;
> > +    if ( order > 0 )
> > +    {
> > +        if ( !allocate_bank_memory(d, kinfo, gaddr_to_gfn(GUEST_RAM1_BASE),
> > order) )
> > +            goto fail;
> > +    }
> 
> How about combining the two if to avoid an extra indentation?

OK

> > +
> > +    for( i = 0; i < kinfo->mem.nr_banks; i++ )
> > +    {
> > +        dprintk(XENLOG_INFO, "Dom%d BANK[%d] %#"PRIpaddr"-%#"PRIpaddr"
> > (%ldMB)\n",
> > +                d->domain_id,
> > +                i,
> > +                kinfo->mem.bank[i].start,
> > +                kinfo->mem.bank[i].start + kinfo->mem.bank[i].size,
> > +                /* Don't want format this as PRIpaddr (16 digit hex) */
> > +                (unsigned long)(kinfo->mem.bank[i].size >> 20));
> > +    }
> > +
> > +    return;
> > +
> > +fail:
> > +    dprintk(XENLOG_ERR, "Failed to allocate requested domain memory."
> > +            /* Don't want format this as PRIpaddr (16 digit hex) */
> > +            " %ldKB unallocated. Fix the VMs configurations.\n",
> > +            (unsigned long)kinfo->unassigned_mem >> 10);
> > +    BUG();
> > +}
> > +#endif
> > +
> >   static int __init write_properties(struct domain *d, struct kernel_info
> > *kinfo,
> >                                      const struct dt_device_node *node)
> >   {
> > 
> 
> Cheers,
> 
> -- 
> Julien Grall
> 

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

  reply	other threads:[~2018-10-19 22:28 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 18:47 [PATCH v4 00/23] dom0less step1: boot multiple domains from device tree Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 01/23] xen: allow console_io hypercalls from certain DomUs Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 02/23] xen/arm: extend device tree based multiboot protocol Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 03/23] xen/arm: document dom0less Stefano Stabellini
2018-10-09 11:52   ` Julien Grall
2018-10-16  7:58     ` Lars Kurth
2018-10-22 23:58       ` Stefano Stabellini
2018-10-23  0:12     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 04/23] xen/arm: increase MAX_MODULES Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 05/23] xen/arm: introduce bootcmdlines Stefano Stabellini
2018-10-09 13:24   ` Julien Grall
2018-10-23  1:59     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 06/23] xen/arm: don't add duplicate boot modules, introduce domU flag Stefano Stabellini
2018-10-09 13:35   ` Julien Grall
2018-10-19 23:36     ` Stefano Stabellini
2018-10-20 12:10       ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 07/23] xen/arm: probe domU kernels and initrds Stefano Stabellini
2018-10-15 14:27   ` Julien Grall
2018-10-20  0:42     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 08/23] xen/arm: rename get_11_allocation_size to get_allocation_size Stefano Stabellini
2018-10-15 14:28   ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 09/23] xen/arm: rename allocate_memory to allocate_memory_11 Stefano Stabellini
2018-10-15 14:29   ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 10/23] xen/arm: introduce allocate_memory Stefano Stabellini
2018-10-15 14:43   ` Julien Grall
2018-10-19 22:28     ` Stefano Stabellini [this message]
2018-10-20 11:58       ` Julien Grall
2018-10-22 23:53         ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 11/23] xen/arm: refactor construct_dom0 Stefano Stabellini
2018-10-15 14:49   ` Julien Grall
2018-10-17 15:06     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 12/23] xen/arm: introduce create_domUs Stefano Stabellini
2018-10-15 15:05   ` Julien Grall
2018-10-19 22:37     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 13/23] xen/arm: implement construct_domU Stefano Stabellini
2018-10-15 15:15   ` Julien Grall
2018-10-19 22:53     ` Stefano Stabellini
2018-10-20 12:01       ` Julien Grall
2018-10-22 19:46         ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 14/23] xen/arm: generate a simple device tree for domUs Stefano Stabellini
2018-10-15 15:24   ` Julien Grall
2018-10-17 15:09     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 15/23] xen/arm: make set_interrupt_ppi able to handle non-PPI Stefano Stabellini
2018-10-15 15:25   ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 16/23] xen/arm: generate vpl011 node on device tree for domU Stefano Stabellini
2018-10-15 15:47   ` Julien Grall
2018-10-17 14:59     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 17/23] xen/arm: introduce a union in vpl011 Stefano Stabellini
2018-10-15 15:49   ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 18/23] xen/arm: refactor vpl011_data_avail Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 19/23] xen/arm: Allow vpl011 to be used by DomU Stefano Stabellini
2018-10-15 15:56   ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 20/23] xen: support console_switching between Dom0 and DomUs on ARM Stefano Stabellini
2018-10-08  9:50   ` Jan Beulich
2018-10-19 23:10     ` Stefano Stabellini
2018-10-25  9:37       ` Jan Beulich
2018-10-05 18:47 ` [PATCH v4 21/23] xen/vpl011: buffer out chars when the backend is xen Stefano Stabellini
2018-10-08  9:41   ` Jan Beulich
2018-10-19 23:20     ` Stefano Stabellini
2018-10-20 12:07       ` Julien Grall
2018-10-22 23:46         ` Stefano Stabellini
2018-10-15 16:10   ` Julien Grall
2018-10-17 15:24     ` Stefano Stabellini
2018-10-05 18:47 ` [PATCH v4 22/23] xen/arm: move kernel.h to asm-arm/ Stefano Stabellini
2018-10-15 16:17   ` Julien Grall
2018-10-17 14:42     ` Stefano Stabellini
2018-10-17 16:11       ` Julien Grall
2018-10-17 16:26         ` Andrew Cooper
2018-10-19 21:54         ` Stefano Stabellini
2018-10-20 10:49           ` Julien Grall
2018-10-05 18:47 ` [PATCH v4 23/23] xen/arm: split domain_build.c 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=alpine.DEB.2.10.1810191456160.31582@sstabellini-ThinkPad-X260 \
    --to=sstabellini@kernel.org \
    --cc=andrii_anisov@epam.com \
    --cc=julien.grall@arm.com \
    --cc=nd@arm.com \
    --cc=stefanos@xilinx.com \
    --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 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.