All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: ufimtseva@gmail.com, dario.faggioli@citrix.com,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	JBeulich@suse.com, boris.ostrovsky@oracle.com
Subject: Re: [PATCH v2 03/19] libxc: allocate memory with vNUMA information for PV guest
Date: Mon, 12 Jan 2015 17:11:02 +0000	[thread overview]
Message-ID: <1421082662.28776.19.camel@citrix.com> (raw)
In-Reply-To: <1417448023-27311-4-git-send-email-wei.liu2@citrix.com>

On Mon, 2014-12-01 at 15:33 +0000, Wei Liu wrote:

No longer description of what is going on? Or at least comments on what
the new fields mean. (I figure two of them form an array mapping v to p,
I'm not sure what the other one is...)

> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Dario Faggioli <dario.faggioli@citrix.com>
> Cc: Elena Ufimtseva <ufimtseva@gmail.com>
> ---
>  tools/libxc/include/xc_dom.h |    5 +++
>  tools/libxc/xc_dom_x86.c     |   72 +++++++++++++++++++++++++++++++++++-------
>  tools/libxc/xc_private.h     |    2 ++
>  3 files changed, 68 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
> index 07d7224..577a017 100644
> --- a/tools/libxc/include/xc_dom.h
> +++ b/tools/libxc/include/xc_dom.h
> @@ -167,6 +167,11 @@ struct xc_dom_image {
>      struct xc_dom_loader *kernel_loader;
>      void *private_loader;
>  
> +    /* vNUMA information */
> +    unsigned int *vnode_to_pnode;
> +    uint64_t *vnode_size;
> +    unsigned int nr_vnodes;
> +
>      /* kernel loader */
>      struct xc_dom_arch *arch_hooks;
>      /* allocate up to virt_alloc_end */
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index bf06fe4..3286232 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -759,7 +759,8 @@ static int x86_shadow(xc_interface *xch, domid_t domid)
>  int arch_setup_meminit(struct xc_dom_image *dom)
>  {
>      int rc;
> -    xen_pfn_t pfn, allocsz, i, j, mfn;
> +    xen_pfn_t pfn, allocsz, mfn, total, pfn_base;
> +    int i, j;
>  
>      rc = x86_compat(dom->xch, dom->guest_domid, dom->guest_type);
>      if ( rc )
> @@ -811,18 +812,67 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>          /* setup initial p2m */
>          for ( pfn = 0; pfn < dom->total_pages; pfn++ )
>              dom->p2m_host[pfn] = pfn;
> -        
> +
> +        /* setup dummy vNUMA information if it's not provided */
> +        if ( dom->nr_vnodes == 0 )
> +        {
> +            dom->nr_vnodes = 1;
> +            dom->vnode_to_pnode = xc_dom_malloc(dom,
> +                                                sizeof(*dom->vnode_to_pnode));
> +            dom->vnode_to_pnode[0] = XC_VNUMA_NO_NODE;

Does this indicate there is no vnode 0, or that vnode 0 maps to an
arbitrary (but unknown) pnode?

> +            dom->vnode_size = xc_dom_malloc(dom, sizeof(*dom->vnode_size));

Might as well to &dummy_foo, which is an on stack thing of the right
dummy type.

> +            dom->vnode_size[0] = ((dom->total_pages << PAGE_SHIFT) >> 20);

One unnecessary set of ()s
> +        }
> +
> +        total = 0;
> +        for ( i = 0; i < dom->nr_vnodes; i++ )
> +            total += ((dom->vnode_size[i] << 20) >> PAGE_SHIFT);
> +        if ( total != dom->total_pages )
> +        {
> +            xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
> +                         "%s: number of pages requested by vNUMA (0x%"PRIpfn") mismatches number of pages configured for domain (0x%"PRIpfn")\n",

Can you formulate a terser message and avoid the long line?

Perhaps "vNUMA page count mismatch 0x%PRIpfn != 0x%PRIpfn" conveys all
the useful bits?

Alternatively what if we were to mandate that dom->total_pages must be
set to zero by the caller iff they are passing nr_vnodes != 0? Then
calculate total_pages internally.

Might have too many knockon effects on callers?

> +                         __FUNCTION__, total, dom->total_pages);
> +            return -EINVAL;
> +        }
> +
>          /* allocate guest memory */
> -        for ( i = rc = allocsz = 0;
> -              (i < dom->total_pages) && !rc;
> -              i += allocsz )
> +        pfn_base = 0;
> +        for ( i = 0; i < dom->nr_vnodes; i++ )
>          {
> -            allocsz = dom->total_pages - i;
> -            if ( allocsz > 1024*1024 )
> -                allocsz = 1024*1024;
> -            rc = xc_domain_populate_physmap_exact(
> -                dom->xch, dom->guest_domid, allocsz,
> -                0, 0, &dom->p2m_host[i]);
> +            unsigned int memflags;
> +            uint64_t pages;
> +
> +            memflags = 0;
> +            if ( dom->vnode_to_pnode[i] != XC_VNUMA_NO_NODE )
> +            {
> +                memflags |= XENMEMF_exact_node(dom->vnode_to_pnode[i]);
> +                memflags |= XENMEMF_exact_node_request;
> +            }
> +
> +            pages = (dom->vnode_size[i] << 20) >> PAGE_SHIFT;
> +
> +            for ( j = 0; j < pages; j += allocsz )
> +            {
> +                allocsz = pages - j;
> +                if ( allocsz > 1024*1024 )
> +                    allocsz = 1024*1024;
> +
> +                rc = xc_domain_populate_physmap_exact(dom->xch,
> +                         dom->guest_domid, allocsz, 0, memflags,
> +                         &dom->p2m_host[pfn_base+j]);
> +
> +                if ( rc )
> +                {
> +                    if ( dom->vnode_to_pnode[i] != XC_VNUMA_NO_NODE )
> +                        xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
> +                                     "%s: fail to allocate 0x%"PRIx64" pages for vnode %d on pnode %d out of 0x%"PRIpfn"\n",

"vNUMA: failed to allocate 0x%"PRIx64"/0x%"PRIx64" pages (v=%d, p=%d)."?

Ian.

  reply	other threads:[~2015-01-12 17:11 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 15:33 [PATCH v2 00/19] Virtual NUMA for PV and HVM Wei Liu
2014-12-01 15:33 ` [PATCH v2 01/19] xen: dump vNUMA information with debug key "u" Wei Liu
2014-12-08 17:01   ` Jan Beulich
2014-12-09 11:22     ` Wei Liu
2014-12-09 11:38       ` Jan Beulich
2014-12-01 15:33 ` [PATCH v2 02/19] xen: make two memory hypercalls vNUMA-aware Wei Liu
2014-12-08 17:05   ` Jan Beulich
2014-12-01 15:33 ` [PATCH v2 03/19] libxc: allocate memory with vNUMA information for PV guest Wei Liu
2015-01-12 17:11   ` Ian Campbell [this message]
2014-12-01 15:33 ` [PATCH v2 04/19] libxl: add emacs local variables in libxl_{x86, arm}.c Wei Liu
2015-01-12 17:11   ` Ian Campbell
2014-12-01 15:33 ` [PATCH v2 05/19] libxl: introduce vNUMA types Wei Liu
2015-01-12 17:17   ` Ian Campbell
2015-01-12 17:21     ` Wei Liu
2015-01-12 17:24       ` Ian Campbell
2014-12-01 15:33 ` [PATCH v2 06/19] libxl: add vmemrange to libxl__domain_build_state Wei Liu
2014-12-01 15:33 ` [PATCH v2 07/19] libxl: introduce libxl__vnuma_config_check Wei Liu
2014-12-01 15:33 ` [PATCH v2 08/19] libxl: x86: factor out e820_host_sanitize Wei Liu
2014-12-01 15:33 ` [PATCH v2 09/19] libxl: functions to build vmemranges for PV guest Wei Liu
2014-12-01 15:33 ` [PATCH v2 10/19] libxl: build, check and pass vNUMA info to Xen " Wei Liu
2014-12-01 15:33 ` [PATCH v2 11/19] xen: handle XENMEMF_get_vnumainfo in compat_memory_op Wei Liu
2014-12-09  9:09   ` Jan Beulich
2014-12-01 15:33 ` [PATCH v2 12/19] hvmloader: retrieve vNUMA information from hypervisor Wei Liu
2014-12-09 16:46   ` Jan Beulich
2014-12-09 17:52     ` Wei Liu
2014-12-10  8:19       ` Jan Beulich
2014-12-01 15:33 ` [PATCH v2 13/19] hvmloader: construct SRAT Wei Liu
2014-12-09 16:53   ` Jan Beulich
2014-12-09 18:06     ` Wei Liu
2014-12-10  8:20       ` Jan Beulich
2014-12-10 10:54         ` Wei Liu
2014-12-10 11:06           ` Jan Beulich
2014-12-10 11:10             ` Wei Liu
2014-12-01 15:33 ` [PATCH v2 14/19] hvmloader: construct SLIT Wei Liu
2014-12-09 16:57   ` Jan Beulich
2014-12-09 18:09     ` Wei Liu
2014-12-01 15:33 ` [PATCH v2 15/19] libxc: allocate memory with vNUMA information for HVM guest Wei Liu
2014-12-01 15:33 ` [PATCH v2 16/19] libxl: build, check and pass vNUMA info to Xen " Wei Liu
2014-12-01 15:33 ` [PATCH v2 17/19] libxl: disallow memory relocation when vNUMA is enabled Wei Liu
2014-12-01 15:33 ` [PATCH v2 18/19] libxlutil: nested list support Wei Liu
2014-12-01 15:33 ` [PATCH v2 19/19] xl: vNUMA support Wei Liu
2014-12-08  9:58 ` [PATCH v2 00/19] Virtual NUMA for PV and HVM Wei Liu
2014-12-08 10:19   ` Jan Beulich

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=1421082662.28776.19.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dario.faggioli@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ufimtseva@gmail.com \
    --cc=wei.liu2@citrix.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.