Sun Jun 3 09:22:34 2018 UTC ()
Make a first pass at documenting the specificdata functionality.

XXX This is just a first pass, and I've probably made a ton of mistakes
XXX while reading the code!  Updates and corrections greatly appreciated.


(pgoyette)
diff -r1.424 -r1.425 src/share/man/man9/Makefile
diff -r0 -r1.1 src/share/man/man9/specificdata.9

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

--- src/share/man/man9/Makefile 2018/06/03 01:52:47 1.424
+++ src/share/man/man9/Makefile 2018/06/03 09:22:34 1.425
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.424 2018/06/03 01:52:47 pgoyette Exp $ 1# $NetBSD: Makefile,v 1.425 2018/06/03 09:22:34 pgoyette 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 \ 5MAN= accept_filter.9 accf_data.9 accf_http.9 \
6 altq.9 arp.9 audio.9 audio_system.9 autoconf.9 \ 6 altq.9 arp.9 audio.9 audio_system.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 \
@@ -41,27 +41,28 @@ MAN= accept_filter.9 accf_data.9 accf_ht @@ -41,27 +41,28 @@ MAN= accept_filter.9 accf_data.9 accf_ht
41 namei.9 nullop.9 opencrypto.9 optstr.9 \ 41 namei.9 nullop.9 opencrypto.9 optstr.9 \
42 panic.9 pathbuf.9 pci.9 pci_configure_bus.9 pci_intr.9 \ 42 panic.9 pathbuf.9 pci.9 pci_configure_bus.9 pci_intr.9 \
43 pci_msi.9 pckbport.9 pcmcia.9 pcq.9 pcu.9 \ 43 pci_msi.9 pckbport.9 pcmcia.9 pcq.9 pcu.9 \
44 percpu.9 pfil.9 physio.9 pmap.9 pmatch.9 pmc.9 pmf.9 pool.9 \ 44 percpu.9 pfil.9 physio.9 pmap.9 pmatch.9 pmc.9 pmf.9 pool.9 \
45 pool_cache.9 powerhook_establish.9 ppsratecheck.9 preempt.9 \ 45 pool_cache.9 powerhook_establish.9 ppsratecheck.9 preempt.9 \
46 proc_find.9 pserialize.9 pslist.9 psref.9 putter.9 \ 46 proc_find.9 pserialize.9 pslist.9 psref.9 putter.9 \
47 radio.9 ras.9 rasops.9 ratecheck.9 resettodr.9 rnd.9 rndsink.9 \ 47 radio.9 ras.9 rasops.9 ratecheck.9 resettodr.9 rnd.9 rndsink.9 \
48 roundup.9 rssadapt.9 rt_timer.9 rwlock.9 RUN_ONCE.9 STACK.9 \ 48 roundup.9 rssadapt.9 rt_timer.9 rwlock.9 RUN_ONCE.9 STACK.9 \
49 scanc.9 \ 49 scanc.9 \
50 sched_4bsd.9 sched_m2.9 scsipi.9 \ 50 sched_4bsd.9 sched_m2.9 scsipi.9 \
51 secmodel_bsd44.9 secmodel_extensions.9 \ 51 secmodel_bsd44.9 secmodel_extensions.9 \
52 secmodel_overlay.9 secmodel_securelevel.9 secmodel_suser.9 \ 52 secmodel_overlay.9 secmodel_securelevel.9 secmodel_suser.9 \
53 SET.9 setbit.9 setjmp.9 shutdownhook_establish.9 \ 53 SET.9 setbit.9 setjmp.9 shutdownhook_establish.9 \
54 signal.9 skpc.9 sockopt.9 softintr.9 spl.9 splraiseipl.9 \ 54 signal.9 skpc.9 sockopt.9 softintr.9 spl.9 specificdata.9 \
 55 splraiseipl.9 \
55 store.9 suspendsched.9 \ 56 store.9 suspendsched.9 \
56 sysctl.9 sysmon_envsys.9 sysmon_pswitch.9 sysmon_taskq.9 tc.9 \ 57 sysctl.9 sysmon_envsys.9 sysmon_pswitch.9 sysmon_taskq.9 tc.9 \
57 tcp_congctl.9 timecounter.9 time_second.9 todr.9 ts2timo.9 tvtohz.9 \ 58 tcp_congctl.9 timecounter.9 time_second.9 todr.9 ts2timo.9 tvtohz.9 \
58 ucas.9 uiomove.9 ucom.9 userret.9 \ 59 ucas.9 uiomove.9 ucom.9 userret.9 \
59 vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \ 60 vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \
60 video.9 vme.9 \ 61 video.9 vme.9 \
61 vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 \ 62 vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 \
62 ubc.9 usbd_status.9 usbdi.9 uvm.9 uvm_hotplug.9 uvm_km.9 uvm_map.9 \ 63 ubc.9 usbd_status.9 usbdi.9 uvm.9 uvm_hotplug.9 uvm_km.9 uvm_map.9 \
63 vmem.9 wapbl.9 wdc.9 workqueue.9 \ 64 vmem.9 wapbl.9 wdc.9 workqueue.9 \
64 wsbell.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \ 65 wsbell.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \
65 xcall.9 66 xcall.9
66 67
67MAN+= boothowto.9 68MAN+= boothowto.9
@@ -863,26 +864,36 @@ MLINKS+=signal.9 siginit.9 \ @@ -863,26 +864,36 @@ MLINKS+=signal.9 siginit.9 \
863 signal.9 sendsig.9 \ 864 signal.9 sendsig.9 \
864 signal.9 sigcode.9 \ 865 signal.9 sigcode.9 \
865 signal.9 sigtramp.9 866 signal.9 sigtramp.9
866MLINKS+=sockopt.9 sockopt_init.9 \ 867MLINKS+=sockopt.9 sockopt_init.9 \
867 sockopt.9 sockopt_destroy.9 \ 868 sockopt.9 sockopt_destroy.9 \
868 sockopt.9 sockopt_get.9 \ 869 sockopt.9 sockopt_get.9 \
869 sockopt.9 sockopt_getint.9 \ 870 sockopt.9 sockopt_getint.9 \
870 sockopt.9 sockopt_set.9 \ 871 sockopt.9 sockopt_set.9 \
871 sockopt.9 sockopt_setint.9 872 sockopt.9 sockopt_setint.9
872MLINKS+=softintr.9 softintr_establish.9 softintr.9 softintr_disestablish.9 \ 873MLINKS+=softintr.9 softintr_establish.9 softintr.9 softintr_disestablish.9 \
873 softintr.9 softintr_schedule.9 softintr.9 softint.9 \ 874 softintr.9 softintr_schedule.9 softintr.9 softint.9 \
874 softintr.9 softint_establish.9 softintr.9 softint_disestablish.9 \ 875 softintr.9 softint_establish.9 softintr.9 softint_disestablish.9 \
875 softintr.9 softint_schedule.9 876 softintr.9 softint_schedule.9
 877MLINKS+=specificdata.9 specificdata_domain_create.9 \
 878 specificdata.9 specificdata_domain_delete.9 \
 879 specificdata.9 specificdata_key_create.9 \
 880 specificdata.9 specificdata_key_delete.9 \
 881 specificdata.9 specificdata_init.9 \
 882 specificdata.9 specificdata_fini.9 \
 883 specificdata.9 specificdata_getspecific.9 \
 884 specificdata.9 specificdata_getspecific_unlocked.9 \
 885 specificdata.9 specificdata_setspecific.9 \
 886 specificdata.9 specificdata_setspecific_nowait .9
876MLINKS+=spl.9 spl0.9 spl.9 splbio.9 spl.9 splclock.9 spl.9 splhigh.9 \ 887MLINKS+=spl.9 spl0.9 spl.9 splbio.9 spl.9 splclock.9 spl.9 splhigh.9 \
877 spl.9 splimp.9 \ 888 spl.9 splimp.9 \
878 spl.9 spllowersoftclock.9 spl.9 splnet.9 \ 889 spl.9 spllowersoftclock.9 spl.9 splnet.9 \
879 spl.9 splsched.9 spl.9 splserial.9 \ 890 spl.9 splsched.9 spl.9 splserial.9 \
880 spl.9 splsoftclock.9 spl.9 splsoftnet.9 spl.9 splsoftserial.9 \ 891 spl.9 splsoftclock.9 spl.9 splsoftnet.9 spl.9 splsoftserial.9 \
881 spl.9 splstatclock.9 spl.9 spltty.9 spl.9 splvm.9 spl.9 splx.9 \ 892 spl.9 splstatclock.9 spl.9 spltty.9 spl.9 splvm.9 spl.9 splx.9 \
882 spl.9 splsoftbio.9 893 spl.9 splsoftbio.9
883MLINKS+=store.9 subyte.9 store.9 suibyte.9 store.9 susword.9 \ 894MLINKS+=store.9 subyte.9 store.9 suibyte.9 store.9 susword.9 \
884 store.9 suswintr.9 store.9 suword.9 store.9 suiword.9 895 store.9 suswintr.9 store.9 suword.9 store.9 suiword.9
885MLINKS+=sysctl.9 old_sysctl.9 \ 896MLINKS+=sysctl.9 old_sysctl.9 \
886 sysctl.9 sysctl_create.9 \ 897 sysctl.9 sysctl_create.9 \
887 sysctl.9 sysctl_createv.9 \ 898 sysctl.9 sysctl_createv.9 \
888 sysctl.9 sysctl_destroy.9 \ 899 sysctl.9 sysctl_destroy.9 \

File Added: src/share/man/man9/specificdata.9
.\"	$NetBSD: specificdata.9,v 1.1 2018/06/03 09:22:34 pgoyette Exp $
.\"
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jason R. Thorpe
.\"
.\" 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 June 3, 2018
.Dt MODULE 9
.Os
.Sh NAME
.Nm specificdata ,
.Nm specificdata_domain_create ,
.Nm specificdata_domain_delete ,
.Nm specificdata_key_create ,
.Nm specificdata_key_delete ,
.Nm specificdata_init ,
.Nm specificdata_fini ,
.Nm specificdata_getspecific ,
.Nm specificdata_getspecific_unlocked ,
.Nm specificdata_setspecific ,
.Nm specificdata_setspecific_nowait
.Nd manipulate arbitrary data attached to objects
.Sh SYNOPSIS
.In sys/specificdata.h
.Ft specificdata_domain_t
.Fn specificdata_domain_create
.Ft void
.Fn specificdata_domain_delete "specificdata_domain_t sd"
.Ft int
.Fn specificdata_key_create "specificdata_domain_t sd" \
"specificdata_key_t *keyp" "specificdata_dtor_t dtor"
.Ft void
.Fn specificdata_key_delete "specificdata_domain_t sd" "specificdata_key_t key"
.Ft int
.Fn specificdata_init "specificdata_domain_t sd" "specificdata_reference *ref"
.Ft void
.Fn specificdata_fini "specificdata_domain_t sd" "specificdata_reference *ref"
.Ft "void *"
.Fn specificdata_getspecific "specificdata_domain_t sd" \
"specificdata_reference *ref" "specificdata_key_t key"
.Ft "void *"
.Fn specificdata_getspecific_unlocked "specificdata_domain_t sd" \
"specificdata_reference *ref" "specificdata_key_t key"
.Ft void
.Fn specificdata_setspecific "specificdata_domain_t sd" \
"specificdata_reference *ref" "specificdata_key_t key" "void *data"
.Ft int
.Fn specificdata_setspecific_nowait "specificdata_domain_t sd" \
"specificdata_reference *ref" "specificdata_key_t key" "void *data"
.Sh DESCRIPTION
The
.Nm
facility provides a mechanism for attaching arbitrary data to the objects
within a particular domain.
.Sh FUNCTIONS
.Bl -tag -width abcd
.It Fn specificdata_domain_create
Create a new domain.
.It Fn specificdata_domain_delete sd
Delete a domain.
.It Fn specificdata_key_create sd keyp dtor
Create a new key for the domain.
The
.Fa dtor
argument specifies a destructor which is called when an item with the
specified key is deleted.
.It Fn specificdata_key_delete sd key
Delete a key for the domain, and delete any associated values.
.It Fn specificdata_init sd ref
Initialize the
.Nm
container
.Fa ref
for use in the specified domain.
.It Fn specificdata_fini sd ref
Destroy the
.Nm
container
.Fa ref ,
and destroy all of the data values stuffed into the container.
.It Fn specificdata_getspecific "specificdata_domain_t sd" \
"specificdata_reference *ref" "specificdata_key_t key"
Retrieve the data value from the
.Nm
container
.Fa ref
associated with
.Fa key .
.It Fn specificdata_getspecific_unlocked sd ref key
Retrieve the data value from the
.Nm
container
.Fa ref
associated with
.Fa key
in a lockless manner.
Care must be taken to ensure that no other thread could cause
.Fa ref
to become invalid (i.e. point at the wrong container) by issuing a
.Fn setspecific
call or by destroying the container.
.It Fn specificdata_setspecific sd ref key data
Store the value
.Fa data
in the
.Nm
container
.Fa ref
and associate it with
.Fa key .
If a value has previously been set, the new value replaces the original
value.
.It Fn specificdata_setspecific_nowait sd ref key data
(Unimplemented)
.El
.Sh CODE REFERENCES
The 
.Nm
functionality is implemented in
.Pa sys/kern/subr_specificdata.c .
.Pp
The header file
.In sys/sys/specificdata.h
describes the public interface.
.Sh HISTORY
The
.Nm
subsystem first appeared in
.Nx 4.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
system was written by
.An Jason Thorpe Aq Mt thorpej@NetBSD.org .
This manual page was written by
.An Paul Goyette Aq Mt pgoyette@NetBSD.org .