summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-03-25 01:38:10 +0000
committerRobert Mustacchi <rm@fingolfin.org>2020-04-02 13:26:54 +0000
commit9e88c82d66b3fb22f1b1f25cbc4632977358de62 (patch)
tree334b58f60654de48f2d12edbbeeab3a367d14bae
parent30c304d9746f4a048a7de56d31333b0fa8e43dee (diff)
downloadillumos-joyent-9e88c82d66b3fb22f1b1f25cbc4632977358de62.tar.gz
12446 3KSTAT manual pages could be clearer about data life time
Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Yuri Pankov <ypankov@fastmail.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
-rw-r--r--usr/src/man/man3kstat/kstat_chain_update.3kstat19
-rw-r--r--usr/src/man/man3kstat/kstat_lookup.3kstat22
2 files changed, 16 insertions, 25 deletions
diff --git a/usr/src/man/man3kstat/kstat_chain_update.3kstat b/usr/src/man/man3kstat/kstat_chain_update.3kstat
index 5a4a0656d3..012a4f3b08 100644
--- a/usr/src/man/man3kstat/kstat_chain_update.3kstat
+++ b/usr/src/man/man3kstat/kstat_chain_update.3kstat
@@ -7,7 +7,6 @@
.SH NAME
kstat_chain_update \- update the kstat header chain
.SH SYNOPSIS
-.LP
.nf
\fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lkstat\fR [ \fIlibrary\fR\&.\|.\|.]
#include <kstat.h>
@@ -18,8 +17,6 @@ kstat_chain_update \- update the kstat header chain
.fi
.SH DESCRIPTION
-.sp
-.LP
The \fBkstat_chain_update()\fR function brings the user's kstat header chain in
sync with that of the kernel. The kstat chain is a linked list of kstat headers
(\fBkstat_t\fR's) pointed to by \fIkc\fR->\fBkc_chain\fR, which is initialized
@@ -27,7 +24,7 @@ by \fBkstat_open\fR(3KSTAT). This chain constitutes a list of all kstats
currently in the system.
.sp
.LP
-During normal operation, the kernel creates new kstats and delete old ones as
+During normal operation, the kernel creates new kstats and deletes old ones as
various device instances are added and removed, thereby causing the user's copy
of the kstat chain to become out of date. The \fBkstat_chain_update()\fR
function detects this condition by comparing the kernel's current kstat chain
@@ -37,15 +34,18 @@ user's KCID, \fIkc\fR->\fBkc_chain_id\fR. If the KCIDs match,
kstat headers from the user's kstat chain, adds any new ones, and sets
\fIkc\fR->\fBkc_chain_id\fR to the new KCID. All other kstat headers in the
user's kstat chain are unmodified.
-.SH RETURN VALUES
.sp
.LP
+Because of the deletion process, any \fBkstat_t\fR structures retrieved by the
+\fBkstat_lookup\fR(3KSTAT) function or data pointers obtained through the
+\fBkstat_data_lookup\fR(3KSTAT) function are invalidated by a call to
+\fRkstat_chain_update\fB(). New lookup calls must be made to obtain fresh
+structures after each chain update.
+.SH RETURN VALUES
Upon successful completion, \fBkstat_chain_update()\fR returns the new KCID if
the kstat chain has changed and 0 if it has not changed. Otherwise, it returns
\(mi1 and sets \fBerrno\fR to indicate the error.
.SH ERRORS
-.sp
-.LP
The \fBkstat_chain_update()\fR function will fail if:
.sp
.ne 2
@@ -84,7 +84,6 @@ The data for the given kstat was too large to be stored in the structure.
.RE
.SH FILES
-.sp
.ne 2
.na
\fB\fB/dev/kstat\fR\fR
@@ -94,8 +93,6 @@ kernel statistics driver
.RE
.SH ATTRIBUTES
-.sp
-.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
@@ -112,7 +109,5 @@ MT-Level Unsafe
.TE
.SH SEE ALSO
-.sp
-.LP
\fBkstat\fR(3KSTAT), \fBkstat_lookup\fR(3KSTAT), \fBkstat_open\fR(3KSTAT),
\fBkstat_read\fR(3KSTAT), \fBattributes\fR(5)
diff --git a/usr/src/man/man3kstat/kstat_lookup.3kstat b/usr/src/man/man3kstat/kstat_lookup.3kstat
index 3458f61f21..7a0f9880e7 100644
--- a/usr/src/man/man3kstat/kstat_lookup.3kstat
+++ b/usr/src/man/man3kstat/kstat_lookup.3kstat
@@ -3,11 +3,10 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH KSTAT_LOOKUP 3KSTAT "Aug 3, 2004"
+.TH KSTAT_LOOKUP 3KSTAT "March 24, 2020"
.SH NAME
kstat_lookup, kstat_data_lookup \- find a kstat by name
.SH SYNOPSIS
-.LP
.nf
\fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lkstat\fR [ \fIlibrary\fR\&.\|.\|.]
#include <kstat.h>
@@ -22,8 +21,6 @@ kstat_lookup, kstat_data_lookup \- find a kstat by name
.fi
.SH DESCRIPTION
-.sp
-.LP
The \fBkstat_lookup()\fR function traverses the kstat chain,
\fIkc\fR->\fBkc_chain\fR, searching for a kstat with the same \fIks_module\fR,
\fIks_instance\fR, and \fIks_name\fR fields; this triplet uniquely identifies a
@@ -37,9 +34,15 @@ The \fBkstat_data_lookup()\fR function searches the kstat's data section for
the record with the specified \fIname\fR. This operation is valid only for
those kstat types that have named data records: \fBKSTAT_TYPE_NAMED\fR and
\fBKSTAT_TYPE_TIMER\fR.
+.SS Lifetime
+The \fBkstat_t\fR structures and any associated data are owned by the library
+and the corresponding handle, \fIkc\fR. That is, two callers with same library
+handle will generally have the same memory returned to them, though this is not
+a guaranteed part of the interface. Callers should not modify or attempt to free
+the data associated with either. Calling the \fBkstat_chain_update\fR(3KSTAT) or
+\fBkstat_close\fR(3KSTAT) functions on the handle \fIkc\fR will cause the
+pointers returned from these functions with the same handle to be invalid.
.SH RETURN VALUES
-.sp
-.LP
The \fBkstat_lookup()\fR function returns a pointer to the requested kstat if
it is found. Otherwise it returns \fINULL\fR and sets \fBerrno\fR to indicate
the error.
@@ -49,8 +52,6 @@ The \fBkstat_data_lookup()\fR function returns a pointer to the requested data
record if it is found. Otherwise it returns \fINULL\fR and sets \fBerrno\fR to
indicate the error .
.SH ERRORS
-.sp
-.LP
The \fBkstat_lookup()\fR and \fBkstat_data_lookup()\fR functions will fail if:
.sp
.ne 2
@@ -72,7 +73,6 @@ The requested kstat could not be found.
.RE
.SH FILES
-.sp
.ne 2
.na
\fB\fB/dev/kstat\fR\fR
@@ -82,8 +82,6 @@ kernel statistics driver
.RE
.SH ATTRIBUTES
-.sp
-.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
@@ -100,7 +98,5 @@ MT-Level Unsafe
.TE
.SH SEE ALSO
-.sp
-.LP
\fBkstat\fR(3KSTAT), \fBkstat_chain_update\fR(3KSTAT),
\fBkstat_open\fR(3KSTAT), \fBkstat_read\fR(3KSTAT), \fBattributes\fR(5)