From owner-svn-src-all@FreeBSD.ORG Fri Aug 23 14:12:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DC7DE5B1; Fri, 23 Aug 2013 14:12:39 +0000 (UTC) (envelope-from davide@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BB0DF2A7C; Fri, 23 Aug 2013 14:12:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7NECdI0081567; Fri, 23 Aug 2013 14:12:39 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7NECdG7081565; Fri, 23 Aug 2013 14:12:39 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201308231412.r7NECdG7081565@svn.freebsd.org> From: Davide Italiano Date: Fri, 23 Aug 2013 14:12:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254703 - in head: share/man/man9 sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Aug 2013 14:12:40 -0000 Author: davide Date: Fri Aug 23 14:12:39 2013 New Revision: 254703 URL: http://svnweb.freebsd.org/changeset/base/254703 Log: Introduce callout_init_rm() so that callouts can be used in conjunction with rmlocks. This works only with non-sleepable rm because handlers run in SWI context. While here, document the new KPI in the timeout(9) manpage. Requested by: adrian, scottl Reviewed by: mav, remko(manpage) Modified: head/share/man/man9/timeout.9 head/sys/sys/callout.h Modified: head/share/man/man9/timeout.9 ============================================================================== --- head/share/man/man9/timeout.9 Fri Aug 23 14:03:48 2013 (r254702) +++ head/share/man/man9/timeout.9 Fri Aug 23 14:12:39 2013 (r254703) @@ -38,6 +38,7 @@ .Nm callout_handle_init , .Nm callout_init , .Nm callout_init_mtx , +.Nm callout_init_rm , .Nm callout_init_rw , .Nm callout_stop , .Nm callout_drain , @@ -73,6 +74,8 @@ struct callout_handle handle = CALLOUT_H .Fn callout_init "struct callout *c" "int mpsafe" .Ft void .Fn callout_init_mtx "struct callout *c" "struct mtx *mtx" "int flags" +.Fn void +.Fn callout_init_rm "struct callout *c" "struct rmlock *rm" "int flags" .Ft void .Fn callout_init_rw "struct callout *c" "struct rwlock *rw" "int flags" .Ft int @@ -203,6 +206,7 @@ Thus they are protected from re-entrancy The functions .Fn callout_init , .Fn callout_init_mtx , +.Fn callout_init_rm , .Fn callout_init_rw , .Fn callout_stop , .Fn callout_drain , @@ -252,15 +256,25 @@ after the callout function returns. .Pp The .Fn callout_init_rw -function serves the need of using rwlocks in conjunction with callouts. -The function does basically the same as -.Fn callout_init_mtx +and the +.Fn callout_init_rm +fuctions serve the need of using rwlocks and rmlocks in conjunction +with callouts. +The functions do the same as +.Fn callout_init with the possibility of specifying an extra .Fa rw +or +.Fa rm argument. -The usable lock classes are currently limited to mutexes and rwlocks, -because callout handlers run in softclock swi, so they cannot sleep nor -acquire sleepable locks like sx or lockmgr. +If an +.Fa rm +argument is specified, the lock should be created without passing the +.It Dv RM_SLEEPABLE +flag. +The usable lock classes are currently limited to mutexes, rwlocks and +non-sleepable rmlocks, because callout handlers run in softclock swi, +so they cannot sleep nor acquire sleepable locks like sx or lockmgr. The following .Fa flags may be specified: Modified: head/sys/sys/callout.h ============================================================================== --- head/sys/sys/callout.h Fri Aug 23 14:03:48 2013 (r254702) +++ head/sys/sys/callout.h Fri Aug 23 14:12:39 2013 (r254703) @@ -71,6 +71,9 @@ void _callout_init_lock(struct callout * #define callout_init_mtx(c, mtx, flags) \ _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \ NULL, (flags)) +#define callout_init_rm(c, rm, flags) + _callout_init_lock((c), ((rm != NULL) ? &(rm)->lock_object : \ + NULL, (flags)) #define callout_init_rw(c, rw, flags) \ _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ NULL, (flags))