From owner-freebsd-arch@FreeBSD.ORG Thu Nov 22 10:17:03 2007 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 EAE0B16A46C; Thu, 22 Nov 2007 10:17:03 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id D86D313C465; Thu, 22 Nov 2007 10:17:03 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id CEDBB1A4D7E; Wed, 21 Nov 2007 14:23:19 -0800 (PST) Date: Wed, 21 Nov 2007 14:23:19 -0800 From: Alfred Perlstein To: arch@freebsd.org Message-ID: <20071121222319.GX44563@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: attilio@freebsd.org Subject: rwlocks, correctness over speed. 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: Thu, 22 Nov 2007 10:17:04 -0000 In summary, I am proposing (temporarily) making read-recursion on rwlocks not supported in order to avoid livelock due to writer starvation. More details: We currently have a problem with our implementation of rwlocks. I think this is a key issue for 7.x as what we decide to support will have rammifications for many years to come. We do not support writer priority or "fair share" usage of rwlocks between readers and writers. We have several choices to rectify this. 1. Disallow recursion on rwlocks (witness can be used to enforce this), this simplifies rwlocks such that we can avoid deadlock when a single reader is trying to recurse while a writer is pending. 2. Track ownership of rwlocks, this can be implemented with a "rwlock stack" in the per-thread control block (struct thread). Using this ownership information we can determine if someone is recursing and allow them to continue recursing despite a pending write request. I think the most simple solution currently is to drop support for recursive reads on rwlocks until we have the facility in place to properly support starvation avoidance. Why is this important? Simply put, developers that quickly "fix" some portion of code, whether that be a driver or part of the kernel proper who use read recursion will open the system to writer starvation and hence the system will destabilize, particulary for high load situations. I would like to get this in before 7.0-RELEASE becasue otherwise we're forced to implement something like the above mentioned solution #2, which will degrade performance for most use cases of rwlocks. Comments? -- - Alfred Perlstein