From owner-freebsd-current@FreeBSD.ORG Mon Aug 7 19:29:17 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org 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 777FF16A527 for ; Mon, 7 Aug 2006 19:29:17 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.233]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4530443D86 for ; Mon, 7 Aug 2006 19:29:04 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by wx-out-0506.google.com with SMTP id i27so592473wxd for ; Mon, 07 Aug 2006 12:29:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=L52lskp90/eNtJzS9dlrWnCCtFJJEuCSYSheVvFrDq2OjfWtEQfhNkIO5n0Xh3+k7YpLqSAkjshCxxgDH04UWkUGfyyqtpMNdPi/NZ7wtm46JRAOmcp/D9YmyJGAqNqixbKve3GbuDW9r/oXx+GGyyJe6s60kHZkw2uB+zusaUY= Received: by 10.70.38.19 with SMTP id l19mr7338328wxl; Mon, 07 Aug 2006 12:27:20 -0700 (PDT) Received: by 10.70.11.18 with HTTP; Mon, 7 Aug 2006 12:27:19 -0700 (PDT) Message-ID: <3bbf2fe10608071227j17c4cfa6qd84e1d8e53668fda@mail.gmail.com> Date: Mon, 7 Aug 2006 21:27:19 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: freebsd-arch@freebsd.org, freebsd-current@freebsd.org, "John Baldwin" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 4138493682e4faea Cc: Subject: [PATCH] Adding Solaris-style "owner of records" to rwlocks X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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, 07 Aug 2006 19:29:17 -0000 This is a first implementation of the owner of records concept in rwlocks. It allows to avoid the priority inversion problem in the current rwlocks implementation (for readers). The main idea (that John and I discussed) is to have as owner of records the first rlock'er for a "class contention". The implementation consists in adding two flags (RW_LOCK_OWNED and RW_LOCK_EXEMPTED) which are used in order to not penalyze the easy case, and syncronizing the operation of acquiring and dropping the owner of records with the turnstile spin-lock. The main scheme might work in this way: thread1::rlock() -> sets the owner of records thread2::rlock() -> checks for RW_LOCK_OWNED bit and, if it is set, go in the easy case thread3::rlock() -> checks for RW_LOCK_OWNED... thread4::wlock() -> blocks and land its priority to thread1 thread1::runlock() -> disable the owner of records (disowning the associated turnstile) and sets the RW_LOCK_EXEMPTED flag. In this way other threads will treact as an easy case. ... What I actually need is a testing suite for heavy-load contentions, since I would like to detect eventual races I missed, etc. If somebody has a get-ready testing suite, please, let me know. The patch against HEAD is here: http://users.gufi.org/~rookie/works/patches/rwlocks.diff Please, this is not intended to be a final implementation for this, since I think that it can be improved; it is just a starting point for ongoing works and improvements. Let me know if something is not clear. Feedbacks, comments, ideas are welcome. Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein