From owner-svn-src-head@freebsd.org Thu Nov 10 07:47:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 477E2C39FC8; Thu, 10 Nov 2016 07:47:02 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F160E7A2; Thu, 10 Nov 2016 07:47:01 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 384141FE022; Thu, 10 Nov 2016 08:46:56 +0100 (CET) Subject: Re: svn commit: r308424 - head/sys/arm/broadcom/bcm2835 To: John Baldwin References: <201611071738.uA7HceYu045944@repo.freebsd.org> <3214848.geWV8qu7rM@ralph.baldwin.cx> <5c170b6b-1189-4712-ffdd-653cc6b8c59e@selasky.org> <2064206.nvhhXHc9vW@ralph.baldwin.cx> Cc: Oleksandr Tymoshenko , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Marshall Kirk McKusick From: Hans Petter Selasky Message-ID: <6bce6a4b-d782-77af-8515-7243eab38cf3@selasky.org> Date: Thu, 10 Nov 2016 08:52:07 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <2064206.nvhhXHc9vW@ralph.baldwin.cx> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2016 07:47:02 -0000 Hi, On 11/09/16 17:32, John Baldwin wrote: > It isn't predicted and avoided by turnstiles. In particular, the cv_signal has > no idea what lock is associated, so it can't try to do something "smart" and > move the thread from the sleepq to the lockq. You will pay the double context > switch. Maybe this is an idea for a turnstile optimisation? In another embedded OS based on FreeBSD I did exactly this. If someone is sleeping through cv_wait() the lock it is sleeping on, if different from NULL, is stored in the sleepqueue. When cv_signal() is invoked we simply check if the saved lock is owned by the caller and then don't do the pre-emption, because we predict it will be locked by cv_wait() before returning. --HPS