All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongyang Yang <yanghy@cn.fujitsu.com>
To: Don Slutz <dslutz@verizon.com>, xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Shriram Rajagopalan <rshriram@cs.ubc.ca>
Subject: Re: [PATCH 1/1] xc_domain_restore: Allow QEMU to increase memory
Date: Tue, 14 Apr 2015 11:46:55 +0800	[thread overview]
Message-ID: <552C8DAF.9070103@cn.fujitsu.com> (raw)
In-Reply-To: <1428941353-18673-1-git-send-email-dslutz@verizon.com>

This patch also fix a triple fault when guests running under COLO mode.
(XEN) d0v1 Over-allocation for domain 1: 524545 > 524544
(XEN) memory.c:155:d0v1 Could not allocate order=0 extent: id=1 memflags=0 (181 
of 235)
(XEN) d1v1 Triple fault - invoking HVM shutdown action 1

On 04/14/2015 12:09 AM, Don Slutz wrote:
> If QEMU has called on xc_domain_setmaxmem to add more memory for
> option ROMs, domain restore needs to also increase the memory.
>
> Signed-off-by: Don Slutz <dslutz@verizon.com>
> ---
> To see the hvmloader loader issue:
>
>    xl cre -p e1000x8.xfg
>    xl save e1000x8 e1000x8.save
>    xl restore e1000x8.save
>
> With e1000x8.xfg:
> -------------------------------------------------------------------------------
> builder = "hvm"
> device_model_args_hvm = [
>   "-monitor",
>   "pty",
>   "-boot",
>   "menu=on",
> ]
> device_model_version = "qemu-xen"
> disk = [
>   "/dev/etherd/e500.1,,xvda",
>   "/dev/etherd/e500.2,,xvdb",
>   "/dev/etherd/e500.3,,xvde",
>   "/local-isos/iso/centos/x86_64/CentOS-6.3-x86_64-bin-DVD1.iso,,hdc,cdrom",
>   "/local-isos/iso/centos/x86_64/CentOS-6.3-x86_64-bin-DVD2.iso,,hdd,cdrom",
> ]
> maxmem = "8192"
> memory = "8192"
> name = "e1000x8"
> serial = "pty"
> tsc_mode = "native_paravirt"
> uuid = "e5000105-3d83-c962-07ae-2bc46c3644a0"
> videoram = "16"
> vif = [
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:a0",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:aa",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:b4",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:be",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:c8",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:d2",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:dc",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:e6",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:f0",
>   "model=e1000,bridge=xenbr0,mac=00:0c:29:86:44:fa",
> ]
> viridian = 0
> xen_platform_pci = 1
> mmio_hole = 2048
> vcpus = 1
> maxvcpus = 6
> on_poweroff = "preserve"
> on_reboot = "preserve"
> on_watchdog = "preserve"
> on_crash = "preserve"
> -------------------------------------------------------------------------------
>
>
>   tools/libxc/xc_domain_restore.c | 75 +++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 73 insertions(+), 2 deletions(-)
>
> diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c
> index 2ab9f46..28b4fa6 100644
> --- a/tools/libxc/xc_domain_restore.c
> +++ b/tools/libxc/xc_domain_restore.c
> @@ -47,6 +47,13 @@
>   #include <xen/hvm/ioreq.h>
>   #include <xen/hvm/params.h>
>
> +/* Leave some slack so that hvmloader does not complain about lack of
> + * memory at boot time ("Could not allocate order=0 extent").
> + * Once hvmloader is modified to cope with that situation without
> + * printing warning messages, QEMU_SPARE_PAGES can be removed.
> + */
> +#define QEMU_SPARE_PAGES 16
> +
>   struct restore_ctx {
>       unsigned long max_mfn; /* max mfn of the current host machine */
>       unsigned long hvirt_start; /* virtual starting address of the hypervisor */
> @@ -209,12 +216,44 @@ static int uncanonicalize_pagetable(
>           if (!ctx->hvm && ctx->superpages)
>               rc = alloc_superpage_mfns(xch, dom, ctx, nr_mfns);
>           else
> +        {
> +            xc_domaininfo_t info;
> +            unsigned long free_pages;
> +
> +            if ((xc_domain_getinfolist(xch, dom, 1, &info) != 1) ||
> +                (info.domain != dom)) {
> +                ERROR("Failed xc_domain_getinfolist for batch (uncanonicalize_pagetable)\n");
> +                errno = ENOMEM;
> +                return 0;
> +            }
> +            free_pages = info.max_pages - info.tot_pages;
> +            if (free_pages > QEMU_SPARE_PAGES) {
> +                free_pages -= QEMU_SPARE_PAGES;
> +            } else {
> +                free_pages = 0;
> +            }
> +            if (free_pages < nr_mfns)
> +            {
> +                DPRINTF("Adjust memory for batch (uncanonicalize_pagetable): free_pages=%lu nr_mfns=%d max_pages=%lu tot_pages=%lu max_mfn=%lu\n",
> +                        free_pages, nr_mfns, (unsigned long)info.max_pages,
> +                        (unsigned long)info.tot_pages, ctx->max_mfn);
> +                if (xc_domain_setmaxmem(xch, dom,
> +                                        ((info.max_pages + nr_mfns - free_pages)
> +                                         << (XC_PAGE_SHIFT - 10))) < 0)
> +                {
> +                    ERROR("Failed xc_domain_setmaxmem for batch (uncanonicalize_pagetable)\n");
> +                    errno = ENOMEM;
> +                    return 0;
> +                }
> +            }
>               rc = xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0, 0,
>                                                     ctx->p2m_batch);
> +        }
>
>           if (rc)
>           {
> -            ERROR("Failed to allocate memory for batch.!\n");
> +            ERROR("Failed to allocate memory for batch. rc=%d nr_mfns=%d!\n",
> +                  rc, nr_mfns);
>               errno = ENOMEM;
>               return 0;
>           }
> @@ -1241,12 +1280,44 @@ static int apply_batch(xc_interface *xch, uint32_t dom, struct restore_ctx *ctx,
>           if (!ctx->hvm && ctx->superpages)
>               rc = alloc_superpage_mfns(xch, dom, ctx, nr_mfns);
>           else
> +        {
> +            xc_domaininfo_t info;
> +            unsigned long free_pages;
> +
> +            if ((xc_domain_getinfolist(xch, dom, 1, &info) != 1) ||
> +                (info.domain != dom)) {
> +                ERROR("Failed xc_domain_getinfolist for apply_batch\n");
> +                errno = ENOMEM;
> +                return -1;
> +            }
> +            free_pages = info.max_pages - info.tot_pages;
> +            if (free_pages > QEMU_SPARE_PAGES) {
> +                free_pages -= QEMU_SPARE_PAGES;
> +            } else {
> +                free_pages = 0;
> +            }
> +            if (free_pages < nr_mfns)
> +            {
> +                DPRINTF("Adjust memory for apply_batch: free_pages=%lu nr_mfns=%d max_pages=%lu tot_pages=%lu max_mfn=%lu\n",
> +                        free_pages, nr_mfns, (unsigned long)info.max_pages,
> +                        (unsigned long)info.tot_pages, ctx->max_mfn);
> +                if (xc_domain_setmaxmem(xch, dom,
> +                                        ((info.max_pages + nr_mfns - free_pages)
> +                                         << (XC_PAGE_SHIFT - 10))) < 0)
> +                {
> +                    ERROR("Failed xc_domain_setmaxmem for apply_batch\n");
> +                    errno = ENOMEM;
> +                    return -1;
> +                }
> +            }
>               rc = xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0, 0,
>                                                     ctx->p2m_batch);
> +        }
>
>           if (rc)
>           {
> -            ERROR("Failed to allocate memory for batch.!\n");
> +            ERROR("Failed to allocate memory for apply_batch. rc=%d nr_mfns=%d max_mfn=%lu!\n",
> +                  rc, nr_mfns, ctx->max_mfn);
>               errno = ENOMEM;
>               return -1;
>           }
>

-- 
Thanks,
Yang.

  parent reply	other threads:[~2015-04-14  3:46 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 16:09 [PATCH 1/1] xc_domain_restore: Allow QEMU to increase memory Don Slutz
2015-04-13 16:20 ` Wei Liu
2015-04-13 23:51   ` Don Slutz
2015-04-13 16:25 ` Andrew Cooper
2015-04-13 23:51   ` Don Slutz
2015-04-14  8:53     ` Wei Liu
2015-04-14 17:34       ` Don Slutz
2015-04-14 17:51         ` Wei Liu
2015-04-15  9:46         ` Stefano Stabellini
2015-04-15 10:09           ` Ian Campbell
2015-04-15 11:15             ` Hongyang Yang
2015-04-15 11:27               ` Stefano Stabellini
2015-04-15 11:56                 ` Ian Campbell
2015-04-15 18:19                   ` Don Slutz
2015-04-14  8:53     ` Andrew Cooper
2015-04-14  9:22       ` Hongyang Yang
2015-04-14  9:28         ` Andrew Cooper
2015-04-14  9:42           ` Hongyang Yang
2015-04-15 14:32             ` Ian Campbell
2015-04-15 20:41               ` Don Slutz
2015-04-14  9:29         ` Wei Liu
2015-04-14  9:40           ` Hongyang Yang
2015-04-14  9:52             ` Wei Liu
2015-04-14 17:43               ` Don Slutz
2015-04-14 17:54                 ` Wei Liu
2015-04-14 22:06                   ` [PATCH v2 1/1] tools: Handle xc_maxmem adjustments Don Slutz
2015-04-15  9:53                     ` Andrew Cooper
2015-04-15  9:57                       ` Stefano Stabellini
2015-04-15 10:03                         ` Andrew Cooper
2015-04-15 10:21                           ` George Dunlap
2015-04-15 11:48                           ` Stefano Stabellini
2015-04-15 21:43                             ` Don Slutz
2015-04-15 10:16                       ` George Dunlap
2015-04-15 10:25                         ` George Dunlap
2015-04-15 10:30                           ` Andrew Cooper
2015-04-15 14:34                   ` [PATCH 1/1] xc_domain_restore: Allow QEMU to increase memory Ian Campbell
2015-04-15 16:36                     ` Wei Liu
2015-04-15 16:45                       ` Ian Campbell
2015-04-15 16:52                         ` Wei Liu
2015-04-15 18:24                           ` Don Slutz
2015-04-16  9:00                           ` Ian Campbell
2015-04-16  9:14                             ` George Dunlap
2015-04-16  9:29                               ` Ian Campbell
2015-04-14  3:46 ` Hongyang Yang [this message]
2015-04-14  8:46   ` Wei Liu
2015-04-15 14:30 ` Ian Campbell
2015-04-15 18:17   ` Don Slutz

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=552C8DAF.9070103@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dslutz@verizon.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=rshriram@cs.ubc.ca \
    --cc=stefano.stabellini@eu.citrix.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.