From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, david.vrabel@citrix.com, JBeulich@suse.com
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH] auto balloon initial domain and fix dom0_mem=X inconsistencies (v5).
Date: Tue, 1 May 2012 12:37:07 -0400 [thread overview]
Message-ID: <20120501163707.GA8741@phenom.dumpdata.com> (raw)
In-Reply-To: <1334596539-18172-1-git-send-email-konrad.wilk@oracle.com>
On Mon, Apr 16, 2012 at 01:15:31PM -0400, Konrad Rzeszutek Wilk wrote:
> Changelog v5 [since v4]:
> - used populate_physmap, fixed bugs.
> [v2-v4: not posted]
> - reworked the code in setup.c to work properly.
> [v1: https://lkml.org/lkml/2012/3/30/492]
> - initial patchset
One bug I found was that with 'dom0_mem=max:1G' (with and without these
patches) I would get a bunch of
(XEN) page_alloc.c:1148:d0 Over-allocation for domain 0: 2097153 > 2097152
(XEN) memory.c:133:d0 Could not allocate order=0 extent: id=0 memflags=0 (0 of 17)
where the (0 of X), sometimes was 1, 2,3,4 or 17 -depending on the machine
I ran on it. I figured it out that the difference was in the ACPI tables
that are allocated - and that those regions - even though are returned
back to the hypervisor, cannot be repopulated. I can't find the actual
exact piece of code in the hypervisor to pin-point and say "Aha".
What I did was use the same metrix that the hypervisor uses to figure
out whether to deny the guest ballooning up - checking the d->tot_pages
against t->max_pages. For that the XENMEM_current_reservation is used.
>From e4568b678455f68d374277319fb5cc41f11b6c4f Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Thu, 26 Apr 2012 22:11:08 -0400
Subject: [PATCH] xen/setup: Cap amount to populate based on current tot_pages
count.
Previous to this patch we would try to populate exactly up to
xen_released_pages number (so the ones that we released), but
that is incorrect as there are some pages that we thought were
released but in actuality were shared. Depending on the platform
it could be small amounts - 2 pages, but some had much higher - 17.
As such, lets use the XENMEM_current_reservation to get the exact
count of pages we are using, subtract it from nr_pages and use the
lesser of this and xen_released_pages to populate back.
This fixes errors such as:
(XEN) page_alloc.c:1148:d0 Over-allocation for domain 0: 2097153 > 2097152
(XEN) memory.c:133:d0 Could not allocate order=0 extent: id=0 memflags=0 (0 of 17)
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/xen/setup.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 506a3e6..8e7dcfd 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -287,7 +287,15 @@ static unsigned long __init xen_get_max_pages(void)
return min(max_pages, MAX_DOMAIN_PAGES);
}
-
+static unsigned long xen_get_current_pages(void)
+{
+ domid_t domid = DOMID_SELF;
+ int ret;
+ ret = HYPERVISOR_memory_op(XENMEM_current_reservation, &domid);
+ if (ret > 0)
+ return ret;
+ return 0;
+}
static void xen_align_and_add_e820_region(u64 start, u64 size, int type)
{
u64 end = start + size;
@@ -358,7 +366,11 @@ char * __init xen_memory_setup(void)
/*
* Populate back the non-RAM pages and E820 gaps that had been
- * released. */
+ * released. But cap it as certain regions cannot be repopulated.
+ */
+ if (xen_get_current_pages())
+ xen_released_pages = min(max_pfn - xen_get_current_pages(),
+ xen_released_pages);
populated = xen_populate_chunk(map, memmap.nr_entries,
max_pfn, &last_pfn, xen_released_pages);
--
1.7.7.5
next prev parent reply other threads:[~2012-05-01 16:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-16 17:15 [PATCH] auto balloon initial domain and fix dom0_mem=X inconsistencies (v5) Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 1/8] xen/p2m: Move code around to allow for better re-usage Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 2/8] xen/p2m: Allow alloc_p2m_middle to call reserve_brk depending on argument Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 3/8] xen/p2m: Collapse early_alloc_p2m_middle redundant checks Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 4/8] xen/p2m: An early bootup variant of set_phys_to_machine Konrad Rzeszutek Wilk
2012-04-16 17:15 ` [PATCH 5/8] xen/setup: Only print "Freeing XXX-YYY pfn range: Z pages freed" if Z > 0 Konrad Rzeszutek Wilk
2012-05-03 11:59 ` David Vrabel
2012-04-16 17:15 ` [PATCH 6/8] xen/setup: Work properly with 'dom0_mem=X' or with not dom0_mem Konrad Rzeszutek Wilk
2012-05-03 11:54 ` [Xen-devel] " David Vrabel
2012-04-16 17:15 ` [PATCH 7/8] xen/setup: Populate freed MFNs from non-RAM E820 entries and gaps to E820 RAM Konrad Rzeszutek Wilk
2012-05-03 11:56 ` [Xen-devel] " David Vrabel
2012-04-16 17:15 ` [PATCH 8/8] xen/setup: Combine the two hypercall functions - since they are quite similar Konrad Rzeszutek Wilk
2012-05-03 11:58 ` [Xen-devel] " David Vrabel
2012-05-03 15:37 ` Konrad Rzeszutek Wilk
2012-05-01 16:37 ` Konrad Rzeszutek Wilk [this message]
2012-05-02 9:05 ` [PATCH] auto balloon initial domain and fix dom0_mem=X inconsistencies (v5) Jan Beulich
2012-05-03 11:48 ` David Vrabel
2012-05-03 15:15 ` [Xen-devel] " David Vrabel
2012-05-03 16:27 ` David Vrabel
2012-05-07 18:48 ` Konrad Rzeszutek Wilk
2012-05-08 18:12 ` David Vrabel
2012-05-08 18:24 ` Konrad Rzeszutek Wilk
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=20120501163707.GA8741@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=JBeulich@suse.com \
--cc=david.vrabel@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xensource.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).