From owner-dev-commits-src-all@freebsd.org Tue Mar 2 09:20:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B2E8A5622FB; Tue, 2 Mar 2021 09:20:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DqWng4hWtz3LbG; Tue, 2 Mar 2021 09:20:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9408C1439D; Tue, 2 Mar 2021 09:20:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1229KdlU069346; Tue, 2 Mar 2021 09:20:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1229KdmU069345; Tue, 2 Mar 2021 09:20:39 GMT (envelope-from git) Date: Tue, 2 Mar 2021 09:20:39 GMT Message-Id: <202103020920.1229KdmU069345@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Philip Paeps Subject: git: 43afeee2fbf9 - main - share/man/man9: document zero_region(9) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43afeee2fbf99e51ffd0006e6bb4adcbbd80a6f4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 09:20:39 -0000 The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=43afeee2fbf99e51ffd0006e6bb4adcbbd80a6f4 commit 43afeee2fbf99e51ffd0006e6bb4adcbbd80a6f4 Author: Ka Ho Ng AuthorDate: 2021-03-02 09:14:05 +0000 Commit: Philip Paeps 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 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.