From owner-freebsd-current Sat May 8 12: 4: 5 1999 Delivered-To: freebsd-current@freebsd.org Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (Postfix) with SMTP id 508A914C31 for ; Sat, 8 May 1999 12:04:02 -0700 (PDT) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id SAA07931; Sat, 8 May 1999 18:55:04 +0200 From: Luigi Rizzo Message-Id: <199905081655.SAA07931@labinfo.iet.unipi.it> Subject: Re: m_get(M_WAIT, ...) _can_ return NULL ? To: imp@harmony.village.org (Warner Losh) Date: Sat, 8 May 1999 18:55:04 +0200 (MET DST) Cc: current@FreeBSD.ORG In-Reply-To: <199905081634.KAA14466@harmony.village.org> from "Warner Losh" at May 8, 99 10:33:59 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 1680 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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