Sat Feb 12 17:10:20 2022 UTC ()
__cpu_simple_lock(9): New man page.

This doesn't mean you should use it!  Mostly it's to document the
semantics to help understand existing uses, which should not
proliferate, and audit definitions.


(riastradh)
diff -r1.2410 -r1.2411 src/distrib/sets/lists/comp/mi
diff -r1.462 -r1.463 src/share/man/man9/Makefile
diff -r0 -r1.1 src/share/man/man9/__cpu_simple_lock.9

cvs diff -r1.2410 -r1.2411 src/distrib/sets/lists/comp/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/comp/mi 2022/01/22 08:58:48 1.2410
+++ src/distrib/sets/lists/comp/mi 2022/02/12 17:10:20 1.2411
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.2410 2022/01/22 08:58:48 skrll Exp $ 1# $NetBSD: mi,v 1.2411 2022/02/12 17:10:20 riastradh Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4./etc/mtree/set.comp comp-sys-root 4./etc/mtree/set.comp comp-sys-root
5./usr/bin/addr2line comp-debug-bin binutils 5./usr/bin/addr2line comp-debug-bin binutils
6./usr/bin/ar comp-util-bin binutils 6./usr/bin/ar comp-util-bin binutils
7./usr/bin/as comp-util-bin binutils 7./usr/bin/as comp-util-bin binutils
8./usr/bin/asa comp-fortran-bin 8./usr/bin/asa comp-fortran-bin
9./usr/bin/atf-compile comp-obsolete obsolete 9./usr/bin/atf-compile comp-obsolete obsolete
10./usr/bin/c++ comp-cxx-bin gcccmds 10./usr/bin/c++ comp-cxx-bin gcccmds
11./usr/bin/c++filt comp-cxx-bin binutils 11./usr/bin/c++filt comp-cxx-bin binutils
12./usr/bin/c11 comp-c-bin 12./usr/bin/c11 comp-c-bin
13./usr/bin/c89 comp-c-bin 13./usr/bin/c89 comp-c-bin
14./usr/bin/c99 comp-c-bin 14./usr/bin/c99 comp-c-bin
@@ -11282,26 +11282,34 @@ @@ -11282,26 +11282,34 @@
11282./usr/share/man/cat9/VOP_SETACL.0 comp-sys-catman .cat 11282./usr/share/man/cat9/VOP_SETACL.0 comp-sys-catman .cat
11283./usr/share/man/cat9/VOP_SETATTR.0 comp-sys-catman .cat 11283./usr/share/man/cat9/VOP_SETATTR.0 comp-sys-catman .cat
11284./usr/share/man/cat9/VOP_SETEXTATTR.0 comp-sys-catman .cat 11284./usr/share/man/cat9/VOP_SETEXTATTR.0 comp-sys-catman .cat
11285./usr/share/man/cat9/VOP_STRATEGY.0 comp-sys-catman .cat 11285./usr/share/man/cat9/VOP_STRATEGY.0 comp-sys-catman .cat
11286./usr/share/man/cat9/VOP_SYMLINK.0 comp-sys-catman .cat 11286./usr/share/man/cat9/VOP_SYMLINK.0 comp-sys-catman .cat
11287./usr/share/man/cat9/VOP_TRUNCATE.0 comp-obsolete obsolete 11287./usr/share/man/cat9/VOP_TRUNCATE.0 comp-obsolete obsolete
11288./usr/share/man/cat9/VOP_UNLOCK.0 comp-sys-catman .cat 11288./usr/share/man/cat9/VOP_UNLOCK.0 comp-sys-catman .cat
11289./usr/share/man/cat9/VOP_UPDATE.0 comp-obsolete obsolete 11289./usr/share/man/cat9/VOP_UPDATE.0 comp-obsolete obsolete
11290./usr/share/man/cat9/VOP_VALLOC.0 comp-obsolete obsolete 11290./usr/share/man/cat9/VOP_VALLOC.0 comp-obsolete obsolete
11291./usr/share/man/cat9/VOP_VFREE.0 comp-obsolete obsolete 11291./usr/share/man/cat9/VOP_VFREE.0 comp-obsolete obsolete
11292./usr/share/man/cat9/VOP_WHITEOUT.0 comp-sys-catman .cat 11292./usr/share/man/cat9/VOP_WHITEOUT.0 comp-sys-catman .cat
11293./usr/share/man/cat9/VOP_WRITE.0 comp-sys-catman .cat 11293./usr/share/man/cat9/VOP_WRITE.0 comp-sys-catman .cat
11294./usr/share/man/cat9/VREF.0 comp-obsolete obsolete 11294./usr/share/man/cat9/VREF.0 comp-obsolete obsolete
 11295./usr/share/man/cat9/__SIMPLELOCK_LOCKED_P.0 comp-sys-catman .cat
 11296./usr/share/man/cat9/__SIMPLELOCK_UNLOCKED_P.0 comp-sys-catman .cat
 11297./usr/share/man/cat9/__cpu_simple_lock_clear.0 comp-sys-catman .cat
 11298./usr/share/man/cat9/__cpu_simple_lock_init.0 comp-sys-catman .cat
 11299./usr/share/man/cat9/__cpu_simple_lock_set.0 comp-sys-catman .cat
 11300./usr/share/man/cat9/__cpu_simple_lock_try.0 comp-sys-catman .cat
 11301./usr/share/man/cat9/__cpu_simple_lock.0 comp-sys-catman .cat
 11302./usr/share/man/cat9/__cpu_simple_unlock.0 comp-sys-catman .cat
11295./usr/share/man/cat9/acl.0 comp-sys-catman .cat 11303./usr/share/man/cat9/acl.0 comp-sys-catman .cat
11296./usr/share/man/cat9/accept_filt_add.0 comp-sys-catman .cat 11304./usr/share/man/cat9/accept_filt_add.0 comp-sys-catman .cat
11297./usr/share/man/cat9/accept_filt_del.0 comp-sys-catman .cat 11305./usr/share/man/cat9/accept_filt_del.0 comp-sys-catman .cat
11298./usr/share/man/cat9/accept_filt_generic_mod_event.0 comp-sys-catman .cat 11306./usr/share/man/cat9/accept_filt_generic_mod_event.0 comp-sys-catman .cat
11299./usr/share/man/cat9/accept_filt_get.0 comp-sys-catman .cat 11307./usr/share/man/cat9/accept_filt_get.0 comp-sys-catman .cat
11300./usr/share/man/cat9/accept_filter.0 comp-sys-catman .cat 11308./usr/share/man/cat9/accept_filter.0 comp-sys-catman .cat
11301./usr/share/man/cat9/access.0 comp-obsolete obsolete 11309./usr/share/man/cat9/access.0 comp-obsolete obsolete
11302./usr/share/man/cat9/accf_data.0 comp-sys-catman .cat 11310./usr/share/man/cat9/accf_data.0 comp-sys-catman .cat
11303./usr/share/man/cat9/accf_http.0 comp-sys-catman .cat 11311./usr/share/man/cat9/accf_http.0 comp-sys-catman .cat
11304./usr/share/man/cat9/allocbuf.0 comp-sys-catman .cat 11312./usr/share/man/cat9/allocbuf.0 comp-sys-catman .cat
11305./usr/share/man/cat9/altq.0 comp-sys-catman .cat 11313./usr/share/man/cat9/altq.0 comp-sys-catman .cat
11306./usr/share/man/cat9/aprint_debug.0 comp-sys-catman .cat 11314./usr/share/man/cat9/aprint_debug.0 comp-sys-catman .cat
11307./usr/share/man/cat9/aprint_debug_dev.0 comp-sys-catman .cat 11315./usr/share/man/cat9/aprint_debug_dev.0 comp-sys-catman .cat
@@ -19512,26 +19520,34 @@ @@ -19512,26 +19520,34 @@
19512./usr/share/man/html9/VOP_RENAME.html comp-sys-htmlman html 19520./usr/share/man/html9/VOP_RENAME.html comp-sys-htmlman html
19513./usr/share/man/html9/VOP_REVOKE.html comp-sys-htmlman html 19521./usr/share/man/html9/VOP_REVOKE.html comp-sys-htmlman html
19514./usr/share/man/html9/VOP_RMDIR.html comp-sys-htmlman html 19522./usr/share/man/html9/VOP_RMDIR.html comp-sys-htmlman html
19515./usr/share/man/html9/VOP_SEEK.html comp-sys-htmlman html 19523./usr/share/man/html9/VOP_SEEK.html comp-sys-htmlman html
19516./usr/share/man/html9/VOP_SETACL.html comp-sys-htmlman html 19524./usr/share/man/html9/VOP_SETACL.html comp-sys-htmlman html
19517./usr/share/man/html9/VOP_SETATTR.html comp-sys-htmlman html 19525./usr/share/man/html9/VOP_SETATTR.html comp-sys-htmlman html
19518./usr/share/man/html9/VOP_SETEXTATTR.html comp-sys-htmlman html 19526./usr/share/man/html9/VOP_SETEXTATTR.html comp-sys-htmlman html
19519./usr/share/man/html9/VOP_STRATEGY.html comp-sys-htmlman html 19527./usr/share/man/html9/VOP_STRATEGY.html comp-sys-htmlman html
19520./usr/share/man/html9/VOP_SYMLINK.html comp-sys-htmlman html 19528./usr/share/man/html9/VOP_SYMLINK.html comp-sys-htmlman html
19521./usr/share/man/html9/VOP_UNLOCK.html comp-sys-htmlman html 19529./usr/share/man/html9/VOP_UNLOCK.html comp-sys-htmlman html
19522./usr/share/man/html9/VOP_WHITEOUT.html comp-sys-htmlman html 19530./usr/share/man/html9/VOP_WHITEOUT.html comp-sys-htmlman html
19523./usr/share/man/html9/VOP_WRITE.html comp-sys-htmlman html 19531./usr/share/man/html9/VOP_WRITE.html comp-sys-htmlman html
19524./usr/share/man/html9/VREF.html comp-obsolete obsolete 19532./usr/share/man/html9/VREF.html comp-obsolete obsolete
 19533./usr/share/man/html9/__SIMPLELOCK_LOCKED_P.html comp-sys-htmlman html
 19534./usr/share/man/html9/__SIMPLELOCK_UNLOCKED_P.html comp-sys-htmlman html
 19535./usr/share/man/html9/__cpu_simple_lock_clear.html comp-sys-htmlman html
 19536./usr/share/man/html9/__cpu_simple_lock_init.html comp-sys-htmlman html
 19537./usr/share/man/html9/__cpu_simple_lock_set.html comp-sys-htmlman html
 19538./usr/share/man/html9/__cpu_simple_lock_try.html comp-sys-htmlman html
 19539./usr/share/man/html9/__cpu_simple_lock.html comp-sys-htmlman html
 19540./usr/share/man/html9/__cpu_simple_unlock.html comp-sys-htmlman html
19525./usr/share/man/html9/acl.html comp-sys-htmlman html 19541./usr/share/man/html9/acl.html comp-sys-htmlman html
19526./usr/share/man/html9/accept_filt_add.html comp-sys-htmlman html 19542./usr/share/man/html9/accept_filt_add.html comp-sys-htmlman html
19527./usr/share/man/html9/accept_filt_del.html comp-sys-htmlman html 19543./usr/share/man/html9/accept_filt_del.html comp-sys-htmlman html
19528./usr/share/man/html9/accept_filt_generic_mod_event.html comp-sys-htmlman html 19544./usr/share/man/html9/accept_filt_generic_mod_event.html comp-sys-htmlman html
19529./usr/share/man/html9/accept_filt_get.html comp-sys-htmlman html 19545./usr/share/man/html9/accept_filt_get.html comp-sys-htmlman html
19530./usr/share/man/html9/accept_filter.html comp-sys-htmlman html 19546./usr/share/man/html9/accept_filter.html comp-sys-htmlman html
19531./usr/share/man/html9/accf_data.html comp-sys-htmlman html 19547./usr/share/man/html9/accf_data.html comp-sys-htmlman html
19532./usr/share/man/html9/accf_http.html comp-sys-htmlman html 19548./usr/share/man/html9/accf_http.html comp-sys-htmlman html
19533./usr/share/man/html9/allocbuf.html comp-sys-htmlman html 19549./usr/share/man/html9/allocbuf.html comp-sys-htmlman html
19534./usr/share/man/html9/altq.html comp-sys-htmlman html 19550./usr/share/man/html9/altq.html comp-sys-htmlman html
19535./usr/share/man/html9/aprint_debug.html comp-sys-htmlman html 19551./usr/share/man/html9/aprint_debug.html comp-sys-htmlman html
19536./usr/share/man/html9/aprint_debug_dev.html comp-sys-htmlman html 19552./usr/share/man/html9/aprint_debug_dev.html comp-sys-htmlman html
19537./usr/share/man/html9/aprint_debug_ifnet.html comp-sys-htmlman html 19553./usr/share/man/html9/aprint_debug_ifnet.html comp-sys-htmlman html
@@ -27845,26 +27861,34 @@ @@ -27845,26 +27861,34 @@
27845./usr/share/man/man9/VOP_SETACL.9 comp-sys-man .man 27861./usr/share/man/man9/VOP_SETACL.9 comp-sys-man .man
27846./usr/share/man/man9/VOP_SETATTR.9 comp-sys-man .man 27862./usr/share/man/man9/VOP_SETATTR.9 comp-sys-man .man
27847./usr/share/man/man9/VOP_SETEXTATTR.9 comp-sys-man .man 27863./usr/share/man/man9/VOP_SETEXTATTR.9 comp-sys-man .man
27848./usr/share/man/man9/VOP_STRATEGY.9 comp-sys-man .man 27864./usr/share/man/man9/VOP_STRATEGY.9 comp-sys-man .man
27849./usr/share/man/man9/VOP_SYMLINK.9 comp-sys-man .man 27865./usr/share/man/man9/VOP_SYMLINK.9 comp-sys-man .man
27850./usr/share/man/man9/VOP_TRUNCATE.9 comp-obsolete obsolete 27866./usr/share/man/man9/VOP_TRUNCATE.9 comp-obsolete obsolete
27851./usr/share/man/man9/VOP_UNLOCK.9 comp-sys-man .man 27867./usr/share/man/man9/VOP_UNLOCK.9 comp-sys-man .man
27852./usr/share/man/man9/VOP_UPDATE.9 comp-obsolete obsolete 27868./usr/share/man/man9/VOP_UPDATE.9 comp-obsolete obsolete
27853./usr/share/man/man9/VOP_VALLOC.9 comp-obsolete obsolete 27869./usr/share/man/man9/VOP_VALLOC.9 comp-obsolete obsolete
27854./usr/share/man/man9/VOP_VFREE.9 comp-obsolete obsolete 27870./usr/share/man/man9/VOP_VFREE.9 comp-obsolete obsolete
27855./usr/share/man/man9/VOP_WHITEOUT.9 comp-sys-man .man 27871./usr/share/man/man9/VOP_WHITEOUT.9 comp-sys-man .man
27856./usr/share/man/man9/VOP_WRITE.9 comp-sys-man .man 27872./usr/share/man/man9/VOP_WRITE.9 comp-sys-man .man
27857./usr/share/man/man9/VREF.9 comp-obsolete obsolete 27873./usr/share/man/man9/VREF.9 comp-obsolete obsolete
 27874./usr/share/man/man9/__SIMPLELOCK_LOCKED_P.9 comp-sys-man .man
 27875./usr/share/man/man9/__SIMPLELOCK_UNLOCKED_P.9 comp-sys-man .man
 27876./usr/share/man/man9/__cpu_simple_lock_clear.9 comp-sys-man .man
 27877./usr/share/man/man9/__cpu_simple_lock_init.9 comp-sys-man .man
 27878./usr/share/man/man9/__cpu_simple_lock_set.9 comp-sys-man .man
 27879./usr/share/man/man9/__cpu_simple_lock_try.9 comp-sys-man .man
 27880./usr/share/man/man9/__cpu_simple_lock.9 comp-sys-man .man
 27881./usr/share/man/man9/__cpu_simple_unlock.9 comp-sys-man .man
27858./usr/share/man/man9/acl.9 comp-sys-man .man 27882./usr/share/man/man9/acl.9 comp-sys-man .man
27859./usr/share/man/man9/accept_filt_add.9 comp-sys-man .man 27883./usr/share/man/man9/accept_filt_add.9 comp-sys-man .man
27860./usr/share/man/man9/accept_filt_del.9 comp-sys-man .man 27884./usr/share/man/man9/accept_filt_del.9 comp-sys-man .man
27861./usr/share/man/man9/accept_filt_generic_mod_event.9 comp-sys-man .man 27885./usr/share/man/man9/accept_filt_generic_mod_event.9 comp-sys-man .man
27862./usr/share/man/man9/accept_filt_get.9 comp-sys-man .man 27886./usr/share/man/man9/accept_filt_get.9 comp-sys-man .man
27863./usr/share/man/man9/accept_filter.9 comp-sys-man .man 27887./usr/share/man/man9/accept_filter.9 comp-sys-man .man
27864./usr/share/man/man9/access.9 comp-obsolete obsolete 27888./usr/share/man/man9/access.9 comp-obsolete obsolete
27865./usr/share/man/man9/accf_data.9 comp-sys-man .man 27889./usr/share/man/man9/accf_data.9 comp-sys-man .man
27866./usr/share/man/man9/accf_http.9 comp-sys-man .man 27890./usr/share/man/man9/accf_http.9 comp-sys-man .man
27867./usr/share/man/man9/allocbuf.9 comp-sys-man .man 27891./usr/share/man/man9/allocbuf.9 comp-sys-man .man
27868./usr/share/man/man9/altq.9 comp-sys-man .man 27892./usr/share/man/man9/altq.9 comp-sys-man .man
27869./usr/share/man/man9/aprint_debug.9 comp-sys-man .man 27893./usr/share/man/man9/aprint_debug.9 comp-sys-man .man
27870./usr/share/man/man9/aprint_debug_dev.9 comp-sys-man .man 27894./usr/share/man/man9/aprint_debug_dev.9 comp-sys-man .man

cvs diff -r1.462 -r1.463 src/share/man/man9/Makefile (expand / switch to unified diff)

--- src/share/man/man9/Makefile 2022/01/17 22:47:43 1.462
+++ src/share/man/man9/Makefile 2022/02/12 17:10:20 1.463
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.462 2022/01/17 22:47:43 christos Exp $ 1# $NetBSD: Makefile,v 1.463 2022/02/12 17:10:20 riastradh Exp $
2 2
3# Makefile for section 9 (kernel function and variable) manual pages. 3# Makefile for section 9 (kernel function and variable) manual pages.
4 4
5MAN= accept_filter.9 accf_data.9 accf_http.9 acl.9 \ 5MAN= accept_filter.9 accf_data.9 accf_http.9 acl.9 \
6 altq.9 arp.9 audio.9 autoconf.9 \ 6 altq.9 arp.9 audio.9 autoconf.9 \
7 bcdtobin.9 bcmp.9 bcopy.9 bintime_add.9 bluetooth.9 boothowto.9 bpf.9 \ 7 bcdtobin.9 bcmp.9 bcopy.9 bintime_add.9 bluetooth.9 boothowto.9 bpf.9 \
8 buffercache.9 bufferio.9 bufq.9 bus_dma.9 bus_space.9 byteorder.9 \ 8 buffercache.9 bufferio.9 bufq.9 bus_dma.9 bus_space.9 byteorder.9 \
9 bzero.9 \ 9 bzero.9 \
10 callback.9 callout.9 cardbus.9 clock.9 cnmagic.9 condvar.9 config.9 \ 10 callback.9 callout.9 cardbus.9 clock.9 cnmagic.9 condvar.9 config.9 \
11 cons.9 copy.9 coredump_write.9 \ 11 cons.9 copy.9 coredump_write.9 \
12 cpu_configure.9 cpu_coredump.9 cpu_dumpconf.9 \ 12 cpu_configure.9 cpu_coredump.9 cpu_dumpconf.9 \
13 cpu_lwp_fork.9 \ 13 cpu_lwp_fork.9 \
14 cpu_idle.9 cpu_initclocks.9 cpu_need_resched.9 \ 14 cpu_idle.9 cpu_initclocks.9 cpu_need_resched.9 \
@@ -61,26 +61,35 @@ MAN= accept_filter.9 accf_data.9 accf_ht @@ -61,26 +61,35 @@ MAN= accept_filter.9 accf_data.9 accf_ht
61 tcp_congctl.9 thmap.9 threadpool.9 timecounter.9 time_second.9 todr.9 \ 61 tcp_congctl.9 thmap.9 threadpool.9 timecounter.9 time_second.9 todr.9 \
62 ts2timo.9 tvtohz.9 \ 62 ts2timo.9 tvtohz.9 \
63 ubc.9 ucas.9 ucom.9 ufetch.9 uiomove.9 \ 63 ubc.9 ucas.9 ucom.9 ufetch.9 uiomove.9 \
64 usbd_status.9 usbdi.9 usbnet.9 \ 64 usbd_status.9 usbdi.9 usbnet.9 \
65 userret.9 ustore.9 \ 65 userret.9 ustore.9 \
66 uvm.9 uvm_hotplug.9 uvm_km.9 uvm_map.9 \ 66 uvm.9 uvm_hotplug.9 uvm_km.9 uvm_map.9 \
67 vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \ 67 vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \
68 video.9 vme.9 vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 vmem.9 \ 68 video.9 vme.9 vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 vmem.9 \
69 wapbl.9 wdc.9 workqueue.9 \ 69 wapbl.9 wdc.9 workqueue.9 \
70 wsbell.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \ 70 wsbell.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \
71 xcall.9 \ 71 xcall.9 \
72 VOP_ACLCHECK.9 VOP_GETACL.9 VOP_SETACL.9 72 VOP_ACLCHECK.9 VOP_GETACL.9 VOP_SETACL.9
73 73
 74MAN+= __cpu_simple_lock.9
 75MLINKS+=__cpu_simple_lock.9 __SIMPLELOCK_LOCKED_P.9 \
 76 __cpu_simple_lock.9 __SIMPLELOCK_UNLOCKED_P.9 \
 77 __cpu_simple_lock.9 __cpu_simple_lock_clear.9 \
 78 __cpu_simple_lock.9 __cpu_simple_lock_init.9 \
 79 __cpu_simple_lock.9 __cpu_simple_lock_set.9 \
 80 __cpu_simple_lock.9 __cpu_simple_lock_try.9 \
 81 __cpu_simple_lock.9 __cpu_simple_unlock.9
 82
74MAN+= atomic_loadstore.9 83MAN+= atomic_loadstore.9
75MLINKS+=atomic_loadstore.9 atomic_load_acquire.9 \ 84MLINKS+=atomic_loadstore.9 atomic_load_acquire.9 \
76 atomic_loadstore.9 atomic_load_consume.9 \ 85 atomic_loadstore.9 atomic_load_consume.9 \
77 atomic_loadstore.9 atomic_load_relaxed.9 \ 86 atomic_loadstore.9 atomic_load_relaxed.9 \
78 atomic_loadstore.9 atomic_store_relaxed.9 \ 87 atomic_loadstore.9 atomic_store_relaxed.9 \
79 atomic_loadstore.9 atomic_store_release.9 88 atomic_loadstore.9 atomic_store_release.9
80 89
81MAN+= boothowto.9 90MAN+= boothowto.9
82MLINKS+=boothowto.9 BOOT_FLAG.9 91MLINKS+=boothowto.9 BOOT_FLAG.9
83 92
84MAN+= cprng.9 93MAN+= cprng.9
85MLINKS+=cprng.9 cprng_strong.9 \ 94MLINKS+=cprng.9 cprng_strong.9 \
86 cprng.9 cprng_strong_create.9 \ 95 cprng.9 cprng_strong_create.9 \

File Added: src/share/man/man9/__cpu_simple_lock.9
.\"	$NetBSD: __cpu_simple_lock.9,v 1.1 2022/02/12 17:10:20 riastradh Exp $
.\"
.\" Copyright (c) 2022 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 12, 2022
.Dt __CPU_SIMPLE_LOCK 9
.Os
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh NAME
.Nm __cpu_simple_lock
.Nd simple spin locks
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh SYNOPSIS
.In sys/lock.h
.\"
.Ft void
.Fn __cpu_simple_lock_init "__cpu_simple_lock_t *lock"
.\"
.Ft void
.Fn __cpu_simple_lock "__cpu_simple_lock_t *lock"
.Ft int
.Fn __cpu_simple_lock_try "__cpu_simple_lock *lock"
.Ft void
.Fn __cpu_simple_unlock "__cpu_simple_lock_t *lock"
.\"
.Ft int
.Fn __SIMPLELOCK_LOCKED_P "__cpu_simple_lock *lock"
.\"
.Fd "/* obsolete and for ABI compat only -- do not use */"
.Ft void
.Fn __cpu_simple_lock_set "__cpu_simple_Lock *lock"
.Ft void
.Fn __cpu_simple_lock_clear "__cpu_simple_lock *lock"
.Ft int
.Fn __SIMPLELOCK_UNLOCKED_P "__cpu_simple_lock *lock"
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh DESCRIPTION
The
.Nm
functions provide a simple spin-lock facility for limited purposes that
cannot be served by
.Xr mutex 9 ,
such as inside the implementation of
.Xr mutex 9
itself on platforms with limited atomic read/modify/write operations.
.Pp
.Nm
is very limited:
.Bl -bullet
.It
.Nm
provides no debugging or diagnostic support through the
.Dv LOCKDEBUG
option.
.It
.Nm
does not synchronize between code on a CPU and interrupt handlers
running on that CPU \(em you must use it with
.Xr spl 9
for any locks that may be taken in interrupt context; failing to do so
will likely lead to hard-to-debug deadlock.
.It
.Nm
does not block preemption, so a thread holding a lock may be preempted,
potentially requiring other callers to spin for long durations until
the scheduler runs the holder again.
.It
.Nm
does no exponential backoff to reduce memory traffic during
contention.
.El
.Pp
Unless you know what you are doing, you should use
.Xr mutex 9
instead.
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh FUNCTIONS
.Bl -tag -width abcd
.It Fn __cpu_simple_lock_init lock
Initialize
.Fa lock
for use with the other
.Nm
functions.
.Pp
The caller is responsible for ensuring
.Fn __cpu_simple_lock_init
happens before any use of the other functions.
.Fn __cpu_simple_lock_init
implies no particular memory ordering on its own.
.\""""""""""""""""
.It Fn __cpu_simple_lock lock
Acquire
.Fa lock ,
waiting until it is released if currently held.
.Pp
Any memory operations preceding the previous
.Fn __cpu_simple_unlock
call that released the lock happen before any memory operations after
the next
.Fn __cpu_simple_lock
call that acquires it.
.\""""""""""""""""
.It Fn __cpu_simple_lock_try lock
Try to acquire
.Fa lock ,
without waiting if it is currently held.
Return 1 if successful, 0 if not.
.Pp
Any memory operations preceding the previous
.Fn __cpu_simple_unlock
call that released the lock happen before any memory operations after
the next
.Em successful
.Fn __cpu_simple_lock_try
call that acquires it.
.\""""""""""""""""
.It Fn __cpu_simple_unlock lock
Release
.Fa lock .
.Pp
Any memory operations preceding
.Fn __cpu_simple_unlock
happen before the next call to
.Fn __cpu_simple_lock ,
or the next successful call to
.Fn __cpu_simple_lock_try ,
that acquires
.Fa lock .
.\""""""""""""""""
.It Fn __SIMPLELOCK_LOCKED_P lock
True if
.Fa lock
is currently locked, by anyone.
.Pp
This is normally only used for diagnostic assertions, or for loops
around
.Fn __cpu_simple_lock_try
that also have higher-level functions like blocking interrupts and
performing exponential backoff.
.Pp
No memory ordering is implied.
.El
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh OBSOLETE FUNCTIONS
The following functions abuse the
.Vt __cpu_simple_lock_t
type to store a boolean.
They are used inside the
.Xr pthread 3
library, and were included in the library ABI, so they can't be removed
without breaking the
.Xr pthread 3
ABI.
Do not use these in new code
.Po
except
.Fn __SIMPLELOCK_LOCKED_P
.Pc .
.Bl -tag -width ".Fn __SIMPLELOCK_UNLOCKED_P lock"
.It Fn __cpu_simple_lock_set lock
Set
.Fa lock
to true.
.It Fn __cpu_simple_lock_clear lock
Set
.Fa lock
to false.
.It Fn __SIMPLELOCK_LOCKED_P lock
True iff
.Fa lock
is true.
.It Fn __SIMPLELOCK_UNLOCKED_P lock
True iff
.Fa lock
is false.
.El
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh CODE REFERENCES
The
.Nm
functions are implemented in
.Pa sys/arch/$ARCH/include/lock.h .
.Pp
A machine-independent implementation, using compiler support for
atomic and memory barrier builtins, is available in
.Pa sys/sys/common_lock.h .
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh SEE ALSO
.Xr locking 9 ,
.Xr mutex 9
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh HISTORY
.Nm
appeared a long time ago.