1f53d15feSStephan Uphoff.\" Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org> 2f53d15feSStephan Uphoff.\" Copyright (c) 2006 Gleb Smirnoff <glebius@FreeBSD.org> 3f53d15feSStephan Uphoff.\" All rights reserved. 4f53d15feSStephan Uphoff.\" 5f53d15feSStephan Uphoff.\" Redistribution and use in source and binary forms, with or without 6f53d15feSStephan Uphoff.\" modification, are permitted provided that the following conditions 7f53d15feSStephan Uphoff.\" are met: 8f53d15feSStephan Uphoff.\" 1. Redistributions of source code must retain the above copyright 9f53d15feSStephan Uphoff.\" notice, this list of conditions and the following disclaimer. 10f53d15feSStephan Uphoff.\" 2. Redistributions in binary form must reproduce the above copyright 11f53d15feSStephan Uphoff.\" notice, this list of conditions and the following disclaimer in the 12f53d15feSStephan Uphoff.\" documentation and/or other materials provided with the distribution. 13f53d15feSStephan Uphoff.\" 14f53d15feSStephan Uphoff.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15f53d15feSStephan Uphoff.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16f53d15feSStephan Uphoff.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17f53d15feSStephan Uphoff.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18f53d15feSStephan Uphoff.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19f53d15feSStephan Uphoff.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20f53d15feSStephan Uphoff.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21f53d15feSStephan Uphoff.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22f53d15feSStephan Uphoff.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23f53d15feSStephan Uphoff.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24f53d15feSStephan Uphoff.\" SUCH DAMAGE. 25f53d15feSStephan Uphoff.\" 26f53d15feSStephan Uphoff.\" $FreeBSD$ 27f53d15feSStephan Uphoff.\" 28f53d15feSStephan Uphoff.\" Based on rwlock.9 man page 29*2816bd84SMitchell Horne.Dd April 12, 2021 30f53d15feSStephan Uphoff.Dt RMLOCK 9 31f53d15feSStephan Uphoff.Os 32f53d15feSStephan Uphoff.Sh NAME 33f53d15feSStephan Uphoff.Nm rmlock , 34f53d15feSStephan Uphoff.Nm rm_init , 351a109c1cSRobert Watson.Nm rm_init_flags , 36f53d15feSStephan Uphoff.Nm rm_destroy , 37f53d15feSStephan Uphoff.Nm rm_rlock , 3836058c09SMax Laier.Nm rm_try_rlock , 39f53d15feSStephan Uphoff.Nm rm_wlock , 40f53d15feSStephan Uphoff.Nm rm_runlock , 41f53d15feSStephan Uphoff.Nm rm_wunlock , 42433ea89aSRobert Watson.Nm rm_wowned , 43cd32bd7aSJohn Baldwin.Nm rm_sleep , 44cd32bd7aSJohn Baldwin.Nm rm_assert , 45755230ebSMark Johnston.Nm RM_SYSINIT , 461f162fefSMateusz Guzik.Nm RM_SYSINIT_FLAGS , 471f162fefSMateusz Guzik.Nm rms_init , 481f162fefSMateusz Guzik.Nm rms_destroy , 491f162fefSMateusz Guzik.Nm rms_rlock , 501f162fefSMateusz Guzik.Nm rms_wlock , 511f162fefSMateusz Guzik.Nm rms_runlock , 521f162fefSMateusz Guzik.Nm rms_wunlock 538403b193SJohn Baldwin.Nd kernel reader/writer lock optimized for read-mostly access patterns 54f53d15feSStephan Uphoff.Sh SYNOPSIS 55f53d15feSStephan Uphoff.In sys/param.h 56f53d15feSStephan Uphoff.In sys/lock.h 57f53d15feSStephan Uphoff.In sys/rmlock.h 58f53d15feSStephan Uphoff.Ft void 591a109c1cSRobert Watson.Fn rm_init "struct rmlock *rm" "const char *name" 601a109c1cSRobert Watson.Ft void 611a109c1cSRobert Watson.Fn rm_init_flags "struct rmlock *rm" "const char *name" "int opts" 62f53d15feSStephan Uphoff.Ft void 63f53d15feSStephan Uphoff.Fn rm_destroy "struct rmlock *rm" 64f53d15feSStephan Uphoff.Ft void 65f53d15feSStephan Uphoff.Fn rm_rlock "struct rmlock *rm" "struct rm_priotracker* tracker" 6636058c09SMax Laier.Ft int 6736058c09SMax Laier.Fn rm_try_rlock "struct rmlock *rm" "struct rm_priotracker* tracker" 68f53d15feSStephan Uphoff.Ft void 69f53d15feSStephan Uphoff.Fn rm_wlock "struct rmlock *rm" 70f53d15feSStephan Uphoff.Ft void 71f53d15feSStephan Uphoff.Fn rm_runlock "struct rmlock *rm" "struct rm_priotracker* tracker" 72f53d15feSStephan Uphoff.Ft void 73f53d15feSStephan Uphoff.Fn rm_wunlock "struct rmlock *rm" 74433ea89aSRobert Watson.Ft int 75d576deedSPawel Jakub Dawidek.Fn rm_wowned "const struct rmlock *rm" 76cd32bd7aSJohn Baldwin.Ft int 77cd32bd7aSJohn Baldwin.Fn rm_sleep "void *wchan" "struct rmlock *rm" "int priority" "const char *wmesg" "int timo" 78cd32bd7aSJohn Baldwin.Pp 79cd32bd7aSJohn Baldwin.Cd "options INVARIANTS" 80cd32bd7aSJohn Baldwin.Cd "options INVARIANT_SUPPORT" 81cd32bd7aSJohn Baldwin.Ft void 82cd32bd7aSJohn Baldwin.Fn rm_assert "struct rmlock *rm" "int what" 83f53d15feSStephan Uphoff.In sys/kernel.h 84755230ebSMark Johnston.Fn RM_SYSINIT "name" "struct rmlock *rm" "const char *desc" 85755230ebSMark Johnston.Fn RM_SYSINIT_FLAGS "name" "struct rmlock *rm" "const char *desc" "int flags" 861f162fefSMateusz Guzik.Ft void 871f162fefSMateusz Guzik.Fn rms_init "struct rmslock *rms" "const char *name" 881f162fefSMateusz Guzik.Ft void 891f162fefSMateusz Guzik.Fn rms_destroy "struct rmslock *rms" 901f162fefSMateusz Guzik.Ft void 911f162fefSMateusz Guzik.Fn rms_rlock "struct rmslock *rms" 921f162fefSMateusz Guzik.Ft void 931f162fefSMateusz Guzik.Fn rms_wlock "struct rmslock *rms" 941f162fefSMateusz Guzik.Ft void 951f162fefSMateusz Guzik.Fn rms_runlock "struct rmslock *rms" 961f162fefSMateusz Guzik.Ft void 971f162fefSMateusz Guzik.Fn rms_wunlock "struct rmslock *rms" 98f53d15feSStephan Uphoff.Sh DESCRIPTION 998403b193SJohn BaldwinRead-mostly locks allow shared access to protected data by multiple threads, 100f53d15feSStephan Uphoffor exclusive access by a single thread. 101f53d15feSStephan UphoffThe threads with shared access are known as 102f53d15feSStephan Uphoff.Em readers 103f53d15feSStephan Uphoffsince they only read the protected data. 104f53d15feSStephan UphoffA thread with exclusive access is known as a 105f53d15feSStephan Uphoff.Em writer 106f53d15feSStephan Uphoffsince it can modify protected data. 107f53d15feSStephan Uphoff.Pp 1088403b193SJohn BaldwinRead-mostly locks are designed to be efficient for locks almost exclusively 109989cbe40SHiten Pandyaused as reader locks and as such should be used for protecting data that 110989cbe40SHiten Pandyararely changes. 1118403b193SJohn BaldwinAcquiring an exclusive lock after the lock has been locked for shared access 112989cbe40SHiten Pandyais an expensive operation. 113f53d15feSStephan Uphoff.Pp 1148403b193SJohn BaldwinNormal read-mostly locks are similar to 1158403b193SJohn Baldwin.Xr rwlock 9 1168403b193SJohn Baldwinlocks and follow the same lock ordering rules as 1178403b193SJohn Baldwin.Xr rwlock 9 1188403b193SJohn Baldwinlocks. 1198403b193SJohn BaldwinRead-mostly locks have full priority propagation like mutexes. 120f53d15feSStephan UphoffUnlike 1218403b193SJohn Baldwin.Xr rwlock 9 , 1228403b193SJohn Baldwinread-mostly locks propagate priority to both readers and writers. 1238403b193SJohn BaldwinThis is implemented via the 124989cbe40SHiten Pandya.Va rm_priotracker 1258403b193SJohn Baldwinstructure argument supplied to 126989cbe40SHiten Pandya.Fn rm_rlock 127989cbe40SHiten Pandyaand 1288403b193SJohn Baldwin.Fn rm_runlock . 1298403b193SJohn BaldwinReaders can recurse if the lock is initialized with the 1308403b193SJohn Baldwin.Dv RM_RECURSE 1318403b193SJohn Baldwinoption; 1328403b193SJohn Baldwinhowever, writers are never allowed to recurse. 1338403b193SJohn Baldwin.Pp 1341f162fefSMateusz GuzikSleeping for writers can be allowed by passing 1358403b193SJohn Baldwin.Dv RM_SLEEPABLE 1368403b193SJohn Baldwinto 1378403b193SJohn Baldwin.Fn rm_init_flags . 1381f162fefSMateusz GuzikIt changes lock ordering rules to the same as for 1398403b193SJohn Baldwin.Xr sx 9 1408403b193SJohn Baldwinlocks. 14127f21fadSGordon BerglingThey do not propagate priority to writers, but they do propagate priority to readers. 14227f21fadSGordon BerglingNote that readers are not permitted to sleep regardless of the flag. 1431f162fefSMateusz Guzik.Pp 1441f162fefSMateusz GuzikSleepable read-mostly locks (created with 1451f162fefSMateusz Guzik.Fn rms_init ) 1461f162fefSMateusz Guzikallow sleeping for both readers and writers, but don't do priority propagation 14727f21fadSGordon Berglingfor either. 14827f21fadSGordon BerglingThey follow 1498403b193SJohn Baldwin.Xr sx 9 1501f162fefSMateusz Guziklock ordering. 151f53d15feSStephan Uphoff.Ss Macros and Functions 152f53d15feSStephan Uphoff.Bl -tag -width indent 1531a109c1cSRobert Watson.It Fn rm_init "struct rmlock *rm" "const char *name" 1548403b193SJohn BaldwinInitialize the read-mostly lock 1558403b193SJohn Baldwin.Fa rm . 1568403b193SJohn BaldwinThe 1578403b193SJohn Baldwin.Fa name 1588403b193SJohn Baldwindescription is used solely for debugging purposes. 159f53d15feSStephan UphoffThis function must be called before any other operations 160f53d15feSStephan Uphoffon the lock. 1611a109c1cSRobert Watson.It Fn rm_init_flags "struct rmlock *rm" "const char *name" "int opts" 1628403b193SJohn BaldwinSimilar to 1638403b193SJohn Baldwin.Fn rm_init , 1648403b193SJohn Baldwininitialize the read-mostly lock 1658403b193SJohn Baldwin.Fa rm 1668403b193SJohn Baldwinwith a set of optional flags. 1678403b193SJohn BaldwinThe 1681a109c1cSRobert Watson.Fa opts 1698403b193SJohn Baldwinarguments contains one or more of the following flags: 1701a109c1cSRobert Watson.Bl -tag -width ".Dv RM_NOWITNESS" 1711a109c1cSRobert Watson.It Dv RM_NOWITNESS 1721a109c1cSRobert WatsonInstruct 1731a109c1cSRobert Watson.Xr witness 4 1741a109c1cSRobert Watsonto ignore this lock. 1751a109c1cSRobert Watson.It Dv RM_RECURSE 1768403b193SJohn BaldwinAllow threads to recursively acquire shared locks for 1771a109c1cSRobert Watson.Fa rm . 17836058c09SMax Laier.It Dv RM_SLEEPABLE 1798403b193SJohn BaldwinCreate a sleepable read-mostly lock. 180fd07ddcfSDmitry Chagin.It Dv RM_NEW 181fd07ddcfSDmitry ChaginIf the kernel has been compiled with 182fd07ddcfSDmitry Chagin.Cd "option INVARIANTS" , 183fd07ddcfSDmitry Chagin.Fn rm_init_flags 184fd07ddcfSDmitry Chaginwill assert that the 185fd07ddcfSDmitry Chagin.Fa rm 186fd07ddcfSDmitry Chaginhas not been initialized multiple times without intervening calls to 187fd07ddcfSDmitry Chagin.Fn rm_destroy 188fd07ddcfSDmitry Chaginunless this option is specified. 189*2816bd84SMitchell Horne.It Dv RM_DUPOK 190*2816bd84SMitchell Horne.Xr witness 4 191*2816bd84SMitchell Horneshould not log messages about duplicate locks being acquired. 1921a109c1cSRobert Watson.El 193f53d15feSStephan Uphoff.It Fn rm_rlock "struct rmlock *rm" "struct rm_priotracker* tracker" 194f53d15feSStephan UphoffLock 195f53d15feSStephan Uphoff.Fa rm 1968403b193SJohn Baldwinas a reader using 197f53d15feSStephan Uphoff.Fa tracker 198f53d15feSStephan Uphoffto track read owners of a lock for priority propagation. 199989cbe40SHiten PandyaThis data structure is only used internally by 200989cbe40SHiten Pandya.Nm 201c6d7cf7bSChristian Bruefferand must persist until 202c6d7cf7bSChristian Brueffer.Fn rm_runlock 203c6d7cf7bSChristian Bruefferhas been called. 204989cbe40SHiten PandyaThis data structure can be allocated on the stack since 2058403b193SJohn Baldwinreaders cannot sleep. 206f53d15feSStephan UphoffIf any thread holds this lock exclusively, the current thread blocks, 207f53d15feSStephan Uphoffand its priority is propagated to the exclusive holder. 208989cbe40SHiten PandyaIf the lock was initialized with the 2098403b193SJohn Baldwin.Dv RM_RECURSE 210989cbe40SHiten Pandyaoption the 211f53d15feSStephan Uphoff.Fn rm_rlock 2128403b193SJohn Baldwinfunction can be called when the current thread has already acquired reader 213f53d15feSStephan Uphoffaccess on 214f53d15feSStephan Uphoff.Fa rm . 21536058c09SMax Laier.It Fn rm_try_rlock "struct rmlock *rm" "struct rm_priotracker* tracker" 21636058c09SMax LaierTry to lock 21736058c09SMax Laier.Fa rm 21836058c09SMax Laieras a reader. 21936058c09SMax Laier.Fn rm_try_rlock 22036058c09SMax Laierwill return 0 if the lock cannot be acquired immediately; 2218403b193SJohn Baldwinotherwise, 2228403b193SJohn Baldwinthe lock will be acquired and a non-zero value will be returned. 22336058c09SMax LaierNote that 22436058c09SMax Laier.Fn rm_try_rlock 22536058c09SMax Laiermay fail even while the lock is not currently held by a writer. 2268403b193SJohn BaldwinIf the lock was initialized with the 2278403b193SJohn Baldwin.Dv RM_RECURSE 2288403b193SJohn Baldwinoption, 2298403b193SJohn Baldwin.Fn rm_try_rlock 2308403b193SJohn Baldwinwill succeed if the current thread has already acquired reader access. 231f53d15feSStephan Uphoff.It Fn rm_wlock "struct rmlock *rm" 232f53d15feSStephan UphoffLock 233f53d15feSStephan Uphoff.Fa rm 234f53d15feSStephan Uphoffas a writer. 235f53d15feSStephan UphoffIf there are any shared owners of the lock, the current thread blocks. 236f53d15feSStephan UphoffThe 237f53d15feSStephan Uphoff.Fn rm_wlock 238f53d15feSStephan Uphofffunction cannot be called recursively. 239f53d15feSStephan Uphoff.It Fn rm_runlock "struct rmlock *rm" "struct rm_priotracker* tracker" 240f53d15feSStephan UphoffThis function releases a shared lock previously acquired by 241f53d15feSStephan Uphoff.Fn rm_rlock . 242f53d15feSStephan UphoffThe 243f53d15feSStephan Uphoff.Fa tracker 244f53d15feSStephan Uphoffargument must match the 245f53d15feSStephan Uphoff.Fa tracker 246f53d15feSStephan Uphoffargument used for acquiring the shared lock 247f53d15feSStephan Uphoff.It Fn rm_wunlock "struct rmlock *rm" 248f53d15feSStephan UphoffThis function releases an exclusive lock previously acquired by 249f53d15feSStephan Uphoff.Fn rm_wlock . 250f53d15feSStephan Uphoff.It Fn rm_destroy "struct rmlock *rm" 251f53d15feSStephan UphoffThis functions destroys a lock previously initialized with 252f53d15feSStephan Uphoff.Fn rm_init . 253f53d15feSStephan UphoffThe 254f53d15feSStephan Uphoff.Fa rm 255f53d15feSStephan Uphofflock must be unlocked. 256d576deedSPawel Jakub Dawidek.It Fn rm_wowned "const struct rmlock *rm" 257433ea89aSRobert WatsonThis function returns a non-zero value if the current thread owns an 258433ea89aSRobert Watsonexclusive lock on 259433ea89aSRobert Watson.Fa rm . 260cd32bd7aSJohn Baldwin.It Fn rm_sleep "void *wchan" "struct rmlock *rm" "int priority" "const char *wmesg" "int timo" 261cd32bd7aSJohn BaldwinThis function atomically releases 262cd32bd7aSJohn Baldwin.Fa rm 263cd32bd7aSJohn Baldwinwhile waiting for an event. 264cd32bd7aSJohn BaldwinThe 265cd32bd7aSJohn Baldwin.Fa rm 266cd32bd7aSJohn Baldwinlock must be exclusively locked. 267cd32bd7aSJohn BaldwinFor more details on the parameters to this function, 268cd32bd7aSJohn Baldwinsee 269cd32bd7aSJohn Baldwin.Xr sleep 9 . 270cd32bd7aSJohn Baldwin.It Fn rm_assert "struct rmlock *rm" "int what" 271cd32bd7aSJohn BaldwinThis function asserts that the 272cd32bd7aSJohn Baldwin.Fa rm 273cd32bd7aSJohn Baldwinlock is in the state specified by 274cd32bd7aSJohn Baldwin.Fa what . 275cd32bd7aSJohn BaldwinIf the assertions are not true and the kernel is compiled with 276cd32bd7aSJohn Baldwin.Cd "options INVARIANTS" 277cd32bd7aSJohn Baldwinand 278cd32bd7aSJohn Baldwin.Cd "options INVARIANT_SUPPORT" , 279cd32bd7aSJohn Baldwinthe kernel will panic. 280cd32bd7aSJohn BaldwinCurrently the following base assertions are supported: 281cd32bd7aSJohn Baldwin.Bl -tag -width ".Dv RA_UNLOCKED" 282cd32bd7aSJohn Baldwin.It Dv RA_LOCKED 283cd32bd7aSJohn BaldwinAssert that current thread holds either a shared or exclusive lock 284cd32bd7aSJohn Baldwinof 285cd32bd7aSJohn Baldwin.Fa rm . 286cd32bd7aSJohn Baldwin.It Dv RA_RLOCKED 287cd32bd7aSJohn BaldwinAssert that current thread holds a shared lock of 288cd32bd7aSJohn Baldwin.Fa rm . 289cd32bd7aSJohn Baldwin.It Dv RA_WLOCKED 290cd32bd7aSJohn BaldwinAssert that current thread holds an exclusive lock of 291cd32bd7aSJohn Baldwin.Fa rm . 292cd32bd7aSJohn Baldwin.It Dv RA_UNLOCKED 293cd32bd7aSJohn BaldwinAssert that current thread holds neither a shared nor exclusive lock of 294cd32bd7aSJohn Baldwin.Fa rm . 295cd32bd7aSJohn Baldwin.El 296cd32bd7aSJohn Baldwin.Pp 297cd32bd7aSJohn BaldwinIn addition, one of the following optional flags may be specified with 298cd32bd7aSJohn Baldwin.Dv RA_LOCKED , 299cd32bd7aSJohn Baldwin.Dv RA_RLOCKED , 300cd32bd7aSJohn Baldwinor 301cd32bd7aSJohn Baldwin.Dv RA_WLOCKED : 302cd32bd7aSJohn Baldwin.Bl -tag -width ".Dv RA_NOTRECURSED" 303cd32bd7aSJohn Baldwin.It Dv RA_RECURSED 304cd32bd7aSJohn BaldwinAssert that the current thread holds a recursive lock of 305cd32bd7aSJohn Baldwin.Fa rm . 306cd32bd7aSJohn Baldwin.It Dv RA_NOTRECURSED 307cd32bd7aSJohn BaldwinAssert that the current thread does not hold a recursive lock of 308cd32bd7aSJohn Baldwin.Fa rm . 309cd32bd7aSJohn Baldwin.El 310f53d15feSStephan Uphoff.El 3111f162fefSMateusz Guzik.Bl -tag -width indent 3121f162fefSMateusz Guzik.It Fn rms_init "struct rmslock *rms" "const char *name" 3131f162fefSMateusz GuzikInitialize the sleepable read-mostly lock 3141f162fefSMateusz Guzik.Fa rms . 3151f162fefSMateusz GuzikThe 3161f162fefSMateusz Guzik.Fa name 3171f162fefSMateusz Guzikdescription is used as 3181f162fefSMateusz Guzik.Fa wmesg 3191f162fefSMateusz Guzikparameter to the 3201f162fefSMateusz Guzik.Xr msleep 9 3211f162fefSMateusz Guzikroutine. 3221f162fefSMateusz GuzikThis function must be called before any other operations on the lock. 3231f162fefSMateusz Guzik.It Fn rms_rlock "struct rmlock *rm" 3241f162fefSMateusz GuzikLock 3251f162fefSMateusz Guzik.Fa rms 3261f162fefSMateusz Guzikas a reader. 3271f162fefSMateusz GuzikIf any thread holds this lock exclusively, the current thread blocks. 3281f162fefSMateusz Guzik.It Fn rms_wlock "struct rmslock *rms" 3291f162fefSMateusz GuzikLock 3301f162fefSMateusz Guzik.Fa rms 3311f162fefSMateusz Guzikas a writer. 3321f162fefSMateusz GuzikIf the lock is already taken, the current thread blocks. 3331f162fefSMateusz GuzikThe 3341f162fefSMateusz Guzik.Fn rms_wlock 3351f162fefSMateusz Guzikfunction cannot be called recursively. 3361f162fefSMateusz Guzik.It Fn rms_runlock "struct rmslock *rms" 3371f162fefSMateusz GuzikThis function releases a shared lock previously acquired by 3381f162fefSMateusz Guzik.Fn rms_rlock . 3391f162fefSMateusz Guzik.It Fn rms_wunlock "struct rmslock *rms" 3401f162fefSMateusz GuzikThis function releases an exclusive lock previously acquired by 3411f162fefSMateusz Guzik.Fn rms_wlock . 3421f162fefSMateusz Guzik.It Fn rms_destroy "struct rmslock *rms" 3431f162fefSMateusz GuzikThis functions destroys a lock previously initialized with 3441f162fefSMateusz Guzik.Fn rms_init . 3451f162fefSMateusz GuzikThe 3461f162fefSMateusz Guzik.Fa rms 3471f162fefSMateusz Guziklock must be unlocked. 348f53d15feSStephan Uphoff.Sh SEE ALSO 349f53d15feSStephan Uphoff.Xr locking 9 , 350f53d15feSStephan Uphoff.Xr mutex 9 , 351f53d15feSStephan Uphoff.Xr panic 9 , 352f53d15feSStephan Uphoff.Xr rwlock 9 , 353f53d15feSStephan Uphoff.Xr sema 9 , 3549972df7dSDmitry Chagin.Xr sleep 9 , 355f53d15feSStephan Uphoff.Xr sx 9 356f53d15feSStephan Uphoff.Sh HISTORY 35727f21fadSGordon BerglingThese functions appeared in 358f53d15feSStephan Uphoff.Fx 7.0 . 359f53d15feSStephan Uphoff.Sh AUTHORS 360f53d15feSStephan Uphoff.An -nosplit 361f53d15feSStephan UphoffThe 362f53d15feSStephan Uphoff.Nm 363f53d15feSStephan Uphofffacility was written by 364f53d15feSStephan Uphoff.An "Stephan Uphoff" . 365f53d15feSStephan UphoffThis manual page was written by 366f53d15feSStephan Uphoff.An "Gleb Smirnoff" 367989cbe40SHiten Pandyafor rwlock and modified to reflect rmlock by 368f53d15feSStephan Uphoff.An "Stephan Uphoff" . 369f53d15feSStephan Uphoff.Sh BUGS 370989cbe40SHiten PandyaThe 371989cbe40SHiten Pandya.Nm 372989cbe40SHiten Pandyaimplementation is currently not optimized for single processor systems. 373989cbe40SHiten Pandya.Pp 37436058c09SMax Laier.Fn rm_try_rlock 37536058c09SMax Laiercan fail transiently even when there is no writer, while another reader 37636058c09SMax Laierupdates the state on the local CPU. 37736058c09SMax Laier.Pp 378989cbe40SHiten PandyaThe 379989cbe40SHiten Pandya.Nm 380c6d7cf7bSChristian Bruefferimplementation uses a single per CPU list shared by all 381989cbe40SHiten Pandyarmlocks in the system. 382c6d7cf7bSChristian BruefferIf rmlocks become popular, hashing to multiple per CPU queues may 383989cbe40SHiten Pandyabe needed to speed up the writer lock process. 384