From 852b00cbc75b83390984a77048e443a43dd0ae48 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 19 Apr 2024 22:08:50 -0400 Subject: kernel: vm: Add vm_object refcount Signed-off-by: Ian Moffett --- sys/include/vm/obj.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/include/vm') diff --git a/sys/include/vm/obj.h b/sys/include/vm/obj.h index 6129889..c1c2f17 100644 --- a/sys/include/vm/obj.h +++ b/sys/include/vm/obj.h @@ -42,9 +42,17 @@ struct vm_object { struct vm_pagerops *pgops; /* Pager operations */ uint8_t is_anon : 1; /* Is an anonymous mapping */ + int ref; /* Ref count */ struct vnode *vnode; /* Only used if `is_anon` is 0 */ }; +#define vm_object_ref(OBJPTR) (++(OBJPTR)->ref) +#define vm_object_unref(OBJPTR) do { \ + if ((OBJPTR)->ref > 1) { \ + --(OBJPTR)->ref; \ + } \ + } while (0); + int vm_obj_init(struct vm_object **res, struct vnode *vnode); int vm_obj_destroy(struct vm_object *obj); -- cgit v1.2.3