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 5/9] mini-os: add nr_free_pages counter
Date: Tue, 19 Jul 2016 10:44:21 +0200 [thread overview]
Message-ID: <1468917865-12828-6-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1468917865-12828-1-git-send-email-jgross@suse.com>
Add a variable holding the number of available memory pages. This will
aid auto-ballooning later.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
include/mm.h | 1 +
mm.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/include/mm.h b/include/mm.h
index a48f485..b97b43e 100644
--- a/include/mm.h
+++ b/include/mm.h
@@ -42,6 +42,7 @@
#define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER
#define STACK_SIZE __STACK_SIZE
+extern unsigned long nr_free_pages;
void init_mm(void);
unsigned long alloc_pages(int order);
diff --git a/mm.c b/mm.c
index 0dd4862..263a356 100644
--- a/mm.c
+++ b/mm.c
@@ -53,6 +53,8 @@ static unsigned long *alloc_bitmap;
#define allocated_in_map(_pn) \
(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1UL<<((_pn)&(PAGES_PER_MAPWORD-1))))
+unsigned long nr_free_pages;
+
/*
* Hint regarding bitwise arithmetic in map_{alloc,free}:
* -(1<<n) sets all bits >= n.
@@ -81,6 +83,8 @@ static void map_alloc(unsigned long first_page, unsigned long nr_pages)
while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL;
alloc_bitmap[curr_idx] |= (1UL<<end_off)-1;
}
+
+ nr_free_pages -= nr_pages;
}
@@ -93,6 +97,8 @@ static void map_free(unsigned long first_page, unsigned long nr_pages)
end_idx = (first_page + nr_pages) / PAGES_PER_MAPWORD;
end_off = (first_page + nr_pages) & (PAGES_PER_MAPWORD-1);
+ nr_free_pages += nr_pages;
+
if ( curr_idx == end_idx )
{
alloc_bitmap[curr_idx] &= -(1UL<<end_off) | ((1UL<<start_off)-1);
--
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 ` Juergen Gross [this message]
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 ` [PATCH 8/9] mini-os: get maximum memory size from hypervisor Juergen Gross
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-6-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).