Module Name: src
Committed By: ad
Date: Tue Apr 7 19:15:24 UTC 2020
Modified Files:
src/sys/uvm: uvm_pager.c
Log Message:
For single page I/O, use direct mapping if available.
To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/uvm/uvm_pager.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_pager.c
diff -u src/sys/uvm/uvm_pager.c:1.123 src/sys/uvm/uvm_pager.c:1.124
--- src/sys/uvm/uvm_pager.c:1.123 Mon Feb 24 12:38:57 2020
+++ src/sys/uvm/uvm_pager.c Tue Apr 7 19:15:23 2020
@@ -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 @@ uvm_pager_init(void)
}
}
+#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 @@ uvm_pagermapin(struct vm_page **pps, int
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 @@ uvm_pagermapout(vaddr_t kva, int npages)
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.
*/