Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Replace the traditional buffer memory management -- base...
details: https://anonhg.NetBSD.org/src/rev/08805808b9c2
branches: trunk
changeset: 556914:08805808b9c2
user: pk <pk%NetBSD.org@localhost>
date: Tue Dec 30 12:33:13 2003 +0000
description:
Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.
This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes). It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms. Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.
On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
diffstat:
sys/arch/acorn26/acorn26/machdep.c | 56 +--
sys/arch/acorn26/acorn26/start.c | 24 +-
sys/arch/algor/algor/machdep.c | 69 +--
sys/arch/alpha/alpha/machdep.c | 66 +--
sys/arch/alpha/alpha/pmap.c | 15 +-
sys/arch/amd64/amd64/autoconf.c | 7 +-
sys/arch/amd64/amd64/machdep.c | 108 +---
sys/arch/amd64/include/cpu.h | 3 +-
sys/arch/amiga/amiga/machdep.c | 74 +--
sys/arch/amigappc/amigappc/machdep.c | 70 +--
sys/arch/arc/arc/machdep.c | 77 +--
sys/arch/arm/arm32/arm32_machdep.c | 77 +--
sys/arch/atari/atari/machdep.c | 68 +--
sys/arch/cesfic/cesfic/machdep.c | 65 +--
sys/arch/cobalt/cobalt/machdep.c | 72 +--
sys/arch/evbmips/alchemy/machdep.c | 77 +--
sys/arch/evbmips/malta/machdep.c | 72 +--
sys/arch/evbppc/explora/machdep.c | 61 +--
sys/arch/evbppc/walnut/machdep.c | 62 +--
sys/arch/evbsh5/evbsh5/machdep.c | 63 +--
sys/arch/hp300/hp300/machdep.c | 65 +--
sys/arch/hp700/hp700/machdep.c | 61 +--
sys/arch/hpcmips/hpcmips/machdep.c | 81 +--
sys/arch/i386/i386/autoconf.c | 7 +-
sys/arch/i386/i386/machdep.c | 107 +---
sys/arch/i386/include/cpu.h | 3 +-
sys/arch/luna68k/luna68k/machdep.c | 69 +--
sys/arch/mac68k/mac68k/machdep.c | 65 +--
sys/arch/mips/mips/pmap.c | 14 +-
sys/arch/mipsco/mipsco/machdep.c | 71 +--
sys/arch/mvme68k/mvme68k/machdep.c | 67 +--
sys/arch/news68k/news68k/machdep.c | 66 +--
sys/arch/newsmips/newsmips/machdep.c | 72 +--
sys/arch/next68k/next68k/machdep.c | 66 +--
sys/arch/pc532/pc532/machdep.c | 70 +--
sys/arch/pdp10/pdp10/machdep.c | 71 +--
sys/arch/playstation2/playstation2/machdep.c | 70 +--
sys/arch/pmax/pmax/machdep.c | 80 +--
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c | 63 +--
sys/arch/powerpc/oea/oea_machdep.c | 67 +--
sys/arch/sbmips/sbmips/machdep.c | 68 +--
sys/arch/sgimips/sgimips/machdep.c | 71 +--
sys/arch/sh3/sh3/pmap.c | 12 +-
sys/arch/sh3/sh3/sh3_machdep.c | 60 +--
sys/arch/sparc/sparc/machdep.c | 93 +---
sys/arch/sparc64/sparc64/machdep.c | 73 +--
sys/arch/sun2/sun2/machdep.c | 67 +--
sys/arch/sun3/sun3/machdep.c | 67 +--
sys/arch/sun3/sun3x/machdep.c | 68 +--
sys/arch/vax/vax/machdep.c | 73 +--
sys/arch/vax/vax/pmap.c | 18 +-
sys/arch/x68k/x68k/machdep.c | 72 +--
sys/conf/files | 3 +-
sys/conf/param.c | 12 +-
sys/kern/init_main.c | 7 +-
sys/kern/vfs_bio.c | 708 ++++++++++++++++++++++----
sys/kern/vfs_subr.c | 58 +--
sys/sys/buf.h | 16 +-
sys/sys/sysctl.h | 5 +-
sys/ufs/ext2fs/ext2fs_subr.c | 8 +-
sys/ufs/ffs/ffs_alloc.c | 8 +-
sys/ufs/ffs/ffs_subr.c | 8 +-
sys/ufs/lfs/lfs_balloc.c | 6 +-
sys/ufs/lfs/lfs_inode.c | 6 +-
sys/uvm/uvm_glue.c | 20 +-
sys/uvm/uvm_pdaemon.c | 5 +-
66 files changed, 814 insertions(+), 3219 deletions(-)
diffs (truncated from 6712 to 300 lines):
diff -r fd248eed39e9 -r 08805808b9c2 sys/arch/acorn26/acorn26/machdep.c
--- a/sys/arch/acorn26/acorn26/machdep.c Tue Dec 30 11:23:20 2003 +0000
+++ b/sys/arch/acorn26/acorn26/machdep.c Tue Dec 30 12:33:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.11 2003/12/05 23:56:20 he Exp $ */
+/* $NetBSD: machdep.c,v 1.12 2003/12/30 12:33:13 pk Exp $ */
/*-
* Copyright (c) 1998 Ben Harris
@@ -32,7 +32,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.11 2003/12/05 23:56:20 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.12 2003/12/30 12:33:13 pk Exp $");
#include <sys/buf.h>
#include <sys/kernel.h>
@@ -146,9 +146,7 @@
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/* Stuff to do here: */
@@ -158,49 +156,8 @@
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /* allocsys() is called from start() */
-
/* Various boilerplate memory allocations. */
-
- /*
- * Allocate virtual address space for file I/O buffers.
- * Note they are different than the array of headers, 'buf',
- * and usually occupy more virtual memory than physical.
- */
- size = MAXBSIZE * nbuf;
- if (uvm_map(kernel_map, (void *) &buffers, round_page(size),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("cpu_startup: cannot allocate VM for buffers");
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- /*
- * Each buffer has MAXBSIZE bytes of VM space allocated. Of
- * that MAXBSIZE space, we allocate and map (base+1) pages
- * for the first "residual" buffers, and then we allocate
- * "base" pages for the rest.
- */
- curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
- curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
-
- while (curbufsize) {
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL)
- panic("cpu_startup: not enough memory for "
- "buffer cache");
- pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ|VM_PROT_WRITE);
- curbuf += PAGE_SIZE;
- curbufsize -= PAGE_SIZE;
- }
- }
- pmap_update(pmap_kernel());
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
@@ -224,13 +181,6 @@
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
curpcb = &lwp0.l_addr->u_pcb;
diff -r fd248eed39e9 -r 08805808b9c2 sys/arch/acorn26/acorn26/start.c
--- a/sys/arch/acorn26/acorn26/start.c Tue Dec 30 11:23:20 2003 +0000
+++ b/sys/arch/acorn26/acorn26/start.c Tue Dec 30 12:33:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: start.c,v 1.4 2003/09/30 00:35:30 thorpej Exp $ */
+/* $NetBSD: start.c,v 1.5 2003/12/30 12:33:13 pk Exp $ */
/*-
* Copyright (c) 1998, 2000 Ben Harris
* All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: start.c,v 1.4 2003/09/30 00:35:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: start.c,v 1.5 2003/12/30 12:33:13 pk Exp $");
#include <sys/msgbuf.h>
#include <sys/user.h>
@@ -93,9 +93,6 @@
start(initbootconfig)
struct bootconfig *initbootconfig;
{
- size_t size;
- caddr_t v;
- char pbuf[9];
int onstack;
/*
@@ -154,23 +151,6 @@
}
#endif
- /*
- * Allocate space for system data structures. These data structures
- * are allocated here instead of cpu_startup() because physical
- * memory is directly addressable. We don't have to map these into
- * virtual address space. This trick is stolen from the alpha port.
- */
- size = (vsize_t)allocsys(0, NULL);
- v = MEMC_PHYS_BASE + bootconfig.freebase;
- bootconfig.freebase += size;
- if (bootconfig.freebase > ptoa(physmem)) {
- format_bytes(pbuf, sizeof(pbuf), size);
- panic("start: out of memory (wanted %s)", pbuf);
- }
- bzero(v, size);
- if ((allocsys(v, NULL) - v) != size)
- panic("start: table size inconsistency");
-
/* Tell UVM about memory */
#if NARCVIDEO == 0
/*
diff -r fd248eed39e9 -r 08805808b9c2 sys/arch/algor/algor/machdep.c
--- a/sys/arch/algor/algor/machdep.c Tue Dec 30 11:23:20 2003 +0000
+++ b/sys/arch/algor/algor/machdep.c Tue Dec 30 12:33:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.25 2003/09/26 16:00:28 simonb Exp $ */
+/* $NetBSD: machdep.c,v 1.26 2003/12/30 12:33:13 pk Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -113,7 +113,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.25 2003/09/26 16:00:28 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 2003/12/30 12:33:13 pk Exp $");
#include "opt_algor_p4032.h"
#include "opt_algor_p5064.h"
@@ -566,12 +566,6 @@
mips_init_msgbuf();
/*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (vsize_t) allocsys(NULL, NULL);
-
- /*
* Initialize the virtual memory system.
*/
led_display('p', 'm', 'a', 'p');
@@ -588,16 +582,6 @@
curpcb->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
/*
- * Allocate space for system data structures. These data structures
- * are allocated here instead of cpu_startup() because physical
- * memory is directly addressable. We don't have to map these into
- * the virtual address space.
- */
- v = (caddr_t) uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
-
- /*
* Initialize debuggers, and break into them, if appropriate.
*/
#if NKSYMS || defined(DDB) || defined(LKM)
@@ -629,8 +613,6 @@
void
cpu_startup(void)
{
- vsize_t size;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
char pbuf[9];
#ifdef DEBUG
@@ -672,45 +654,7 @@
}
#endif
- /*
- * Allocate virtual address space for file I/O buffers.
- * Note they are different than the array of headers, 'buf',
- * and usually occupy more virtual memory than physical.
- */
- size = MAXBSIZE * nbuf;
- if (uvm_map(kernel_map, (vaddr_t *)(void *) &buffers, round_page(size),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("cpu_startup: cannot allocate VM for buffers");
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- /*
- * Each buffer has MAXBSIZE bytes of VM space allocated. Of
- * that MAXBSIZE space, we allocate and map (base+1) pages
- * for the first "residual" buffers, and then we allocate
- * "base" pages for the rest.
- */
- curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
- curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
-
- while (curbufsize) {
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL)
- panic("cpu_startup: not enough memory for "
- "buffer cache");
- pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ|VM_PROT_WRITE);
- curbuf += PAGE_SIZE;
- curbufsize -= PAGE_SIZE;
- }
- }
- pmap_update(pmap_kernel());
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
@@ -736,13 +680,6 @@
#endif
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
-
- /*
- * Set up buffers, so they can be used to read disklabels.
- */
- bufinit();
}
int waittime = -1;
diff -r fd248eed39e9 -r 08805808b9c2 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Tue Dec 30 11:23:20 2003 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Tue Dec 30 12:33:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.278 2003/12/04 19:38:21 atatat Exp $ */
+/* $NetBSD: machdep.c,v 1.279 2003/12/30 12:33:13 pk Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.278 2003/12/04 19:38:21 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.279 2003/12/30 12:33:13 pk Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -231,11 +231,9 @@
struct vm_physseg *vps;
vaddr_t kernstart, kernend;
paddr_t kernstartpfn, kernendpfn, pfn0, pfn1;
- vsize_t size;
cpuid_t cpu_id;
struct cpu_info *ci;
char *p;
- caddr_t v;
const char *bootinfo_msg;
const struct cpuinit *c;
@@ -651,17 +649,6 @@
(struct user *)uvm_pageboot_alloc(UPAGES * PAGE_SIZE);
/*
- * Allocate space for system data structures. These data structures
- * are allocated here instead of cpu_startup() because physical
- * memory is directly addressable. We don't have to map these into
Home |
Main Index |
Thread Index |
Old Index