Tools: Expose to libxc the total number of shared frames and space saved
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 26 Jan 2012 12:46:26 +0000 (12:46 +0000)
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 26 Jan 2012 12:46:26 +0000 (12:46 +0000)
Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Tim Deegan <tim@xen.org>
tools/libxc/xc_memshr.c
tools/libxc/xenctrl.h

index d82d4d9226ab67e405fe3303e6e3ee5ec431e9ae..810200c5e4b764d1f44005315546e2257f2933ba 100644 (file)
@@ -225,3 +225,13 @@ int xc_memshr_debug_gref(xc_interface *xch,
     return do_domctl(xch, &domctl);
 }
 
+long xc_sharing_freed_pages(xc_interface *xch)
+{
+    return do_memory_op(xch, XENMEM_get_sharing_freed_pages, NULL, 0);
+}
+
+long xc_sharing_used_frames(xc_interface *xch)
+{
+    return do_memory_op(xch, XENMEM_get_sharing_shared_pages, NULL, 0);
+}
+
index 2b445085b6631207db2e5ee9716d92a2615856e4..78133315ae0ff3ec5f63e7d655b97107c5f2da9f 100644 (file)
@@ -1228,6 +1228,23 @@ int xc_mmuext_op(xc_interface *xch, struct mmuext_op *op, unsigned int nr_ops,
 /* System wide memory properties */
 long xc_maximum_ram_page(xc_interface *xch);
 
+/**
+ * This function returns the total number of pages freed by using sharing
+ * on the system.  For example, if two domains contain a single entry in
+ * their p2m map that points to the same shared page (and no other pages
+ * in the system are shared), then this function should return 1.
+ */
+long xc_sharing_freed_pages(xc_interface *xch);
+
+/**
+ * This function returns the total number of frames occupied by shared
+ * pages on the system.  This is independent of the number of domains
+ * pointing at these frames.  For example, in the above scenario this
+ * should return 1. The following should hold:
+ *  memory usage without sharing = freed_pages + used_frames
+ */
+long xc_sharing_used_frames(xc_interface *xch);
+
 /* Get current total pages allocated to a domain. */
 long xc_get_tot_pages(xc_interface *xch, uint32_t domid);