|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [PATCH 8/9] mini-os: get maximum memory size from hypervisor
Add support for obtaining the maximum memory size from the hypervisor.
This will make it possible to support ballooning.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
include/mm.h | 1 +
mm.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/mm.h b/include/mm.h
index b97b43e..161483f 100644
--- a/include/mm.h
+++ b/include/mm.h
@@ -43,6 +43,7 @@
#define STACK_SIZE __STACK_SIZE
extern unsigned long nr_free_pages;
+extern unsigned long nr_max_pages;
void init_mm(void);
unsigned long alloc_pages(int order);
diff --git a/mm.c b/mm.c
index 185a8a5..d4a8f1e 100644
--- a/mm.c
+++ b/mm.c
@@ -54,6 +54,7 @@ static unsigned long *alloc_bitmap;
(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1UL<<((_pn)&(PAGES_PER_MAPWORD-1))))
unsigned long nr_free_pages;
+unsigned long nr_max_pages;
/*
* Hint regarding bitwise arithmetic in map_{alloc,free}:
@@ -350,7 +351,27 @@ void *sbrk(ptrdiff_t increment)
}
#endif
+#ifdef CONFIG_BALLOON
+static void get_max_pages(void)
+{
+ long ret;
+ domid_t domid = DOMID_SELF;
+ ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
+ if (ret < 0) {
+ printk("Could not get maximum pfn\n");
+ return;
+ }
+
+ nr_max_pages = ret;
+ printk("Maximum memory size: %ld pages\n", nr_max_pages);
+}
+#else
+static unsigned long get_max_pages(void)
+{
+ return 0;
+}
+#endif
void init_mm(void)
{
@@ -359,6 +380,7 @@ void init_mm(void)
printk("MM: Init\n");
+ get_max_pages();
arch_init_mm(&start_pfn, &max_pfn);
/*
* now we can initialise the page allocator
--
2.6.6
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |