[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/6] xen/arm: unpopulate memory when domain is static
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Penny Zheng <Penny.Zheng@xxxxxxx>
- Date: Wed, 27 Apr 2022 17:27:42 +0800
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rCND5tjX5cKrs7fmmCD71EclFIECccAGVb3ArYFdizM=; b=RBR5KkIyVp5gpUt7Eu4MJi3NvQluON6G3W3eywgyhW9bNwt1g4NZWmt+Ru31RFbvfYUP+cOPVrxUQzhhYIbfeMhuiMtCHxWidRRPsiCQOTKZTr9aRJWsN4QdXQp70SP2IX5J0n5I+F871AyI0ZYgG/7gLkjvdzIj+rQjYQk2hD+4oemlveXIL0XueuMvZuuprBHo7P6Qo+KoVopsWdw/NiHlxQd8me98rk05A5E0S5vzW712fPpDAqOBupprT9Dp1TgAAjboFl2n3C4R0ritHDUgNE+1ubPapzaadJDGYkTF34O8k4JVpq3oRS9S6EBPm5+7bZIbM8nYTjNhnmagPw==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rCND5tjX5cKrs7fmmCD71EclFIECccAGVb3ArYFdizM=; b=mYTkotw3LsfsobX6sYZ/FfNfEwK2wW2W/6vpMvVudajP5GD65FAepkRcYH8f1b5CMBt8ORrtDJRvAxAYmblIm5bzQlQwfFbTZly71kA/muxJfGcC2uMFTKEkPAbn4cjNRwxVvKMuLou7rLSAIQmIE4VeRGrHSYCFNji7xZzLSBYY3NanwpPQmkf9BCR2vpix/JSxXgumoypDs8p1EOL6ncOSOTqXmhHZAu/xPSufOCJhV5tLsbCiEeELTIjqI5FIXzszeFRmYrz3Rj0O1WN+NF0Vxx7YayIvopDEHuhg03mWbut+GrAeZiudxFFyfLYbU3yZeZPt3TJ1teQ3/kJMVQ==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Lp14PJgJSL8DfRY/vNVSTgnaJP2+SXMtOOaxSIdSN0G4aM5/fBYLJIYOAFjptaxa+83YZhxJED9CAGp+7zwj0E6fc0Qlfr9XBRJP+HDrXXEwd4Ow1xEiEMDKbnJ7J/lJednUxQsCAF02YPLXXpfaapzeuSYqvg7+RZ7RW4ZylLhZY/72Xkgp8AkvrpnQFr0iU+dLU40fgzOvBoBtIRlpg2qVviFOVl5Rv78ey7WWnNbIOqduYP8ZxAAxmXTGMv7Y0YYVT9SOsQz6xRROZUUw/yP/vleGtXsZ+DHJTxDCSFoJoZNHH2A1DxRF8SFld7T7EQ74K7FFjW8KvRrukTVJOw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DW8tuW/3PO3wj6ibJeBkmJxfFZgNLMjZ7tiByBHf0tda8nRNSZ3rplcFJROl57zqMDK5i9Zb/EPy8DzeA1ItH60aptA44Ok7GNKXGPSkuIpQPvBQQwZT/HvsAH5UXUEWd+DlpE+n3Oo0iaKwiFrrlnKY3k6isataHH7eQG6QNnsWKYG4p7tQPAYWFy9qhyCU0fGHnTimmMZYYhkxhyva1Q9CQMCzpcD0Vdj/o/EjOqdwb4g6lWjmzBNME9V6VKHFAo73/qhYRwLfVLqaqHi3SQnCHxetujQUsFNm17oZu7A56smfPc49t2Pjo0PO3nBakb+1PV9TgTscui6Rej1DIw==
- Cc: <wei.chen@xxxxxxx>, <henry.wang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
- Delivery-date: Wed, 27 Apr 2022 09:29:22 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
Today when a domain unpopulates the memory on runtime, they will always
hand the memory back to the heap allocator. And it will be a problem if domain
is static.
Pages as guest RAM for static domain shall be reserved to only this domain
and not be used for any other purposes, so they shall never go back to heap
allocator.
This commit puts reserved pages on the new list resv_page_list only after
having taken them off the "normal" list, when the last ref dropped.
Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
v3 changes:
- have page_list_del() just once out of the if()
- remove resv_pages counter
- make arch_free_heap_page be an expression, not a compound statement.
---
v2 changes:
- put reserved pages on resv_page_list after having taken them off
the "normal" list
---
xen/arch/arm/include/asm/mm.h | 12 ++++++++++++
xen/common/domain.c | 4 ++++
xen/include/xen/sched.h | 3 +++
3 files changed, 19 insertions(+)
diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
index 424aaf2823..c6426c1705 100644
--- a/xen/arch/arm/include/asm/mm.h
+++ b/xen/arch/arm/include/asm/mm.h
@@ -358,6 +358,18 @@ void clear_and_clean_page(struct page_info *page);
unsigned int arch_get_dma_bitsize(void);
+/*
+ * Put free pages on the resv page list after having taken them
+ * off the "normal" page list, when pages from static memory
+ */
+#ifdef CONFIG_STATIC_MEMORY
+#define arch_free_heap_page(d, pg) ({ \
+ page_list_del(pg, page_to_list(d, pg)); \
+ if ( (pg)->count_info & PGC_reserved ) \
+ page_list_add_tail(pg, &(d)->resv_page_list); \
+})
+#endif
+
#endif /* __ARCH_ARM_MM__ */
/*
* Local variables:
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 6373407047..13fe7cecff 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -604,6 +604,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/include/xen/sched.h b/xen/include/xen/sched.h
index 49415a113a..368e5c1c53 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()
--
2.25.1
|