xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Shannon Zhao <shannon.zhao@linaro.org>
Cc: sstabellini@kernel.org, Wei Liu <wei.liu2@citrix.com>,
	ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com,
	xen-devel@lists.xen.org, julien.grall@arm.com,
	z00226004 <zhaoshenglong@huawei.com>,
	boris.ostrovsky@oracle.com
Subject: Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
Date: Wed, 28 Sep 2016 11:00:31 +0100	[thread overview]
Message-ID: <20160928100031.GP16004@citrix.com> (raw)
In-Reply-To: <16a28f47-d722-e076-e821-8282e0b8efe6@linaro.org>

On Tue, Sep 27, 2016 at 11:43:38AM -0700, Shannon Zhao wrote:
> 
> 
> On 2016/9/27 9:35, Wei Liu wrote:
> >On Tue, Sep 27, 2016 at 09:01:00AM -0700, Shannon Zhao wrote:
> >>
> >>
> >>On 2016/9/27 2:41, Wei Liu wrote:
> >>>On Mon, Sep 26, 2016 at 02:54:55PM -0700, Shannon Zhao wrote:
> >>>>
> >>>>
> >>>>On 2016/9/22 7:10, Wei Liu wrote:
> >>>>>>diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> >>>>>>>index 2924629..118beab 100644
> >>>>>>>--- a/tools/libxl/libxl_dom.c
> >>>>>>>+++ b/tools/libxl/libxl_dom.c
> >>>>>>>@@ -408,8 +408,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> >>>>>>>        }
> >>>>>>>    }
> >>>>>>>
> >>>>>>>+
> >>>>>>>+    rc = libxl__arch_memory_constant(gc, info, state);
> >>>>>>>+    if (rc < 0) {
> >>>>>>>+        LOGE(ERROR, "Couldn't get arch constant memory size");
> >>>>>>>+        return ERROR_FAIL;
> >>>>>>>+    }
> >>>>>>>+
> >>>>>>>    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> >>>>>>>-        LIBXL_MAXMEM_CONSTANT) < 0) {
> >>>>>>>+        LIBXL_MAXMEM_CONSTANT + rc) < 0) {
> >>>>>I think this LIBXL_MAXMEM_CONSTANT should be pushed to your helper
> >>>>>function, too.
> >>>>>
> >>>>>So that, we can have all LIBXL_MAXMEM_CONSTANT removed in libxl
> >>>>>functions (see libxl.c and libxl_dom.c)
> >>>>>
> >>>>If we push LIBXL_MAXMEM_CONSTANT to the libxl_arch_memory_constant and
> >>>>remove it from libxl.c, do we need to call libxl_arch_memory_constant there
> >>>>in libxl_set_memory_target()?
> >>>>
> >>>
> >>>Yes, we need to call that function everywhere to get consistent results.
> >>>That's the reason I asked you to consolidate it to a function.
> >>>
> >>Well it's a little awkward I think, since in libxl_domain_setmaxmem() and
> >>libxl_set_memory_target() it seems it can't get the parameters info and
> >>state for libxl__arch_memory_constant().
> >>I'm not sure how to solve it. Wei, any suggestion?
> >>
> >
> >Hmm...
> >
> >The first question is can state be derived from build_info ? From my
> >quick skim of the code the answer is likely yes.
> >
> I'm not familiar with the relationship between these structures and not sure
> how to do this. Please give me some suggestion.
> 

Oh, I was just reading the code in your patch series and existing code
in libxl_arm.c.  Here is my analysis of the code, please point out any
inaccuracy.

In your patch that estimates the size of ACPI table(s), xc_config is
needed. In particular, you need to know the gic version -- in fact
that's the only thing you need to know as far as I can tell.

In libxl_arm.c, the gic version is finally saved to  d_config, which
means you should be able to later extract that from d_config.

But, as I understand it, you can't use  d_config only while *building*
the domain, because the gic version might be determined only after the
domain is constructed (_NATIVE case). If you want to do so, you need to
move some code around, which might or might not be feasible -- I haven't
checked.

So based on my analysis, it would make sense to have such function:

   libxl__arch_extra_memory(gc, d_config)

This is the function that is used in libxl_set_memory_target and
friends.

Obviously x86 would only need to return a constant in that function.

Then, in arm implementation:

   libxl__get_acpi_size(gc, info, gic_version /* not build_state anymore */)

   /* also fix up libxl__estimate_madt_size */


   /* this is the function called when constructing the domain etc, only
    * in libxl_arm.c */
   static acpi_extra_memory(gc, build_info, gic_version)
   {
        libxl__get_acpi_size...
   }

   libxl__arch_extra_memory(gc, d_config)
   {
        gic_version = d_config->..gic_version;

        acpi_extra_memory...
   }

Does this make sense?

One thing I don't quite understand is that in patch 4
libxl__estimate_acpi_size seems to do allocations as well. You might
want to rename that libxl__allocate_acpi_tables or something.

Wei.

> >Then, you can call libxl_retrieve_domain_configuration to get
> >domain_config, then domain_config->build_info, so that you can derive
> >state from it.
> >
> >Feel free to ask more questions.
> >
> >Without such arrangement, ballooning is going to be broken for ARM
> >guests.
> >
> I see.
> 
> Thanks,
> -- 
> Shannon

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

  reply	other threads:[~2016-09-28 10:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 12:52 [PATCH v6 00/16] Xen ARM DomU ACPI support z00226004
2016-09-22 12:52 ` [PATCH v6 01/16] tools/libxl: Add an unified configuration option for ACPI z00226004
2016-09-22 12:52 ` [PATCH v6 02/16] libxl/arm: prepare for constructing ACPI tables z00226004
2016-09-22 14:13   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 03/16] libxl/arm: Generate static ACPI DSDT table z00226004
2016-09-22 12:52 ` [PATCH v6 04/16] libxl/arm: Estimate the size of ACPI tables z00226004
2016-09-22 14:21   ` Wei Liu
2016-09-27 15:20   ` [PATCH v7 " Shannon Zhao
2016-09-22 12:52 ` [PATCH v6 05/16] libxl/arm: Construct ACPI RSDP table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 06/16] libxl/arm: Construct ACPI XSDT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 07/16] libxl/arm: Construct ACPI GTDT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 08/16] libxl/arm: Factor MPIDR computing codes out as a helper z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 09/16] libxl/arm: Construct ACPI MADT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 10/16] libxl/arm: Construct ACPI FADT table z00226004
2016-09-22 14:14   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 11/16] libxl/arm: Construct ACPI DSDT table z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 13/16] libxl/arm: Add ACPI module z00226004
2016-09-22 14:15   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI z00226004
2016-09-22 14:44   ` Julien Grall
2016-09-22 15:00   ` Jan Beulich
2016-09-26 19:45     ` Shannon Zhao
2016-09-27  8:01       ` Jan Beulich
2016-09-27 15:27   ` [PATCH v7 " Shannon Zhao
2016-09-28 10:55     ` Jan Beulich
2016-09-22 12:52 ` [PATCH v6 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ z00226004
2016-09-22 14:16   ` Wei Liu
2016-09-22 12:52 ` [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem z00226004
2016-09-22 14:10   ` Wei Liu
2016-09-22 14:32     ` Wei Liu
2016-09-26  7:08       ` Shannon Zhao
2016-09-26  9:05         ` Wei Liu
2016-09-26 18:30           ` Shannon Zhao
2016-09-27  9:30             ` Wei Liu
2016-09-26 21:54     ` Shannon Zhao
2016-09-27  9:41       ` Wei Liu
2016-09-27 16:01         ` Shannon Zhao
2016-09-27 16:35           ` Wei Liu
2016-09-27 18:43             ` Shannon Zhao
2016-09-28 10:00               ` Wei Liu [this message]
2016-09-28 13:11                 ` Shannon Zhao
2016-09-28 13:17                   ` Wei Liu
2016-09-28 17:52                     ` Julien Grall
2016-09-22 13:27 ` [PATCH v6 00/16] Xen ARM DomU ACPI support Julien Grall
2016-09-22 13:32   ` Shannon Zhao
2016-09-22 13:37     ` Julien Grall
2016-09-22 13:38       ` Shannon Zhao
2016-09-22 14:27 ` Julien Grall

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=20160928100031.GP16004@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=shannon.zhao@linaro.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.org \
    --cc=zhaoshenglong@huawei.com \
    /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).