From: Daniel Kiper <daniel.kiper@oracle.com>
To: carsten@schiers.de, darren.s.shepherd@gmail.com,
david.vrabel@citrix.com, ian.campbell@citrix.com,
ian.jackson@eu.citrix.com, james-xen@dingwall.me.uk,
konrad.wilk@oracle.com, linux-kernel@vger.kernel.org,
xen-devel@lists.xensource.com
Cc: Daniel Kiper <daniel.kiper@oracle.com>
Subject: [PATCH v2 2/2] xen/balloon: Enforce various limits on target
Date: Mon, 29 Apr 2013 13:37:48 +0200 [thread overview]
Message-ID: <1367235468-8360-3-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1367235468-8360-1-git-send-email-daniel.kiper@oracle.com>
This patch enforces on target limit statically defined in Linux Kernel
source and limit defined by hypervisor or host. This way the balloon
driver should not attempt to populate pages above given limits
because they may fail.
Particularly this patch fixes bug which led to flood
of dom0 kernel log with messages similar to:
System RAM resource [mem 0x1b8000000-0x1bfffffff] cannot be added
xen_balloon: reserve_additional_memory: add_memory() failed: -17
v2 - suggestions/fixes:
- always use maximum reservation as a refernce
(suggested by David Vrabel),
- change logging level for dom0
(suggested by Konrad Rzeszutek Wilk),
- improve commit comment
(suggested by David Vrabel).
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
drivers/xen/balloon.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 856661f..a3a8eaa 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -81,7 +81,6 @@ enum bp_state {
BP_ECANCELED
};
-
static DEFINE_MUTEX(balloon_mutex);
struct balloon_stats balloon_stats;
@@ -90,6 +89,12 @@ EXPORT_SYMBOL_GPL(balloon_stats);
/* We increase/decrease in batches which fit in a page */
static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)];
+/*
+ * Extra internal memory reserved by libxl.
+ * Check tools/libxl/libxl_memory.txt file in Xen source for more details.
+ */
+#define LIBXL_MAXMEM_CONSTANT_PAGES (1024 * 1024 / PAGE_SIZE)
+
#ifdef CONFIG_HIGHMEM
#define inc_totalhigh_pages() (totalhigh_pages++)
#define dec_totalhigh_pages() (totalhigh_pages--)
@@ -491,11 +496,42 @@ static void balloon_process(struct work_struct *work)
mutex_unlock(&balloon_mutex);
}
-/* Resets the Xen limit, sets new target, and kicks off processing. */
+/* Enforce limits, set new target and kick off processing. */
void balloon_set_new_target(unsigned long target)
{
+ domid_t domid = DOMID_SELF;
+ int rc;
+
+ /* Enforce statically defined limit. */
+ target = min(target, MAX_DOMAIN_PAGES);
+
+ rc = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
+
+ if (xen_initial_domain()) {
+ if (rc <= 0) {
+ pr_debug("xen_balloon: %s: Initial domain target limit "
+ "could not be established: %i\n",
+ __func__, rc);
+ goto no_host_limit;
+ }
+ } else {
+ if (rc <= 0) {
+ pr_info("xen_balloon: %s: Guest domain target limit "
+ "could not be established: %i\n", __func__, rc);
+ goto no_host_limit;
+ }
+
+ /* Do not take into account memory reserved for internal stuff. */
+ rc -= LIBXL_MAXMEM_CONSTANT_PAGES;
+ }
+
+ /* Enforce hypervisor/host defined limit. */
+ target = min_t(unsigned long, target, rc);
+
+no_host_limit:
/* No need for lock. Not read-modify-write updates. */
balloon_stats.target_pages = target;
+
schedule_delayed_work(&balloon_worker, 0);
}
EXPORT_SYMBOL_GPL(balloon_set_new_target);
--
1.7.10.4
next prev parent reply other threads:[~2013-04-29 11:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-29 11:37 [PATCH v2 0/2] xen/balloon: Extension and fix Daniel Kiper
2013-04-29 11:37 ` [PATCH v2 1/2] xen/balloon: Notify a host about a guest memory size limit Daniel Kiper
2013-04-29 14:35 ` Ian Campbell
2013-04-30 12:40 ` Daniel Kiper
2013-04-29 11:37 ` Daniel Kiper [this message]
2013-04-29 14:44 ` [PATCH v2 2/2] xen/balloon: Enforce various limits on target Ian Campbell
2013-04-30 12:59 ` Daniel Kiper
2013-04-30 13:44 ` Ian Campbell
2013-04-30 18:58 ` Daniel Kiper
2013-05-02 11:34 ` Stefano Stabellini
2013-05-02 18:04 ` Konrad Rzeszutek Wilk
2013-05-03 8:15 ` [Xen-devel] " Ian Campbell
2013-05-03 13:00 ` Daniel Kiper
2013-05-03 13:21 ` Ian Campbell
2013-05-03 13:47 ` Daniel Kiper
2013-05-03 14:11 ` Ian Campbell
2013-05-03 15:47 ` Daniel Kiper
2013-05-03 16:00 ` Ian Campbell
2013-05-03 8:04 ` Ian Campbell
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=1367235468-8360-3-git-send-email-daniel.kiper@oracle.com \
--to=daniel.kiper@oracle.com \
--cc=carsten@schiers.de \
--cc=darren.s.shepherd@gmail.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=james-xen@dingwall.me.uk \
--cc=konrad.wilk@oracle.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