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

[Xen-changelog] [mini-os master] mini-os: add nr_free_pages counter



commit bec5839b19f51485c4a92c9321e7986ed97b9065
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Jul 12 13:43:55 2016 +0200
Commit:     Juergen Gross <jgross@xxxxxxxx>
CommitDate: Thu Aug 11 13:03:50 2016 +0200

    mini-os: add nr_free_pages counter
    
    Add a variable holding the number of available memory pages. This will
    aid auto-ballooning later.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
 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);
--
generated by git-patchbot for /home/xen/git/mini-os.git#master

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

 


Rackspace

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