Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm uao_get(): handle PGO_OVERWRITE.



details:   https://anonhg.NetBSD.org/src/rev/ad94ee612503
branches:  trunk
changeset: 933220:ad94ee612503
user:      ad <ad%NetBSD.org@localhost>
date:      Fri May 22 19:02:59 2020 +0000

description:
uao_get(): handle PGO_OVERWRITE.

diffstat:

 sys/uvm/uvm_aobj.c |  18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r b8fba6496e41 -r ad94ee612503 sys/uvm/uvm_aobj.c
--- a/sys/uvm/uvm_aobj.c        Fri May 22 17:44:05 2020 +0000
+++ b/sys/uvm/uvm_aobj.c        Fri May 22 19:02:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_aobj.c,v 1.143 2020/05/20 12:47:36 hannken Exp $   */
+/*     $NetBSD: uvm_aobj.c,v 1.144 2020/05/22 19:02:59 ad Exp $        */
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.143 2020/05/20 12:47:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.144 2020/05/22 19:02:59 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_uvmhist.h"
@@ -804,6 +804,7 @@
        struct vm_page *ptmp = NULL;    /* Quell compiler warning */
        int lcv, gotpages, maxpages, swslot = -1, pageidx = -1; /* XXX: gcc */
        UVMHIST_FUNC("uao_get"); UVMHIST_CALLED(pdhist);
+       bool overwrite = ((flags & PGO_OVERWRITE) != 0);
 
        UVMHIST_LOG(pdhist, "aobj=%#jx offset=%jd, flags=%jd",
                    (uintptr_t)uobj, offset, flags,0);
@@ -921,7 +922,8 @@
                                pageidx = current_offset >> PAGE_SHIFT;
                                swslot = uao_find_swslot(uobj, pageidx);
                                ptmp = uao_pagealloc(uobj, current_offset,
-                                   swslot == 0 ? UVM_PGA_ZERO : 0);
+                                   swslot != 0 || overwrite ? 0 :
+                                   UVM_PGA_ZERO);
 
                                /* out of RAM? */
                                if (ptmp == NULL) {
@@ -1036,9 +1038,15 @@
 
                /*
                 * note that we will allow the page being writably-mapped
-                * (!PG_RDONLY) regardless of access_type.
+                * (!PG_RDONLY) regardless of access_type.  if overwrite,
+                * the page can be modified through an unmanaged mapping
+                * so mark it dirty up front.
                 */
-               uvm_pagemarkdirty(ptmp, UVM_PAGE_STATUS_UNKNOWN);
+               if (overwrite) {
+                       uvm_pagemarkdirty(ptmp, UVM_PAGE_STATUS_DIRTY);
+               } else {
+                       uvm_pagemarkdirty(ptmp, UVM_PAGE_STATUS_UNKNOWN);
+               }
 
                /*
                 * we got the page!   clear the fake flag (indicates valid



Home | Main Index | Thread Index | Old Index