bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] Report VM cache size in meminfo


From: Richard Braun
Subject: [PATCH] Report VM cache size in meminfo
Date: Sun, 13 Jan 2013 21:53:59 +0100

* rootdir.c: Include <mach/gnumach.h> and <mach/vm_cache_statistics.h>.
(rootdir_gc_meminfo): Call vm_cache_statistics and return the VM cache size.
---
 rootdir.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/rootdir.c b/rootdir.c
index 1fa71b0..31e2d8c 100644
--- a/rootdir.c
+++ b/rootdir.c
@@ -17,8 +17,10 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#include <mach/gnumach.h>
 #include <mach/vm_param.h>
 #include <mach/vm_statistics.h>
+#include <mach/vm_cache_statistics.h>
 #include <mach/default_pager.h>
 #include <hurd/paths.h>
 #include <stdio.h>
@@ -263,6 +265,7 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t 
*contents_len)
   host_basic_info_data_t hbi;
   mach_msg_type_number_t cnt;
   struct vm_statistics vmstats;
+  struct vm_cache_statistics cache_stats;
   default_pager_info_t swap;
   error_t err;
 
@@ -270,6 +273,10 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t 
*contents_len)
   if (err)
     return EIO;
 
+  err = vm_cache_statistics (mach_task_self (), &cache_stats);
+  if (err)
+    return EIO;
+
   cnt = HOST_BASIC_INFO_COUNT;
   err = host_info (mach_host_self (), HOST_BASIC_INFO, (host_info_t) &hbi, 
&cnt);
   if (err)
@@ -294,7 +301,7 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t 
*contents_len)
       (long unsigned) hbi.memory_size / 1024,
       (long unsigned) vmstats.free_count * PAGE_SIZE / 1024,
       0,
-      0,
+      (long unsigned) cache_stats.cache_count * PAGE_SIZE / 1024,
       (long unsigned) vmstats.active_count * PAGE_SIZE / 1024,
       (long unsigned) vmstats.inactive_count * PAGE_SIZE / 1024,
       (long unsigned) vmstats.wire_count * PAGE_SIZE / 1024,
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]