Index | Thread | Search

From:
Martin Pieuchot <mpi@grenadille.net>
Subject:
uvmfault_anonget: return values
To:
tech@openbsd.org
Cc:
tb@openbsd.org
Date:
Mon, 25 Nov 2024 14:56:58 +0100

Download raw body.

Thread
Diff below changes the uvmfault_anonget() return value to avoid a
conversion.  The idea is to return errno(2) values that are, then,
returned by uvm_fault().  This reduces the diff with NetBSD and is
necessary for upcoming changes.

This diff doesn't include any behavior change.  We could later return
EIO instead of EACCES when appropriate.  But for the moment I'm
concerned about reducing the amount of VM_PAGER_* usages.

ok?

Index: uvm/uvm_fault.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_fault.c,v
diff -u -p -r1.144 uvm_fault.c
--- uvm/uvm_fault.c	25 Nov 2024 13:46:55 -0000	1.144
+++ uvm/uvm_fault.c	25 Nov 2024 13:48:49 -0000
@@ -315,7 +315,7 @@ uvmfault_anonget(struct uvm_faultinfo *u
 			 * try again.
 			 */
 			if ((pg->pg_flags & (PG_BUSY|PG_RELEASED)) == 0)
-				return (VM_PAGER_OK);
+				return 0;
 			atomic_setbits_int(&pg->pg_flags, PG_WANTED);
 			counters_inc(uvmexp_counters, flt_pgwait);
 
@@ -404,7 +404,7 @@ uvmfault_anonget(struct uvm_faultinfo *u
 					uvmfault_unlockall(ufi, NULL, NULL);
 				uvm_anon_release(anon);	/* frees page for us */
 				counters_inc(uvmexp_counters, flt_pgrele);
-				return (VM_PAGER_REFAULT);	/* refault! */
+				return ERESTART;	/* refault! */
 			}
 
 			if (error != VM_PAGER_OK) {
@@ -435,7 +435,12 @@ uvmfault_anonget(struct uvm_faultinfo *u
 					uvmfault_unlockall(ufi, NULL, NULL);
 				}
 				rw_exit(anon->an_lock);
-				return (VM_PAGER_ERROR);
+				/*
+				 * An error occurred while trying to bring
+				 * in the page -- this is the only error we
+				 * return right now.
+				 */
+				return EACCES;	/* XXX */
 			}
 
 			/*
@@ -457,7 +462,7 @@ uvmfault_anonget(struct uvm_faultinfo *u
 			if (we_own) {
 				rw_exit(anon->an_lock);
 			}
-			return (VM_PAGER_REFAULT);
+			return ERESTART;
 		}
 
 		/*
@@ -468,7 +473,7 @@ uvmfault_anonget(struct uvm_faultinfo *u
 				ufi->orig_rvaddr - ufi->entry->start) != anon) {
 
 			uvmfault_unlockall(ufi, amap, NULL);
-			return (VM_PAGER_REFAULT);
+			return ERESTART;
 		}
 
 		/*
@@ -942,25 +947,14 @@ uvm_fault_upper(struct uvm_faultinfo *uf
 	 */
 	error = uvmfault_anonget(ufi, amap, anon);
 	switch (error) {
-	case VM_PAGER_OK:
+	case 0:
 		break;
 
-	case VM_PAGER_REFAULT:
+	case ERESTART:
 		return ERESTART;
 
-	case VM_PAGER_ERROR:
-		/*
-		 * An error occurred while trying to bring in the
-		 * page -- this is the only error we return right
-		 * now.
-		 */
-		return EACCES;	/* XXX */
 	default:
-#ifdef DIAGNOSTIC
-		panic("uvm_fault: uvmfault_anonget -> %d", error);
-#else
-		return EACCES;
-#endif
+		return error;
 	}
 
 	KASSERT(rw_write_held(amap->am_lock));