From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: andres@gridcentric.ca, tim@xen.org, adin@gridcentric.ca
Subject: [PATCH 4 of 4] Global virq for low memory situations
Date: Wed, 15 Feb 2012 22:57:07 -0500 [thread overview]
Message-ID: <65c15f3c96117a249140.1329364627@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1329364623@xdev.gridcentric.ca>
xen/common/page_alloc.c | 10 ++++++++++
xen/include/public/xen.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
When a low memory threshold on the Xen heap is reached, we fire a global dom0
virq. If someone's listening, they can free up some more memory. The low
threshold is configurable via the command line token 'low_mem_virq_limit", and
defaults to 64MiB. We define a new virq VIRQ_ENOMEM. Potential listeners
include squeezed, xenballoond, or anything else that can be fired through
xencommons.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r 407b5ac709aa -r 65c15f3c9611 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -35,6 +35,7 @@
#include <xen/perfc.h>
#include <xen/numa.h>
#include <xen/nodemask.h>
+#include <xen/event.h>
#include <xen/tmem.h>
#include <xen/tmem_xen.h>
#include <public/sysctl.h>
@@ -300,6 +301,12 @@ static unsigned long init_node_heap(int
return needed;
}
+/* Default to 64 MiB */
+#define DEFAULT_LOW_MEM_VIRQ_MIB 64
+static unsigned long long __read_mostly opt_low_mem_virq =
+ (DEFAULT_LOW_MEM_VIRQ_MIB << 20);
+size_param("low_mem_virq_limit", opt_low_mem_virq);
+
/* Allocate 2^@order contiguous pages. */
static struct page_info *alloc_heap_pages(
unsigned int zone_lo, unsigned int zone_hi,
@@ -420,6 +427,9 @@ static struct page_info *alloc_heap_page
total_avail_pages -= request;
ASSERT(total_avail_pages >= 0);
+ if ( (total_avail_pages << PAGE_SHIFT) <= opt_low_mem_virq )
+ send_global_virq(VIRQ_ENOMEM);
+
if ( d != NULL )
d->last_alloc_node = node;
diff -r 407b5ac709aa -r 65c15f3c9611 xen/include/public/xen.h
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -157,6 +157,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */
#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */
#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */
+#define VIRQ_ENOMEM 12 /* G. (DOM0) Dangerously low on heap memory */
/* Architecture-specific VIRQ definitions. */
#define VIRQ_ARCH_0 16
next prev parent reply other threads:[~2012-02-16 3:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 3:57 [PATCH 0 of 4] Handling of (some) low memory conditions Andres Lagar-Cavilla
2012-02-16 3:57 ` [PATCH 1 of 4] Prevent low values of max_pages for domains doing sharing or paging Andres Lagar-Cavilla
2012-02-16 9:16 ` Jan Beulich
2012-02-16 10:20 ` Tim Deegan
2012-02-16 14:45 ` Andres Lagar-Cavilla
2012-02-16 14:58 ` Tim Deegan
2012-02-16 15:32 ` Jan Beulich
2012-02-16 16:08 ` Tim Deegan
2012-02-16 16:44 ` Jan Beulich
2012-02-16 3:57 ` [PATCH 2 of 4] x86/mm: Allow to not sleep on mem event ring Andres Lagar-Cavilla
2012-02-16 16:11 ` Tim Deegan
2012-02-17 16:57 ` Andres Lagar-Cavilla
2012-02-16 3:57 ` [PATCH 3 of 4] Memory sharing: better handling of ENOMEM while unsharing Andres Lagar-Cavilla
2012-02-16 16:19 ` Tim Deegan
2012-02-17 17:01 ` Andres Lagar-Cavilla
2012-02-16 3:57 ` Andres Lagar-Cavilla [this message]
2012-02-16 9:31 ` [PATCH 0 of 4] Handling of (some) low memory conditions Jan Beulich
2012-02-16 14:40 ` Andres Lagar-Cavilla
2012-02-16 15:22 ` Jan Beulich
2012-02-16 15:34 ` Andres Lagar-Cavilla
2012-02-16 16:26 ` 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=65c15f3c96117a249140.1329364627@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=adin@gridcentric.ca \
--cc=andres@gridcentric.ca \
--cc=tim@xen.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).