Subject: Re: buffer cache memory management revision
To: None <tech-kern@netbsd.org>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: tech-kern
Date: 12/22/2003 15:27:27
Here's my latest revision of the buffer cache memory management patches.
I've run this code on various configurations: different amounts of
main memory (24MB & 64MB sparcstation, 650MB i386) and assorted
filesystems (FFS{v1,v2}, LFS, NFS) with good results.
The LFS code probably needs some additional tweaking since it more or less
assumes a fixed number of buffer for its own tuning parameters.
All MD bits in this set of patches are known to at least compile on
all cross-compilable platforms.
-pk
Index: arch/acorn26/acorn26/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/machdep.c,v
retrieving revision 1.11
diff -c -r1.11 machdep.c
*** arch/acorn26/acorn26/machdep.c 5 Dec 2003 23:56:20 -0000 1.11
--- arch/acorn26/acorn26/machdep.c 22 Dec 2003 13:55:01 -0000
***************
*** 146,154 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/* Stuff to do here: */
--- 146,152 ----
***************
*** 158,206 ****
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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 156,163 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
/* Various boilerplate memory allocations. */
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 224,236 ****
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;
--- 181,186 ----
Index: arch/acorn26/acorn26/start.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/start.c,v
retrieving revision 1.4
diff -c -r1.4 start.c
*** arch/acorn26/acorn26/start.c 30 Sep 2003 00:35:30 -0000 1.4
--- arch/acorn26/acorn26/start.c 22 Dec 2003 13:55:01 -0000
***************
*** 93,101 ****
start(initbootconfig)
struct bootconfig *initbootconfig;
{
- size_t size;
- caddr_t v;
- char pbuf[9];
int onstack;
/*
--- 93,98 ----
***************
*** 154,176 ****
}
#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
/*
--- 151,156 ----
Index: arch/algor/algor/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/algor/algor/machdep.c,v
retrieving revision 1.25
diff -c -r1.25 machdep.c
*** arch/algor/algor/machdep.c 26 Sep 2003 16:00:28 -0000 1.25
--- arch/algor/algor/machdep.c 22 Dec 2003 13:55:02 -0000
***************
*** 566,577 ****
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');
--- 566,571 ----
***************
*** 588,603 ****
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)
--- 582,587 ----
***************
*** 629,636 ****
void
cpu_startup(void)
{
- vsize_t size;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
char pbuf[9];
#ifdef DEBUG
--- 613,618 ----
***************
*** 672,716 ****
}
#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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 654,660 ----
}
#endif
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 736,748 ****
#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;
--- 680,685 ----
Index: arch/alpha/alpha/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.278
diff -c -r1.278 machdep.c
*** arch/alpha/alpha/machdep.c 4 Dec 2003 19:38:21 -0000 1.278
--- arch/alpha/alpha/machdep.c 22 Dec 2003 13:55:02 -0000
***************
*** 235,241 ****
cpuid_t cpu_id;
struct cpu_info *ci;
char *p;
- caddr_t v;
const char *bootinfo_msg;
const struct cpuinit *c;
--- 235,240 ----
***************
*** 651,667 ****
(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
- * virtual address space.
- */
- size = (vsize_t)allocsys(NULL, NULL);
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("alpha_init: table size inconsistency");
-
- /*
* Initialize the virtual memory system, and set the
* page table base register in proc 0's PCB.
*/
--- 650,655 ----
***************
*** 856,864 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#if defined(DEBUG)
extern int pmapdebug;
--- 844,850 ----
***************
*** 887,931 ****
printf("WARNING: %s of memory with unknown purpose\n", pbuf);
}
! /*
! * 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("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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 873,879 ----
printf("WARNING: %s of memory with unknown purpose\n", pbuf);
}
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 959,971 ****
printf("stolen memory for VM structures = %s\n", pbuf);
}
#endif
- 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();
/*
* Set up the HWPCB so that it's safe to configure secondary
--- 907,912 ----
Index: arch/alpha/alpha/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/pmap.c,v
retrieving revision 1.205
diff -c -r1.205 pmap.c
*** arch/alpha/alpha/pmap.c 29 Oct 2003 04:48:40 -0000 1.205
--- arch/alpha/alpha/pmap.c 22 Dec 2003 13:55:03 -0000
***************
*** 812,819 ****
* kernel. We also reserve space for kmem_alloc_pageable()
* for vm_fork().
*/
! lev3mapsize = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
! nbuf * MAXBSIZE + 16 * NCARGS + PAGER_MAP_SIZE) / PAGE_SIZE +
(maxproc * UPAGES) + nkmempages;
#ifdef SYSVSHM
--- 812,820 ----
* kernel. We also reserve space for kmem_alloc_pageable()
* for vm_fork().
*/
! lev3mapsize =
! (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
! buf_memcalc() + 16 * NCARGS + PAGER_MAP_SIZE) / PAGE_SIZE +
(maxproc * UPAGES) + nkmempages;
#ifdef SYSVSHM
Index: arch/amd64/amd64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.18
diff -c -r1.18 machdep.c
*** arch/amd64/amd64/machdep.c 6 Dec 2003 17:35:44 -0000 1.18
--- arch/amd64/amd64/machdep.c 22 Dec 2003 13:55:04 -0000
***************
*** 253,299 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (unsigned long)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! v2 = allocsys(v, NULL);
! if ((v2 - v) != sz)
! panic("startup: table size inconsistency");
!
! /*
! * Allocate virtual address space for the buffers. The area
! * is not managed by the VM system.
! */
! 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");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
!
! /*
! * XXX We defer allocation of physical pages for buffers until
! * XXX after autoconfiguration has run. We must do this because
! * XXX on system with large amounts of memory or with large
! * XXX user-configured buffer caches, the buffer cache will eat
! * XXX up all of the lower 16M of RAM. This prevents ISA DMA
! * XXX maps from allocating bounce pages.
! *
! * XXX Note that nothing can use buffer cache buffers until after
! * XXX autoconfiguration completes!!
! *
! * XXX This is a hack, and needs to be replaced with a better
! * XXX solution! --thorpej@NetBSD.org, December 6, 1997
! */
/*
* Allocate a submap for exec arguments. This map effectively
--- 253,259 ----
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 320,334 ****
lkm_map = &lkm_map_store;
#endif
! /*
! * XXX Buffer cache pages haven't yet been allocated, so
! * XXX we need to account for those pages when printing
! * XXX the amount of free memory.
! */
! format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free - bufpages));
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);
/* Safe for i/o port / memory space allocation to use malloc now. */
x86_bus_space_mallocok();
--- 280,287 ----
lkm_map = &lkm_map_store;
#endif
! format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
/* Safe for i/o port / memory space allocation to use malloc now. */
x86_bus_space_mallocok();
***************
*** 389,444 ****
ci->ci_idle_tss_sel = tss_alloc(pcb);
}
- /*
- * XXX Finish up the deferred buffer cache allocation and initialization.
- * XXXfvdl share.
- */
- void
- x86_64_bufinit()
- {
- u_int i, base, residual;
-
- 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) {
- /*
- * Attempt to allocate buffers from the first
- * 16M of RAM to avoid bouncing file system
- * transfers.
- */
- pg = uvm_pagealloc_strat(NULL, 0, NULL, 0,
- UVM_PGA_STRAT_FALLBACK, VM_FREELIST_FIRST16);
- 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());
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
- }
-
/*
* machine dependent system variables.
--- 342,347 ----
Index: arch/amd64/amd64/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/autoconf.c,v
retrieving revision 1.6
diff -c -r1.6 autoconf.c
*** arch/amd64/amd64/autoconf.c 8 Oct 2003 04:25:44 -0000 1.6
--- arch/amd64/amd64/autoconf.c 22 Dec 2003 13:55:04 -0000
***************
*** 122,130 ****
spl0();
lcr8(0);
-
- /* XXX Finish deferred buffer cache allocation. */
- x86_64_bufinit();
}
void
--- 122,127 ----
Index: arch/amd64/include/cpu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/include/cpu.h,v
retrieving revision 1.2
diff -c -r1.2 cpu.h
*** arch/amd64/include/cpu.h 7 Aug 2003 16:26:36 -0000 1.2
--- arch/amd64/include/cpu.h 22 Dec 2003 13:55:04 -0000
***************
*** 278,284 ****
int cpu_maxproc __P((void));
void cpu_reset __P((void));
void x86_64_proc0_tss_ldt_init __P((void));
- void x86_64_bufinit __P((void));
void x86_64_init_pcb_tss_ldt __P((struct cpu_info *));
void cpu_proc_fork __P((struct proc *, struct proc *));
--- 278,283 ----
Index: arch/amiga/amiga/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amiga/amiga/machdep.c,v
retrieving revision 1.187
diff -c -r1.187 machdep.c
*** arch/amiga/amiga/machdep.c 4 Dec 2003 19:38:21 -0000 1.187
--- arch/amiga/amiga/machdep.c 22 Dec 2003 13:55:04 -0000
***************
*** 261,275 ****
void
cpu_startup()
{
- caddr_t v;
- u_int i, base, residual;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
#endif
! paddr_t minaddr, maxaddr;
! paddr_t size = 0;
if (fputype != FPU_NONE)
m68k_make_fpu_idle_frame();
--- 261,273 ----
void
cpu_startup()
{
char pbuf[9];
+ u_int i;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
#endif
! vaddr_t minaddr, maxaddr;
if (fputype != FPU_NONE)
m68k_make_fpu_idle_frame();
***************
*** 300,358 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- size = (vm_size_t)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != size)
- panic("startup: table size inconsistency");
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they usually occupy more virtual memory than physical.
! */
! size = MAXBSIZE * nbuf;
! if (uvm_map(kernel_map, (vm_offset_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("startup: cannot allocate VM for buffers");
! minaddr = (vm_offset_t) buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! for (i = 0; i < nbuf; i++) {
! vm_size_t curbufsize;
! vm_offset_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 = (vm_offset_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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 298,305 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 379,386 ****
#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);
/*
* display memory configuration passed from loadbsd
--- 326,331 ----
***************
*** 402,416 ****
#ifdef DEBUG_KERNEL_START
printf("survived initcpu...\n");
#endif
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
-
- #ifdef DEBUG_KERNEL_START
- printf("survived bufinit...\n");
- #endif
}
/*
--- 347,352 ----
Index: arch/amigappc/amigappc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amigappc/amigappc/machdep.c,v
retrieving revision 1.25
diff -c -r1.25 machdep.c
*** arch/amigappc/amigappc/machdep.c 14 Jul 2003 23:40:34 -0000 1.25
--- arch/amigappc/amigappc/machdep.c 22 Dec 2003 13:55:04 -0000
***************
*** 702,711 ****
void
cpu_startup()
{
- u_int i, base, residual;
caddr_t v;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
initmsgbuf((caddr_t)msgbuf_paddr, round_page(MSGBUFSIZE));
--- 702,709 ----
***************
*** 719,782 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses
- */
- size = (int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0) {
- panic("startup: no room for tables");
- }
- if (allocsys(v, NULL) - v != size) {
- panic("startup: table size inconsistency");
- }
-
- /*
- * Now allocate buffers proper; they are different than the above
- * in that they usually occupy more virtual memory than physical
- */
- size = MAXBSIZE * nbuf;
minaddr = 0;
- if (uvm_map(kernel_map, (vaddr_t *)&minaddr, 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("startup: cannot allocate VM for buffers");
- }
- buffers = (char *)minaddr;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- 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(kernel_map->pmap);
/*
* Allocate a submap for exec arguments. This map effectively
--- 717,723 ----
***************
*** 799,811 ****
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 the buffers, so they can be used to read disk labels
- */
- bufinit();
}
/*
--- 740,745 ----
Index: arch/arc/arc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/machdep.c,v
retrieving revision 1.81
diff -c -r1.81 machdep.c
*** arch/arc/arc/machdep.c 26 Sep 2003 16:00:28 -0000 1.81
--- arch/arc/arc/machdep.c 22 Dec 2003 13:55:04 -0000
***************
*** 243,249 ****
int i;
paddr_t kernstartpfn, kernendpfn, first, last;
caddr_t kernend, v;
- vsize_t size;
/* clear the BSS segment in kernel code */
kernend = (caddr_t)mips_round_page(end);
--- 243,248 ----
***************
*** 456,467 ****
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.
*/
pmap_bootstrap();
--- 455,460 ----
***************
*** 474,489 ****
lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
curpcb = &lwp0.l_addr->u_pcb;
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
- * virtual address space.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
void
--- 467,472 ----
***************
*** 536,544 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 519,525 ----
***************
*** 555,606 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * 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");
!
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
!
! /* now allocate RAM for buffers */
! 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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 536,542 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 626,638 ****
#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 disk labels.
- */
- bufinit();
}
int waittime = -1;
--- 562,567 ----
Index: arch/arm/arm32/arm32_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/arm32_machdep.c,v
retrieving revision 1.41
diff -c -r1.41 arm32_machdep.c
*** arch/arm/arm32/arm32_machdep.c 13 Dec 2003 12:07:41 -0000 1.41
--- arch/arm/arm32/arm32_machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 209,220 ****
void
cpu_startup()
{
! paddr_t minaddr;
! paddr_t maxaddr;
! caddr_t sysbase;
! caddr_t size;
! vsize_t bufsize;
! u_int loop, base, residual;
char pbuf[9];
/* Set the cpu control register */
--- 209,217 ----
void
cpu_startup()
{
! vaddr_t minaddr;
! vaddr_t maxaddr;
! u_int loop;
char pbuf[9];
/* Set the cpu control register */
***************
*** 249,310 ****
format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = allocsys(NULL, NULL);
! sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page((vaddr_t)size));
! if (sysbase == 0)
! panic(
! "cpu_startup: no room for system tables; %d bytes required",
! (u_int)size);
! if ((caddr_t)((allocsys(sysbase, NULL) - sysbase)) != size)
! panic("cpu_startup: system table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they usually occupy more virtual memory than physical.
! */
! bufsize = MAXBSIZE * nbuf;
! if (uvm_map(kernel_map, (void *)&buffers, round_page(bufsize),
! 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 UVM space for buffers");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
!
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! for (loop = 0; loop < nbuf; ++loop) {
! 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 + (loop * MAXBSIZE);
! curbufsize = PAGE_SIZE * ((loop < 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());
/*
* Allocate a submap for exec arguments. This map effectively
--- 246,252 ----
format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 328,340 ****
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;
curpcb->pcb_flags = 0;
--- 270,275 ----
Index: arch/atari/atari/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/atari/atari/machdep.c,v
retrieving revision 1.131
diff -c -r1.131 machdep.c
*** arch/atari/atari/machdep.c 4 Dec 2003 19:38:21 -0000 1.131
--- arch/atari/atari/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 230,237 ****
{
extern void etext __P((void));
extern int iomem_malloc_safe;
- caddr_t v;
- u_int i, base, residual;
char pbuf[9];
#ifdef DEBUG
--- 230,235 ----
***************
*** 239,245 ****
int opmapdebug = pmapdebug;
#endif
vaddr_t minaddr, maxaddr;
- vsize_t size = 0;
extern vsize_t mem_size; /* from pmap.c */
#ifdef DEBUG
--- 237,242 ----
***************
*** 258,316 ****
format_bytes(pbuf, sizeof(pbuf), mem_size);
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != size)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! 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(kernel_map->pmap);
/*
* Allocate a submap for exec arguments. This map effectively
--- 255,261 ----
format_bytes(pbuf, sizeof(pbuf), mem_size);
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 357,369 ****
#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 disk labels.
- */
- bufinit();
/*
* Alloc extent allocation to use malloc
--- 302,307 ----
Index: arch/cesfic/cesfic/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cesfic/cesfic/machdep.c,v
retrieving revision 1.25
diff -c -r1.25 machdep.c
*** arch/cesfic/cesfic/machdep.c 4 Dec 2003 19:38:21 -0000 1.25
--- arch/cesfic/cesfic/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 294,303 ****
cpu_startup()
{
extern char *etext;
- caddr_t v;
- int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
--- 294,300 ----
***************
*** 315,370 ****
identifycpu();
printf("real mem = %d\n", ctob(physmem));
! /*
! * Find out how much space we need, allocate it,
! * and the give everything true virtual addresses.
! */
! size = (vm_size_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if ((allocsys(v, NULL) - v) != size)
! panic("startup: talbe size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they usually occupy more virtual memory than physical.
! */
! size = MAXBSIZE * nbuf;
! if (uvm_map(kernel_map, (vm_offset_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("startup: cannot allocate VM for buffers");
! minaddr = (vm_offset_t)buffers;
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! for (i = 0; i < nbuf; i++) {
! vm_size_t curbufsize;
! vm_offset_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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 312,318 ----
identifycpu();
printf("real mem = %d\n", ctob(physmem));
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 389,396 ****
pmapdebug = opmapdebug;
#endif
printf("avail mem = %ld\n", ptoa(uvmexp.free));
- printf("using %u buffers containing %d bytes of memory\n",
- nbuf, bufpages * PAGE_SIZE);
/*
* Tell the VM system that writing to kernel text isn't allowed.
--- 337,342 ----
***************
*** 399,409 ****
if (uvm_map_protect(kernel_map, KERNBASE, m68k_round_page(&etext),
UVM_PROT_READ|UVM_PROT_EXEC, TRUE) != 0)
panic("can't protect kernel text");
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 345,350 ----
Index: arch/cobalt/cobalt/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/machdep.c,v
retrieving revision 1.48
diff -c -r1.48 machdep.c
*** arch/cobalt/cobalt/machdep.c 26 Sep 2003 16:00:28 -0000 1.48
--- arch/cobalt/cobalt/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 130,136 ****
{
caddr_t kernend, v;
u_long first, last;
- vsize_t size;
extern char edata[], end[];
/*
--- 130,135 ----
***************
*** 204,215 ****
*/
mips_init_msgbuf();
- /*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (vsize_t)allocsys(NULL, NULL);
-
pmap_bootstrap();
/*
--- 203,208 ----
***************
*** 220,235 ****
lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
curpcb = &lwp0.l_addr->u_pcb;
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
- * virtual address space.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
/*
--- 213,218 ----
***************
*** 238,246 ****
void
cpu_startup()
{
- int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 221,227 ----
***************
*** 250,296 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! /*
! * 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 231,237 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 311,323 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf(", %s free", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf(", %s in %u buffers\n", pbuf, nbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
int waittime = -1;
--- 252,257 ----
Index: arch/evbmips/alchemy/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/alchemy/machdep.c,v
retrieving revision 1.14
diff -c -r1.14 machdep.c
*** arch/evbmips/alchemy/machdep.c 8 Nov 2003 05:05:14 -0000 1.14
--- arch/evbmips/alchemy/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 303,314 ****
mips_init_msgbuf();
/*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- memsize = (u_long)allocsys(NULL, NULL);
-
- /*
* Initialize the virtual memory system.
*/
pmap_bootstrap();
--- 303,308 ----
***************
*** 322,337 ****
curpcb = &lwp0.l_addr->u_pcb;
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(memsize);
- if ((allocsys(v, NULL) - v) != memsize)
- panic("mach_init: table size inconsistency");
-
#if NOHCI > 0
{
#define USBH_ALL (0x1f<<10) /* All relevant bits in USBH portion of SYS_CLKSRC */
--- 316,321 ----
***************
*** 382,389 ****
{
char pbuf[9];
vaddr_t minaddr, maxaddr;
- vsize_t size;
- u_int i, base, residual;
#ifdef DEBUG
extern int pmapdebug; /* XXX */
int opmapdebug = pmapdebug;
--- 366,371 ----
***************
*** 399,451 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * 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");
!
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
!
! /* now allocate RAM for buffers */
! 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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 381,387 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 470,482 ****
#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();
}
void
--- 406,411 ----
Index: arch/evbmips/malta/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/malta/machdep.c,v
retrieving revision 1.16
diff -c -r1.16 machdep.c
*** arch/evbmips/malta/machdep.c 27 Oct 2003 23:47:00 -0000 1.16
--- arch/evbmips/malta/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 202,208 ****
bus_space_handle_t sh;
caddr_t kernend, v;
u_long first, last;
- vsize_t size;
char *cp;
int freqok, i, howto;
uint8_t *brkres = (uint8_t *)MIPS_PHYS_TO_KSEG1(MALTA_BRKRES);
--- 202,207 ----
***************
*** 316,327 ****
*/
mips_init_msgbuf();
- /*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (vsize_t)allocsys(NULL, NULL);
-
pmap_bootstrap();
/*
--- 315,320 ----
***************
*** 334,349 ****
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)
--- 327,332 ----
***************
*** 372,380 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 355,361 ----
***************
*** 390,436 ****
*/
malta_configuration.mc_mallocsafe = 1;
! /*
! * 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 371,377 ----
*/
malta_configuration.mc_mallocsafe = 1;
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 451,463 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf(", %s free", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf(", %s in %u buffers\n", pbuf, nbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
int waittime = -1;
--- 392,397 ----
Index: arch/evbppc/explora/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/explora/machdep.c,v
retrieving revision 1.4
diff -c -r1.4 machdep.c
*** arch/evbppc/explora/machdep.c 12 Aug 2003 05:06:55 -0000 1.4
--- arch/evbppc/explora/machdep.c 22 Dec 2003 13:55:05 -0000
***************
*** 308,316 ****
void
cpu_startup(void)
{
- caddr_t v;
vaddr_t minaddr, maxaddr;
- u_int sz, i, base, residual;
char pbuf[9];
/*
--- 308,314 ----
***************
*** 325,379 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (u_int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
- */
- sz = MAXBSIZE * nbuf;
minaddr = 0;
- if (uvm_map(kernel_map, (vaddr_t *)&minaddr, round_page(sz),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("startup: cannot allocate VM for buffers");
- buffers = (char *)minaddr;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- curbuf = (vaddr_t)buffers + i * MAXBSIZE;
- curbufsize = NBPG * (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;
- }
- }
-
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 323,329 ----
***************
*** 395,407 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
- printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
-
- /*
- * Set up the buffers.
- */
- bufinit();
/*
* Set up the board properties database.
--- 345,350 ----
Index: arch/evbppc/walnut/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/walnut/machdep.c,v
retrieving revision 1.18
diff -c -r1.18 machdep.c
*** arch/evbppc/walnut/machdep.c 18 Aug 2003 21:34:11 -0000 1.18
--- arch/evbppc/walnut/machdep.c 22 Dec 2003 13:55:06 -0000
***************
*** 359,367 ****
void
cpu_startup(void)
{
- caddr_t v;
vaddr_t minaddr, maxaddr;
- u_int sz, i, base, residual;
char pbuf[9];
/*
--- 359,365 ----
***************
*** 381,442 ****
initmsgbuf((caddr_t)msgbuf, round_page(MSGBUFSIZE));
#endif
-
printf("%s", version);
printf("Walnut PowerPC 405GP Evaluation Board\n");
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (u_int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
- */
- sz = MAXBSIZE * nbuf;
minaddr = 0;
- if (uvm_map(kernel_map, (vaddr_t *)&minaddr, round_page(sz),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("startup: cannot allocate VM for buffers");
- buffers = (char *)minaddr;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- 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;
- }
- }
-
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 379,391 ----
***************
*** 458,470 ****
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 the buffers.
- */
- bufinit();
/*
* Set up the board properties database.
--- 407,412 ----
Index: arch/evbsh5/evbsh5/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbsh5/evbsh5/machdep.c,v
retrieving revision 1.17
diff -c -r1.17 machdep.c
*** arch/evbsh5/evbsh5/machdep.c 6 Dec 2003 03:16:48 -0000 1.17
--- arch/evbsh5/evbsh5/machdep.c 22 Dec 2003 13:55:06 -0000
***************
*** 183,189 ****
struct boot_params *bp;
u_long ksize;
vsize_t size;
- caddr_t v;
paddr_t kseg0_phys;
int i, j;
--- 183,188 ----
***************
*** 262,276 ****
#endif
boothowto = bp->bp_flags;
-
- /*
- * Call allocsys() now so we can steal pages from KSEG0.
- */
- size = (vsize_t)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_pageboot_alloc(round_page(size))) == 0)
- panic("startup: no room for tables");
- if ((allocsys(v, NULL) - v) != size)
- panic("startup: table size inconsistency");
}
#ifndef SH5_CPU_SPEED
--- 261,266 ----
***************
*** 332,381 ****
void
cpu_startup(void)
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[16];
! /*
! * Now allocate buffers proper.
! */
! 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 322,331 ----
void
cpu_startup(void)
{
vaddr_t minaddr, maxaddr;
char pbuf[16];
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 403,415 ****
printf("total memory = %s\n", pbuf);
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 bytes of memory\n", nbuf, pbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
void
--- 353,358 ----
Index: arch/hp300/hp300/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/machdep.c,v
retrieving revision 1.176
diff -c -r1.176 machdep.c
*** arch/hp300/hp300/machdep.c 4 Dec 2003 19:38:21 -0000 1.176
--- arch/hp300/hp300/machdep.c 22 Dec 2003 13:55:06 -0000
***************
*** 321,330 ****
cpu_startup()
{
extern char *etext;
- caddr_t v;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 321,327 ----
***************
*** 349,404 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and the give everything true virtual addresses.
! */
! size = (vsize_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if ((allocsys(v, NULL) - v) != size)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 346,352 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 424,431 ****
#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);
/*
* Tell the VM system that page 0 isn't mapped.
--- 372,377 ----
***************
*** 452,462 ****
*/
initcpu();
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
-
/* Safe to use malloc for extio_ex now. */
extio_ex_malloc_safe = 1;
}
--- 398,403 ----
Index: arch/hp700/hp700/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp700/hp700/machdep.c,v
retrieving revision 1.16
diff -c -r1.16 machdep.c
*** arch/hp700/hp700/machdep.c 4 Dec 2003 19:38:21 -0000 1.16
--- arch/hp700/hp700/machdep.c 22 Dec 2003 13:55:06 -0000
***************
*** 423,429 ****
vaddr_t vstart, vend;
int error;
int hptsize; /* size of HPT table if supported */
- int sz;
u_int *p, *q;
struct pdc_cpuid pdc_cpuid PDC_ALIGNMENT;
const char *model;
--- 423,428 ----
***************
*** 701,712 ****
*/
physmem = totalphysmem;
- sz = (int)allocsys(NULL, NULL);
- memset((void *)vstart, 0, sz);
- if (allocsys((caddr_t)vstart, NULL) - (caddr_t)vstart != sz)
- panic("startup: table size inconsistency");
- vstart += sz;
- vstart = hppa_round_page(vstart);
/* Allocate the msgbuf. */
msgbufaddr = (caddr_t) vstart;
--- 700,705 ----
***************
*** 837,844 ****
cpu_startup(void)
{
vaddr_t minaddr, maxaddr;
- vsize_t size;
- u_int i, base, residual;
char pbuf[3][9];
#ifdef PMAPDEBUG
extern int pmapdebug;
--- 830,835 ----
***************
*** 868,911 ****
printf("real mem = %s (%s reserved for PROM, %s used by NetBSD)\n",
pbuf[0], pbuf[1], pbuf[2]);
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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");
! minaddr = (vaddr_t)buffers;
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! for (i = 0; i < nbuf; i++) {
! vsize_t curbufsize;
! vaddr_t curbuf;
! struct vm_page *pg;
!
! /*
! * First <residual> buffers get (base+1) physical pages
! * allocated for them. The rest get (base) physical pages.
! *
! * The rest of each buffer occupies virtual space,
! * but has no physical memory allocated for it.
! */
! curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
! curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
!
! while (curbufsize) {
! if ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == 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;
! }
! }
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 859,865 ----
printf("real mem = %s (%s reserved for PROM, %s used by NetBSD)\n",
pbuf[0], pbuf[1], pbuf[2]);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 926,935 ****
pmapdebug = opmapdebug;
#endif
format_bytes(pbuf[0], sizeof(pbuf[0]), ptoa(uvmexp.free));
- format_bytes(pbuf[1], sizeof(pbuf[1]), bufpages * PAGE_SIZE);
printf("avail mem = %s\n", pbuf[0]);
- printf("using %u buffers containing %s of memory\n",
- nbuf, pbuf[1]);
/*
* Allocate a virtual page (for use by /dev/mem)
--- 880,886 ----
***************
*** 937,948 ****
* it has to be in the normal kernel VA range.
*/
vmmap = uvm_km_valloc_wait(kernel_map, PAGE_SIZE);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
-
}
/*
--- 888,893 ----
Index: arch/hpcmips/hpcmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcmips/hpcmips/machdep.c,v
retrieving revision 1.84
diff -c -r1.84 machdep.c
*** arch/hpcmips/hpcmips/machdep.c 26 Sep 2003 16:00:28 -0000 1.84
--- arch/hpcmips/hpcmips/machdep.c 22 Dec 2003 13:55:06 -0000
***************
*** 265,272 ****
#if NKSYMS || defined(DDB) || defined(LKM)
extern caddr_t esym;
#endif
! caddr_t kernend, v;
! unsigned size;
char *cp;
int i;
--- 265,271 ----
#if NKSYMS || defined(DDB) || defined(LKM)
extern caddr_t esym;
#endif
! caddr_t kernend;
char *cp;
int i;
***************
*** 533,557 ****
mips_init_msgbuf();
/*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (unsigned)allocsys(NULL, NULL);
-
- /*
* Initialize the virtual memory system.
*/
pmap_bootstrap();
-
- /*
- * 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.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
/*
--- 532,540 ----
***************
*** 561,570 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
--- 544,552 ----
void
cpu_startup()
{
vaddr_t minaddr, maxaddr;
char pbuf[9];
+ u_int i;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
***************
*** 591,643 ****
}
}
! /*
! * 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");
!
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
!
! /* now allocate RAM for buffers */
! 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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 573,579 ----
}
}
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 662,674 ****
#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 disk labels.
- */
- bufinit();
}
void
--- 598,603 ----
Index: arch/luna68k/luna68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/machdep.c,v
retrieving revision 1.35
diff -c -r1.35 machdep.c
*** arch/luna68k/luna68k/machdep.c 4 Dec 2003 19:38:21 -0000 1.35
--- arch/luna68k/luna68k/machdep.c 22 Dec 2003 13:55:07 -0000
***************
*** 247,256 ****
void
cpu_startup()
{
- caddr_t v;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
extern void greeting __P((void));
--- 247,253 ----
***************
*** 271,330 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != size)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! 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 = (vsize_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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 268,274 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 347,354 ****
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);
/*
* Tell the VM system that the area before the text segment
--- 291,296 ----
***************
*** 371,381 ****
panic("can't protect kernel text");
/*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
-
- /*
* Say "Hi" to the world
*/
greeting();
--- 313,318 ----
Index: arch/mac68k/mac68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.294
diff -c -r1.294 machdep.c
*** arch/mac68k/mac68k/machdep.c 4 Dec 2003 19:38:21 -0000 1.294
--- arch/mac68k/mac68k/machdep.c 22 Dec 2003 13:55:07 -0000
***************
*** 417,427 ****
{
extern char *start;
extern char *etext;
- caddr_t v;
int vers;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size = 0; /* To avoid compiler warning */
int delay;
char pbuf[9];
--- 417,424 ----
***************
*** 455,510 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (vm_size_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != size)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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(kernel_map->pmap);
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 452,458 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 526,533 ****
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);
/*
* Tell the VM system that writing to kernel text isn't allowed.
--- 474,479 ----
***************
*** 547,557 ****
*/
initcpu();
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
-
/* Safe for extent allocation to use malloc now. */
iomem_malloc_safe = 1;
}
--- 493,498 ----
Index: arch/mipsco/mipsco/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mipsco/mipsco/machdep.c,v
retrieving revision 1.39
diff -c -r1.39 machdep.c
*** arch/mipsco/mipsco/machdep.c 7 Aug 2003 16:28:36 -0000 1.39
--- arch/mipsco/mipsco/machdep.c 22 Dec 2003 13:55:08 -0000
***************
*** 379,390 ****
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.
*/
pmap_bootstrap();
--- 379,384 ----
***************
*** 399,416 ****
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
- * virtual address space.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
- /*
* Set up interrupt handling and I/O addresses.
*/
-
pizazz_init();
}
--- 393,400 ----
***************
*** 423,431 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 407,413 ----
***************
*** 442,488 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * 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 *)&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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 424,430 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 506,518 ****
#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 disk labels.
- */
- bufinit();
}
/*
--- 448,453 ----
Index: arch/mips/mips/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/pmap.c,v
retrieving revision 1.154
diff -c -r1.154 pmap.c
*** arch/mips/mips/pmap.c 12 Dec 2003 14:55:58 -0000 1.154
--- arch/mips/mips/pmap.c 22 Dec 2003 13:55:08 -0000
***************
*** 307,314 ****
* We also reserve space for kmem_alloc_pageable() for vm_fork().
*/
Sysmapsize = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
! nbuf * MAXBSIZE + 16 * NCARGS + PAGER_MAP_SIZE) / NBPG +
! (maxproc * UPAGES) + nkmempages;
#ifdef SYSVSHM
Sysmapsize += shminfo.shmall;
--- 307,314 ----
* We also reserve space for kmem_alloc_pageable() for vm_fork().
*/
Sysmapsize = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
! buf_memcalc() + 16 * NCARGS + PAGER_MAP_SIZE) / NBPG +
! (maxproc * UPAGES) + nkmempages;
#ifdef SYSVSHM
Sysmapsize += shminfo.shmall;
Index: arch/mvme68k/mvme68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/machdep.c,v
retrieving revision 1.107
diff -c -r1.107 machdep.c
*** arch/mvme68k/mvme68k/machdep.c 4 Dec 2003 19:38:22 -0000 1.107
--- arch/mvme68k/mvme68k/machdep.c 22 Dec 2003 13:55:08 -0000
***************
*** 469,480 ****
cpu_startup()
{
extern char *kernel_text, *etext;
- caddr_t v;
- u_int i, base, residual;
u_quad_t vmememsize;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
--- 469,478 ----
cpu_startup()
{
extern char *kernel_text, *etext;
u_quad_t vmememsize;
vaddr_t minaddr, maxaddr;
char pbuf[9];
+ u_int i;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
***************
*** 512,568 ****
printf("\n");
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (vsize_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if ((allocsys(v, NULL) - v) != size)
! panic("startup: table size inconsistency");
!
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 510,516 ----
printf("\n");
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 587,594 ****
#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);
/*
* Tell the VM system that the area before the text segment
--- 535,540 ----
***************
*** 614,624 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 560,565 ----
Index: arch/news68k/news68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/news68k/news68k/machdep.c,v
retrieving revision 1.47
diff -c -r1.47 machdep.c
*** arch/news68k/news68k/machdep.c 4 Dec 2003 19:38:22 -0000 1.47
--- arch/news68k/news68k/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 245,255 ****
void
cpu_startup()
{
- caddr_t v;
- int sz;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 245,251 ----
***************
*** 274,329 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! if ((allocsys(v, NULL) - v) != sz)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 270,276 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 348,355 ****
#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);
/*
* Tell the VM system that the area before the text segment
--- 295,300 ----
***************
*** 374,384 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 319,324 ----
Index: arch/newsmips/newsmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/machdep.c,v
retrieving revision 1.75
diff -c -r1.75 machdep.c
*** arch/newsmips/newsmips/machdep.c 23 Nov 2003 08:54:57 -0000 1.75
--- arch/newsmips/newsmips/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 254,260 ****
{
u_long first, last;
caddr_t kernend, v;
- vsize_t size;
struct btinfo_magic *bi_magic;
struct btinfo_bootarg *bi_arg;
struct btinfo_systype *bi_systype;
--- 254,259 ----
***************
*** 403,414 ****
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.
*/
pmap_bootstrap();
--- 402,407 ----
***************
*** 423,438 ****
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
- * virtual address space.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
-
- /*
* Determine what model of computer we are running on.
*/
switch (systype) {
--- 416,421 ----
***************
*** 494,502 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 477,483 ----
***************
*** 512,558 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 493,499 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 576,588 ****
#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 disk labels.
- */
- bufinit();
}
/*
--- 517,522 ----
Index: arch/next68k/next68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/next68k/next68k/machdep.c,v
retrieving revision 1.65
diff -c -r1.65 machdep.c
*** arch/next68k/next68k/machdep.c 4 Dec 2003 19:38:22 -0000 1.65
--- arch/next68k/next68k/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 322,331 ****
cpu_startup()
{
extern char *kernel_text, *etext;
- caddr_t v;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
--- 322,328 ----
***************
*** 350,406 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (vsize_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if ((allocsys(v, NULL) - v) != size)
! panic("startup: table size inconsistency");
!
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 347,353 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 425,432 ****
#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);
/*
* Tell the VM system that the area before the text segment
--- 372,377 ----
***************
*** 452,462 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 397,402 ----
Index: arch/pc532/pc532/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pc532/pc532/machdep.c,v
retrieving revision 1.153
diff -c -r1.153 machdep.c
*** arch/pc532/pc532/machdep.c 4 Dec 2003 19:38:22 -0000 1.153
--- arch/pc532/pc532/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 187,197 ****
cpu_startup()
{
extern char kernel_text[];
- caddr_t v;
- int sz;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 187,193 ----
***************
*** 213,272 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != sz)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! 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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 209,215 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 298,310 ****
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();
}
/*
--- 241,246 ----
Index: arch/pdp10/pdp10/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pdp10/pdp10/machdep.c,v
retrieving revision 1.3
diff -c -r1.3 machdep.c
*** arch/pdp10/pdp10/machdep.c 6 Dec 2003 03:16:49 -0000 1.3
--- arch/pdp10/pdp10/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 56,65 ****
{
extern int avail_end;
vaddr_t minaddr, maxaddr;
- vsize_t size;
- caddr_t v;
char pbuf[9];
- int sz, base, i, residual;
spl0(); /* Enable interrupts */
--- 56,62 ----
***************
*** 74,136 ****
format_bytes(pbuf, sizeof(pbuf), avail_end);
pbuf[strlen(pbuf)-1] = 0; /* Remove 'B' */
printf("total memory = %sW\n", pbuf);
- /*
- * Find out how much space we need, allocate it, and then give
- * everything true virtual addresses.
- */
-
- sz = (int) allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if ((allocsys(v, NULL) - v) != sz)
- panic("startup: table size inconsistency");
- /*
- * Now allocate buffers proper. They are different than the above in
- * that they usually occupy more virtual memory than physical.
- */
- size = MAXBSIZE * nbuf; /* # bytes for buffers */
-
- /* allocate VM for buffers... area is not managed by VM system */
- if (uvm_map(kernel_map, &minaddr, 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");
-
- buffers = (char *)minaddr;
- if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
- /* don't want to alloc more physical mem than needed */
- bufpages = btoc(MAXBSIZE) * nbuf;
- }
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- /* now allocate RAM for buffers */
- for (i = 0 ; i < nbuf ; i++) {
- vaddr_t curbuf;
- vsize_t curbufsize;
- struct vm_page *pg;
-
- /*
- * First <residual> buffers get (base+1) physical pages
- * allocated for them. The rest get (base) physical pages.
- *
- * The rest of each buffer occupies virtual space, but has no
- * physical memory allocated for it.
- */
- curbuf = (vaddr_t) buffers + i * MAXBSIZE;
- curbufsize = NBPG * (i < residual ? base + 1 : base);
- while (curbufsize) {
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL)
- panic("cpu_startup: "
- "not enough RAM for buffer cache");
- pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ | VM_PROT_WRITE);
- curbuf += NBPG;
- curbufsize -= NBPG;
- }
- }
/*
* Allocate a submap for exec arguments. This map effectively limits
* the number of processes exec'ing at any time.
--- 71,78 ----
format_bytes(pbuf, sizeof(pbuf), avail_end);
pbuf[strlen(pbuf)-1] = 0; /* Remove 'B' */
printf("total memory = %sW\n", pbuf);
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively limits
* the number of processes exec'ing at any time.
***************
*** 149,163 ****
pbuf[strlen(pbuf)-1] = 0; /* Remove 'B' */
printf("avail memory = %sW\n", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG/4);
- pbuf[strlen(pbuf)-1] = 0; /* Remove 'B' */
- printf("using %d buffers containing %sW of memory\n", nbuf, pbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
-
- bufinit();
#ifdef DDB
if (boothowto & RB_KDB)
Debugger();
--- 91,96 ----
Index: arch/playstation2/playstation2/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/playstation2/playstation2/machdep.c,v
retrieving revision 1.10
diff -c -r1.10 machdep.c
*** arch/playstation2/playstation2/machdep.c 15 Jul 2003 02:54:38 -0000 1.10
--- arch/playstation2/playstation2/machdep.c 22 Dec 2003 13:55:09 -0000
***************
*** 155,166 ****
*/
mips_init_msgbuf();
- /*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (vsize_t)allocsys(NULL, NULL);
-
pmap_bootstrap();
/*
--- 155,160 ----
***************
*** 174,189 ****
#ifdef IPL_ICU_MASK
curpcb->pcb_ppl = 0;
#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.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
/*
--- 168,173 ----
***************
*** 192,200 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 176,182 ----
***************
*** 205,250 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! /*
! * 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 *)&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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 187,193 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 265,277 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf(", %s free", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf(", %s in %u buffers\n", pbuf, nbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
void
--- 208,213 ----
Index: arch/pmax/pmax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/pmax/machdep.c,v
retrieving revision 1.207
diff -c -r1.207 machdep.c
*** arch/pmax/pmax/machdep.c 31 Oct 2003 03:32:19 -0000 1.207
--- arch/pmax/pmax/machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 204,211 ****
char *cp, *bootinfo_msg;
u_long first, last;
int i;
! caddr_t kernend, v;
! unsigned size;
#if NKSYMS || defined(DDB) || defined(LKM)
caddr_t ssym = 0;
struct btinfo_symtab *bi_syms;
--- 204,210 ----
char *cp, *bootinfo_msg;
u_long first, last;
int i;
! caddr_t kernend;
#if NKSYMS || defined(DDB) || defined(LKM)
caddr_t ssym = 0;
struct btinfo_symtab *bi_syms;
***************
*** 404,428 ****
mips_init_msgbuf();
/*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (unsigned)allocsys(NULL, NULL);
-
- /*
* Initialize the virtual memory system.
*/
pmap_bootstrap();
-
- /*
- * 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.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
void
--- 403,411 ----
***************
*** 447,455 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug; /* XXX */
--- 430,436 ----
***************
*** 466,518 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * 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");
!
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
!
! /* now allocate RAM for buffers */
! 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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 447,453 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 537,549 ****
#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 disk labels.
- */
- bufinit();
}
/*
--- 472,477 ----
Index: arch/powerpc/ibm4xx/ibm40x_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/ibm40x_machdep.c,v
retrieving revision 1.1
diff -c -r1.1 ibm40x_machdep.c
*** arch/powerpc/ibm4xx/ibm40x_machdep.c 23 Sep 2003 15:14:02 -0000 1.1
--- arch/powerpc/ibm4xx/ibm40x_machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 318,327 ****
void
ibm4xx_startup(const char *model)
{
- uintptr_t sz;
- u_int i;
- u_long base, residual;
- caddr_t v;
vaddr_t minaddr, maxaddr;
char pbuf[9];
--- 318,323 ----
***************
*** 354,408 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (u_int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
- */
- sz = MAXBSIZE * nbuf;
minaddr = 0;
- if (uvm_map(kernel_map, (vaddr_t *)&minaddr, round_page(sz),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("startup: cannot allocate VM for buffers");
- buffers = (char *)minaddr;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- 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;
- }
- }
-
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 350,356 ----
***************
*** 424,436 ****
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 the buffers.
- */
- bufinit();
}
void
--- 372,377 ----
Index: arch/powerpc/oea/oea_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/oea_machdep.c,v
retrieving revision 1.12
diff -c -r1.12 oea_machdep.c
*** arch/powerpc/oea/oea_machdep.c 21 Nov 2003 18:07:29 -0000 1.12
--- arch/powerpc/oea/oea_machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 609,619 ****
oea_startup(const char *model)
{
uintptr_t sz;
- u_int i;
- u_long base, residual;
caddr_t v;
vaddr_t minaddr, maxaddr;
char pbuf[9];
KASSERT(curcpu() != NULL);
KASSERT(lwp0.l_cpu != NULL);
--- 609,618 ----
oea_startup(const char *model)
{
uintptr_t sz;
caddr_t v;
vaddr_t minaddr, maxaddr;
char pbuf[9];
+ u_int i;
KASSERT(curcpu() != NULL);
KASSERT(lwp0.l_cpu != NULL);
***************
*** 651,707 ****
printf("total memory = %s\n", pbuf);
/*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (uintptr_t)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
- * Allocate the buffer starting at the top of the kernel VM space.
- */
- sz = MAXBSIZE * nbuf;
- minaddr = VM_MAX_KERNEL_ADDRESS - round_page(sz);
- if (uvm_map(kernel_map, &minaddr, round_page(sz),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("startup: cannot allocate VM for buffers");
- buffers = (char *)minaddr;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- 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());
-
- /*
* Allocate away the pages that map to 0xDEA[CDE]xxxx. Do this after
* the bufpages are allocated in case they overlap since it's not
* fatal if we can't allocate these.
--- 650,655 ----
***************
*** 717,724 ****
printf("oea_startup: failed to allocate DEAD "
"ZONE: error=%d\n", error);
}
- minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time. These
--- 665,672 ----
printf("oea_startup: failed to allocate DEAD "
"ZONE: error=%d\n", error);
}
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time. These
***************
*** 745,757 ****
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 the buffers.
- */
- bufinit();
}
/*
--- 693,698 ----
Index: arch/sbmips/sbmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sbmips/sbmips/machdep.c,v
retrieving revision 1.22
diff -c -r1.22 machdep.c
*** arch/sbmips/sbmips/machdep.c 26 Sep 2003 16:00:28 -0000 1.22
--- arch/sbmips/sbmips/machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 162,170 ****
void
mach_init(long fwhandle, long magic, long bootdata, long reserved)
{
! caddr_t kernend, v, p0;
u_long first, last;
- vsize_t size;
extern char edata[], end[];
int i;
uint32_t config;
--- 162,169 ----
void
mach_init(long fwhandle, long magic, long bootdata, long reserved)
{
! caddr_t kernend, p0;
u_long first, last;
extern char edata[], end[];
int i;
uint32_t config;
***************
*** 331,347 ****
curpcb = &lwp0.l_addr->u_pcb;
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
- * virtual address space.
- */
- size = (vsize_t)allocsys(NULL, NULL);
- v = (caddr_t)pmap_steal_memory(size, NULL, NULL);
- if ((allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
-
pmap_bootstrap();
/*
--- 330,335 ----
***************
*** 365,373 ****
void
cpu_startup(void)
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 353,359 ----
***************
*** 377,422 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! /*
! * 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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;
! }
! }
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 363,369 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 438,450 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf(", %s free", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf(", %s in %u buffers\n", pbuf, nbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
int waittime = -1;
--- 385,390 ----
Index: arch/sgimips/sgimips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/sgimips/machdep.c,v
retrieving revision 1.66
diff -c -r1.66 machdep.c
*** arch/sgimips/sgimips/machdep.c 15 Dec 2003 13:02:28 -0000 1.66
--- arch/sgimips/sgimips/machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 536,547 ****
*/
mips_init_msgbuf();
- /*
- * Compute the size of system data structures. pmap_bootstrap()
- * needs some of this information.
- */
- size = (vsize_t)allocsys(NULL, NULL);
-
pmap_bootstrap();
/*
--- 536,541 ----
***************
*** 552,567 ****
lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
curpcb = &lwp0.l_addr->u_pcb;
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
- * virtual address space.
- */
- v = (caddr_t)uvm_pageboot_alloc(size);
- if ((vsize_t) (allocsys(v, NULL) - v) != size)
- panic("mach_init: table size inconsistency");
}
void
--- 546,551 ----
***************
*** 586,594 ****
void
cpu_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
printf(version);
--- 570,576 ----
***************
*** 596,642 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! /*
! * 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 578,584 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("%s memory", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 659,671 ****
printf(", %s free", pbuf);
format_bytes(pbuf, sizeof(pbuf), ctob(arcsmem));
printf(", %s for ARCS", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf(", %s in %u buffers\n", pbuf, nbuf);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
int waittime = -1;
--- 601,606 ----
Index: arch/sh3/sh3/sh3_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/sh3_machdep.c,v
retrieving revision 1.53
diff -c -r1.53 sh3_machdep.c
*** arch/sh3/sh3/sh3_machdep.c 23 Nov 2003 23:13:11 -0000 1.53
--- arch/sh3/sh3/sh3_machdep.c 22 Dec 2003 13:55:10 -0000
***************
*** 249,257 ****
void
sh_startup()
{
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
printf(version);
--- 249,255 ----
***************
*** 277,328 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they usually occupy more virtual memory than physical.
! */
! size = MAXBSIZE * nbuf;
! buffers = 0;
! 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("sh3_startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
!
! 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("sh3_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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 275,281 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 338,350 ****
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();
}
/*
--- 291,296 ----
Index: arch/sh3/sh3/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/pmap.c,v
retrieving revision 1.49
diff -c -r1.49 pmap.c
*** arch/sh3/sh3/pmap.c 10 Aug 2003 02:03:31 -0000 1.49
--- arch/sh3/sh3/pmap.c 22 Dec 2003 13:55:11 -0000
***************
*** 105,122 ****
void
pmap_bootstrap()
{
- size_t sz;
- caddr_t v;
/* Steal msgbuf area */
initmsgbuf((caddr_t)uvm_pageboot_alloc(MSGBUFSIZE), MSGBUFSIZE);
- /* Allocate space for system data structures. */
- sz = (size_t)allocsys(NULL, NULL);
- v = (caddr_t)uvm_pageboot_alloc(sz);
- if ((allocsys(v, NULL) - v) != sz)
- panic("pmap_bootstrap: table size inconsistency");
-
avail_start = ptoa(vm_physmem[0].start);
avail_end = ptoa(vm_physmem[vm_nphysseg - 1].end);
__pmap_kve = VM_MIN_KERNEL_ADDRESS;
--- 105,114 ----
Index: arch/sparc64/sparc64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/machdep.c,v
retrieving revision 1.159
diff -c -r1.159 machdep.c
*** arch/sparc64/sparc64/machdep.c 4 Dec 2003 19:38:22 -0000 1.159
--- arch/sparc64/sparc64/machdep.c 22 Dec 2003 13:55:11 -0000
***************
*** 170,184 ****
void
cpu_startup()
{
- caddr_t v;
- long sz;
- u_int i, base, residual;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
#endif
vaddr_t minaddr, maxaddr;
- vsize_t size;
extern struct user *proc0paddr;
char pbuf[9];
--- 170,180 ----
***************
*** 196,258 ****
format_bytes(pbuf, sizeof(pbuf), ctob((u_int64_t)physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (long)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for %lx bytes of tables", sz);
! if (allocsys(v, NULL) - v != sz)
! panic("startup: table size inconsistency");
!
! /*
! * allocate virtual and physical memory for the buffers.
! */
! size = MAXBSIZE * nbuf; /* # bytes for buffers */
!
! /* allocate VM for buffers... area is not managed by VM system */
! 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");
!
! minaddr = (vaddr_t) buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
!
! /* now allocate RAM for buffers */
! for (i = 0 ; i < nbuf ; i++) {
! vaddr_t curbuf;
! vsize_t curbufsize;
! 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 RAM 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(kernel_map->pmap);
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 192,198 ----
format_bytes(pbuf, sizeof(pbuf), ctob((u_int64_t)physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 271,283 ****
#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 disk labels.
- */
- bufinit();
#if 0
pmap_redzone();
--- 211,216 ----
Index: arch/sun2/sun2/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun2/sun2/machdep.c,v
retrieving revision 1.31
diff -c -r1.31 machdep.c
*** arch/sun2/sun2/machdep.c 4 Dec 2003 19:38:22 -0000 1.31
--- arch/sun2/sun2/machdep.c 22 Dec 2003 13:55:11 -0000
***************
*** 287,294 ****
cpu_startup()
{
caddr_t v;
- vsize_t size;
- u_int sz, i, base, residual;
vaddr_t minaddr, maxaddr;
char pbuf[9];
--- 287,292 ----
***************
*** 343,402 ****
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (u_int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they 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("startup: cannot allocate VM for buffers");
- minaddr = (vaddr_t)buffers;
- if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
- /* don't want to alloc more physical mem than needed */
- bufpages = btoc(MAXBSIZE) * nbuf;
- }
- 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());
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 341,348 ----
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 419,426 ****
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);
/*
* Allocate a virtual page (for use by /dev/mem)
--- 365,370 ----
***************
*** 442,452 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 386,391 ----
Index: arch/sun3/sun3/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3/machdep.c,v
retrieving revision 1.169
diff -c -r1.169 machdep.c
*** arch/sun3/sun3/machdep.c 4 Dec 2003 19:38:22 -0000 1.169
--- arch/sun3/sun3/machdep.c 22 Dec 2003 13:55:12 -0000
***************
*** 220,227 ****
cpu_startup()
{
caddr_t v;
- vsize_t size;
- int i, sz, base, residual;
vaddr_t minaddr, maxaddr;
char pbuf[9];
--- 220,225 ----
***************
*** 255,314 ****
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (u_int)allocsys(NULL, NULL);
- if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v, NULL) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they 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("startup: cannot allocate VM for buffers");
- minaddr = (vaddr_t)buffers;
- if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
- /* don't want to alloc more physical mem than needed */
- bufpages = btoc(MAXBSIZE) * nbuf;
- }
- 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());
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 253,260 ----
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
+ minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 331,338 ****
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);
/*
* Allocate a virtual page (for use by /dev/mem)
--- 277,282 ----
***************
*** 350,360 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 294,299 ----
Index: arch/sun3/sun3x/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3x/machdep.c,v
retrieving revision 1.93
diff -c -r1.93 machdep.c
*** arch/sun3/sun3x/machdep.c 4 Dec 2003 19:38:22 -0000 1.93
--- arch/sun3/sun3x/machdep.c 22 Dec 2003 13:55:12 -0000
***************
*** 221,228 ****
cpu_startup()
{
caddr_t v;
- vsize_t size;
- int sz, i, base, residual;
vaddr_t minaddr, maxaddr;
char pbuf[9];
--- 221,226 ----
***************
*** 256,315 ****
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (u_int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != sz)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! 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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 254,260 ----
if ((dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE)) == 0)
panic("startup: alloc dumppage");
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 332,339 ****
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);
/*
* Allocate a virtual page (for use by /dev/mem)
--- 277,282 ----
***************
*** 351,361 ****
* Set up CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 294,299 ----
Index: arch/vax/vax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/machdep.c,v
retrieving revision 1.143
diff -c -r1.143 machdep.c
*** arch/vax/vax/machdep.c 8 Dec 2003 09:29:30 -0000 1.143
--- arch/vax/vax/machdep.c 22 Dec 2003 13:55:12 -0000
***************
*** 179,188 ****
void
cpu_startup()
{
- caddr_t v;
- u_int base, residual, i, sz;
vaddr_t minaddr, maxaddr;
- vsize_t size;
extern paddr_t avail_end;
char pbuf[9];
--- 179,185 ----
***************
*** 205,268 ****
mtpr(AST_NO, PR_ASTLVL);
spl0();
! /*
! * Find out how much space we need, allocate it, and then give
! * everything true virtual addresses.
! */
!
! sz = (u_int) allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != sz)
! panic("startup: table size inconsistency");
! /*
! * Now allocate buffers proper. They are different than the above in
! * that they usually occupy more virtual memory than physical.
! */
! size = MAXBSIZE * nbuf; /* # bytes for buffers */
!
! /* allocate VM for buffers... area is not managed by VM system */
! 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");
!
! minaddr = (vaddr_t) buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! /* now allocate RAM for buffers */
! for (i = 0 ; i < nbuf ; i++) {
! vaddr_t curbuf;
! vsize_t curbufsize;
! struct vm_page *pg;
!
! /*
! * First <residual> buffers get (base+1) physical pages
! * allocated for them. The rest get (base) physical pages.
! *
! * The rest of each buffer occupies virtual space, but has no
! * physical memory allocated for it.
! */
! 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 RAM 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(kernel_map->pmap);
!
/*
* Allocate a submap for exec arguments. This map effectively limits
* the number of processes exec'ing at any time.
--- 202,208 ----
mtpr(AST_NO, PR_ASTLVL);
spl0();
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively limits
* the number of processes exec'ing at any time.
***************
*** 282,295 ****
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();
#ifdef DDB
if (boothowto & RB_KDB)
Debugger();
--- 222,228 ----
Index: arch/vax/vax/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/pmap.c,v
retrieving revision 1.131
diff -c -r1.131 pmap.c
*** arch/vax/vax/pmap.c 14 Dec 2003 19:39:24 -0000 1.131
--- arch/vax/vax/pmap.c 22 Dec 2003 13:55:12 -0000
***************
*** 199,207 ****
static vsize_t
calc_kvmsize(vsize_t usrptsize)
{
- extern u_int bufcache;
vsize_t kvmsize;
- u_int n, bp, bc;
/* All physical memory */
kvmsize = avail_end;
--- 199,205 ----
***************
*** 220,230 ****
kvmsize += (physmem * sizeof(struct vm_anon));
/* allocated buffer space etc... This is a hack */
- n = nbuf; bp = bufpages; bc = bufcache;
- kvmsize += (u_int)allocsys(NULL, NULL);
/* Buffer space */
! kvmsize += (MAXBSIZE * nbuf);
! nbuf = n; bufpages = bp; bufcache = bc;
/* UBC submap space */
kvmsize += (UBC_NWINS << UBC_WINSHIFT);
--- 218,225 ----
kvmsize += (physmem * sizeof(struct vm_anon));
/* allocated buffer space etc... This is a hack */
/* Buffer space */
! kvmsize += buf_memcalc();
/* UBC submap space */
kvmsize += (UBC_NWINS << UBC_WINSHIFT);
Index: arch/x68k/x68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x68k/x68k/machdep.c,v
retrieving revision 1.123
diff -c -r1.123 machdep.c
*** arch/x68k/x68k/machdep.c 4 Dec 2003 19:38:22 -0000 1.123
--- arch/x68k/x68k/machdep.c 22 Dec 2003 13:55:13 -0000
***************
*** 261,271 ****
void
cpu_startup()
{
- caddr_t v;
- u_int i, base, residual;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
--- 261,269 ----
void
cpu_startup()
{
vaddr_t minaddr, maxaddr;
char pbuf[9];
+ u_int i;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
***************
*** 303,364 ****
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! size = (vm_size_t)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(size))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != size)
! panic("startup: table size inconsistency");
!
! /*
! * Now allocate buffers proper. They are different than the above
! * in that they 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("startup: cannot allocate VM for buffers");
! minaddr = (vaddr_t)buffers;
! #if 0
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
! #endif
! 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 = (vsize_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());
!
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
--- 301,307 ----
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
***************
*** 384,401 ****
#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 CPU-specific registers, cache, etc.
*/
initcpu();
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
}
/*
--- 327,337 ----
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.545
diff -c -r1.545 machdep.c
*** arch/i386/i386/machdep.c 4 Dec 2003 19:38:21 -0000 1.545
--- arch/i386/i386/machdep.c 22 Dec 2003 13:55:13 -0000
***************
*** 282,291 ****
void
cpu_startup()
{
! caddr_t v;
! int sz, x;
vaddr_t minaddr, maxaddr;
- vsize_t size;
char pbuf[9];
/*
--- 282,289 ----
void
cpu_startup()
{
! int x;
vaddr_t minaddr, maxaddr;
char pbuf[9];
/*
***************
*** 315,360 ****
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
! /*
! * Find out how much space we need, allocate it,
! * and then give everything true virtual addresses.
! */
! sz = (int)allocsys(NULL, NULL);
! if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
! panic("startup: no room for tables");
! if (allocsys(v, NULL) - v != sz)
! panic("startup: table size inconsistency");
!
! /*
! * Allocate virtual address space for the buffers. The area
! * is not managed by the VM system.
! */
! 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");
! minaddr = (vaddr_t)buffers;
! if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
! /* don't want to alloc more physical mem than needed */
! bufpages = btoc(MAXBSIZE) * nbuf;
! }
!
! /*
! * XXX We defer allocation of physical pages for buffers until
! * XXX after autoconfiguration has run. We must do this because
! * XXX on system with large amounts of memory or with large
! * XXX user-configured buffer caches, the buffer cache will eat
! * XXX up all of the lower 16M of RAM. This prevents ISA DMA
! * XXX maps from allocating bounce pages.
! *
! * XXX Note that nothing can use buffer cache buffers until after
! * XXX autoconfiguration completes!!
! *
! * XXX This is a hack, and needs to be replaced with a better
! * XXX solution! --thorpej@NetBSD.org, December 6, 1997
! */
/*
* Allocate a submap for exec arguments. This map effectively
--- 313,319 ----
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
! minaddr = 0;
/*
* Allocate a submap for exec arguments. This map effectively
***************
*** 375,389 ****
mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
nmbclusters * mclbytes, VM_MAP_INTRSAFE, FALSE, NULL);
! /*
! * XXX Buffer cache pages haven't yet been allocated, so
! * XXX we need to account for those pages when printing
! * XXX the amount of free memory.
! */
! format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free - bufpages));
printf("avail memory = %s\n", pbuf);
- format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
- printf("using %d buffers containing %s of memory\n", nbuf, pbuf);
/* Safe for i/o port / memory space allocation to use malloc now. */
x86_bus_space_mallocok();
--- 334,341 ----
mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
nmbclusters * mclbytes, VM_MAP_INTRSAFE, FALSE, NULL);
! format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
/* Safe for i/o port / memory space allocation to use malloc now. */
x86_bus_space_mallocok();
***************
*** 442,496 ****
}
/*
- * XXX Finish up the deferred buffer cache allocation and initialization.
- */
- void
- i386_bufinit()
- {
- int i, base, residual;
-
- 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) {
- /*
- * Attempt to allocate buffers from the first
- * 16M of RAM to avoid bouncing file system
- * transfers.
- */
- pg = uvm_pagealloc_strat(NULL, 0, NULL, 0,
- UVM_PGA_STRAT_FALLBACK, VM_FREELIST_FIRST16);
- 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());
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
- }
-
- /*
* sysctl helper routine for machdep.tm* nodes.
*/
static int
--- 394,399 ----
Index: arch/i386/i386/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/autoconf.c,v
retrieving revision 1.74
diff -c -r1.74 autoconf.c
*** arch/i386/i386/autoconf.c 27 Oct 2003 14:11:46 -0000 1.74
--- arch/i386/i386/autoconf.c 22 Dec 2003 13:55:13 -0000
***************
*** 154,162 ****
#if NLAPIC > 0
lapic_tpr = 0;
#endif
-
- /* XXX Finish deferred buffer cache allocation. */
- i386_bufinit();
}
void
--- 154,159 ----
Index: arch/i386/include/cpu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/include/cpu.h,v
retrieving revision 1.109
diff -c -r1.109 cpu.h
*** arch/i386/include/cpu.h 27 Oct 2003 13:44:20 -0000 1.109
--- arch/i386/include/cpu.h 22 Dec 2003 13:55:13 -0000
***************
*** 351,357 ****
void cpu_reset(void);
void i386_init_pcb_tss_ldt(struct cpu_info *);
void i386_proc0_tss_ldt_init(void);
- void i386_bufinit(void);
/* identcpu.c */
extern int tmx86_has_longrun;
--- 351,356 ----
Index: arch/sparc/sparc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/machdep.c,v
retrieving revision 1.241
diff -c -r1.241 machdep.c
*** arch/sparc/sparc/machdep.c 4 Dec 2003 19:38:22 -0000 1.241
--- arch/sparc/sparc/machdep.c 22 Dec 2003 13:55:14 -0000
***************
*** 162,177 ****
void dumpsys __P((void));
void stackdump __P((void));
- caddr_t mdallocsys __P((caddr_t));
-
/*
* Machine-dependent startup code
*/
void
cpu_startup()
{
- caddr_t v;
- u_int i, base, residual;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
--- 162,173 ----
***************
*** 286,355 ****
}
/*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- size = (vsize_t)allocsys(NULL, mdallocsys);
-
- if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(size))) == 0)
- panic("startup: no room for tables");
-
- if ((vsize_t)(allocsys(v, mdallocsys) - v) != size)
- panic("startup: table size inconsistency");
-
- /*
- * allocate virtual and physical memory for the buffers.
- */
- size = MAXBSIZE * nbuf; /* # bytes for buffers */
-
- /* allocate VM for buffers... area is not managed by VM system */
- 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");
-
- minaddr = (vaddr_t) buffers;
- if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
- bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
- }
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
-
- /* now allocate RAM for buffers */
- for (i = 0 ; i < nbuf ; i++) {
- vaddr_t curbuf;
- vsize_t curbufsize;
- 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 RAM 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());
-
- /*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
! exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
! 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
if (CPU_ISSUN4 || CPU_ISSUN4C) {
/*
--- 282,293 ----
}
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
! minaddr = 0;
! exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
! 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
if (CPU_ISSUN4 || CPU_ISSUN4C) {
/*
***************
*** 374,402 ****
#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 disk labels.
- */
- bufinit();
pmap_redzone();
}
- caddr_t
- mdallocsys(v)
- caddr_t v;
- {
-
- /* Clip bufpages if necessary. */
- if (CPU_ISSUN4C && bufpages > (128 * (65536/MAXBSIZE)))
- bufpages = (128 * (65536/MAXBSIZE));
-
- return (v);
- }
-
/*
* Set up registers on exec.
*
--- 312,321 ----
***************
*** 871,877 ****
*
* Send an an upcall to userland.
*/
! void
cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted,
void *sas, void *ap, void *sp, sa_upcall_t upcall)
{
--- 790,796 ----
*
* Send an an upcall to userland.
*/
! void
cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted,
void *sas, void *ap, void *sp, sa_upcall_t upcall)
{
Index: conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.648
diff -c -r1.648 files
*** conf/files 12 Dec 2003 20:54:30 -0000 1.648
--- conf/files 22 Dec 2003 13:55:14 -0000
***************
*** 1115,1121 ****
file kern/init_sysctl.c
file kern/init_sysent.c
file kern/kern_acct.c
- file kern/kern_allocsys.c
file kern/kern_clock.c
file kern/kern_descrip.c
file kern/kern_event.c
--- 1115,1120 ----
Index: conf/param.c
===================================================================
RCS file: /cvsroot/src/sys/conf/param.c,v
retrieving revision 1.43
diff -c -r1.43 param.c
*** conf/param.c 30 Oct 2003 20:37:01 -0000 1.43
--- conf/param.c 22 Dec 2003 13:55:14 -0000
***************
*** 186,199 ****
#endif
/*
- * These have to be allocated somewhere; allocating
- * them here forces loader errors if this file is omitted
- * (if they've been externed everywhere else; hah!).
- */
- struct buf *buf;
- char *buffers;
-
- /*
* These control when and to what priority a process gets after a certain
* amount of CPU time expires. AUTONICETIME is in seconds.
* AUTONICEVAL is NOT offset by NZERO, i.e. it's between PRIO_MIN and PRIO_MAX.
--- 186,191 ----
Index: kern/init_main.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_main.c,v
retrieving revision 1.227
diff -c -r1.227 init_main.c
*** kern/init_main.c 14 Nov 2003 07:13:25 -0000 1.227
--- kern/init_main.c 22 Dec 2003 13:55:14 -0000
***************
*** 258,263 ****
--- 258,266 ----
/* Initialize callouts. */
callout_startup();
+ /* Initialize the buffer cache */
+ bufinit();
+
/*
* Initialize mbuf's. Do this now because we might attempt to
* allocate mbufs or mbuf clusters during autoconfiguration.
Index: kern/vfs_bio.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_bio.c,v
retrieving revision 1.99
diff -c -r1.99 vfs_bio.c
*** kern/vfs_bio.c 2 Dec 2003 04:18:19 -0000 1.99
--- kern/vfs_bio.c 22 Dec 2003 13:55:15 -0000
***************
*** 77,82 ****
--- 77,83 ----
* UNIX Operating System (Addison Welley, 1989)
*/
+ #include "opt_bufcache.h"
#include "opt_softdep.h"
#include <sys/cdefs.h>
***************
*** 84,101 ****
--- 85,121 ----
#include <sys/param.h>
#include <sys/systm.h>
+ #include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/malloc.h>
#include <sys/resourcevar.h>
+ #include <sys/sysctl.h>
#include <sys/conf.h>
#include <uvm/uvm.h>
#include <miscfs/specfs/specdev.h>
+ #ifndef BUFPAGES
+ # define BUFPAGES 0
+ #endif
+
+ #ifdef BUFCACHE
+ # if (BUFCACHE < 5) || (BUFCACHE > 95)
+ # error BUFCACHE is not between 5 and 95
+ # endif
+ #else
+ # define BUFCACHE 30
+ #endif
+
+ u_int nbuf; /* XXX - for softdep_lockedbufs */
+ u_int bufpages = BUFPAGES; /* optional hardwired count */
+ u_int bufcache = BUFCACHE; /* max % of RAM to use for buffer cache */
+
+
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
***************
*** 126,132 ****
#define BQ_LOCKED 0 /* super-blocks &c */
#define BQ_LRU 1 /* lru, useful buffers */
#define BQ_AGE 2 /* rubbish */
- #define BQ_EMPTY 3 /* buffer headers with no memory */
TAILQ_HEAD(bqueues, buf) bufqueues[BQUEUES];
int needbuffer;
--- 146,151 ----
***************
*** 142,147 ****
--- 161,200 ----
*/
struct pool bufpool;
+ #define NMEMPOOLS 7
+ #define MEMPOOL_INDEX_OFFSET 10 /* smallest pool is 1k */
+ #if (1 << (NMEMPOOLS + MEMPOOL_INDEX_OFFSET - 1)) != MAXBSIZE
+ #error update vfs_bio buffer memory parameters
+ #endif
+
+ /* Buffer memory pools */
+ struct pool bmempools[NMEMPOOLS];
+
+ /* Buffer memory pool allocator */
+ static void *bufpool_page_alloc(struct pool *pp, int flags)
+ {
+ return (void *)uvm_km_kmemalloc1(kernel_map,
+ uvm.kernel_object, MAXBSIZE, MAXBSIZE,
+ UVM_UNKNOWN_OFFSET,
+ (flags & PR_WAITOK)?0:UVM_KMF_NOWAIT);
+ }
+
+ static void bufpool_page_free(struct pool *pp, void *v)
+ {
+ uvm_km_free(kernel_map, (vaddr_t)v, MAXBSIZE);
+ }
+
+ struct pool_allocator bufmempool_allocator = {
+ bufpool_page_alloc, bufpool_page_free, MAXBSIZE,
+ };
+
+ /* Buffer memory management variables */
+ u_long bufmem_hiwater;
+ u_long bufmem_lowater;
+ u_long bufmem;
+
+ static int buf_trim(void);
+
/*
* bread()/breadn() helper.
*/
***************
*** 182,189 ****
KDASSERT(!debug_verify_freelist ||
checkfreelist(bp, &bufqueues[BQ_AGE]) ||
checkfreelist(bp, &bufqueues[BQ_LRU]) ||
! checkfreelist(bp, &bufqueues[BQ_LOCKED]) ||
! checkfreelist(bp, &bufqueues[BQ_EMPTY]));
/*
* We only calculate the head of the freelist when removing
--- 235,241 ----
KDASSERT(!debug_verify_freelist ||
checkfreelist(bp, &bufqueues[BQ_AGE]) ||
checkfreelist(bp, &bufqueues[BQ_LRU]) ||
! checkfreelist(bp, &bufqueues[BQ_LOCKED]) );
/*
* We only calculate the head of the freelist when removing
***************
*** 206,251 ****
TAILQ_REMOVE(dp, bp, b_freelist);
}
/*
* Initialize buffers and hash links for buffers.
*/
void
bufinit()
{
- struct buf *bp;
struct bqueues *dp;
! u_int i, base, residual;
/*
! * Initialize the buffer pool. This pool is used for buffers
! * which are strictly I/O control blocks, not buffer cache
! * buffers.
*/
pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", NULL);
for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
TAILQ_INIT(dp);
bufhashtbl = hashinit(nbuf, HASH_LIST, M_CACHE, M_WAITOK, &bufhash);
! base = bufpages / nbuf;
! residual = bufpages % nbuf;
! for (i = 0; i < nbuf; i++) {
! bp = &buf[i];
! memset((char *)bp, 0, sizeof(*bp));
! BUF_INIT(bp);
! bp->b_dev = NODEV;
! bp->b_vnbufs.le_next = NOLIST;
! bp->b_data = buffers + i * MAXBSIZE;
! if (i < residual)
! bp->b_bufsize = (base + 1) * PAGE_SIZE;
! else
! bp->b_bufsize = base * PAGE_SIZE;
! bp->b_flags = B_INVAL;
! dp = bp->b_bufsize ? &bufqueues[BQ_AGE] : &bufqueues[BQ_EMPTY];
! binsheadfree(bp, dp);
! binshash(bp, &invalhash);
}
}
static __inline struct buf *
bio_doread(vp, blkno, size, cred, async)
struct vnode *vp;
--- 258,429 ----
TAILQ_REMOVE(dp, bp, b_freelist);
}
+ u_long buf_memcalc()
+ {
+ u_int n;
+
+ /*
+ * Determine the upper bound of memory to use for buffers.
+ *
+ * - If bufpages is specified, use that as the number
+ * pages.
+ *
+ * - Otherwise, use bufcache as the percentage of
+ * physical memory.
+ */
+ if (bufpages != 0) {
+ n = bufpages;
+ } else {
+ if (bufcache < 5) {
+ printf("forcing bufcache %d -> 5", bufcache);
+ bufcache = 5;
+ }
+ if (bufcache > 95) {
+ printf("forcing bufcache %d -> 95", bufcache);
+ bufcache = 95;
+ }
+ n = physmem / 100 * bufcache;
+ }
+
+ return (n << PAGE_SHIFT);
+ }
+
/*
* Initialize buffers and hash links for buffers.
*/
void
bufinit()
{
struct bqueues *dp;
! u_int i;
!
! /*
! * Initialize buffer cache memory parameters.
! */
! bufmem = 0;
! bufmem_hiwater = buf_memcalc();
! /* lowater is approx. 2% of memory (with bufcache=30) */
! bufmem_lowater = (bufmem_hiwater >> 4);
! if (bufmem_lowater < 64 * 1024)
! /* Ensure a reasonable minimum value */
! bufmem_lowater = 64 * 1024;
/*
! * Initialize the buffer pools.
*/
pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", NULL);
+ for (i = 0; i < NMEMPOOLS; i++) {
+ struct pool_allocator *pa;
+ struct pool *pp = &bmempools[i];
+ u_int size = 1 << (i + MEMPOOL_INDEX_OFFSET);
+ char *name = malloc(8, M_TEMP, M_WAITOK);
+ snprintf(name, 8, "buf%dk", 1 << i);
+ pa = (size <= PAGE_SIZE)
+ ? &pool_allocator_nointr
+ : &bufmempool_allocator;
+ pool_init(pp, size, 0, 0, 0, name, pa);
+ pool_setlowat(pp, 1);
+ }
+
for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
TAILQ_INIT(dp);
+
+ /*
+ * Estimate hash table size based on the amount of memory we
+ * intend to use for the buffer cache. The average buffer
+ * size is dependent on our clients (i.e. filesystems).
+ *
+ * For now, use an empirical 3K per buffer.
+ */
+ nbuf = (bufmem_hiwater / 1024) / 3;
bufhashtbl = hashinit(nbuf, HASH_LIST, M_CACHE, M_WAITOK, &bufhash);
! }
!
! static int
! buf_lotsfree(void)
! {
! return (bufmem < bufmem_lowater ||
! (bufmem < bufmem_hiwater && uvmexp.free > 2*uvmexp.freetarg));
! }
!
! /*
! * Return estimate of # of buffers we think need to be
! * released to help resolve low memory conditions.
! */
! static int
! buf_canrelease(void)
! {
! int n;
!
! if (bufmem < bufmem_lowater)
! return 0;
!
! n = uvmexp.freetarg - uvmexp.free;
! if (n < 0)
! n = 0;
! return 2*n;
! }
!
! /*
! * Buffer memory allocation helper functions
! */
! static __inline__ u_long buf_mempoolidx(u_long size)
! {
! u_int n = 0;
!
! size -= 1;
! size >>= MEMPOOL_INDEX_OFFSET;
! while (size) {
! size >>= 1;
! n += 1;
}
+ if (n >= NMEMPOOLS)
+ panic("buf mem pool index %d", n);
+ return n;
}
+ static __inline__ u_long buf_roundsize(u_long size)
+ {
+ /* Round up to nearest power of 2 */
+ return (1 << (buf_mempoolidx(size) + MEMPOOL_INDEX_OFFSET));
+ }
+
+ static __inline__ caddr_t buf_malloc(size_t size)
+ {
+ u_int n = buf_mempoolidx(size);
+ caddr_t addr;
+ int canwait = 0 /*curproc == uvm.pagedaemon_proc*/;
+ int s;
+
+ while (1) {
+ addr = pool_get(&bmempools[n], canwait?PR_WAITOK:PR_NOWAIT);
+ if (addr != NULL)
+ break;
+
+ /* No memory, see if we can free some. If so, try again */
+ if (buf_drain(1) > 0)
+ continue;
+
+ /* Wait for buffers to arrive on the LRU queue */
+ s = splbio();
+ simple_lock(&bqueue_slock);
+ needbuffer = 1;
+ ltsleep(&needbuffer, PNORELOCK | (PRIBIO+1),
+ "buf_malloc", 0, &bqueue_slock);
+ splx(s);
+ }
+
+ return addr;
+ }
+
+ static void buf_mrelease(caddr_t addr, size_t size)
+ {
+
+ pool_put(&bmempools[buf_mempoolidx(size)], addr);
+ }
+
+
static __inline struct buf *
bio_doread(vp, blkno, size, cred, async)
struct vnode *vp;
***************
*** 611,617 ****
KDASSERT(!debug_verify_freelist || !checkfreelist(bp, &bufqueues[BQ_AGE]));
KDASSERT(!debug_verify_freelist || !checkfreelist(bp, &bufqueues[BQ_LRU]));
- KDASSERT(!debug_verify_freelist || !checkfreelist(bp, &bufqueues[BQ_EMPTY]));
KDASSERT(!debug_verify_freelist || !checkfreelist(bp, &bufqueues[BQ_LOCKED]));
if ((bp->b_bufsize <= 0) || ISSET(bp->b_flags, B_INVAL)) {
--- 789,794 ----
***************
*** 628,634 ****
}
if (bp->b_bufsize <= 0)
/* no data */
! bufq = &bufqueues[BQ_EMPTY];
else
/* invalid data */
bufq = &bufqueues[BQ_AGE];
--- 805,811 ----
}
if (bp->b_bufsize <= 0)
/* no data */
! goto already_queued;
else
/* invalid data */
bufq = &bufqueues[BQ_AGE];
***************
*** 671,676 ****
--- 848,859 ----
/* Allow disk interrupts. */
simple_unlock(&bp->b_interlock);
simple_unlock(&bqueue_slock);
+ if (bp->b_bufsize <= 0) {
+ #ifdef DEBUG
+ memset((char *)bp, 0, sizeof(*bp));
+ #endif
+ pool_put(&bufpool, bp);
+ }
splx(s);
}
***************
*** 714,719 ****
--- 897,903 ----
{
struct buf *bp;
int s, err;
+ int preserve;
start:
s = splbio();
***************
*** 743,750 ****
#endif
SET(bp->b_flags, B_BUSY);
bremfree(bp);
} else {
! if ((bp = getnewbuf(slpflag, slptimeo)) == NULL) {
simple_unlock(&bqueue_slock);
splx(s);
goto start;
--- 927,935 ----
#endif
SET(bp->b_flags, B_BUSY);
bremfree(bp);
+ preserve = 1;
} else {
! if ((bp = getnewbuf(slpflag, slptimeo, 0)) == NULL) {
simple_unlock(&bqueue_slock);
splx(s);
goto start;
***************
*** 753,758 ****
--- 938,944 ----
binshash(bp, BUFHASH(vp, blkno));
bp->b_blkno = bp->b_lblkno = bp->b_rawblkno = blkno;
bgetvp(vp, bp);
+ preserve = 0;
}
simple_unlock(&bp->b_interlock);
simple_unlock(&bqueue_slock);
***************
*** 764,770 ****
if (ISSET(bp->b_flags, B_LOCKED)) {
KASSERT(bp->b_bufsize >= size);
} else {
! allocbuf(bp, size);
}
return (bp);
}
--- 950,956 ----
if (ISSET(bp->b_flags, B_LOCKED)) {
KASSERT(bp->b_bufsize >= size);
} else {
! allocbuf(bp, size, preserve);
}
return (bp);
}
***************
*** 781,787 ****
s = splbio();
simple_lock(&bqueue_slock);
! while ((bp = getnewbuf(0, 0)) == 0)
;
SET(bp->b_flags, B_INVAL);
--- 967,973 ----
s = splbio();
simple_lock(&bqueue_slock);
! while ((bp = getnewbuf(0, 0, 0)) == 0)
;
SET(bp->b_flags, B_INVAL);
***************
*** 789,795 ****
simple_unlock(&bqueue_slock);
simple_unlock(&bp->b_interlock);
splx(s);
! allocbuf(bp, size);
return (bp);
}
--- 975,981 ----
simple_unlock(&bqueue_slock);
simple_unlock(&bp->b_interlock);
splx(s);
! allocbuf(bp, size, 0);
return (bp);
}
***************
*** 802,895 ****
* responsibility to fill out the buffer's additional contents.
*/
void
! allocbuf(bp, size)
struct buf *bp;
int size;
{
! struct buf *nbp;
! vsize_t desired_size;
! int s;
! desired_size = round_page((vsize_t)size);
if (desired_size > MAXBSIZE)
! panic("allocbuf: buffer larger than MAXBSIZE requested");
! if (bp->b_bufsize == desired_size)
! goto out;
/*
! * If the buffer is smaller than the desired size, we need to snarf
! * it from other buffers. Get buffers (via getnewbuf()), and
! * steal their pages.
*/
! while (bp->b_bufsize < desired_size) {
! int amt;
!
! /* find a buffer */
! s = splbio();
! simple_lock(&bqueue_slock);
! while ((nbp = getnewbuf(0, 0)) == NULL)
! ;
!
! SET(nbp->b_flags, B_INVAL);
! binshash(nbp, &invalhash);
!
! simple_unlock(&nbp->b_interlock);
! simple_unlock(&bqueue_slock);
! splx(s);
!
! /* and steal its pages, up to the amount we need */
! amt = min(nbp->b_bufsize, (desired_size - bp->b_bufsize));
! pagemove((nbp->b_data + nbp->b_bufsize - amt),
! bp->b_data + bp->b_bufsize, amt);
! bp->b_bufsize += amt;
! nbp->b_bufsize -= amt;
!
! /* reduce transfer count if we stole some data */
! if (nbp->b_bcount > nbp->b_bufsize)
! nbp->b_bcount = nbp->b_bufsize;
!
! #ifdef DIAGNOSTIC
! if (nbp->b_bufsize < 0)
! panic("allocbuf: negative bufsize");
! #endif
! brelse(nbp);
! }
/*
! * If we want a buffer smaller than the current size,
! * shrink this buffer. Grab a buf head from the EMPTY queue,
! * move a page onto it, and put it on front of the AGE queue.
! * If there are no free buffer headers, leave the buffer alone.
*/
! if (bp->b_bufsize > desired_size) {
! s = splbio();
! simple_lock(&bqueue_slock);
! if ((nbp = TAILQ_FIRST(&bufqueues[BQ_EMPTY])) == NULL) {
! /* No free buffer head */
! simple_unlock(&bqueue_slock);
! splx(s);
! goto out;
! }
! /* No need to lock nbp since it came from the empty queue */
! bremfree(nbp);
! SET(nbp->b_flags, B_BUSY | B_INVAL);
! simple_unlock(&bqueue_slock);
! splx(s);
! /* move the page to it and note this change */
! pagemove(bp->b_data + desired_size,
! nbp->b_data, bp->b_bufsize - desired_size);
! nbp->b_bufsize = bp->b_bufsize - desired_size;
! bp->b_bufsize = desired_size;
! nbp->b_bcount = 0;
! /* release the newly-filled buffer and leave */
! brelse(nbp);
}
out:
! bp->b_bcount = size;
}
/*
--- 988,1045 ----
* responsibility to fill out the buffer's additional contents.
*/
void
! allocbuf(bp, size, preserve)
struct buf *bp;
int size;
+ int preserve;
{
! vsize_t oldsize, desired_size;
! caddr_t addr;
! int s, delta;
! desired_size = buf_roundsize(size);
if (desired_size > MAXBSIZE)
! printf("allocbuf: buffer larger than MAXBSIZE requested");
! bp->b_bcount = size;
!
! oldsize = bp->b_bufsize;
! if (oldsize == desired_size)
! return;
/*
! * If we want a buffer of a different size, re-allocate the
! * buffer's memory; copy old content only if needed.
*/
! addr = buf_malloc(desired_size);
! if (preserve)
! memcpy(addr, bp->b_data, MIN(oldsize,desired_size));
! if (bp->b_data != NULL)
! buf_mrelease(bp->b_data, oldsize);
! bp->b_data = addr;
! bp->b_bufsize = desired_size;
/*
! * Update overall buffer memory counter (protected by bqueue_slock)
*/
! delta = (long)desired_size - (long)oldsize;
! s = splbio();
! simple_lock(&bqueue_slock);
! if ((bufmem += delta) < bufmem_hiwater)
! goto out;
! /*
! * Need to trim overall memory usage.
! */
! while (buf_canrelease()) {
! if (buf_trim() == 0)
! break;
}
out:
! simple_unlock(&bqueue_slock);
! splx(s);
}
/*
***************
*** 897,914 ****
* Select something from a free list.
* Preference is to AGE list, then LRU list.
*
! * Called with buffer queues locked.
* Return buffer locked.
*/
struct buf *
! getnewbuf(slpflag, slptimeo)
! int slpflag, slptimeo;
{
struct buf *bp;
start:
LOCK_ASSERT(simple_lock_held(&bqueue_slock));
if ((bp = TAILQ_FIRST(&bufqueues[BQ_AGE])) != NULL ||
(bp = TAILQ_FIRST(&bufqueues[BQ_LRU])) != NULL) {
simple_lock(&bp->b_interlock);
--- 1047,1078 ----
* Select something from a free list.
* Preference is to AGE list, then LRU list.
*
! * Called at splbio and with buffer queues locked.
* Return buffer locked.
*/
struct buf *
! getnewbuf(slpflag, slptimeo, from_bufq)
! int slpflag, slptimeo, from_bufq;
{
struct buf *bp;
start:
LOCK_ASSERT(simple_lock_held(&bqueue_slock));
+ /*
+ * Get a new buffer from the pool; but use NOWAIT because
+ * we have the buffer queues locked.
+ */
+ if (buf_lotsfree() && !from_bufq &&
+ (bp = pool_get(&bufpool, PR_NOWAIT)) != NULL) {
+ memset((char *)bp, 0, sizeof(*bp));
+ BUF_INIT(bp);
+ bp->b_dev = NODEV;
+ bp->b_vnbufs.le_next = NOLIST;
+ bp->b_flags = B_BUSY;
+ return (bp);
+ }
+
if ((bp = TAILQ_FIRST(&bufqueues[BQ_AGE])) != NULL ||
(bp = TAILQ_FIRST(&bufqueues[BQ_LRU])) != NULL) {
simple_lock(&bp->b_interlock);
***************
*** 921,926 ****
--- 1085,1095 ----
return (NULL);
}
+ #ifdef DIAGNOSTIC
+ if (bp->b_bufsize <= 0)
+ panic("buffer %p: on queue but empty", bp);
+ #endif
+
if (ISSET(bp->b_flags, B_VFLUSH)) {
/*
* This is a delayed write buffer being flushed to disk. Make
***************
*** 974,979 ****
--- 1143,1204 ----
}
/*
+ * Attempt to free an aged buffer off the queues.
+ * Called at splbio and with queue lock held.
+ * Returns the amount of buffer memory freed.
+ */
+ int buf_trim(void)
+ {
+ struct buf *bp;
+ long size = 0;
+ int wanted;
+
+ /* Instruct getnewbuf() to get buffers off the queues */
+ if ((bp = getnewbuf(PCATCH,1,1)) == NULL)
+ return 0;
+
+ wanted = ISSET(bp->b_flags, B_WANTED);
+ simple_unlock(&bp->b_interlock);
+ if (wanted) {
+ printf("buftrim: got WANTED buffer\n");
+ SET(bp->b_flags, B_INVAL);
+ binshash(bp, &invalhash);
+ simple_unlock(&bqueue_slock);
+ goto out;
+ }
+ size = bp->b_bufsize;
+ bufmem -= size;
+ simple_unlock(&bqueue_slock);
+ if (size > 0) {
+ buf_mrelease(bp->b_data, size);
+ bp->b_bcount = bp->b_bufsize = 0;
+ }
+
+ out:
+ /* brelse() will return the buffer to the global buffer pool */
+ brelse(bp);
+ simple_lock(&bqueue_slock);
+ return size;
+ }
+
+ int buf_drain(int n)
+ {
+ int s, size = 0;
+
+ /* If not asked for a specific amount, make our own estimate */
+ if (n == 0)
+ n = buf_canrelease();
+
+ s = splbio();
+ simple_lock(&bqueue_slock);
+ while (n-- > 0 && bufmem > bufmem_lowater)
+ size += buf_trim();
+ simple_unlock(&bqueue_slock);
+ splx(s);
+ return size;
+ }
+
+ /*
* Wait for operations on the buffer to complete.
* When they do, extract and return the I/O's error value.
*/
***************
*** 1073,1078 ****
--- 1298,1498 ----
return (n);
}
+ /*
+ * Wait for all buffers to complete I/O
+ * Return the number of "stuck" buffers.
+ */
+ int
+ buf_syncwait(void)
+ {
+ struct buf *bp;
+ int iter, nbusy, nbusy_prev = 0, dcount, s, ihash;
+
+ dcount = 10000;
+ for (iter = 0; iter < 20;) {
+ s = splbio();
+ simple_lock(&bqueue_slock);
+ nbusy = 0;
+ for (ihash = 0; ihash < bufhash+1; ihash++) {
+ LIST_FOREACH(bp, &bufhashtbl[ihash], b_hash) {
+ if ((bp->b_flags & (B_BUSY|B_INVAL|B_READ)) == B_BUSY)
+ nbusy++;
+ /*
+ * With soft updates, some buffers that are
+ * written will be remarked as dirty until other
+ * buffers are written.
+ */
+ if (bp->b_vp && bp->b_vp->v_mount
+ && (bp->b_vp->v_mount->mnt_flag & MNT_SOFTDEP)
+ && (bp->b_flags & B_DELWRI)) {
+ simple_lock(&bp->b_interlock);
+ bremfree(bp);
+ bp->b_flags |= B_BUSY;
+ nbusy++;
+ simple_unlock(&bp->b_interlock);
+ simple_unlock(&bqueue_slock);
+ bawrite(bp);
+ if (dcount-- <= 0) {
+ printf("softdep ");
+ goto fail;
+ }
+ simple_lock(&bqueue_slock);
+ }
+ }
+ }
+
+ simple_unlock(&bqueue_slock);
+ splx(s);
+
+ if (nbusy == 0)
+ break;
+ if (nbusy_prev == 0)
+ nbusy_prev = nbusy;
+ printf("%d ", nbusy);
+ tsleep(&nbusy, PRIBIO, "bflush",
+ (iter == 0) ? 1 : hz / 25 * iter);
+ if (nbusy >= nbusy_prev) /* we didn't flush anything */
+ iter++;
+ else
+ nbusy_prev = nbusy;
+ }
+
+ if (nbusy) {
+ fail:;
+ #if defined(DEBUG) || defined(DEBUG_HALT_BUSY)
+ printf("giving up\nPrinting vnodes for busy buffers\n");
+ for (ihash = 0; ihash < bufhash+1; ihash++) {
+ LIST_FOREACH(bp, &bufhashtbl[ihash], b_hash) {
+ if ((bp->b_flags & (B_BUSY|B_INVAL|B_READ)) == B_BUSY)
+ vprint(NULL, bp->b_vp);
+ }
+ }
+ #endif
+ }
+
+ return nbusy;
+ }
+
+ #define KERN_BUFSLOP 100
+ static int
+ sysctl_dobuf(SYSCTLFN_ARGS)
+ {
+ struct buf *bp;
+ char *dp;
+ u_int i, elem_size;
+ size_t len, buflen, needed;
+ int error, s;
+
+ dp = oldp;
+ len = buflen = oldp != NULL ? *oldlenp : 0;
+ error = 0;
+ needed = 0;
+ elem_size = sizeof(struct buf);
+
+ PHOLD(l);
+ if (buflen != 0) {
+ /* Lock user buffer */
+ error = uvm_vslock(l->l_proc, oldp, buflen, VM_PROT_WRITE);
+ if (error)
+ goto out;
+ }
+
+ s = splbio();
+ simple_lock(&bqueue_slock);
+ for (i = 0; i < BQUEUES; i++) {
+ TAILQ_FOREACH(bp, &bufqueues[i], b_freelist) {
+ if (len >= sizeof(elem_size)) {
+ error = copyout(bp, dp, elem_size);
+ if (error)
+ goto cleanup;
+ dp += elem_size;
+ len -= elem_size;
+ }
+ needed += elem_size;
+ }
+ }
+ cleanup:
+ simple_unlock(&bqueue_slock);
+ splx(s);
+ if (buflen)
+ uvm_vsunlock(curproc, oldp, buflen);
+
+ if (oldp != NULL) {
+ *oldlenp = (char *)dp - (char *)oldp;
+ if (needed > *oldlenp)
+ error = ENOMEM;
+ } else {
+ needed += KERN_BUFSLOP;
+ *oldlenp = needed;
+ }
+
+ out:
+ PRELE(l);
+ return (error);
+ }
+
+ static int sysctlnum_bufcache, sysctlnum_bufmemhiwater, sysctlnum_bufmemlowater;
+
+ static int
+ sysctl_bufvm_update(SYSCTLFN_ARGS)
+ {
+ int t, error;
+ struct sysctlnode node;
+
+ node = *rnode;
+ node.sysctl_data = &t;
+ t = *(int*)rnode->sysctl_data;
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return (error);
+
+ if (rnode->sysctl_num == sysctlnum_bufcache) {
+ if (t < 0 || t > 100)
+ return (EINVAL);
+ bufcache = t;
+ bufmem_hiwater = buf_memcalc();
+ bufmem_lowater = (bufmem_hiwater >> 4);
+ } else if (rnode->sysctl_num == sysctlnum_bufmemlowater) {
+ bufmem_lowater = t;
+ } else if (rnode->sysctl_num == sysctlnum_bufmemhiwater) {
+ bufmem_hiwater = t;
+ } else
+ return (EINVAL);
+
+ return 0;
+ }
+
+ SYSCTL_SETUP(sysctl_kern_buf_setup, "sysctl kern.buf subtree setup")
+ {
+ struct sysctlnode *rnode;
+
+ sysctl_createv(SYSCTL_PERMANENT,
+ CTLTYPE_NODE, "buf", NULL,
+ sysctl_dobuf, 0, NULL, 0,
+ CTL_KERN, KERN_BUF, CTL_EOL);
+
+ rnode = NULL;
+ if (sysctl_createv(SYSCTL_PERMANENT|SYSCTL_READWRITE,
+ CTLTYPE_INT, "bufcache", &rnode,
+ sysctl_bufvm_update, 0, &bufcache, 0,
+ CTL_VM, CTL_CREATE, CTL_EOL) == 0)
+ sysctlnum_bufcache = rnode->sysctl_num;
+
+ rnode = NULL;
+ if (sysctl_createv(SYSCTL_PERMANENT|SYSCTL_READWRITE,
+ CTLTYPE_INT, "bufmem_lowater", &rnode,
+ sysctl_bufvm_update, 0, &bufmem_lowater, 0,
+ CTL_VM, CTL_CREATE, CTL_EOL) == 0)
+ sysctlnum_bufmemlowater = rnode->sysctl_num;
+
+ rnode = NULL;
+ if (sysctl_createv(SYSCTL_PERMANENT|SYSCTL_READWRITE,
+ CTLTYPE_INT, "bufmem_hiwater", &rnode,
+ sysctl_bufvm_update, 0, &bufmem_hiwater, 0,
+ CTL_VM, CTL_CREATE, CTL_EOL) == 0)
+ sysctlnum_bufmemhiwater = rnode->sysctl_num;
+ }
+
#ifdef DEBUG
/*
* Print out statistics on the current allocation of the buffer pool.
***************
*** 1086,1092 ****
struct buf *bp;
struct bqueues *dp;
int counts[(MAXBSIZE / PAGE_SIZE) + 1];
! static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE", "EMPTY" };
for (dp = bufqueues, i = 0; dp < &bufqueues[BQUEUES]; dp++, i++) {
count = 0;
--- 1506,1512 ----
struct buf *bp;
struct bqueues *dp;
int counts[(MAXBSIZE / PAGE_SIZE) + 1];
! static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE" };
for (dp = bufqueues, i = 0; dp < &bufqueues[BQUEUES]; dp++, i++) {
count = 0;
Index: kern/vfs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
retrieving revision 1.212
diff -c -r1.212 vfs_subr.c
*** kern/vfs_subr.c 4 Dec 2003 19:38:24 -0000 1.212
--- kern/vfs_subr.c 22 Dec 2003 13:55:16 -0000
***************
*** 2605,2612 ****
void
vfs_shutdown()
{
- struct buf *bp;
- int iter, nbusy, nbusy_prev = 0, dcount, s;
struct lwp *l = curlwp;
struct proc *p;
--- 2605,2610 ----
***************
*** 2626,2686 ****
sys_sync(l, NULL, NULL);
/* Wait for sync to finish. */
! dcount = 10000;
! for (iter = 0; iter < 20;) {
! nbusy = 0;
! for (bp = &buf[nbuf]; --bp >= buf; ) {
! if ((bp->b_flags & (B_BUSY|B_INVAL|B_READ)) == B_BUSY)
! nbusy++;
! /*
! * With soft updates, some buffers that are
! * written will be remarked as dirty until other
! * buffers are written.
! */
! if (bp->b_vp && bp->b_vp->v_mount
! && (bp->b_vp->v_mount->mnt_flag & MNT_SOFTDEP)
! && (bp->b_flags & B_DELWRI)) {
! s = splbio();
! simple_lock(&bqueue_slock);
! bremfree(bp);
! simple_unlock(&bqueue_slock);
! bp->b_flags |= B_BUSY;
! splx(s);
! nbusy++;
! bawrite(bp);
! if (dcount-- <= 0) {
! printf("softdep ");
! goto fail;
! }
! }
! }
! if (nbusy == 0)
! break;
! if (nbusy_prev == 0)
! nbusy_prev = nbusy;
! printf("%d ", nbusy);
! tsleep(&nbusy, PRIBIO, "bflush",
! (iter == 0) ? 1 : hz / 25 * iter);
! if (nbusy >= nbusy_prev) /* we didn't flush anything */
! iter++;
! else
! nbusy_prev = nbusy;
! }
! if (nbusy) {
! fail:
! #if defined(DEBUG) || defined(DEBUG_HALT_BUSY)
! printf("giving up\nPrinting vnodes for busy buffers\n");
! for (bp = &buf[nbuf]; --bp >= buf; )
! if ((bp->b_flags & (B_BUSY|B_INVAL|B_READ)) == B_BUSY)
! vprint(NULL, bp->b_vp);
!
#if defined(DDB) && defined(DEBUG_HALT_BUSY)
Debugger();
#endif
-
- #else /* defined(DEBUG) || defined(DEBUG_HALT_BUSY) */
printf("giving up\n");
- #endif /* defined(DEBUG) || defined(DEBUG_HALT_BUSY) */
return;
} else
printf("done\n");
--- 2624,2634 ----
sys_sync(l, NULL, NULL);
/* Wait for sync to finish. */
! if (buf_syncwait() != 0) {
#if defined(DDB) && defined(DEBUG_HALT_BUSY)
Debugger();
#endif
printf("giving up\n");
return;
} else
printf("done\n");
Index: sys/buf.h
===================================================================
RCS file: /cvsroot/src/sys/sys/buf.h,v
retrieving revision 1.65
diff -c -r1.65 buf.h
*** sys/buf.h 4 Dec 2003 15:00:32 -0000 1.65
--- sys/buf.h 22 Dec 2003 13:55:16 -0000
***************
*** 278,284 ****
extern struct pool bufpool;
__BEGIN_DECLS
! void allocbuf __P((struct buf *, int));
void bawrite __P((struct buf *));
void bdirty __P((struct buf *));
void bdwrite __P((struct buf *));
--- 278,284 ----
extern struct pool bufpool;
__BEGIN_DECLS
! void allocbuf __P((struct buf *, int, int));
void bawrite __P((struct buf *));
void bdirty __P((struct buf *));
void bdwrite __P((struct buf *));
***************
*** 300,315 ****
void cluster_write __P((struct buf *, u_quad_t));
struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
struct buf *geteblk __P((int));
! struct buf *getnewbuf __P((int, int));
struct buf *incore __P((struct vnode *, daddr_t));
void minphys __P((struct buf *));
int physio __P((void (*)(struct buf *), struct buf *, dev_t,
int, void (*)(struct buf *), struct uio *));
! void brelvp __P((struct buf *));
! void reassignbuf __P((struct buf *, struct vnode *));
! void bgetvp __P((struct vnode *, struct buf *));
#ifdef DDB
void vfs_buf_print __P((struct buf *, int, void (*)(const char *, ...)));
#endif
--- 300,318 ----
void cluster_write __P((struct buf *, u_quad_t));
struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
struct buf *geteblk __P((int));
! struct buf *getnewbuf __P((int, int, int));
struct buf *incore __P((struct vnode *, daddr_t));
void minphys __P((struct buf *));
int physio __P((void (*)(struct buf *), struct buf *, dev_t,
int, void (*)(struct buf *), struct uio *));
! void brelvp __P((struct buf *));
! void reassignbuf __P((struct buf *, struct vnode *));
! void bgetvp __P((struct vnode *, struct buf *));
! int buf_syncwait __P((void));
! u_long buf_memcalc __P((void));
! int buf_drain __P((int));
#ifdef DDB
void vfs_buf_print __P((struct buf *, int, void (*)(const char *, ...)));
#endif
Index: sys/sysctl.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.102
diff -c -r1.102 sysctl.h
*** sys/sysctl.h 6 Dec 2003 04:16:33 -0000 1.102
--- sys/sysctl.h 22 Dec 2003 13:55:16 -0000
***************
*** 248,254 ****
#define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */
#define KERN_ROOT_PARTITION 74 /* int: root partition */
#define KERN_DRIVERS 75 /* struct: driver names and majors #s */
! #define KERN_MAXID 76 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
--- 248,255 ----
#define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */
#define KERN_ROOT_PARTITION 74 /* int: root partition */
#define KERN_DRIVERS 75 /* struct: driver names and majors #s */
! #define KERN_BUF 76 /* struct: buffers */
! #define KERN_MAXID 77 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
Index: ufs/ffs/ffs_alloc.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.71
diff -c -r1.71 ffs_alloc.c
*** ufs/ffs/ffs_alloc.c 27 Nov 2003 04:52:55 -0000 1.71
--- ufs/ffs/ffs_alloc.c 22 Dec 2003 13:55:16 -0000
***************
*** 285,291 ****
if (bpp != NULL) {
if (bp->b_blkno != fsbtodb(fs, bno))
panic("bad blockno");
! allocbuf(bp, nsize);
bp->b_flags |= B_DONE;
memset(bp->b_data + osize, 0, nsize - osize);
*bpp = bp;
--- 285,291 ----
if (bpp != NULL) {
if (bp->b_blkno != fsbtodb(fs, bno))
panic("bad blockno");
! allocbuf(bp, nsize, 1);
bp->b_flags |= B_DONE;
memset(bp->b_data + osize, 0, nsize - osize);
*bpp = bp;
***************
*** 364,370 ****
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
bp->b_blkno = fsbtodb(fs, bno);
! allocbuf(bp, nsize);
bp->b_flags |= B_DONE;
memset(bp->b_data + osize, 0, (u_int)nsize - osize);
*bpp = bp;
--- 364,370 ----
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
bp->b_blkno = fsbtodb(fs, bno);
! allocbuf(bp, nsize, 1);
bp->b_flags |= B_DONE;
memset(bp->b_data + osize, 0, (u_int)nsize - osize);
*bpp = bp;
Index: ufs/ffs/ffs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_subr.c,v
retrieving revision 1.31
diff -c -r1.31 ffs_subr.c
*** ufs/ffs/ffs_subr.c 2 Dec 2003 04:40:43 -0000 1.31
--- ufs/ffs/ffs_subr.c 22 Dec 2003 13:55:17 -0000
***************
*** 199,204 ****
--- 199,205 ----
struct buf *bp;
struct inode *ip;
{
+ #if 0
struct buf *ebp, *ep;
daddr_t start, last;
struct vnode *vp;
***************
*** 225,230 ****
--- 226,234 ----
ep->b_blkno + btodb(ep->b_bcount) - 1);
panic("Disk buffer overlap");
}
+ #else
+ printf("ffs_checkoverlap disabled due to buffer cache implementation changes\n");
+ #endif
}
#endif /* _KERNEL && DIAGNOSTIC */
Index: ufs/lfs/lfs_balloc.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/lfs/lfs_balloc.c,v
retrieving revision 1.46
diff -c -r1.46 lfs_balloc.c
*** ufs/lfs/lfs_balloc.c 29 Oct 2003 01:25:04 -0000 1.46
--- ufs/lfs/lfs_balloc.c 22 Dec 2003 13:55:17 -0000
***************
*** 429,435 ****
if (bpp) {
obufsize = (*bpp)->b_bufsize;
! allocbuf(*bpp, nsize);
/* Adjust locked-list accounting */
if (((*bpp)->b_flags & (B_LOCKED | B_CALL)) == B_LOCKED)
--- 429,435 ----
if (bpp) {
obufsize = (*bpp)->b_bufsize;
! allocbuf(*bpp, nsize, 1);
/* Adjust locked-list accounting */
if (((*bpp)->b_flags & (B_LOCKED | B_CALL)) == B_LOCKED)
Index: ufs/lfs/lfs_inode.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/lfs/lfs_inode.c,v
retrieving revision 1.80
diff -c -r1.80 lfs_inode.c
*** ufs/lfs/lfs_inode.c 7 Nov 2003 14:48:28 -0000 1.80
--- ufs/lfs/lfs_inode.c 22 Dec 2003 13:55:17 -0000
***************
*** 379,385 ****
if (ovp->v_type != VDIR)
memset((char *)bp->b_data + offset, 0,
(u_int)(size - offset));
! allocbuf(bp, size);
if ((bp->b_flags & (B_LOCKED | B_CALL)) == B_LOCKED)
locked_queue_bytes -= obufsize - bp->b_bufsize;
if (bp->b_flags & B_DELWRI)
--- 379,385 ----
if (ovp->v_type != VDIR)
memset((char *)bp->b_data + offset, 0,
(u_int)(size - offset));
! allocbuf(bp, size, 1);
if ((bp->b_flags & (B_LOCKED | B_CALL)) == B_LOCKED)
locked_queue_bytes -= obufsize - bp->b_bufsize;
if (bp->b_flags & B_DELWRI)
Index: ufs/ext2fs/ext2fs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_subr.c,v
retrieving revision 1.11
diff -c -r1.11 ext2fs_subr.c
*** ufs/ext2fs/ext2fs_subr.c 5 Oct 2003 17:48:49 -0000 1.11
--- ufs/ext2fs/ext2fs_subr.c 22 Dec 2003 13:55:17 -0000
***************
*** 119,124 ****
--- 119,125 ----
struct buf *bp;
struct inode *ip;
{
+ #if 0
struct buf *ebp, *ep;
daddr_t start, last;
struct vnode *vp;
***************
*** 145,149 ****
--- 146,153 ----
ep->b_blkno + btodb(ep->b_bcount) - 1);
panic("Disk buffer overlap");
}
+ #else
+ printf("ext2fs_checkoverlap disabled due to buffer cache implementation changes\n");
+ #endif
}
#endif
Index: uvm/uvm_glue.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_glue.c,v
retrieving revision 1.73
diff -c -r1.73 uvm_glue.c
*** uvm/uvm_glue.c 13 Nov 2003 03:09:30 -0000 1.73
--- uvm/uvm_glue.c 22 Dec 2003 13:55:17 -0000
***************
*** 103,112 ****
* XXXCDC: do these really belong here?
*/
- int readbuffers = 0; /* allow KGDB to read kern buffer pool */
- /* XXX: see uvm_kernacc */
-
-
/*
* uvm_kernacc: can the kernel access a region of memory
*
--- 103,108 ----
***************
*** 129,146 ****
rv = uvm_map_checkprot(kernel_map, saddr, eaddr, prot);
vm_map_unlock_read(kernel_map);
- /*
- * XXX there are still some things (e.g. the buffer cache) that
- * are managed behind the VM system's back so even though an
- * address is accessible in the mind of the VM system, there may
- * not be physical pages where the VM thinks there is. This can
- * lead to bogus allocation of pages in the kernel address space
- * or worse, inconsistencies at the pmap level. We only worry
- * about the buffer cache for now.
- */
- if (!readbuffers && rv && (eaddr > (vaddr_t)buffers &&
- saddr < (vaddr_t)buffers + MAXBSIZE * nbuf))
- rv = FALSE;
return(rv);
}
--- 125,130 ----
Index: uvm/uvm_pdaemon.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_pdaemon.c,v
retrieving revision 1.55
diff -c -r1.55 uvm_pdaemon.c
*** uvm/uvm_pdaemon.c 26 Sep 2003 04:03:39 -0000 1.55
--- uvm/uvm_pdaemon.c 22 Dec 2003 13:55:18 -0000
***************
*** 269,274 ****
--- 269,275 ----
uvm_unlock_pageq();
+ buf_drain(0);
/*
* drain pool resources now that we're not holding any locks
*/