From owner-freebsd-arch@FreeBSD.ORG Wed Jan 8 16:31:29 2014 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 812D1766; Wed, 8 Jan 2014 16:31:29 +0000 (UTC) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 987991A05; Wed, 8 Jan 2014 16:31:28 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA29993; Wed, 08 Jan 2014 18:31:20 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1W0w2K-000AAz-2L; Wed, 08 Jan 2014 18:31:20 +0200 Message-ID: <52CD7D07.2010608@FreeBSD.org> Date: Wed, 08 Jan 2014 18:29:59 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Adrian Chadd , "freebsd-arch@freebsd.org" Subject: Re: Acquiring a lock on the same CPU that holds it - what can be done? References: In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jan 2014 16:31:29 -0000 I am sure that the following approach was suggested before, but I can not find any references now. So, the idea is to auto-associate a priority with a lock. Every time a priority lending would kick in we would record the priority in the lock. The next time a thread with a lower priority acquires that lock we would automatically boost the thread to the recorded priority until it releases the lock. This should prevent the situation that you've described where a higher priority thread preempts a lower priority thread just to discover that it holds a required lock and priority lending is required before relinquishing a CPU to the preempted thread. I am sure that there could be downsides to this approach. -- Andriy Gapon