xenpaging: track number of paged pages in struct domain
authorOlaf Hering <olafiaepfle.de>
Mon, 26 Sep 2011 21:19:42 +0000 (22:19 +0100)
committerOlaf Hering <olafiaepfle.de>
Mon, 26 Sep 2011 21:19:42 +0000 (22:19 +0100)
The toolstack should know how many pages are paged-out at a given point
in time so it could make smarter decisions about how many pages should
be paged or ballooned.

Add a new member to xen_domctl_getdomaininfo and bump interface version.
Use the new member in xc_dominfo_t.
The SONAME of libxc should be changed if this patch gets applied.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
tools/libxc/xc_domain.c
tools/libxc/xenctrl.h
xen/arch/x86/mm/p2m.c
xen/common/domctl.c
xen/include/public/domctl.h
xen/include/xen/sched.h

index d6f007df531c953a5998f58ef431f237b9c57471..b6c67a2e4aa71dd7bb813811aa015574393f4429 100644 (file)
@@ -235,6 +235,7 @@ int xc_domain_getinfo(xc_interface *xch,
         info->ssidref  = domctl.u.getdomaininfo.ssidref;
         info->nr_pages = domctl.u.getdomaininfo.tot_pages;
         info->nr_shared_pages = domctl.u.getdomaininfo.shr_pages;
+        info->nr_paged_pages = domctl.u.getdomaininfo.paged_pages;
         info->max_memkb = domctl.u.getdomaininfo.max_pages << (PAGE_SHIFT-10);
         info->shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
         info->cpu_time = domctl.u.getdomaininfo.cpu_time;
index 4bcb9bd6c9d6135d8c987b824f3d11e5b11d3d68..3a6071f114ecd07146f64aaf506019c3ade151ee 100644 (file)
@@ -351,6 +351,7 @@ typedef struct xc_dominfo {
     unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
     unsigned long nr_pages; /* current number, not maximum */
     unsigned long nr_shared_pages;
+    unsigned long nr_paged_pages;
     unsigned long shared_info_frame;
     uint64_t      cpu_time;
     unsigned long max_memkb;
index c62aa12da7eea69ffea3b97870d8e6c1214110ab..b6fb4d82759275e0e504d76b5d9d2ef9ad54b145 100644 (file)
@@ -746,6 +746,9 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn)
     /* Put the page back so it gets freed */
     put_page(page);
 
+    /* Track number of paged gfns */
+    atomic_inc(&d->paged_pages);
+
     return 0;
 }
 
@@ -831,6 +834,8 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn)
     audit_p2m(p2m, 1);
     p2m_unlock(p2m);
 
+    atomic_dec(&d->paged_pages);
+
     return 0;
 }
 
index 5f7194dc880633d01fa22d971c9d5b5a25eadc71..57c906cb750c2de65ab791e674742be2a20bd1f8 100644 (file)
@@ -137,6 +137,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
     info->tot_pages         = d->tot_pages;
     info->max_pages         = d->max_pages;
     info->shr_pages         = atomic_read(&d->shr_pages);
+    info->paged_pages       = atomic_read(&d->paged_pages);
     info->shared_info_frame = mfn_to_gmfn(d, __pa(d->shared_info)>>PAGE_SHIFT);
     BUG_ON(SHARED_M2P(info->shared_info_frame));
 
index ae512aac10d7097428563ac38ded34240aef1309..ea8fce63d9a99086964270ecf69419f928a7da21 100644 (file)
@@ -35,7 +35,7 @@
 #include "xen.h"
 #include "grant_table.h"
 
-#define XEN_DOMCTL_INTERFACE_VERSION 0x00000007
+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000008
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -95,6 +95,7 @@ struct xen_domctl_getdomaininfo {
     uint64_aligned_t tot_pages;
     uint64_aligned_t max_pages;
     uint64_aligned_t shr_pages;
+    uint64_aligned_t paged_pages;
     uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
     uint64_aligned_t cpu_time;
     uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
index c6b3a5916fa3d29b8fe3c287dd1581139f0be6cb..784bcecdab60fc66447d26dbf4abe9fd6c1bdbe6 100644 (file)
@@ -208,6 +208,7 @@ struct domain
     unsigned int     tot_pages;       /* number of pages currently possesed */
     unsigned int     max_pages;       /* maximum value for tot_pages        */
     atomic_t         shr_pages;       /* number of shared pages             */
+    atomic_t         paged_pages;     /* number of paged-out pages          */
     unsigned int     xenheap_pages;   /* # pages allocated from Xen heap    */
 
     unsigned int     max_vcpus;