From owner-freebsd-current@FreeBSD.ORG Mon May 5 14:04:42 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E8FF337B401; Mon, 5 May 2003 14:04:42 -0700 (PDT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A8AA43F3F; Mon, 5 May 2003 14:04:42 -0700 (PDT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.12.9/8.12.9) with SMTP id h45L4s9S064663; Mon, 5 May 2003 17:04:55 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Mon, 5 May 2003 17:04:53 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Petri Helenius In-Reply-To: <02ed01c31347$56f023d0$932a40c1@PHE> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-current@FreeBSD.org cc: John Baldwin cc: sos@FreeBSD.org Subject: Re: kthread_exit and giant X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 05 May 2003 21:04:43 -0000 On Mon, 5 May 2003, Petri Helenius wrote: > > The kthread is supposed to acquire Giant before calling kthread_exit(). > > Actually, my guess is that the ar kthread needs to acquire Giant for the > > lifetime of the thread. I have an untested patch locally: > > > I thought the lifetime of the thread is the duration of the rebuild > process? Which can be minutes to hours. Locking giant for that kind of > time does not sound right, so locking it just before thread exit sounds > like the right thing to do, as long as the code othervise keeps critical > sections locked. Giant is a funnel-style mutex intended to emulate the older spinlock protection of the kernel from parallelism. It operates somewhat like a normal sleep mutex except that you release the mutex whenever you (the thread holding Giant) sleep so if the rebuild process involves sleeping, it will release Giant every time it sleeps. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories