All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: z00226004 <zhaoshenglong@huawei.com>
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com,
	xen-devel@lists.xen.org, julien.grall@arm.com,
	shannon.zhao@linaro.org, boris.ostrovsky@oracle.com
Subject: Re: [PATCH v6 16/16] libxl/arm: Add the size of ACPI tables to maxmem
Date: Thu, 22 Sep 2016 15:32:46 +0100	[thread overview]
Message-ID: <20160922143246.GO16004@citrix.com> (raw)
In-Reply-To: <20160922141046.GB16004@citrix.com>

On Thu, Sep 22, 2016 at 03:10:46PM +0100, Wei Liu wrote:
> On Thu, Sep 22, 2016 at 08:52:33PM +0800, z00226004 wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > 
> > Here it adds the ACPI tables size to set the target maxmem to avoid
> > providing less available memory for guest.
> > 
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> >  tools/libxl/libxl_arch.h        |  4 ++++
> >  tools/libxl/libxl_arm.c         | 16 ++++++++++++++++
> >  tools/libxl/libxl_arm.h         |  4 ++++
> >  tools/libxl/libxl_arm_acpi.c    | 20 ++++++++++++++++++++
> >  tools/libxl/libxl_arm_no_acpi.c |  6 ++++++
> >  tools/libxl/libxl_dom.c         |  9 ++++++++-
> >  tools/libxl/libxl_internal.h    |  2 ++
> >  tools/libxl/libxl_x86.c         |  6 ++++++
> >  8 files changed, 66 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> > index 8cb9ba7..a066bbd 100644
> > --- a/tools/libxl/libxl_arch.h
> > +++ b/tools/libxl/libxl_arch.h
> > @@ -66,6 +66,10 @@ _hidden
> >  void libxl__arch_domain_build_info_acpi_setdefault(
> >                                          libxl_domain_build_info *b_info);
> >  
> > +_hidden
> > +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> > +                                libxl__domain_build_state *state);
> 
> I think the prototype should change a bit.
> 
> _hidden
> int libxl__arch_extra_memory(libxl__gc, *gc,
>                              const libxl_domain_build_info *info,
>                              const libxl__domain_build_state *state,
>                              uint64_t *out);
> 
> The important bit is to not overload the return value to carry the
> output value.
> 
> > +
> >  #if defined(__i386__) || defined(__x86_64__)
> >  
> >  #define LAPIC_BASE_ADDRESS  0xfee00000
> > diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> > index 913f401..932e674 100644
> > --- a/tools/libxl/libxl_arm.c
> > +++ b/tools/libxl/libxl_arm.c
> > @@ -106,6 +106,22 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
> >      return 0;
> >  }
> >  
> > +int libxl__arch_memory_constant(libxl__gc *gc, libxl_domain_build_info *info,
> > +                                libxl__domain_build_state *state)
> > +{
> > +    int size;
> > +
> > +    if (libxl_defbool_val(info->acpi)) {
> > +        size = libxl__get_acpi_size(gc, info, state);
> > +        if (size < 0)
> > +            return ERROR_FAIL;
> > +
> > +        return DIV_ROUNDUP(size, 1024);
> > +    }
> > +
> > +    return 0;
> > +}
> > +
> >  static struct arch_info {
> >      const char *guest_type;
> >      const char *timer_compat;
> > diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
> > index a91ff93..37b1f15 100644
> > --- a/tools/libxl/libxl_arm.h
> > +++ b/tools/libxl/libxl_arm.h
> > @@ -24,6 +24,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> >                          libxl__domain_build_state *state,
> >                          struct xc_dom_image *dom);
> >  
> > +_hidden
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state);
> > +
> 
> Same here, don't overload the return value for output.
> 
> >  static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
> >  {
> >      /*
> > diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> > index 9c4005f..0d4092d 100644
> > --- a/tools/libxl/libxl_arm_acpi.c
> > +++ b/tools/libxl/libxl_arm_acpi.c
> > @@ -94,6 +94,26 @@ static int libxl__estimate_madt_size(libxl__gc *gc,
> >      return rc;
> >  }
> >  
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state)
> > +{
> > +    int size;
> > +
> > +    size = libxl__estimate_madt_size(gc, info, &state->config);
> > +    if (size < 0)
> > +        goto out;
> > +
> > +    size = ROUNDUP(size, 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_rsdp), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_xsdt), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_gtdt), 3) +
> > +           ROUNDUP(sizeof(struct acpi_table_fadt), 3) +
> > +           ROUNDUP(sizeof(dsdt_anycpu_arm_len), 3);
> > +
> > +out:
> > +    return size;
> > +}
> > +
> >  static int libxl__estimate_acpi_size(libxl__gc *gc,
> >                                       libxl_domain_build_info *info,
> >                                       struct xc_dom_image *dom,
> > diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c
> > index e7f7411..5eeb825 100644
> > --- a/tools/libxl/libxl_arm_no_acpi.c
> > +++ b/tools/libxl/libxl_arm_no_acpi.c
> > @@ -25,6 +25,12 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
> >      return ERROR_FAIL;
> >  }
> >  
> > +int libxl__get_acpi_size(libxl__gc *gc, libxl_domain_build_info *info,
> > +                         libxl__domain_build_state *state)
> > +{
> > +    return ERROR_FAIL;
> > +}
> > +
> >  /*
> >   * Local variables:
> >   * mode: C
> > 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)
> 

FAOD:

I think all the issues I found so far in this patch and other patch(es)
are mostly cosmetic. I would be happy to accept incremental patches on
top of this series to make those changes.

No need to resend just yet unless there is something substantial that
you need to change.

Wei.

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

  reply	other threads:[~2016-09-22 14:32 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 [this message]
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
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=20160922143246.GO16004@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 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.