From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 28 14:32:34 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F0AB106566C for ; Thu, 28 Feb 2008 14:32:34 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.158]) by mx1.freebsd.org (Postfix) with ESMTP id A94DF8FC20 for ; Thu, 28 Feb 2008 14:32:32 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so2580785fgg.35 for ; Thu, 28 Feb 2008 06:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=1AbyXVTqjiqcRdElqVLFIj8JZolOodCQ/DGMESuCH+k=; b=HRj1VNZbPhEKzJVlia/jGjMBXhwjwgGpQt4YXACwwrRTwS7JkHOIEeF4SgOR965QE01S/g5qyWZNHpBAa9uwnDtefmoGXnHV5UxIyqmIMk56JB4JgVSNbba+qeXAZTddJE7ZAbd31Iw4XBv4Tr6bwmGrqbJlGwI5ukYaQ78Zk8A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=A4jwRaaYEu4cWfXDwvG6/jP++dQ16+XUMerXxec9c1sPeWwkeyQiZUdP5da5DJb1K61Sf7gBwqbvtpQar8JCtpg/USVOp8zXiP48sLuBwjxH2P39EmxqU8r00IJEz0vPcpYCzem7SRX4/yD84GLZkZN6RuVXZ40WDANHZtS6Ixs= Received: by 10.86.31.18 with SMTP id e18mr8238397fge.35.1204207495489; Thu, 28 Feb 2008 06:04:55 -0800 (PST) Received: by 10.86.30.17 with HTTP; Thu, 28 Feb 2008 06:04:55 -0800 (PST) Message-ID: <3bbf2fe10802280604t4266c0a9uaa0075689ce67632@mail.gmail.com> Date: Thu, 28 Feb 2008 15:04:55 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Yuri Pankov" In-Reply-To: <20080228111222.GE92245@mail.irbisnet.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080228111222.GE92245@mail.irbisnet.ru> X-Google-Sender-Auth: a5721e333098e17f Cc: freebsd-hackers@freebsd.org Subject: Re: pfind() in ithread handler X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2008 14:32:34 -0000 2008/2/28, Yuri Pankov : > Hi, > > I'm trying to understand the cause of following panic. > > panic: Trying sleep, but thread marked as sleeping prohibited > cpuid = 0 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2a > panic() at panic+0x17d > sleepq_add() at sleepq_add+0x2e1 > _sx_slock_hard() at _sx_slock_hard+0x15d > _sx_slock() at _sx_slock+0xc1 > pfind() at pfind+0x24 > saa_intr() at saa_intr+0x313 > ithread_loop() at ithread_loop+0xda > fork_exit() at fork_exit+0x12a > fork_trampoline() at fork_trampoline+0xe > --- trap 0, rip = 0, rsp = 0xffffffffac3c0d30, rbp = 0 --- > > Can someone enlighten me on what is causing the panic and is it ok to > use pfind() in interrupt handler (I have very limited understanding of > kernel internals)? > > Code in question (taken from saa driver > http://freebsd.ricin.com/ports/distfiles/kbtv-1.92.tbz) can be found at > http://www.pastebin.ca/921830 ithreads cannot perform unbound sleeps and pfind() needs to access to allproc_lock which is a sx lock and *performs* an unbound sleep, so there is a mismatch. Btw, it sounds like allproc_lock and other similar locks are just using an sx lock for *legacy*, they should be probabilly converted to rwlock. It also imposes little problems in the TTY layer, for example, where I saw you need to use a unbounded sleeping primitive because of processes locks acquisitions. A nice janitor task would be to convert these sx locks into rw and see what happens. Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein