NetBSD Problem Report #47115

From campbell@mumble.net  Tue Oct 23 20:24:12 2012
Return-Path: <campbell@mumble.net>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id B25ED63E398
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Oct 2012 20:24:11 +0000 (UTC)
Message-Id: <20121023202333.13A3D604BF@jupiter.mumble.net>
Date: Tue, 23 Oct 2012 20:23:32 +0000 (UTC)
From: Taylor R Campbell <campbell+netbsd@mumble.net>
Reply-To: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: rules for mutex_owned, rw_write_held, &c., are not clear
X-Send-Pr-Version: 3.95

>Number:         47115
>Category:       kern
>Synopsis:       rules for mutex_owned, rw_write_held, &c., are not clear
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 23 20:25:00 +0000 2012
>Originator:     Taylor R Campbell <campbell+netbsd@mumble.net>
>Release:        NetBSD 6.99.14
>Organization:
>Environment:
Architecture: any
Machine: any
>Description:

	The rules for using the routines mutex_owned, rw_write_held,
	rw_read_held, VOP_ISLOCKED, and so on, are not self-evident (at
	least to mere mortals such as me), and the intent does not seem
	to be reflected accurately in the man pages, as a private
	discussion among several developers revealed.

	These things are clear:

	. It's kosher to kassert any of these positively.
	. Kasserting !rw_read_held or !VOP_ISLOCKED is wrong.
	. Non-diagnostic uses of these are bogus.
	. We have a lot of uses in tree that are wrong or unclear.

	These things are not so clear:

	. Is KASSERT(VOP_ISLOCKED(vp) != LK_EXCLUSIVE) kosher?
	. Is kasserting !mutex_owned or !rw_write_held kosher?
	. How are the rules different for a spin vs adaptive mutex?
	. and maybe others.

	The vop issue should largely go away once we take a chainsaw to
	the whole vop protocol, but that won't happen for a little
	while.

>How-To-Repeat:

	Read some code and find negative kassertions.  Ask developers
	whether they are OK.  Fail to reach a consensus.  Throw up
	hands and hit the big red SEND-PR button with them.  (Reattach
	hands to wrists once they have plummeted back to the table from
	the ceiling.  Clean up the ensuing mess.)

>Fix:

	Yes, please!

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.