From owner-cvs-all Sat Sep 9 18:18: 0 2000 Delivered-To: cvs-all@freebsd.org Received: from netplex.com.au (adsl-63-207-30-186.dsl.snfc21.pacbell.net [63.207.30.186]) by hub.freebsd.org (Postfix) with ESMTP id 990BD37B645; Sat, 9 Sep 2000 18:17:52 -0700 (PDT) Received: from netplex.com.au (peter@localhost [127.0.0.1]) by netplex.com.au (8.11.0/8.9.3) with ESMTP id e8A1HqG75602; Sat, 9 Sep 2000 18:17:52 -0700 (PDT) (envelope-from peter@netplex.com.au) Message-Id: <200009100117.e8A1HqG75602@netplex.com.au> X-Mailer: exmh version 2.1.1 10/15/1999 To: Jason Evans Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_malloc.c In-Reply-To: <200009092227.PAA38766@freefall.freebsd.org> Date: Sat, 09 Sep 2000 18:17:52 -0700 From: Peter Wemm Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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