From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 31 14:48:00 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B7D21065686 for ; Tue, 31 Jan 2012 14:48:00 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 136088FC18 for ; Tue, 31 Jan 2012 14:48:00 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id B982B46B0D; Tue, 31 Jan 2012 09:47:59 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 2C29CB965; Tue, 31 Jan 2012 09:47:59 -0500 (EST) From: John Baldwin To: dmitry.krivenok@emc.com Date: Tue, 31 Jan 2012 07:54:02 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) References: <9C7BACB01B839A499792154E76C9ADE5563FDD39ED@MX19A.corp.emc.com> In-Reply-To: <9C7BACB01B839A499792154E76C9ADE5563FDD39ED@MX19A.corp.emc.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201201310754.02343.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 31 Jan 2012 09:47:59 -0500 (EST) Cc: freebsd-hackers@freebsd.org Subject: Re: mtx_trylock() on a spin mutex X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jan 2012 14:48:00 -0000 On Tuesday, January 31, 2012 6:35:08 am dmitry.krivenok@emc.com wrote: > Hello, > Could someone please explain why mtx_trylock() must not be called on a spin mutex? > Is it conceptually wrong or is it a restriction of FreeBSD kernel implementation? The current mutex API generally uses different methods for the different types of mutexes (at some point I may split spin locks out into a completely separate API to simplify things). If we wanted to do trylocks on spinlocks, then a new mtx_trylock_spin() method would be added as you've done. To date we haven't had any use cases for trylock operations on a spin lock. Even try locks on other locking primitives are used fairly rarely. -- John Baldwin