Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys for in-kernel maps,
details: https://anonhg.NetBSD.org/src/rev/a2bc7a2b8861
branches: trunk
changeset: 572387:a2bc7a2b8861
user: yamt <yamt%NetBSD.org@localhost>
date: Sat Jan 01 21:00:06 2005 +0000
description:
for in-kernel maps,
- allocate kva for vm_map_entry from the map itsself and
remove the static limit, MAX_KMAPENT.
- keep merged entries for later splitting to fix allocate-to-free problem.
PR/24039.
diffstat:
sys/arch/amd64/amd64/pmap.c | 6 +-
sys/arch/i386/i386/pmap.c | 6 +-
sys/arch/pc532/pc532/pmap.c | 6 +-
sys/arch/xen/i386/pmap.c | 6 +-
sys/uvm/uvm.h | 4 +-
sys/uvm/uvm_amap.c | 8 +-
sys/uvm/uvm_extern.h | 3 +-
sys/uvm/uvm_io.c | 7 +-
sys/uvm/uvm_km.c | 36 +-
sys/uvm/uvm_map.c | 699 +++++++++++++++++++++++++++++++++++--------
sys/uvm/uvm_map.h | 70 +++-
sys/uvm/uvm_map_i.h | 9 +-
sys/uvm/uvm_mmap.c | 6 +-
sys/uvm/uvm_pager.c | 6 +-
14 files changed, 678 insertions(+), 194 deletions(-)
diffs (truncated from 1631 to 300 lines):
diff -r 455952de6194 -r a2bc7a2b8861 sys/arch/amd64/amd64/pmap.c
--- a/sys/arch/amd64/amd64/pmap.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/arch/amd64/amd64/pmap.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.14 2004/08/10 18:57:09 drochner Exp $ */
+/* $NetBSD: pmap.c,v 1.15 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -108,7 +108,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.14 2004/08/10 18:57:09 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.15 2005/01/01 21:00:06 yamt Exp $");
#ifndef __x86_64__
#include "opt_cputype.h"
@@ -1652,7 +1652,7 @@
/* unmap the page */
dead_entries = NULL;
uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE,
- &dead_entries);
+ &dead_entries, NULL);
vm_map_unlock(map);
if (dead_entries != NULL)
diff -r 455952de6194 -r a2bc7a2b8861 sys/arch/i386/i386/pmap.c
--- a/sys/arch/i386/i386/pmap.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/arch/i386/i386/pmap.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.179 2004/10/10 09:55:24 yamt Exp $ */
+/* $NetBSD: pmap.c,v 1.180 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.179 2004/10/10 09:55:24 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.180 2005/01/01 21:00:06 yamt Exp $");
#include "opt_cputype.h"
#include "opt_user_ldt.h"
@@ -1492,7 +1492,7 @@
/* unmap the page */
dead_entries = NULL;
uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE,
- &dead_entries);
+ &dead_entries, NULL);
vm_map_unlock(map);
if (dead_entries != NULL)
diff -r 455952de6194 -r a2bc7a2b8861 sys/arch/pc532/pc532/pmap.c
--- a/sys/arch/pc532/pc532/pmap.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/arch/pc532/pc532/pmap.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.74 2003/07/15 02:54:35 lukem Exp $ */
+/* $NetBSD: pmap.c,v 1.75 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74 2003/07/15 02:54:35 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2005/01/01 21:00:06 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1170,7 +1170,7 @@
/* unmap the page */
dead_entries = NULL;
uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE,
- &dead_entries);
+ &dead_entries, NULL);
vm_map_unlock(map);
if (dead_entries != NULL)
diff -r 455952de6194 -r a2bc7a2b8861 sys/arch/xen/i386/pmap.c
--- a/sys/arch/xen/i386/pmap.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/arch/xen/i386/pmap.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.6 2004/05/07 15:51:04 cl Exp $ */
+/* $NetBSD: pmap.c,v 1.7 2005/01/01 21:00:06 yamt Exp $ */
/* NetBSD: pmap.c,v 1.172 2004/04/12 13:17:46 yamt Exp */
/*
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.6 2004/05/07 15:51:04 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.7 2005/01/01 21:00:06 yamt Exp $");
#include "opt_cputype.h"
#include "opt_user_ldt.h"
@@ -1690,7 +1690,7 @@
/* unmap the page */
dead_entries = NULL;
uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE,
- &dead_entries);
+ &dead_entries, NULL);
vm_map_unlock(map);
if (dead_entries != NULL)
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm.h
--- a/sys/uvm/uvm.h Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm.h Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm.h,v 1.38 2004/11/23 04:51:56 yamt Exp $ */
+/* $NetBSD: uvm.h,v 1.39 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -110,8 +110,6 @@
struct vm_anon *afree; /* anon free list */
struct simplelock afreelock; /* lock on anon free list */
- /* static kernel map entry pool */
- struct vm_map_entry *kentry_free; /* free page pool */
struct simplelock kentry_lock;
/* aio_done is locked by uvm.pagedaemon_lock and splbio! */
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm_amap.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_amap.c,v 1.55 2004/05/12 20:09:50 yamt Exp $ */
+/* $NetBSD: uvm_amap.c,v 1.56 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.55 2004/05/12 20:09:50 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.56 2005/01/01 21:00:06 yamt Exp $");
#undef UVM_AMAP_INLINE /* enable/disable amap inlines */
@@ -741,10 +741,10 @@
UVMHIST_LOG(maphist, " chunk amap ==> clip 0x%x->0x%x"
"to 0x%x->0x%x", entry->start, entry->end, startva,
endva);
- UVM_MAP_CLIP_START(map, entry, startva);
+ UVM_MAP_CLIP_START(map, entry, startva, NULL);
/* watch out for endva wrap-around! */
if (endva >= startva)
- UVM_MAP_CLIP_END(map, entry, endva);
+ UVM_MAP_CLIP_END(map, entry, endva, NULL);
}
UVMHIST_LOG(maphist, "<- done [creating new amap 0x%x->0x%x]",
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm_extern.h Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.93 2004/08/28 22:12:40 thorpej Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.94 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -143,6 +143,7 @@
#define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce malloc() */
#define UVM_FLAG_TRYLOCK 0x200000 /* fail if we can not lock map */
#define UVM_FLAG_NOWAIT 0x400000 /* not allowed to sleep */
+#define UVM_FLAG_QUANTUM 0x800000 /* entry never be splitted later */
/* macros to extract info */
#define UVM_PROTECTION(X) ((X) & UVM_PROT_MASK)
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm_io.c
--- a/sys/uvm/uvm_io.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm_io.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_io.c,v 1.18 2003/04/23 00:55:21 tls Exp $ */
+/* $NetBSD: uvm_io.c,v 1.19 2005/01/01 21:00:06 yamt Exp $ */
/*
*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.18 2003/04/23 00:55:21 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.19 2005/01/01 21:00:06 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,7 +142,8 @@
*/
vm_map_lock(kernel_map);
- uvm_unmap_remove(kernel_map, kva, kva + chunksz, &dead_entries);
+ uvm_unmap_remove(kernel_map, kva, kva + chunksz, &dead_entries,
+ NULL);
vm_map_unlock(kernel_map);
if (dead_entries != NULL)
uvm_unmap_detach(dead_entries, AMAP_REFALL);
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm_km.c
--- a/sys/uvm/uvm_km.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm_km.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.c,v 1.69 2004/03/24 07:47:32 junyoung Exp $ */
+/* $NetBSD: uvm_km.c,v 1.70 2005/01/01 21:00:06 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -134,7 +134,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.69 2004/03/24 07:47:32 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.70 2005/01/01 21:00:06 yamt Exp $");
#include "opt_uvmhist.h"
@@ -155,6 +155,7 @@
*/
static struct vm_map kernel_map_store;
+static struct vm_map_entry kernel_first_mapent_store;
/*
* uvm_km_init: init kernel maps and objects to reflect reality (i.e.
@@ -187,12 +188,25 @@
uvm_map_setup(&kernel_map_store, base, end, VM_MAP_PAGEABLE);
kernel_map_store.pmap = pmap_kernel();
- if (start != base &&
- uvm_map(&kernel_map_store, &base, start - base, NULL,
- UVM_UNKNOWN_OFFSET, 0,
+ if (start != base) {
+ int error;
+ struct uvm_map_args args;
+
+ error = uvm_map_prepare(&kernel_map_store, base, start - base,
+ NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
- UVM_ADV_RANDOM, UVM_FLAG_FIXED)) != 0)
- panic("uvm_km_init: could not reserve space for kernel");
+ UVM_ADV_RANDOM, UVM_FLAG_FIXED), &args);
+ if (!error) {
+ kernel_first_mapent_store.flags =
+ UVM_MAP_KERNEL | UVM_MAP_FIRST;
+ error = uvm_map_enter(&kernel_map_store, &args,
+ &kernel_first_mapent_store);
+ }
+
+ if (error)
+ panic(
+ "uvm_km_init: could not reserve space for kernel");
+ }
/*
* install!
@@ -398,7 +412,8 @@
if (__predict_false(uvm_map(map, &kva, size, obj, prefer, align,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
UVM_ADV_RANDOM,
- (flags & (UVM_KMF_TRYLOCK | UVM_KMF_NOWAIT))))
+ (flags & (UVM_KMF_TRYLOCK | UVM_KMF_NOWAIT))
+ | UVM_FLAG_QUANTUM))
!= 0)) {
UVMHIST_LOG(maphist, "<- done (no VM)",0,0,0,0);
return(0);
@@ -509,7 +524,7 @@
vm_map_lock(map);
uvm_unmap_remove(map, trunc_page(addr), round_page(addr + size),
- &dead_entries);
+ &dead_entries, NULL);
wakeup(map);
vm_map_unlock(map);
if (dead_entries != NULL)
@@ -545,7 +560,7 @@
if (__predict_false(uvm_map(map, &kva, size, uvm.kernel_object,
UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL,
UVM_INH_NONE, UVM_ADV_RANDOM,
- 0)) != 0)) {
+ UVM_FLAG_QUANTUM)) != 0)) {
UVMHIST_LOG(maphist,"<- done (no VM)",0,0,0,0);
return(0);
}
@@ -632,6 +647,7 @@
if (size > vm_map_max(map) - vm_map_min(map))
return (0);
+ flags |= UVM_FLAG_QUANTUM;
for (;;) {
kva = vm_map_min(map); /* hint */
diff -r 455952de6194 -r a2bc7a2b8861 sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Jan 01 19:29:59 2005 +0000
+++ b/sys/uvm/uvm_map.c Sat Jan 01 21:00:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_map.c,v 1.173 2004/09/25 04:19:38 yamt Exp $ */
Home |
Main Index |
Thread Index |
Old Index