> In message <[email protected]> Luigi Rizzo writes:
> : m = m_get(M_WAIT, ...)
> : looking at the code, it seems that m_get() _can_ return a NULL pointer
> : even if one specifies M_WAIT.
>
> Looking at the man page for malloc:
> M_WAITOK
> indicates that it is Ok to wait for resources. It is unconve-
> niently defined as 0 so care should be taken never to compare
> against this value directly or try to AND it as a flag. The de-
> fault operation is to block until the memory allocation succeeds.
> malloc() can only return NULL if M_NOWAIT is specified.
>
> Sounds like a bug to me.
i have 2.2.6 online here, and i see that m_get() calls MGET which in
turn calls m_retry(), which in turn calls m_reclaim() , which can try to
recover memory but it is not guaranteed to succeed.
And at the end of the chain there is a check for failure:
if (m != NULL)
mbstat.m_wait++;
else
mbstat.m_drops++;
return (m);
the comment in m_retry says
* Must only do the reclaim if not in an interrupt context.
but i don't know how this can be identified.
cheers
luigi
>
-----------------------------------+-------------------------------------
Luigi RIZZO, [email protected] . Dip. di Ing. dell'Informazione
http://www.iet.unipi.it/~luigi/ . Universita` di Pisa
TEL/FAX: +39-050-568.533/522 . via Diotisalvi 2, 56126 PISA (Italy)
http://www.iet.unipi.it/~luigi/ngc99/
==== First International Workshop on Networked Group Communication ====
-----------------------------------+-------------------------------------
To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-current" in the body of the message