[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 08/18] 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>
---
V2: Moved new stuff to balloon.c
---
 balloon.c         | 22 ++++++++++++++++++++++
 include/balloon.h |  6 ++++++
 mm.c              |  3 ++-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/balloon.c b/balloon.c
index 9cabde0..4c18c5c 100644
--- a/balloon.c
+++ b/balloon.c
@@ -21,4 +21,26 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <mini-os/os.h>
 #include <mini-os/balloon.h>
+#include <mini-os/lib.h>
+#include <xen/xen.h>
+#include <xen/memory.h>
+
+unsigned long nr_max_pages;
+
+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);
+}
diff --git a/include/balloon.h b/include/balloon.h
index 399fff4..e7219f8 100644
--- a/include/balloon.h
+++ b/include/balloon.h
@@ -26,7 +26,13 @@
 
 #ifdef CONFIG_BALLOON
 
+extern unsigned long nr_max_pages;
+
+void get_max_pages(void);
+
 #else /* CONFIG_BALLOON */
 
+static inline void get_max_pages(void) { }
+
 #endif /* CONFIG_BALLOON */
 #endif /* _BALLOON_H_ */
diff --git a/mm.c b/mm.c
index 8cf3210..25ee3da 100644
--- a/mm.c
+++ b/mm.c
@@ -38,6 +38,7 @@
 #include <mini-os/hypervisor.h>
 #include <xen/memory.h>
 #include <mini-os/mm.h>
+#include <mini-os/balloon.h>
 #include <mini-os/types.h>
 #include <mini-os/lib.h>
 #include <mini-os/xmalloc.h>
@@ -353,7 +354,6 @@ void *sbrk(ptrdiff_t increment)
 #endif
 
 
-
 void init_mm(void)
 {
 
@@ -361,6 +361,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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.