Date: Tue, 2 Mar 2021 09:20:39 GMT From: Philip Paeps <philip@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 43afeee2fbf9 - main - share/man/man9: document zero_region(9) Message-ID: <202103020920.1229KdmU069345@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=43afeee2fbf99e51ffd0006e6bb4adcbbd80a6f4 commit 43afeee2fbf99e51ffd0006e6bb4adcbbd80a6f4 Author: Ka Ho Ng <khng300@gmail.com> AuthorDate: 2021-03-02 09:14:05 +0000 Commit: Philip Paeps <philip@FreeBSD.org> CommitDate: 2021-03-02 09:14:06 +0000 share/man/man9: document zero_region(9) The zero_region() kernel interface was previously undocumented. Add a new zero_region(9) manual page to document it. Submitted by: Ka Ho Ng <khng@freebsdfoundation.org> Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28914 --- share/man/man9/Makefile | 1 + share/man/man9/zero_region.9 | 86 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 50e760d3e047..64e234c3d696 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -442,6 +442,7 @@ MAN= accept_filter.9 \ vrele.9 \ vslock.9 \ watchdog.9 \ + zero_region.9 \ zone.9 MLINKS= unr.9 alloc_unr.9 \ diff --git a/share/man/man9/zero_region.9 b/share/man/man9/zero_region.9 new file mode 100644 index 000000000000..27b1b50be14d --- /dev/null +++ b/share/man/man9/zero_region.9 @@ -0,0 +1,86 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2021 The FreeBSD Foundation +.\" +.\" 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 AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD$ +.\" +.Dd March 2, 2021 +.Dt ZERO_REGION 9 +.Os +.Sh NAME +.Nm zero_region +.Nd Read-only region prefilled with zeroes +.Sh SYNOPSIS +.In sys/param.h +.In sys/systm.h +.In vm/vm_param.h +.Vt extern const void *zero_region ; +.Sh DESCRIPTION +The global variable +.Va zero_region +points to a read-only region prefilled with zeroes. +The size of the region is specified by the +.Dv ZERO_REGION_SIZE +macro. +.Sh IMPLEMENTATION NOTES +The region +.Va zero_region +points to is mapped to the same page multiple times. +.Sh EXAMPLES +.Bd -literal +/* + * This function writes zeroes to the vnode at offset 0 + * with ZERO_REGION_SIZE length. + */ +static int +write_example(struct vnode *vp) +{ + struct thread *td; + struct iovec aiov; + struct uio auio; + int error; + + td = curthread; + + aiov.iov_base = __DECONST(void *, zero_region); + aiov.iov_len = ZERO_REGION_SIZE; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = 0; + auio.uio_resid = ZERO_REGION_SIZE; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_td = td; + + error = VOP_WRITE(vp, &auio, 0, td->td_ucred); + return (error); +} +.Ed +.Sh SEE ALSO +.Xr pmap 9 , +.Xr vm_map 9 +.Sh AUTHORS +This manual page was written by +.An Ka Ho Ng Aq Mt khng@FreeBSDFoundation.org +under sponsorship from the FreeBSD Foundation.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103020920.1229KdmU069345>