Date: Sat, 09 Sep 2000 18:17:52 -0700 From: Peter Wemm <peter@netplex.com.au> To: Jason Evans <jasone@FreeBSD.org> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_malloc.c Message-ID: <200009100117.e8A1HqG75602@netplex.com.au> In-Reply-To: <200009092227.PAA38766@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Jason Evans wrote: > jasone 2000/09/09 15:27:35 PDT > > Modified files: > sys/kern kern_malloc.c > Log: > Add a mutex to the malloc interfaces so that it can safely be called > without owning the Giant lock. Actually, this is even more deadly than I first thought.. s = splmem(); mtx_enter(&malloc_mtx, MTX_DEF); while (ksp->ks_memuse >= ksp->ks_limit) { .... tsleep((caddr_t)ksp, PSWP+2, type->ks_shortdesc, 0); } Behold, instant death. We must release all locks (except Giant) before calling tsleep(). The calls to kmem_malloc() and kmem_free() etc must also be wrapped with releasing the malloc mutex and obtaining Giant before the call, and backing out again afterwards. The same for printf() etc. I don't mean to pick on Jason, but this is a classic example of why we must not rush into slapping locks all over the place without carefully mapping out the interaction between locks, sleeps, locking protocol, etc. Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009100117.e8A1HqG75602>