Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm For single page I/O, use direct mapping if available.



details:   https://anonhg.NetBSD.org/src/rev/90da58a765e4
branches:  trunk
changeset: 970952:90da58a765e4
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Apr 07 19:15:23 2020 +0000

description:
For single page I/O, use direct mapping if available.

diffstat:

 sys/uvm/uvm_pager.c |  49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diffs (84 lines):

diff -r 31731061ba3d -r 90da58a765e4 sys/uvm/uvm_pager.c
--- a/sys/uvm/uvm_pager.c       Tue Apr 07 19:12:25 2020 +0000
+++ b/sys/uvm/uvm_pager.c       Tue Apr 07 19:15:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_pager.c,v 1.123 2020/02/24 12:38:57 rin Exp $      */
+/*     $NetBSD: uvm_pager.c,v 1.124 2020/04/07 19:15:23 ad Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.123 2020/02/24 12:38:57 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.124 2020/04/07 19:15:23 ad Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_readahead.h"
@@ -154,6 +154,24 @@
        }
 }
 
+#ifdef PMAP_DIRECT
+/*
+ * uvm_pagermapdirect: map a single page via the pmap's direct segment
+ *
+ * this is an abuse of pmap_direct_process(), since the kva is being grabbed
+ * and no processing is taking place, but for now..
+ */
+
+static int
+uvm_pagermapdirect(void *kva, size_t sz, void *cookie)
+{
+
+       KASSERT(sz == PAGE_SIZE);
+       *(vaddr_t *)cookie = (vaddr_t)kva;
+       return 0;
+}
+#endif
+
 /*
  * uvm_pagermapin: map pages into KVA (pager_map) for I/O that needs mappings
  *
@@ -176,6 +194,22 @@
        UVMHIST_LOG(maphist,"(pps=%#jx, npages=%jd, first_color=%ju)",
                (uintptr_t)pps, npages, first_color, 0);
 
+#ifdef PMAP_DIRECT
+       /* 
+        * for a single page the direct mapped segment can be used.
+        */
+
+       if (npages == 1) {
+               int error __diagused;
+               KASSERT((pps[0]->flags & PG_BUSY) != 0);
+               error = pmap_direct_process(VM_PAGE_TO_PHYS(pps[0]), 0,
+                   PAGE_SIZE, uvm_pagermapdirect, &kva);
+               KASSERT(error == 0);
+               UVMHIST_LOG(maphist, "<- done, direct (KVA=%#jx)", kva,0,0,0);
+               return kva;
+       }
+#endif
+
        /*
         * compute protection.  outgoing I/O only needs read
         * access to the page, whereas incoming needs read/write.
@@ -250,6 +284,17 @@
 
        UVMHIST_LOG(maphist, " (kva=%#jx, npages=%jd)", kva, npages,0,0);
 
+#ifdef PMAP_DIRECT
+       /* 
+        * solitary pages are mapped directly.
+        */
+
+       if (npages == 1) {
+               UVMHIST_LOG(maphist,"<- done, direct", 0,0,0,0);
+               return;
+       }
+#endif
+
        /*
         * duplicate uvm_unmap, but add in pager_map_wanted handling.
         */



Home | Main Index | Thread Index | Old Index