From owner-freebsd-current@FreeBSD.ORG Mon Mar 26 20:58:48 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE62E16A406; Mon, 26 Mar 2007 20:58:48 +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 5091B13C4BC; Mon, 26 Mar 2007 20:58:46 +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 l2QKwEWR015293; Mon, 26 Mar 2007 15:58:25 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Mon, 26 Mar 2007 15:11:03 -0400 User-Agent: KMail/1.9.6 References: <45F0D1F5.9010200@elischer.org> In-Reply-To: <45F0D1F5.9010200@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703261511.04364.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]); Mon, 26 Mar 2007 15:58:28 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2934/Mon Mar 26 15:04:46 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Julian Elischer , FreeBSD Current Subject: Re: proc lock might become an sx lock? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2007 20:58:48 -0000 On Thursday 08 March 2007 10:18:13 pm Julian Elischer wrote: > currently the thread list in the process is protected by the sched lock. > for a process with a lot of threads this is probably not a good idea. > I experimented with making it protected by the proc loc, but the following > sort of thing happens a lot: > > sx_slock(&allproc_lock); > FOREACH_PROC_IN_SYSTEM(p) { > mtx_lock_spin(&sched_lock); > FOREACH_THREAD_IN_PROC(p, td) { > ... > } > mtx_unlock_spin(&sched_lock); > > Changing the protection of the thread list to use the proc lock would > replace the sched_lock with the proc lock, but..... > this has a problem.. the proc lock is a mutex and can therefore not be inside the > allproc_lock. > > and in fact you get: > > Trying to mount root from ufs:/dev/aacd0s1d > panic: blockable sleep lock (sleep mutex) process lock @ kern/sched_4bsd.c:383 > cpuid = 2 > KDB: enter: panic > [thread pid 48 tid 100054 ] > Stopped at kdb_enter+0x2b: nop > db> bt > Tracing pid 48 tid 100054 td 0xc5ff4a20 > kdb_enter(c06ce300) at kdb_enter+0x2b > panic(c06d3506,c06e7061,c06cd73b,c06cff47,17f,...) at panic+0x11c > witness_checkorder(c60a12c8,9,c06cff47,17f) at witness_checkorder+0xb8 > _mtx_lock_flags(c60a12c8,0,c06cff3e,17f,85,...) at _mtx_lock_flags+0x87 > schedcpu(e65a9d24,c0516f50,0,e65a9d38,c6259000,...) at schedcpu+0x80 > schedcpu_thread(0,e65a9d38) at schedcpu_thread+0x9 > > My reading of the man page is that making it an sx lock and locking it in > shared mode would be sufficient for this sort of thing (assuming we are not changing > the thread list) and would be just fine. > > I'm not very familiar with the implementation of sx locks in freeBSD so I'm just learning > about them. > > am I reading this right? and does anyone else have any thoughts on this? Use rwlocks to make a mutex have reader/writer semantics but still fit into the current lock order. However, you likely should coordinate sched_lock changes like this with Attilio and Jeff R first as they are removing sched_lock and already have substantial diffs. -- John Baldwin