> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/vm_fault_prefault.9.md).

# vm\_fault\_prefault.9

`vm_fault_prefault` — 将页面错误聚集到进程的地址空间中

## 名称

`vm_fault_prefault`

## 概要

`#include <sys/param.h>`

`#include <vm/vm.h>`

`#include <vm/pmap.h>`

`void vm_fault_prefault(pmap_t pmap, vm_offset_t addra, vm_map_entry_t entry)`

## 描述

`vm_fault_prefault()` 函数提供了一种将页面错误聚集到进程地址空间中的手段。它对物理映射 `pmap` 进行操作。`entry` 参数指定要预错误的条目；`addra` 参数指定进程虚拟地址空间中映射的起始位置。

它通常在第一次页面错误后由 `vm_fault()` 调用。它通过消除对 `vm_fault()` 的重复调用来使 execve(2) 系统调用受益，否则需要进行这些重复调用以将进程的可执行页面调入物理内存。

## 实现说明

这是一个机器无关函数，它调用机器相关的 [pmap\_is\_prefaultable(9)](/man/man9/pmap_is_prefaultable.9.md) 辅助函数来确定页面是否可以预错误到物理内存中。

## 参见

execve(2), [pmap\_is\_prefaultable(9)](/man/man9/pmap_is_prefaultable.9.md)

## 作者

本手册页由 Bruce M Simpson <bms@spc.org> 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/vm_fault_prefault.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
