From owner-cvs-src@FreeBSD.ORG Tue Oct 14 14:16:48 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 249FA16A4B3; Tue, 14 Oct 2003 14:16:48 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BBF443FDF; Tue, 14 Oct 2003 14:16:47 -0700 (PDT) (envelope-from sam@errno.com) Received: from 66.127.85.91 ([66.127.85.91]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.9) with ESMTP id h9ELGg0x057602 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Tue, 14 Oct 2003 14:16:43 -0700 (PDT) (envelope-from sam@errno.com) From: Sam Leffler Organization: Errno Consulting To: John Baldwin , Jeff Roberson Date: Tue, 14 Oct 2003 14:17:54 -0700 User-Agent: KMail/1.5.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310141417.54617.sam@errno.com> cc: cvs-src@FreeBSD.org cc: Jeff Roberson cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys mutex.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2003 21:16:48 -0000 On Tuesday 14 October 2003 02:08 pm, John Baldwin wrote: > On 14-Oct-2003 Jeff Roberson wrote: > > On Tue, 14 Oct 2003, John Baldwin wrote: > >> On 12-Oct-2003 Jeff Roberson wrote: > >> > jeff 2003/10/12 14:02:55 PDT > >> > > >> > FreeBSD src repository > >> > > >> > Modified files: > >> > sys/sys mutex.h > >> > Log: > >> > - Implement a mtx_ownedby() macro which can be used to determine if > >> > a particular thread owns a mutex. This cannot be done without races > >> > unless the thread is curthread. > >> > >> This is a very bad idea. What use do you have for this that is not > >> already handled by mtx_owned() or a mutex assertion? > > > > I know it is racy in most contexts. I use it to check to see if a thread > > on the runq owns giant. Since I have the sched lock it isn't racy but > > even if it was it wouldn't matter in this case. > > sched lock doesn't keep it from being racy. Uncontested acquire and > releases don't go anywhere near sched lock. Are you checking a > non-curthread thread pointer? Maybe you could just do it for curthread > and that would be enough for your heuristic, i.e. > > if (thread == curthread && mtx_owned(&Giant)) { > ... > } > > I'm just worried that if this is there someone is going to use it. :( Putting this in mutex.h will entice people to use it. Seems it should go away. Sam