diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 6a1b6bde72..10c6b22093 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -316,11 +316,14 @@ static struct page_info *alloc_heap_pages( spin_lock(&heap_lock); /* - * TMEM: When available memory is scarce, allow only mid-size allocations - * to avoid worst of fragmentation issues. Others try TMEM pools then fail. + * TMEM: When available memory is scarce due to tmem absorbing it, allow + * only mid-size allocations to avoid worst of fragmentation issues. + * Others try tmem pools then fail. This is a workaround until all + * post-dom0-creation-multi-page allocations can be eliminated. */ if ( opt_tmem && ((order == 0) || (order >= 9)) && - (total_avail_pages <= midsize_alloc_zone_pages) ) + (total_avail_pages <= midsize_alloc_zone_pages) && + tmem_freeable_pages() ) goto try_tmem; /* diff --git a/xen/common/tmem.c b/xen/common/tmem.c index a3f236ae0b..b917fae522 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -2850,6 +2850,11 @@ EXPORT void *tmem_relinquish_pages(unsigned int order, unsigned int memflags) return pfp; } +EXPORT unsigned long tmem_freeable_pages(void) +{ + return tmh_freeable_pages(); +} + /* called at hypervisor startup */ static int __init init_tmem(void) { diff --git a/xen/include/xen/tmem.h b/xen/include/xen/tmem.h index 9140b08847..cc19110505 100644 --- a/xen/include/xen/tmem.h +++ b/xen/include/xen/tmem.h @@ -11,6 +11,7 @@ extern void tmem_destroy(void *); extern void *tmem_relinquish_pages(unsigned int, unsigned int); +extern unsigned long tmem_freeable_pages(void); extern int opt_tmem; #endif /* __XEN_TMEM_H__ */