Subject: Memory pools
To: None <tech-kern@netbsd.org>
From: =?iso-8859-1?Q?P=E5l_Halvorsen?= <paalh@unik.no>
List: tech-kern
Date: 05/10/2000 16:07:20
Hi all!

I'm currently porting some code from NetBSD 1.3.? (some current version),
where I want ro have an in-kernel, zero-copy data path from disk to
network for a multimedia server. However, the memory management is all
new, UWM and the pool resource management utility.=20

I have a new buffer structure (mmbuf from Warshington University, St.
Louis) similar to mbuf and have made an "mmbinit" similar to mbinit in
kern/uipc_mbuf.c where I make two pools "mmbpool" and "mmclpool"
allocating memory from a new kernel map "mmb_map":

  pool_init(&mmbpool, MMSIZE, 0, 0, 0, "mmbpl", 0, NULL, NULL, 0);
  pool_init(&mmclpool, MMCLBYTES, 0, 0, 0, "mmclpl", 0, mmclpool_alloc,
=09mmclpool_release, 0);
  pool_sethardlimit(&mmclpool, NBMMBCL, "WARNING: mmclpool limit reached;
=09increase NBMMBCL", 60);
=09

Does pool_get(&mmbpool, M_NOWAIT) return a MMSIZE memory area? And if so
shouls I always use pool_get and pool_put to get and free the memory
allocated?

Furthermore, the "new" mmbuf structure stores all data in external
clusters/storage. Should all this memory be taken from the "mmclpool"? If
so, why does MEXTMALLOC in sys/mbuf.h still make a=20
=09(m)->m_ext.ext_buf =3D=20
=09     (caddr_t)malloc((size), mbtypes[(m)->m_type], (how)); ?

What is the difference of MCLGET, MEXTMALLOC, and MEXTADD (or when do you=
=20
use which)? When do you use a cluster from the pool and when do you
allocate external storage?

Is there any documentation about the "pool resource management utility"?

Than you very much in advance for your help!!

Best regards,
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 --(_____)