From owner-freebsd-net@FreeBSD.ORG Sat Aug 20 22:39:54 2005 Return-Path: X-Original-To: net@freebsd.org 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 51D1C16A420 for ; Sat, 20 Aug 2005 22:39:54 +0000 (GMT) (envelope-from ups@tree.com) Received: from smtp.speedfactory.net (smtp.speedfactory.net [66.23.216.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7EB9B43D46 for ; Sat, 20 Aug 2005 22:39:53 +0000 (GMT) (envelope-from ups@tree.com) Received: (qmail 4963 invoked by uid 210); 20 Aug 2005 22:40:26 +0000 Received: from 66.23.216.49 by talon (envelope-from , uid 201) with qmail-scanner-1.25st (clamdscan: 0.85.1/1034. spamassassin: 3.0.2. perlscan: 1.25st. Clear:RC:1(66.23.216.49):. Processed in 0.03338 secs); 20 Aug 2005 22:40:26 -0000 X-Qmail-Scanner-Mail-From: ups@tree.com via talon X-Qmail-Scanner: 1.25st (Clear:RC:1(66.23.216.49):. Processed in 0.03338 secs Process 4958) Received: from 66-23-216-49.clients.speedfactory.net (HELO palm.tree.com) (66.23.216.49) by smtp.speedfactory.net with AES256-SHA encrypted SMTP; 20 Aug 2005 22:40:26 +0000 Received: from [127.0.0.1] (ups@localhost.tree.com [127.0.0.1]) by palm.tree.com (8.12.10/8.12.10) with ESMTP id j7KMdnrK021451; Sat, 20 Aug 2005 18:39:51 -0400 (EDT) (envelope-from ups@tree.com) From: Stephan Uphoff To: Luigi Rizzo In-Reply-To: <20050818073124.A87225@xorpc.icir.org> References: <20050816170519.A74422@xorpc.icir.org> <200508170435.34688.max@love2party.net> <20050817170248.A70991@xorpc.icir.org> <200508180332.34895.max@love2party.net> <20050818005739.A83776@xorpc.icir.org> <1124374713.1360.64660.camel@palm> <20050818073124.A87225@xorpc.icir.org> Content-Type: text/plain Message-Id: <1124577589.1360.73337.camel@palm> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sat, 20 Aug 2005 18:39:49 -0400 Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org, Max Laier , net@freebsd.org Subject: Re: duplicate read/write locks in net/pfil.c and netinet/ip_fw2.c X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 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, 20 Aug 2005 22:39:54 -0000 On Thu, 2005-08-18 at 10:31, Luigi Rizzo wrote: > On Thu, Aug 18, 2005 at 10:18:33AM -0400, Stephan Uphoff wrote: > > On Thu, 2005-08-18 at 03:57, Luigi Rizzo wrote: > ... > > > In fact i don't understand why you consider spinning and sleeping > > > on a mutex two different things. > > > > The major difference between sleeping (cv_wait,msleep,..) and blocking > > on a mutex is priority inheritance. > > If you need to be able to use (non-spin) mutexes while holding a > > [R|W]LOCK and use a [R|W]LOCK while holding a (non-spin) mutex then you > > need to implement priority inheritance for [R|W]LOCKs. > > is that required (in FreeBSD, i mean) for algorithmic > correctness or just for performance ? Hi Luigi, It is theoretically required since otherwise low priority user threads (programs) could block system (interrupt) threads indefinitely long. Example: Extreme low priority (nice?) thread A holds read/write lock RW as reader Thread B is holding mutex M tries to acquire read/write lock RW as writer and sleeps. Thread C with better priority than A runs and enters a busy loop (in user space). Interrupt thread preempts C and tries to acquire Mutex M. Interrupt priority is propagated to B BUT NOT TO A. Interrupt thread blocks on Mutex M. Thread C resumes and will block thread I forever if it can keep a better priority than thread A. In practice you would probably just see bad latency every now and then and may never encounter a hang. Stephan