2003-09-30 00:54:06 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
|
|
|
|
.\" 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 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 July 19, 2003
|
2003-10-23 06:06:33 +00:00
|
|
|
.Dt VM_MAP 9
|
2003-09-30 00:54:06 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm vm_map
|
|
|
|
.Nd virtual address space portion of virtual memory subsystem
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In sys/param.h
|
|
|
|
.In vm/vm.h
|
|
|
|
.In vm/vm_map.h
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
subsystem is used to manage virtual address spaces.
|
|
|
|
This section describes the main data structures used within the code.
|
|
|
|
.Pp
|
|
|
|
The
|
2004-07-06 06:53:42 +00:00
|
|
|
.Vt "struct vm_map"
|
2003-09-30 00:54:06 +00:00
|
|
|
is a generic representation of an address space.
|
|
|
|
This address space may belong to a user process or the kernel.
|
|
|
|
The kernel actually uses several maps, which are maintained as
|
|
|
|
subordinate maps, created using the
|
|
|
|
.Xr vm_map_submap 9
|
|
|
|
function.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct vm_map {
|
|
|
|
struct vm_map_entry header;
|
|
|
|
struct lock lock;
|
|
|
|
struct mtx system_mtx;
|
|
|
|
int nentries;
|
|
|
|
vm_size_t size;
|
|
|
|
u_char needs_wakeup;
|
|
|
|
u_char system_map;
|
|
|
|
u_char infork;
|
|
|
|
vm_map_entry_t root;
|
|
|
|
unsigned int timestamp;
|
|
|
|
vm_map_entry_t first_free;
|
|
|
|
pmap_t pmap;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The fields of
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map
|
2003-09-30 00:54:06 +00:00
|
|
|
are as follows:
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Va needs_wakeup"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va header
|
2003-09-30 00:54:06 +00:00
|
|
|
Head node of a circular, doubly linked list of
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_entry
|
2003-09-30 00:54:06 +00:00
|
|
|
objects.
|
|
|
|
Each object defines a particular region within this map's address space.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va lock
|
2003-09-30 00:54:06 +00:00
|
|
|
Used to serialize access to the structure.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va system_mtx
|
2003-09-30 00:54:06 +00:00
|
|
|
A mutex which is used if the map is a system map.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va nentries
|
2003-09-30 00:54:06 +00:00
|
|
|
A count of the members in use within the circular map entry list.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va size
|
2003-09-30 00:54:06 +00:00
|
|
|
Specifies the size of the virtual address space.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va infork
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicates if the map structure is currently undergoing fork processing.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va needs_wakeup
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicates if a thread is waiting for an allocation within the map.
|
|
|
|
Used only by system maps.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va system_map
|
2003-09-30 00:54:06 +00:00
|
|
|
Set to TRUE to indicate that map is a system map; otherwise, it belongs
|
|
|
|
to a user process.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va root
|
2003-09-30 00:54:06 +00:00
|
|
|
Root node of a binary search tree used for fast lookup of map entries.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va timestamp
|
2003-09-30 00:54:06 +00:00
|
|
|
Used to determine if the map has changed since its last access.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va first_free
|
2003-09-30 00:54:06 +00:00
|
|
|
Provides a hint to the first free space within the map.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va pmap
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the underlying physical map with which this virtual map
|
|
|
|
is associated.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following flags can be passed to
|
|
|
|
.Xr vm_map_find 9
|
|
|
|
and
|
|
|
|
.Xr vm_map_insert 9
|
|
|
|
to specify the copy-on-write properties of regions within the map:
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Dv MAP_PREFAULT_MADVISE"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_COPY_ON_WRITE
|
2003-09-30 00:54:06 +00:00
|
|
|
The mapping is copy-on-write.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_NOFAULT
|
2003-09-30 00:54:06 +00:00
|
|
|
The mapping should not generate page faults.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_PREFAULT
|
2003-09-30 00:54:06 +00:00
|
|
|
The mapping should be prefaulted into physical memory.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_PREFAULT_PARTIAL
|
2003-09-30 00:54:06 +00:00
|
|
|
The mapping should be partially prefaulted into physical memory.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_DISABLE_SYNCER
|
2003-09-30 00:54:06 +00:00
|
|
|
Do not periodically flush dirty pages; only flush them when absolutely
|
|
|
|
necessary.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_DISABLE_COREDUMP
|
2003-09-30 00:54:06 +00:00
|
|
|
Do not include the mapping in a core dump.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_PREFAULT_MADVISE
|
2003-09-30 00:54:06 +00:00
|
|
|
Specify that the request from a user process calling
|
|
|
|
.Xr madvise 2 .
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_entry
|
2003-09-30 00:54:06 +00:00
|
|
|
is a generic representation of a region.
|
|
|
|
The region managed by each entry is associated with a
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt union vm_map_object ,
|
2003-09-30 00:54:06 +00:00
|
|
|
described below.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct vm_map_entry {
|
|
|
|
struct vm_map_entry *prev;
|
|
|
|
struct vm_map_entry *next;
|
|
|
|
struct vm_map_entry *left;
|
|
|
|
struct vm_map_entry *right;
|
|
|
|
vm_offset_t start;
|
|
|
|
vm_offset_t end;
|
|
|
|
vm_offset_t avail_ssize;
|
|
|
|
union vm_map_object object;
|
|
|
|
vm_ooffset_t offset;
|
|
|
|
vm_eflags_t eflags;
|
|
|
|
/* Only in task maps: */
|
|
|
|
vm_prot_t protection;
|
|
|
|
vm_prot_t max_protection;
|
|
|
|
vm_inherit_t inheritance;
|
|
|
|
int wired_count;
|
|
|
|
vm_pindex_t lastr;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The fields of
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_entry
|
2003-09-30 00:54:06 +00:00
|
|
|
are as follows:
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Va avail_ssize"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va prev
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the previous node in a doubly-linked, circular list.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va next
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the next node in a doubly-linked, circular list.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va left
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the left node in a binary search tree.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va right
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the right node in a binary search tree.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va start
|
2003-09-30 00:54:06 +00:00
|
|
|
Lower address bound of this entry's region.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va end
|
2003-09-30 00:54:06 +00:00
|
|
|
Upper address bound of this entry's region.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va avail_ssize
|
2003-09-30 00:54:06 +00:00
|
|
|
If the entry is for a process stack, specifies how much the entry can grow.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va object
|
2003-09-30 00:54:06 +00:00
|
|
|
Pointer to the
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_object
|
2003-09-30 00:54:06 +00:00
|
|
|
with which this entry is associated.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va offset
|
2003-09-30 00:54:06 +00:00
|
|
|
Offset within the
|
2003-10-23 06:06:33 +00:00
|
|
|
.Va object
|
2003-09-30 00:54:06 +00:00
|
|
|
which is mapped from
|
2003-10-23 06:06:33 +00:00
|
|
|
.Va start
|
2003-09-30 00:54:06 +00:00
|
|
|
onwards.
|
2004-07-06 06:53:42 +00:00
|
|
|
.It Va eflags
|
2003-09-30 00:54:06 +00:00
|
|
|
Flags applied to this entry, described below.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following five members are only valid for entries forming part of
|
|
|
|
a user process's address space:
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Va max_protection"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va protection
|
2003-09-30 00:54:06 +00:00
|
|
|
Memory protection bits applied to this region.
|
|
|
|
These are identical to those defined for
|
|
|
|
.Xr vm_page_protect 9 .
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va max_protection
|
2003-09-30 00:54:06 +00:00
|
|
|
Mask for the memory protection bits which may be actually be applied to
|
|
|
|
this region.
|
|
|
|
These are identical to those defined for
|
|
|
|
.Xr vm_page_protect 9 .
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va inheritance
|
2003-09-30 00:54:06 +00:00
|
|
|
Contains flags which specify how this entry should be treated
|
|
|
|
during fork processing.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va wired_count
|
2003-09-30 00:54:06 +00:00
|
|
|
Count of how many times this entry has been wired into physical memory.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Va lastr
|
2003-09-30 00:54:06 +00:00
|
|
|
Contains the address of the last read which caused a page fault.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following flags may be applied to each entry, by specifying them
|
|
|
|
as a mask within the
|
2004-07-06 06:53:42 +00:00
|
|
|
.Va eflags
|
2003-09-30 00:54:06 +00:00
|
|
|
member:
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Dv MAP_ENTRY_BEHAV_SEQUENTIAL"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_NOSYNC
|
2003-09-30 00:54:06 +00:00
|
|
|
The system should not flush the data associated with this map
|
|
|
|
periodically, but only when it needs to.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_IS_SUB_MAP
|
2003-09-30 00:54:06 +00:00
|
|
|
If set, then the
|
2003-10-23 06:06:33 +00:00
|
|
|
.Va object
|
2003-09-30 00:54:06 +00:00
|
|
|
member specifies a subordinate map.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_COW
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicate that this is a copy-on-write region.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_NEEDS_COPY
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicate that a copy-on-write region needs to be copied.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_NOFAULT
|
2003-09-30 00:54:06 +00:00
|
|
|
Specifies that accesses within this region should never cause a page fault.
|
|
|
|
If a page fault occurs within this region, the system will panic.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_USER_WIRED
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicate that this region was wired on behalf of a user process.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_BEHAV_NORMAL
|
2003-09-30 00:54:06 +00:00
|
|
|
The system should use the default paging behaviour for this region.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_BEHAV_SEQUENTIAL
|
2003-09-30 00:54:06 +00:00
|
|
|
The system should depress the priority of pages immediately preceding
|
|
|
|
each page within this region when faulted in.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_BEHAV_RANDOM
|
2003-09-30 00:54:06 +00:00
|
|
|
Is a hint that pages within this region will be accessed randomly,
|
|
|
|
and that prefetching is likely not advantageous.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_IN_TRANSITION
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicate that wiring or unwiring of an entry is in progress, and that
|
|
|
|
other kernel threads should not attempt to modify fields in the structure.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_NEEDS_WAKEUP
|
2003-09-30 00:54:06 +00:00
|
|
|
Indicate that there are kernel threads waiting for this region to become
|
|
|
|
available.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv MAP_ENTRY_NOCOREDUMP
|
2003-09-30 00:54:06 +00:00
|
|
|
The region should not be included in a core dump.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
2004-07-06 06:53:42 +00:00
|
|
|
.Va inheritance
|
2003-09-30 00:54:06 +00:00
|
|
|
member has type
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt vm_inherit_t .
|
2003-09-30 00:54:06 +00:00
|
|
|
This governs the inheritance behaviour for a map entry during fork processing.
|
|
|
|
The following values are defined for
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt vm_inherit_t :
|
2004-07-06 06:53:42 +00:00
|
|
|
.Bl -tag -width ".Dv VM_INHERIT_DEFAULT"
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv VM_INHERIT_SHARE
|
2003-09-30 00:54:06 +00:00
|
|
|
The object associated with the entry should be cloned and shared
|
|
|
|
with the new map.
|
|
|
|
A new
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_object
|
2003-09-30 00:54:06 +00:00
|
|
|
will be created if necessary.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv VM_INHERIT_COPY
|
2003-09-30 00:54:06 +00:00
|
|
|
The object associated with the entry should be copied to the new map.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv VM_INHERIT_NONE
|
2003-09-30 00:54:06 +00:00
|
|
|
The entry should not be copied to the new map.
|
2003-10-23 06:06:33 +00:00
|
|
|
.It Dv VM_INHERIT_DEFAULT
|
2003-09-30 00:54:06 +00:00
|
|
|
Specifies the default behaviour,
|
2003-10-23 06:06:33 +00:00
|
|
|
.Dv VM_INHERIT_COPY .
|
2003-09-30 00:54:06 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt union vm_map_object
|
2003-09-30 00:54:06 +00:00
|
|
|
is used to specify the structure which a
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_entry
|
2003-09-30 00:54:06 +00:00
|
|
|
is associated with.
|
|
|
|
.Pp
|
|
|
|
The fields of
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt union vm_map_object
|
2003-09-30 00:54:06 +00:00
|
|
|
are as follows:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
union vm_map_object {
|
|
|
|
struct vm_object *vm_object;
|
|
|
|
struct vm_map *sub_map;
|
|
|
|
};
|
|
|
|
.Pp
|
|
|
|
.Ed
|
|
|
|
Normally, the
|
2003-10-23 06:06:33 +00:00
|
|
|
.Va sub_map
|
2003-09-30 00:54:06 +00:00
|
|
|
member is only used by system maps to indicate that a memory range
|
|
|
|
is managed by a subordinate system map.
|
|
|
|
Within a user process map, each
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_map_entry
|
2003-09-30 00:54:06 +00:00
|
|
|
is backed by a
|
2003-10-23 06:06:33 +00:00
|
|
|
.Vt struct vm_object .
|
2003-09-30 00:54:06 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr pmap 9 ,
|
|
|
|
.Xr vm_map_check_protection 9 ,
|
|
|
|
.Xr vm_map_clean 9 ,
|
|
|
|
.Xr vm_map_create 9 ,
|
|
|
|
.Xr vm_map_delete 9 ,
|
|
|
|
.Xr vm_map_find 9 ,
|
|
|
|
.Xr vm_map_findspace 9 ,
|
|
|
|
.Xr vm_map_inherit 9 ,
|
|
|
|
.Xr vm_map_init 9 ,
|
|
|
|
.Xr vm_map_insert 9 ,
|
|
|
|
.Xr vm_map_lock 9 ,
|
|
|
|
.Xr vm_map_lookup 9 ,
|
|
|
|
.Xr vm_map_madvise 9 ,
|
|
|
|
.Xr vm_map_max 9 ,
|
|
|
|
.Xr vm_map_min 9 ,
|
|
|
|
.Xr vm_map_pmap 9 ,
|
|
|
|
.Xr vm_map_protect 9 ,
|
|
|
|
.Xr vm_map_remove 9 ,
|
|
|
|
.Xr vm_map_simplify_entry 9 ,
|
|
|
|
.Xr vm_map_stack 9 ,
|
|
|
|
.Xr vm_map_submap 9 ,
|
|
|
|
.Xr vm_map_wire 9 ,
|
|
|
|
.Xr vm_page_protect 9
|
|
|
|
.Sh AUTHORS
|
2003-10-23 06:06:33 +00:00
|
|
|
This manual page was written by
|
2003-09-30 00:54:06 +00:00
|
|
|
.An Bruce M Simpson Aq bms@spc.org .
|