From owner-freebsd-arch@FreeBSD.ORG Sat Mar 29 13:20:13 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F07DE106566C; Sat, 29 Mar 2008 13:20:13 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe15.tele2.se [212.247.155.193]) by mx1.freebsd.org (Postfix) with ESMTP id 29DB48FC1B; Sat, 29 Mar 2008 13:20:12 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [62.113.132.89] (account mc467741@c2i.net [62.113.132.89] verified) by mailfe15.swip.net (CommuniGate Pro SMTP 5.1.13) with ESMTPA id 134377604; Sat, 29 Mar 2008 13:20:09 +0100 From: Hans Petter Selasky To: freebsd-arch@freebsd.org Date: Sat, 29 Mar 2008 13:21:13 +0100 User-Agent: KMail/1.9.7 References: <10004.1205307334@critter.freebsd.dk> <200803291013.28797.hselasky@c2i.net> <20080328235600.O72156@desktop> In-Reply-To: <20080328235600.O72156@desktop> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803291321.15896.hselasky@c2i.net> Cc: arch@freebsd.org Subject: Re: timeout/callout small step forward X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Mar 2008 13:20:14 -0000 Hi Jeff, Probably you're right that the chance of congestion is not very high, hence most clients will use a per-object lock, except for Giant locked systems. Though it would be nice if you could get this part right while you are first working at it. I get the feeling that you understand my point: Multiple worker threads will not help if the functions called by the worker threads are protected by the same mutex. Then it is better to run these in series on the same thread. --HPS On Saturday 29 March 2008, Jeff Roberson wrote: > On Sat, 29 Mar 2008, Hans Petter Selasky wrote: > > Hi, > > > > How does this patch handle when multiple callouts use the same mutex ? > > Imagine that two threads are about to lock the same mutex, then the > > second thread will get nowhere while waiting for the first thread to > > execute the callback. > > You are worried that there will be too much contention or that there is > some correctness issue? > > If you're worried about contention, it would seem that most callers use > some per-object mutex for the callout. So there isn't likely to be > much contention among callouts. > > > I think the solution is that callbacks are put in a tree. Giant locked > > callbacks go all into the same tree. Else the user of callouts is > > responsible for making up the tree. > > > > struct callout { > > struct thread *exec_td; > > struct callout *parent; > > }; > > > > struct callout *c; > > > > while (c->parent != NULL) { > > c = c->parent; > > } > > > > if (c->exec_td != NULL) { > > callout should go into the same thread; > > } else { > > pick the next free thread and set "c->exec_td" > > } > > > > Callouts that belong to the same tree are run from the same thread. This > > does not only apply for callouts, but also multithreaded node systems ... > > > > Yours > > --HPS > > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"