From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
samuel.thibault@ens-lyon.org, wei.liu2@citrix.com
Subject: [PATCH 8/9] mini-os: get maximum memory size from hypervisor
Date: Tue, 19 Jul 2016 10:44:24 +0200 [thread overview]
Message-ID: <1468917865-12828-9-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1468917865-12828-1-git-send-email-jgross@suse.com>
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@suse.com>
---
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
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-19 8:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 8:44 [PATCH 0/9] mini-os: prepare for support of ballooning Juergen Gross
2016-07-19 8:44 ` [PATCH 1/9] mini-os: correct first free pfn Juergen Gross
2016-07-19 8:44 ` [PATCH 2/9] mini-os: remove unused alloc_contig_pages() function Juergen Gross
2016-07-19 8:44 ` [PATCH 3/9] mini-os: remove MM_DEBUG code Juergen Gross
2016-07-19 8:44 ` [PATCH 4/9] mini-os: add description of x86 memory usage Juergen Gross
2016-07-19 8:44 ` [PATCH 5/9] mini-os: add nr_free_pages counter Juergen Gross
2016-07-19 8:44 ` [PATCH 6/9] mini-os: let memory allocation fail if no free page available Juergen Gross
2016-07-19 8:44 ` [PATCH 7/9] mini-os: add ballooning config item Juergen Gross
2016-07-19 8:44 ` Juergen Gross [this message]
2016-07-19 8:44 ` [PATCH 9/9] mini-os: modify virtual memory layout for support of ballooning Juergen Gross
2016-07-25 13:52 ` [PATCH 0/9] mini-os: prepare " Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468917865-12828-9-git-send-email-jgross@suse.com \
--to=jgross@suse.com \
--cc=minios-devel@lists.xenproject.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).