malloc() in kernel and increasing mbuf and cluster size

Sangwoo Shim sangwoos at gmail.com
Mon Oct 17 09:59:23 PDT 2005


2005/10/17, kamal kc <kamal_ckk at yahoo.com>:
> > > sys/malloc.h has function prototypes for malloc()
> > > kern/kern_malloc.c defines the malloc()
> > >
> > > the malloc() definition is
> > >
> > > void *
> > > malloc(size, type, flags)
> > >     unsigned long size;
> > >     struct malloc_type *type;
> > >     int flags;
> > >
> > > i understand the size and flags but what shall i
> > > do with the malloc_type.
> >
> > man 9 malloc :-)
> >
>
> i saw the man pages.
>
> it says to use malloc_type via
>
> MALLOC_DEFINE(type,shortdesc,longdesc)
> MALLOC_DECLARE(type)
>
> the man pages use M_FOOBUF(where did it come from ??)
> in the field type.
>
> Now how should i code it.
>
> struct malloc_type  mytype;
> mytype=MALLOC_DEFINE(.....,"mybuffers","mybuffers");
>
> what should i put in the type field ??
>
> thanks in advance,
> kamal
malloc type is defined for some kind of statistics/trackings.
If you define some specific malloc types for your module/driver etc., you
can track the memory usage more accurately. For example, if you do vmstat -m
you can see how much memories are used for specific allocations by looking
at type field.

Regards,
Sangwoo Shim

>
>
>
>
>
>
>
>
> __________________________________
> Yahoo! Music Unlimited
> Access over 1 million songs. Try it free.
> http://music.yahoo.com/unlimited/
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list