From owner-freebsd-arch@FreeBSD.ORG Tue Oct 28 19:34:10 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6F0A7E64; Tue, 28 Oct 2014 19:34:10 +0000 (UTC) Received: from mail-wg0-x229.google.com (mail-wg0-x229.google.com [IPv6:2a00:1450:400c:c00::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CFFA2BFB; Tue, 28 Oct 2014 19:34:09 +0000 (UTC) Received: by mail-wg0-f41.google.com with SMTP id k14so279534wgh.14 for ; Tue, 28 Oct 2014 12:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=/aDpkQjplcyzjm2A6G41Q0oy4tZyAMn6R7C9/6NS6lw=; b=ysubuULWHwMjbbZMIvxHCC+s23v3LQcyNfDhfZgTJYXKf6M+T4af0McRqZneNk8tLB Q18OSRN3DXme5c526mpU4rqgP4tg9WWSD9/IjdOISrqiaj17zBkKVlxLq8thESsAc6Ka wZrPmRPLIlK7J4l8M15tJzE3dtKz3jPCwy1r+fyCCypcPHfED9FV+OF146qb1zMn6Oeb SJvkfMPUCvrKQHuGOPVytoESguKqq//099hxGQQ+X1DS1U4EDWdNjnRdHYYQoNF0/oqZ FLwL+rrznf9tZjOBzVYQvdGJo2zx9crgikrxvLI/FeCz0uHkGUtzpNpIxEx+rBymSHaQ 8FXg== X-Received: by 10.194.158.4 with SMTP id wq4mr7192449wjb.58.1414524847957; Tue, 28 Oct 2014 12:34:07 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id dg3sm3224593wib.14.2014.10.28.12.34.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 28 Oct 2014 12:34:07 -0700 (PDT) Date: Tue, 28 Oct 2014 20:34:04 +0100 From: Mateusz Guzik To: John Baldwin Subject: Re: refcount_release_take_##lock Message-ID: <20141028193404.GB12014@dft-labs.eu> References: <20141025184448.GA19066@dft-labs.eu> <201410281154.54581.jhb@freebsd.org> <20141028174428.GA12014@dft-labs.eu> <201410281413.58414.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201410281413.58414.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: John-Mark Gurney , freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Oct 2014 19:34:10 -0000 On Tue, Oct 28, 2014 at 02:13:58PM -0400, John Baldwin wrote: > On Tuesday, October 28, 2014 1:44:28 pm Mateusz Guzik wrote: > > diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c > > index f8ae0e6..e94ccde 100644 > > --- a/sys/kern/kern_jail.c > > +++ b/sys/kern/kern_jail.c > > The diff looks good to me. Just need to update refcount.9 as well. > diff --git a/share/man/man9/refcount.9 b/share/man/man9/refcount.9 index e7702a2..61b9b51 100644 --- a/share/man/man9/refcount.9 +++ b/share/man/man9/refcount.9 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 20, 2009 +.Dd October 28, 2014 .Dt REFCOUNT 9 .Os .Sh NAME @@ -44,6 +44,15 @@ .Fn refcount_acquire "volatile u_int *count" .Ft int .Fn refcount_release "volatile u_int *count" +.In sys/mutex.h +.Fn refcount_release_lock_mtx "volatile u_int *count, struct mtx *lock" +.In sys/rmlock.h +.Fn refcount_release_lock_rmlock "volatile u_int *count, struct rmlock *lock" +.In sys/rwlock.h +.Fn refcount_release_lock_rwlock "volatile u_int *count, struct rwlock *lock" +.In sys/lock.h +.In sys/sx.h +.Fn refcount_release_lock_sx "volatile u_int *count, struct sx *lock" .Sh DESCRIPTION The .Nm @@ -77,6 +86,13 @@ The function returns a non-zero value if the reference being released was the last reference; otherwise, it returns zero. .Pp +.Fn refcount_release_lock_* +functions release an existing reference holding the lock if it is the last +reference. +These functions return with the lock held and a non-zero value if the reference +being released was the last reference; +otherwise, they returns zero and the lock is not held. +.Pp Note that these routines do not provide any inter-CPU synchronization, data protection, or memory ordering guarantees except for managing the counter. @@ -91,6 +107,18 @@ The .Nm refcount_release function returns non-zero when releasing the last reference and zero when releasing any other reference. +.Pp +.Nm refcount_release_lock_* +functions return with the lock held and non-zero value when releasing the last +reference, zero without the lock held when releasing any other reference. .Sh HISTORY -These functions were introduced in +.Fn refcount_init , +.Fn refcount_acquire +and +.Fn refcount_release +functions were introduced in .Fx 6.0 . +.Pp +.Fn refcount_release_lock_* +functions were introduced in +.Fx 10.2 . -- Mateusz Guzik