.\"	$NetBSD: uvm_obj_wirepages.9,v 1.2 2024/06/14 14:36:32 uwe Exp $
.\"
.\" Copyright (c) 2024 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" 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 14, 2024
.Dt UVM_OBJ_WIREPAGES 9
.Os
.Sh NAME
.Nm uvm_obj_wirepages
.Nm uvm_obj_unwirepages
.Nd temporarily wire pages of a UVM object into RAM
.Sh SYNOPSIS
.In uvm/uvm_extern.h
.Ft int
.Fn uvm_obj_wirepages "struct uvm_object *uobj" "off_t start" "off_t end" "struct pglist *list"
.Ft void
.Fn uvm_obj_unwirepages "struct uvm_object *uobj" "off_t start" "off_t end"
.Sh DESCRIPTION
.Fn uvm_obj_wirepages
temporarily wires a range of pages in a UVM object into RAM.
If any pages from
.Fa start
(inclusive)
to
.Fa end
(exclusive)
are currently paged out, it pages them back in first, and arranges that
the pages in the range will not be paged out until unwired with
.Fn uvm_obj_unwirepages .
.Pp
If
.Fa list
is nonnull, it is initialized to a tailq of pages linked through the
.Fa pageq.queue
member of
.Vt struct vm_page ,
for the convenience of the caller.
The caller is not transferred ownership of any part of
.Fa list
and need not free anything afterward \(em
.Fn uvm_obj_unwirepages
will free the pages when done.
.Pp
.Fa start
and
.Fa end
must be page-aligned.
.Pp
Calls to
.Fn uvm_obj_wirepages
must be matched by
.Fn uvm_obj_unwirepages
with the same range.
.Pp
Overlapping ranges may be simultaneously wired; each page may be wired
up to 2^32 - 1 times, and will not be paged out until all ranges
covering it have been unwired.
.Sh RETURN VALUES
The
.Fn uvm_obj_wirepages
function returns zero on success, or returns an
.Xr errno 3
error code and leaves the wired status of all pages unchanged on
failure.
.Sh SEE ALSO
.Xr mlock 3 ,
.Xr uvm 9 ,
.Xr uvm_map 9