Module Name:    src
Committed By:   ad
Date:           Wed May 20 18:37:50 UTC 2020

Modified Files:
        src/sys/uvm: uvm_loan.c

Log Message:
uvm_loanuobjpages():

- there are no pages to unbusy in the error case
- always clear the caller's page array


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/uvm/uvm_loan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_loan.c
diff -u src/sys/uvm/uvm_loan.c:1.102 src/sys/uvm/uvm_loan.c:1.103
--- src/sys/uvm/uvm_loan.c:1.102	Tue May 19 21:52:04 2020
+++ src/sys/uvm/uvm_loan.c	Wed May 20 18:37:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_loan.c,v 1.102 2020/05/19 21:52:04 ad Exp $	*/
+/*	$NetBSD: uvm_loan.c,v 1.103 2020/05/20 18:37:50 ad Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.102 2020/05/19 21:52:04 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.103 2020/05/20 18:37:50 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -538,6 +538,9 @@ uvm_loanuobjchunk(struct uvm_object *uob
 		/* loan out pages.  they will be unbusied whatever happens. */
 		error = uvm_loanpage(pgpp, npages, true);
 		rw_exit(uobj->vmobjlock);
+		if (error != 0) {
+			memset(pgpp, 0, sizeof(pgpp[0]) * npages);
+		}
 		return error;
 
 	case EAGAIN:
@@ -546,11 +549,6 @@ uvm_loanuobjchunk(struct uvm_object *uob
 		goto reget;
 
 	default:
-		if (npages > 0) {
-			rw_enter(uobj->vmobjlock, RW_WRITER);
-			uvm_page_unbusy(pgpp, npages);
-			rw_exit(uobj->vmobjlock);
-		}
 		return error;
 	}
 }
@@ -569,6 +567,7 @@ uvm_loanuobjpages(struct uvm_object *uob
 
 	KASSERT(npages > 0);
 
+	memset(pgpp, 0, sizeof(pgpp[0]) * npages);
 	for (ndone = 0; ndone < npages; ndone += chunk) {
 		chunk = MIN(UVM_LOAN_GET_CHUNK, npages - ndone);
 		error = uvm_loanuobjchunk(uobj, pgoff + (ndone << PAGE_SHIFT),

Reply via email to