Subject: Memory management
To: None <tech-kern@netbsd.org, port-i386@netbsd.org>
From: =?iso-8859-1?Q?P=E5l_Halvorsen?= <paalh@unik.no>
List: tech-kern
Date: 05/30/2000 14:56:17
Hi all,

I'm making a mbuf like kernel map and have initialized it by pool_init. The=
=20
problem is, however, that _pool_get_ fails:=20

panic: pool_get: mmclpl: page empty

Does there exist any documentation on pools - other than the man=20
page - on how to create, initialize and retrieve elemements from the pool?
Does anyone have an idea of what might have went wrong? (Implementation=20
described below)

PS! The _pool_sethardlimit_ also fails if enabled during boot time.

Best regards,
P=E5l Halvorsen

-------------------- implementation code --------------------------

* * * * In conf/i386/i386/machdep.c: * * * *=20
=2E..
vm_map_t mmb_map =3D NULL;
=2E..
[cpu_startup()]
=2E..
=09mmb_map =3D uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,=20
=09=09=09=09  VM_MMBUF_SIZE, FALSE, FALSE, NULL);


* * * *  In conf/i386/include/param.h: * * * *=20
#define MMCLBYTES               (1<<14)

* * * * In conf/i386/include/param.h: * * * *=20
#define VM_MMBUF_SIZE           (NBMMBCL*MMCLBYTES) /* 24 MB =3D 25165824 *=
/

* * * * In vm/vm_kern.h: * * * *=20
extern vm_map_t=09mmb_map;=20

* * * *  In kern/init_main: * * * *=20
mmbinit();

* * * * In an "own_file": * * * *=20
void mmbinit()
{
  pool_init(&mmbpool, MMSIZE, 0, 0, 0, "mmbpl", 0,=20
=09=09       NULL, NULL, 0);
  pool_init(&mmclpool, MMCLBYTES, 0, 0, 0, "mmclpl", 0,=20
=09=09       mmclpool_alloc, mmclpool_release, 0);

  /*
   * Set the hard limit on the mmclpool to the number of mmbuf clusters the=
=20
   * kernel is to support.  Log the limit reached message max once a minute=
=2E
   */
   /* Commented out because it fails ....=20
  pool_sethardlimit(&mmclpool, NBMMBCL, "WARNING: mmclpool limit=20
=09=09=09       reached; increase NBMMBCL", 60);
   */
}

void * mmclpool_alloc(sz, flags, mtype)
=09unsigned long sz;
=09int flags;
=09int mtype;
{
  boolean_t waitok =3D (flags & PR_WAITOK) ? TRUE : FALSE;

  return ((void *)uvm_km_alloc_poolpage1(mmb_map, uvmexp.mb_object, waitok)=
);
}

void mmclpool_release(v, sz, mtype)
=09void *v;
=09unsigned long sz;
=09int mtype;
{
  uvm_km_free_poolpage1(mmb_map, (vaddr_t) v);
}

-------------------- implementation code --------------------------

P=E5l Halvorsen
---       . o  o   .  o  .  o ..  o ..  o .. o oo . o  . o o o
         _n_n_n____i_i _++++++_ _______ ________ _+++++++++++_
      *>(____________I I______I I_____I I______I I___________I
 __^__  /ooOOOO OOOOoo  oo ooo  oo   oo oo    oo ooo       ooo  __^__
( ___ )--------------------------------------------------------( ___ )
 | / | Paal Halvorsen   UniK - Center for technology at Kjeller | \ |
 | / |                                       University of Oslo | \ |
 | / | Phone: +47 64844731                               PB. 70 | \ |
 | / | Phone: +47 64844700 (switchboard)       N - 2027 KJELLER | \ |
 |_/_| Fax:   +47 63818146                               Norway |__|
(_____)-- E-mail: paalh@unik.no -- http://www.unik.no/~paalh --(_____)