From owner-freebsd-net@FreeBSD.ORG Sat Mar 12 17:16:52 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A7BE116A4CE; Sat, 12 Mar 2005 17:16:52 +0000 (GMT) Received: from stephanie.unixdaemons.com (stephanie.unixdaemons.com [67.18.111.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00D7843D48; Sat, 12 Mar 2005 17:16:52 +0000 (GMT) (envelope-from bmilekic@technokratis.com) Received: from stephanie.unixdaemons.com (bmilekic@localhost.unixdaemons.com [127.0.0.1])j2CHGmVR018359; Sat, 12 Mar 2005 12:16:48 -0500 (EST) Received: (from bmilekic@localhost) by stephanie.unixdaemons.com (8.13.3/8.12.1/Submit) id j2CHGmGs018358; Sat, 12 Mar 2005 12:16:48 -0500 (EST) (envelope-from bmilekic@technokratis.com) X-Authentication-Warning: stephanie.unixdaemons.com: bmilekic set sender to bmilekic@technokratis.com using -f Date: Sat, 12 Mar 2005 12:16:48 -0500 From: Bosko Milekic To: Pawel Jakub Dawidek Message-ID: <20050312171648.GA12186@technokratis.com> References: <20050311110234.GA87255@cell.sick.ru> <20050311141450.GF9291@darkness.comp.waw.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050311141450.GF9291@darkness.comp.waw.pl> User-Agent: Mutt/1.4.2.1i cc: dima <_pppp@mail.ru> cc: John Baldwin cc: Luigi Rizzo cc: Gleb Smirnoff cc: ru@FreeBSD.org cc: net@FreeBSD.org cc: rwatson@FreeBSD.org Subject: Re: Giant-free polling [PATCH] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Mar 2005 17:16:52 -0000 On Fri, Mar 11, 2005 at 03:14:50PM +0100, Pawel Jakub Dawidek wrote: > On Fri, Mar 11, 2005 at 04:55:25PM +0300, dima wrote: > +> I thought about using list also, but considered it to bring > +> too much overhead to the code. The original idea of handling arrays > +> seems to be very elegant. > > Overhead? Did you run any benchmarks to prove it? > I find list-version much more elegant that using an array. You should however be aware that iterating over an array of references as opposed to a list in the polling path, if you only consider the cost of iteration itself, is faster on both SMP and UP. With the list approach, you will have to bring in at least three items into cache, at each iteration: (1) The list node; (2) The list node's member (the 'pr' reference data in your patch); (3) The device's mutex. With the array approach, you will remove (1). If the relative frequency of insertions and removals is low (which I think it is in the polling case), you ought to consider doing the array thing (considering the predictable scheduling nature of polling, you could use the cache advantages due to the use of the array). Also, you will still be able to implement dynamic removal/insertion from/to the polling array. The fact that it is an array might just require re-allocation, not a big deal. > I also don't like the idea of calling handler method with two locks > held (one sx and one mutex)... Yeah, this should be re-worked. However, the use of the sx lock is neat. Unfortunately, our sx lock implementation always resorts to using a regular mutex lock, even when doing a shared lock (read only) acquisition. Since the window of the underlying sx lock mutex is relatively short, in most cases the performance advantage of using the sx lock is noticable. However, if the window of the original mutex is also short (compared to the sx lock window), then I wonder if it is worth it. The sx lock is really only designed for optimizing long-reads, in our case. Regards, -- Bosko Milekic bmilekic@technokratis.com bmilekic@FreeBSD.org