Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 May 1999 18:55:04 +0200 (MET DST)
From:      Luigi Rizzo <luigi@labinfo.iet.unipi.it>
To:        imp@harmony.village.org (Warner Losh)
Cc:        current@FreeBSD.ORG
Subject:   Re: m_get(M_WAIT, ...) _can_ return NULL ?
Message-ID:  <199905081655.SAA07931@labinfo.iet.unipi.it>
In-Reply-To: <199905081634.KAA14466@harmony.village.org> from "Warner Losh" at May 8, 99 10:33:59 am

next in thread | previous in thread | raw e-mail | index | archive | help
> In message <199905081332.PAA07452@labinfo.iet.unipi.it> 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, luigi@iet.unipi.it  . 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199905081655.SAA07931>