Subject: Re: buffer cache memory management revision
To: Ben Harris <bjh21@netbsd.org>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: tech-kern
Date: 12/01/2003 17:28:35
> You don't seem to have a patch for sys/arch/acorn26/acorn26/machdep.c in
> the, but it contains the usual buffer-cache-setup boilerplate. Similarly,
> there are calls to allocsys() in sys/arch/acorn26/acorn26/start.c, which
> will need excising.
Here it is..
There's also a patch for arch/sh3/sh3/pmap.c, which I missed as well.
-pk
--------
Index: arch/acorn26/acorn26/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/machdep.c,v
retrieving revision 1.10
diff -c -r1.10 machdep.c
*** arch/acorn26/acorn26/machdep.c 30 Sep 2003 00:35:30 -0000 1.10
--- arch/acorn26/acorn26/machdep.c 1 Dec 2003 16:34:14 -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 1 Dec 2003 16:34:14 -0000
***************
*** 93,100 ****
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
/*
--- 152,157 ----
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 1 Dec 2003 16:34:14 -0000
***************
*** 105,121 ****
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);
--- 105,113 ----