From 05eb9f648569d708e167272e04437466a2f0b594 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 23 May 2024 01:55:41 -0400 Subject: kernel: vm: Keep track of vmobj count Signed-off-by: Ian Moffett --- sys/include/vm/obj.h | 1 + sys/include/vm/vm.h | 1 + sys/vm/vm_obj.c | 10 ++++++++++ sys/vm/vm_stat.c | 2 ++ 4 files changed, 14 insertions(+) (limited to 'sys') diff --git a/sys/include/vm/obj.h b/sys/include/vm/obj.h index ef07a1e..e4258ac 100644 --- a/sys/include/vm/obj.h +++ b/sys/include/vm/obj.h @@ -54,6 +54,7 @@ struct vm_object { } \ } while (0); +size_t vm_obj_count(void); int vm_obj_init(struct vm_object **res, struct vnode *vnode); int vm_obj_destroy(struct vm_object *obj); diff --git a/sys/include/vm/vm.h b/sys/include/vm/vm.h index f6fba66..1c23b8a 100644 --- a/sys/include/vm/vm.h +++ b/sys/include/vm/vm.h @@ -55,6 +55,7 @@ struct vm_range { struct vm_memstat { struct physmem_stat pmem_stat; + size_t vmobj_cnt; }; /* diff --git a/sys/vm/vm_obj.c b/sys/vm/vm_obj.c index 7487b47..8f34ff3 100644 --- a/sys/vm/vm_obj.c +++ b/sys/vm/vm_obj.c @@ -32,6 +32,8 @@ #include #include +static size_t obj_count = 0; + static void vm_set_pgops(struct vm_object *obj, struct vnode *vnode) { @@ -63,6 +65,7 @@ vm_obj_init(struct vm_object **res, struct vnode *vnode) vm_set_pgops(obj, vnode); *res = obj; + ++obj_count; return 0; } @@ -79,5 +82,12 @@ vm_obj_destroy(struct vm_object *obj) return -EBUSY; dynfree(obj); + --obj_count; return 0; } + +size_t +vm_obj_count(void) +{ + return obj_count; +} diff --git a/sys/vm/vm_stat.c b/sys/vm/vm_stat.c index 99ee9a9..6374699 100644 --- a/sys/vm/vm_stat.c +++ b/sys/vm/vm_stat.c @@ -29,6 +29,7 @@ #include #include +#include struct vm_memstat vm_memstat(void) @@ -36,5 +37,6 @@ vm_memstat(void) struct vm_memstat stat; stat.pmem_stat = vm_phys_memstat(); + stat.vmobj_cnt = vm_obj_count(); return stat; } -- cgit v1.2.3