From owner-cvs-all@FreeBSD.ORG Tue Jun 5 17:27:28 2007 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6CCE516A400; Tue, 5 Jun 2007 17:27:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id E297E13C484; Tue, 5 Jun 2007 17:27:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l55HROur029442; Tue, 5 Jun 2007 13:27:25 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: "Attilio Rao" Date: Tue, 5 Jun 2007 13:27:20 -0400 User-Agent: KMail/1.9.6 References: <200706051420.l55EKEih018925@repoman.freebsd.org> <200706051230.21242.jhb@freebsd.org> <3bbf2fe10706051012x76381687g98e034ceb47b3f26@mail.gmail.com> In-Reply-To: <3bbf2fe10706051012x76381687g98e034ceb47b3f26@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200706051327.21307.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 05 Jun 2007 13:27:25 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3360/Tue Jun 5 00:32:46 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Kostik Belousov , cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org, Bruce Evans Subject: Re: cvs commit: src/sys/kern kern_mutex.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2007 17:27:28 -0000 On Tuesday 05 June 2007 01:12:01 pm Attilio Rao wrote: > 2007/6/5, John Baldwin : > > On Tuesday 05 June 2007 11:43:03 am Attilio Rao wrote: > > > 2007/6/5, Attilio Rao : > > > > 2007/6/5, Bruce Evans : > > > > > > > > > > I get a "spin lock held too long" panic during (an interrupt in?) acpi > > > > > initialization on booting non-PREEMPTION SCHED_4BSD SMP. Haven't tried > > > > > other cases. > > > > > > > > Do you have a backtrace or any other debugging stuffs available? > > > > > > Mmm, I think I got the bug. > > > basically, in kern_mutex.c::_mtx_unlock_sleep(), in the not-preemptive > > > case what happens at some point is: > > > > > > td = curthread; > > > if (td->td_critnest > 0 || td1->td_priority >= td->td_priority) > > > return; > > > > > > thread_lock(td1); > > > if (!TD_IS_RUNNING(td1)) { > > > ... > > > > > > mi_switch(SW_INVOL, NULL); > > > ... > > > } > > > thread_unlock(td1); > > > > > > Which is wrong beacause td1 is not curthread and really curthread > > > should be locked too when context switching. > > > > > > To a first look the idea is that td and td1 should be locked both, but > > > I just want more time to look better at it. > > > > If this is the old #ifndef PREEMPTION manual preemption stuff, then just > > remove it. I've been wanting to axe it for a while, rwlocks don't do the > > manual preemption either, and if it is getting in the way it's best to just > > purge it. > > Yes. > More specifically, I always thought that code would just force a > PREEMPTION point in the mtx_unlock(), instead it just happens in the > !PREEMPTION case... is this a bug? > I don't see why doing something like that in the !PREEMPTION point > (but it can be I'm missing something :)). In the PREEMPTION case, the act of making the threads runnable will trigger a preemption (or set td_owepreempt). The !PREEMPTION stuff is to make mtx_unlock() preempt when PREEMPTION isn't enabled in the kernel. -- John Baldwin