[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 3/5] xen/arm: unpopulate memory when domain on static allocation
Today when a domain unpopulates the memory on runtime, they will always hand the memory over to the heap allocator. And it will be a problem if domain on static allocation. Guest RAM for domain on static allocation is static memory, which is reserved to only this domain, so it shall never go back to heap. For above purpose, this commit tries to keep page allocated and store it in page list d->resv_page_list on guest_remove_page, when domain on static allocation. Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx> --- xen/common/domain.c | 4 ++++ xen/common/memory.c | 22 +++++++++++++++++++++- xen/include/xen/sched.h | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 351029f8b2..e572f27fce 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -602,6 +602,10 @@ struct domain *domain_create(domid_t domid, INIT_PAGE_LIST_HEAD(&d->page_list); INIT_PAGE_LIST_HEAD(&d->extra_page_list); INIT_PAGE_LIST_HEAD(&d->xenpage_list); +#ifdef CONFIG_STATIC_MEMORY + INIT_PAGE_LIST_HEAD(&d->resv_page_list); +#endif + spin_lock_init(&d->node_affinity_lock); d->node_affinity = NODE_MASK_ALL; diff --git a/xen/common/memory.c b/xen/common/memory.c index 69b0cd1e50..2afc3c6f10 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -35,6 +35,10 @@ #include <asm/guest.h> #endif +#ifndef is_domain_on_static_allocation +#define is_domain_on_static_allocation(d) 0 +#endif + struct memop_args { /* INPUT */ struct domain *domain; /* Domain to be affected. */ @@ -405,13 +409,29 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) * device must retrieve the same pfn when the hypercall populate_physmap * is called. * + * When domain on static allocation, they should always get pages from the + * reserved static region when the hypercall populate_physmap is called. + * * For this purpose (and to match populate_physmap() behavior), the page * is kept allocated. */ - if ( !rc && !is_domain_direct_mapped(d) ) + if ( !rc && !(is_domain_direct_mapped(d) || + is_domain_on_static_allocation(d)) ) put_page_alloc_ref(page); put_page(page); +#ifdef CONFIG_STATIC_MEMORY + /* + * When domain on static allocation, we shall store pages to resv_page_list, + * so the hypercall populate_physmap could retrieve pages from it, + * rather than allocating from heap. + */ + if ( is_domain_on_static_allocation(d) ) + { + page_list_add_tail(page, &d->resv_page_list); + d->resv_pages++; + } +#endif #ifdef CONFIG_X86 out_put_gfn: diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 406d9bc610..d7e047bf36 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -376,6 +376,9 @@ struct domain struct page_list_head page_list; /* linked list */ struct page_list_head extra_page_list; /* linked list (size extra_pages) */ struct page_list_head xenpage_list; /* linked list (size xenheap_pages) */ +#ifdef CONFIG_STATIC_MEMORY + struct page_list_head resv_page_list; /* linked list (size resv_pages) */ +#endif /* * This field should only be directly accessed by domain_adjust_tot_pages() @@ -389,6 +392,9 @@ struct domain unsigned int extra_pages; /* pages not included in domain_tot_pages() */ atomic_t shr_pages; /* shared pages */ atomic_t paged_pages; /* paged-out pages */ +#ifdef CONFIG_STATIC_MEMORY + unsigned int resv_pages; /* reserved pages from static region. */ +#endif /* Scheduling. */ void *sched_priv; /* scheduler-specific data */ -- 2.25.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |