From owner-freebsd-arch Thu Oct 12 17:46:31 2000 Delivered-To: freebsd-arch@freebsd.org Received: from io.yi.org (h24-69-199-88.gv.shawcable.net [24.69.199.88]) by hub.freebsd.org (Postfix) with ESMTP id BB10337B502; Thu, 12 Oct 2000 17:46:27 -0700 (PDT) Received: from io.yi.org (localhost.gvcl1.bc.wave.home.com [127.0.0.1]) by io.yi.org (Postfix) with ESMTP id 978DFBA76; Thu, 12 Oct 2000 17:46:26 -0700 (PDT) X-Mailer: exmh version 2.1.1 10/15/1999 To: mjacob@feral.com Cc: John Baldwin , arch@FreeBSD.ORG Subject: Re: when is it safe to call msleep? In-Reply-To: Message from Matthew Jacob of "Thu, 12 Oct 2000 10:34:41 PDT." Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_7696409280" Date: Thu, 12 Oct 2000 17:46:26 -0700 From: Jake Burkholder Message-Id: <20001013004626.978DFBA76@io.yi.org> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multipart MIME message. --==_Exmh_7696409280 Content-Type: text/plain; charset=us-ascii > > I've been fooling around with the new lock stuff and trying to convert things > over, and I called msleep with an initialized MTX_DEF lock held (on my > pc164) during probes, but I got a panic: > Hmm. I don't know about the panic, but the releasing of the mutex is probably in the wrong place if its going to be called early in boot, when cold is true. Could you try this: Jake --==_Exmh_7696409280 Content-Type: text/plain ; name="tsleep.diff"; charset=us-ascii Content-Description: tsleep.diff Content-Disposition: attachment; filename="tsleep.diff" Index: kern_synch.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_synch.c,v retrieving revision 1.101 diff -u -r1.101 kern_synch.c --- kern_synch.c 2000/10/06 02:20:20 1.101 +++ kern_synch.c 2000/10/13 00:20:30 @@ -436,15 +436,6 @@ WITNESS_SLEEP(0, mtx); mtx_enter(&sched_lock, MTX_SPIN); - if (mtx != NULL) { - KASSERT(mtx->mtx_recurse == 0, - ("sleeping on recursed mutex %s", mtx->mtx_description)); - WITNESS_SAVE(mtx, mtx); - mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); - if (priority & PDROP) - mtx = NULL; - } - s = splhigh(); if (cold || panicstr) { /* @@ -456,6 +447,15 @@ mtx_exit(&sched_lock, MTX_SPIN); splx(s); return (0); + } + + if (mtx != NULL) { + KASSERT(mtx->mtx_recurse == 0, + ("sleeping on recursed mutex %s", mtx->mtx_description)); + WITNESS_SAVE(mtx, mtx); + mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); + if (priority & PDROP) + mtx = NULL; } KASSERT(p != NULL, ("tsleep1")); --==_Exmh_7696409280-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message