From f70322f7eac222c57b74c04ff5922c4668369778 Mon Sep 17 00:00:00 2001
From: Ian Moffett <ian@osmora.org>
Date: Fri, 14 Mar 2025 12:25:30 -0400
Subject: kernel: vm: Only hold pgres with timeout

Signed-off-by: Ian Moffett <ian@osmora.org>
---
 sys/vm/vm_anon.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'sys/vm')

diff --git a/sys/vm/vm_anon.c b/sys/vm/vm_anon.c
index 9ca8842..2110ecd 100644
--- a/sys/vm/vm_anon.c
+++ b/sys/vm/vm_anon.c
@@ -87,6 +87,8 @@ anon_get(struct vm_object *obp, struct vm_page **pgs, off_t off, size_t len)
             continue;
         }
 
+        *pgres = *pgtmp;
+
         /*
          * We are *just* populating `pgs' and therefore nobody
          * should even attempt to acquire this lock... Shit
@@ -99,9 +101,6 @@ anon_get(struct vm_object *obp, struct vm_page **pgs, off_t off, size_t len)
             return -ETIMEDOUT;
         }
 
-        /* Hold pgres before configuring it */
-        spinlock_acquire(&pgres->lock);
-        *pgres = *pgtmp;
         pgres->flags |= (PG_VALID | PG_CLEAN);
         spinlock_release(&pgres->lock);
 
-- 
cgit v1.2.3