Page MenuHomeFreeBSD

D28914.id84648.diff
No OneTemporary

D28914.id84648.diff

Index: share/man/man9/Makefile
===================================================================
--- share/man/man9/Makefile
+++ share/man/man9/Makefile
@@ -441,6 +441,7 @@
vrele.9 \
vslock.9 \
watchdog.9 \
+ zero_region.9 \
zone.9
MLINKS= unr.9 alloc_unr.9 \
Index: share/man/man9/zero_region.9
===================================================================
--- /dev/null
+++ share/man/man9/zero_region.9
@@ -0,0 +1,84 @@
+.\" 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 February 24, 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 EXAMPLES
+.Bd -literal
+static int
+write_example(struct vnode *vp)
+{
+ struct thread *td;
+ struct iovec aiov;
+ struct uio auio;
+ int error;
+
+ td = curthread;
+
+ ASSERT_VOP_ELOCKED(vp, "vnode must be locked");
+
+ 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.
+.Sh CAVEATS
+It is incorrect to assume the kernel virtual address (KVA) pointed by
+.Va zero_region
+is mapped to physically contiguous memory chunks.

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 6, 3:57 PM (7 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28449036
Default Alt Text
D28914.id84648.diff (3 KB)

Event Timeline