[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Policy for malloc types in kernel
Dave Byrne <dave@glynjones.com> writes:
> What is the policy for creating new types for malloc in
> /sys/sys/malloc.h?
>
>
> Is it to just pick a free range?
>
> ie.. (from malloc.h)
>
> #define M_CRYPTO_DATA 108 /* Crypto framework data buffers (keys etc.)
> /* 109 - free */
> #define M_CREDENTIALS 110 /* IPsec-related credentials and ID info */
>
> then #define M_WHATEVER 109?
>
> I am trying to port over some code from freebsd that uses an additional
> type M_ACCF. However, FreeBSD makes use of MALLOC_DEFINE and
> MALLOC_DECLARE macros to take care of creating new kernel malloc types.
First question. Do you really need a new malloc type?
If you are allocating static sized structs, use pool(9).
If you will allocate dynamically sized data, pick the first unused
malloc type and use it. What's M_ACCF?
//art