From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andres Lagar-Cavilla Subject: [PATCH 4 of 4] Global virq for low memory situations Date: Wed, 15 Feb 2012 22:57:07 -0500 Message-ID: <65c15f3c96117a249140.1329364627@xdev.gridcentric.ca> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: andres@gridcentric.ca, tim@xen.org, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org 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 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 #include #include +#include #include #include #include @@ -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