Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys Directly allocate zero'ed vm_page for XIP unalloc...
details: https://anonhg.NetBSD.org/src/rev/1358bbeb37ba
branches: uebayasi-xip
changeset: 751728:1358bbeb37ba
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Jul 06 07:20:26 2010 +0000
description:
Directly allocate zero'ed vm_page for XIP unallocated blocks, instead
of abusing pool page. Move the code to XIP vnode pager in genfs_io.c.
diffstat:
sys/miscfs/genfs/genfs_io.c | 25 ++++++++++++++++++---
sys/uvm/uvm_km.c | 51 +-------------------------------------------
sys/uvm/uvm_km.h | 7 +-----
3 files changed, 24 insertions(+), 59 deletions(-)
diffs (150 lines):
diff -r 067571c625d6 -r 1358bbeb37ba sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c Wed Jun 09 15:29:58 2010 +0000
+++ b/sys/miscfs/genfs/genfs_io.c Tue Jul 06 07:20:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_io.c,v 1.36.2.10 2010/06/08 03:30:00 uebayasi Exp $ */
+/* $NetBSD: genfs_io.c,v 1.36.2.11 2010/07/06 07:20:27 uebayasi Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.10 2010/06/08 03:30:00 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.11 2010/07/06 07:20:27 uebayasi Exp $");
#include "opt_direct_page.h"
#include "opt_xip.h"
@@ -51,6 +51,7 @@
#include <sys/kauth.h>
#include <sys/fstrans.h>
#include <sys/buf.h>
+#include <sys/once.h>
#include <miscfs/genfs/genfs.h>
#include <miscfs/genfs/genfs_node.h>
@@ -742,6 +743,20 @@
}
#ifdef XIP
+static struct uvm_object xip_zero_obj;
+static struct vm_page *xip_zero_page;
+
+static int
+xip_zero_page_init(void)
+{
+
+ UVM_OBJ_INIT(&xip_zero_obj, NULL, 0);
+ xip_zero_page = uvm_pagealloc(&xip_zero_obj, 0, NULL, UVM_PGA_ZERO);
+ KASSERT(xip_zero_page != NULL);
+ uvm_pagewire(xip_zero_page);
+ return 0;
+}
+
/*
* genfs_do_getpages_xip
* Return "direct pages" of XIP vnode. The block addresses of XIP
@@ -814,8 +829,10 @@
UVMHIST_LOG(ubchist, "xip VOP_BMAP: lbn=%ld blkno=%ld run=%d", (long)lbn, (long)blkno, run, 0);
if (blkno < 0) {
- /* unallocated page is redirected to read-only zero-filled page */
- phys_addr = uvm_pageofzero_xip_phys_addr();
+ static ONCE_DECL(xip_zero_page_inited);
+
+ RUN_ONCE(&xip_zero_page_inited, xip_zero_page_init);
+ phys_addr = xip_zero_page->phys_addr;
} else {
struct vm_physseg *seg;
diff -r 067571c625d6 -r 1358bbeb37ba sys/uvm/uvm_km.c
--- a/sys/uvm/uvm_km.c Wed Jun 09 15:29:58 2010 +0000
+++ b/sys/uvm/uvm_km.c Tue Jul 06 07:20:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.c,v 1.104.2.4 2010/05/31 13:26:38 uebayasi Exp $ */
+/* $NetBSD: uvm_km.c,v 1.104.2.5 2010/07/06 07:20:26 uebayasi Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -127,7 +127,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.104.2.4 2010/05/31 13:26:38 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.104.2.5 2010/07/06 07:20:26 uebayasi Exp $");
#include "opt_uvmhist.h"
#include "opt_direct_page.h"
@@ -795,50 +795,3 @@
uvm_km_free(map, addr, PAGE_SIZE, UVM_KMF_WIRED);
#endif /* PMAP_UNMAP_POOLPAGE */
}
-
-#ifdef XIP
-/*
- * uvm_pageofzero_xip: return a read-only page filled with zeroes.
- *
- * XXXUEBS Need better names.
- */
-
-static void *uvm_pageofzero_xip_vaddr;
-static paddr_t uvm_pageofzero_xip_paddr;
-static int uvm_pageofzero_xip_init(void);
-
-void *
-uvm_pageofzero_xip(void)
-{
- static ONCE_DECL(uvm_pageofzero_xip_inited);
-
- RUN_ONCE(&uvm_pageofzero_xip_inited, uvm_pageofzero_xip_init);
- return uvm_pageofzero_xip_vaddr;
-}
-
-paddr_t
-uvm_pageofzero_xip_phys_addr(void)
-{
- static ONCE_DECL(uvm_pageofzero_xip_inited);
-
- RUN_ONCE(&uvm_pageofzero_xip_inited, uvm_pageofzero_xip_init);
- return uvm_pageofzero_xip_paddr;
-}
-
-static int
-uvm_pageofzero_xip_init(void)
-{
- bool rv;
-
- ASSERT_SLEEPABLE();
-
- uvm_pageofzero_xip_vaddr = (void *)uvm_km_alloc_poolpage(kernel_map, true);
- KASSERT(uvm_pageofzero_xip_vaddr != NULL);
-
- rv = pmap_extract(pmap_kernel(), (vaddr_t)uvm_pageofzero_xip_vaddr,
- &uvm_pageofzero_xip_paddr);
- KASSERT(rv == true && uvm_pageofzero_xip_paddr != 0);
-
- return 0;
-}
-#endif
diff -r 067571c625d6 -r 1358bbeb37ba sys/uvm/uvm_km.h
--- a/sys/uvm/uvm_km.h Wed Jun 09 15:29:58 2010 +0000
+++ b/sys/uvm/uvm_km.h Tue Jul 06 07:20:26 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.h,v 1.18.6.1 2010/02/10 08:12:02 uebayasi Exp $ */
+/* $NetBSD: uvm_km.h,v 1.18.6.2 2010/07/06 07:20:27 uebayasi Exp $ */
/*
*
@@ -57,11 +57,6 @@
#endif /* defined(DEBUG) */
void uvm_km_va_drain(struct vm_map *, uvm_flag_t);
-#ifdef XIP
-void *uvm_pageofzero_xip(void);
-paddr_t uvm_pageofzero_xip_phys_addr(void);
-#endif
-
#endif /* _KERNEL */
#endif /* _UVM_UVM_KM_H_ */
Home |
Main Index |
Thread Index |
Old Index