diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2011-09-27 20:35:45 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2011-09-27 20:35:45 +0000 |
commit | 3f293c7dd5d5e4abd8eeb19a6c1a19d4c0e22cb8 (patch) | |
tree | ceadcaeca04451ec0ca9e59b5823681aef548552 /sys/arch | |
parent | 7a683eaab815ed37a8ff95c00aafe5fa8ae90254 (diff) |
Use a pool to allocate pv_entry from, instead of allocating whole pages and
maintaining our own free lists. No functional change.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/m68k/include/pmap_motorola.h | 25 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/pmap_motorola.c | 60 |
2 files changed, 8 insertions, 77 deletions
diff --git a/sys/arch/m68k/include/pmap_motorola.h b/sys/arch/m68k/include/pmap_motorola.h index 7fde6d45d29..e40e7f4a03d 100644 --- a/sys/arch/m68k/include/pmap_motorola.h +++ b/sys/arch/m68k/include/pmap_motorola.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_motorola.h,v 1.24 2011/05/24 15:27:36 ariane Exp $ */ +/* $OpenBSD: pmap_motorola.h,v 1.25 2011/09/27 20:35:44 miod Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -88,29 +88,6 @@ typedef struct pmap *pmap_t; /* XXX - struct pv_entry moved to vmparam.h because of include ordering issues */ -struct pv_page; - -struct pv_page_info { - TAILQ_ENTRY(pv_page) pgi_list; - struct pv_entry *pgi_freelist; - int pgi_nfree; -}; - -/* - * This is basically: - * ((PAGE_SIZE - sizeof(struct pv_page_info)) / sizeof(struct pv_entry)) - */ -#if PAGE_SHIFT == 13 -#define NPVPPG 340 -#elif PAGE_SHIFT == 12 -#define NPVPPG 170 -#endif - -struct pv_page { - struct pv_page_info pvp_pgi; - struct pv_entry pvp_pv[NPVPPG]; -}; - extern struct pmap kernel_pmap_store; #define pmap_kernel() (&kernel_pmap_store) diff --git a/sys/arch/m68k/m68k/pmap_motorola.c b/sys/arch/m68k/m68k/pmap_motorola.c index 3eaffedb664..ceaa9f74e97 100644 --- a/sys/arch/m68k/m68k/pmap_motorola.c +++ b/sys/arch/m68k/m68k/pmap_motorola.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_motorola.c,v 1.63 2011/09/22 17:41:00 jasper Exp $ */ +/* $OpenBSD: pmap_motorola.c,v 1.64 2011/09/27 20:35:44 miod Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -273,14 +273,12 @@ vsize_t mem_size; /* memory size in bytes */ vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ -TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist; -int pv_nfree; - #if defined(M68040) || defined(M68060) int protostfree; /* prototype (default) free ST map */ #endif struct pool pmap_pmap_pool; /* memory pool for pmap structures */ +struct pool pmap_pv_pool; /* memory pool for pv pages */ /* * Internal routines @@ -406,8 +404,6 @@ pmap_init() PMAP_DPRINTF(PDB_FOLLOW, ("pmap_init()\n")); - TAILQ_INIT(&pv_page_freelist); - #ifndef __HAVE_PMAP_DIRECT /* * Before we do anything else, initialize the PTE pointers @@ -549,7 +545,9 @@ pmap_init() * Initialize the pmap pools. */ pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl", - &pool_allocator_nointr); + NULL); + pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pvpl", + NULL); } /* @@ -560,35 +558,7 @@ pmap_init() struct pv_entry * pmap_alloc_pv() { - struct pv_page *pvp; - struct pv_entry *pv; - int i; - - if (pv_nfree == 0) { - pvp = (struct pv_page *)uvm_km_kmemalloc(kernel_map, - uvm.kernel_object, PAGE_SIZE, UVM_KMF_NOWAIT); - if (pvp == NULL) - return NULL; - pvp->pvp_pgi.pgi_freelist = pv = &pvp->pvp_pv[1]; - for (i = NPVPPG - 2; i; i--, pv++) - pv->pv_next = pv + 1; - pv->pv_next = NULL; - pv_nfree += pvp->pvp_pgi.pgi_nfree = NPVPPG - 1; - TAILQ_INSERT_HEAD(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - pv = &pvp->pvp_pv[0]; - } else { - --pv_nfree; - pvp = TAILQ_FIRST(&pv_page_freelist); - if (--pvp->pvp_pgi.pgi_nfree == 0) { - TAILQ_REMOVE(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - } - pv = pvp->pvp_pgi.pgi_freelist; -#ifdef DIAGNOSTIC - if (pv == NULL) - panic("pmap_alloc_pv: pgi_nfree inconsistent"); -#endif - pvp->pvp_pgi.pgi_freelist = pv->pv_next; - } + pv = (struct pv_entry *)pool_get(&pmap_pv_pool, PR_NOWAIT); return pv; } @@ -601,23 +571,7 @@ void pmap_free_pv(pv) struct pv_entry *pv; { - struct pv_page *pvp; - - pvp = (struct pv_page *) trunc_page((vaddr_t)pv); - switch (++pvp->pvp_pgi.pgi_nfree) { - case 1: - TAILQ_INSERT_TAIL(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - default: - pv->pv_next = pvp->pvp_pgi.pgi_freelist; - pvp->pvp_pgi.pgi_freelist = pv; - ++pv_nfree; - break; - case NPVPPG: - pv_nfree -= NPVPPG - 1; - TAILQ_REMOVE(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - uvm_km_free(kernel_map, (vaddr_t)pvp, PAGE_SIZE); - break; - } + pool_put(&pmap_pv_pool, pv); } /* |