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

This commit is contained in:
ad 2020-04-07 19:15:23 +00:00
parent 5294ba607b
commit e7b964a876
1 changed files with 47 additions and 2 deletions

View File

@ -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 npages, int flags)
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.
*/