summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-03-25 10:23:12 -0400
committerIan Moffett <ian@osmora.org>2025-03-25 10:23:12 -0400
commit7497caf0fc2ca740229205bc857ce5fb2ff698be (patch)
treea1247e1f6e40e7cf5780d3974c802d28ab93057a /sys
parente195477d2f762729b98404557303b10d19e87ac3 (diff)
kernel: vm: Fix vm_page insertions
Ensure vm_page entries are properly kept track of. This commit additionally simplifies and cleans up vm_pageinsert() Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_page.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 52ded0e..3403a49 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -43,11 +43,12 @@ RBT_GENERATE(vm_objtree, vm_page, objt, vm_pagecmp);
static inline void
vm_pageinsert(struct vm_page *pg, struct vm_object *obp)
{
- struct vm_page *tmp;
+ struct vm_page *tmp;
- tmp = RBT_INSERT(vm_objtree, &obp->objt, pg);
- __assert(tmp == NULL);
- ++obp->npages;
+ tmp = RBT_INSERT(vm_objtree, &obp->objt, pg);
+ if (tmp != NULL)
+ return;
+ ++obp->npages;
}
static inline void
@@ -79,6 +80,7 @@ vm_pagealloc(struct vm_object *obj, int flags)
memset(tmp, 0, sizeof(*tmp));
tmp->phys_addr = vm_alloc_frame(1);
tmp->flags |= (PG_VALID | PG_CLEAN);
+ tmp->offset = tmp->phys_addr >> 12;
__assert(tmp->phys_addr != 0);
if (ISSET(flags, PALLOC_ZERO)) {