From owner-cvs-src@FreeBSD.ORG Wed Jun 9 18:15:05 2004 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 61C3616A4CE; Wed, 9 Jun 2004 18:15:05 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3E9B43D45; Wed, 9 Jun 2004 18:15:04 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.11/8.12.11) with ESMTP id i59IEYhA057190; Wed, 9 Jun 2004 20:14:34 +0200 (CEST) (envelope-from phk@phk.freebsd.dk) To: Bosko Milekic From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 09 Jun 2004 18:06:42 -0000." <20040609180642.GA33304@freefall.freebsd.org> Date: Wed, 09 Jun 2004 20:14:34 +0200 Message-ID: <57189.1086804874@critter.freebsd.dk> cc: src-committers@FreeBSD.org cc: Pawel Jakub Dawidek cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: Julian Elischer cc: Nate Lawson cc: "M. Warner Losh" Subject: Re: cvs commit: src/sys/kern kern_proc.c 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: Wed, 09 Jun 2004 18:15:05 -0000 In message <20040609180642.GA33304@freefall.freebsd.org>, Bosko Milekic writes: > While this idea is initially appealing, you should be aware that > it is not as straight-forward as it sounds. > > Namely, it is sometimes more advantageous to protect the manipulation > of the reference count within a section of code already protected by > an appropriate object mutex, and other times (in the absence of a mutex), > it might be more advantageous to use atomic ops (no need for a mutex, > slightly less costly per-instance). So defining an API that does one > OR the other might not always be appropriate. A still hot from the oven example of this is the code I just added in kern/tty.c: ttyrel() needs to do more locking than ttyref() because it might unlink the tty from a TAILQ whereas ttyref() will never touch the TAILQ. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.