![页面错误可能涉及也可能不涉及使该页面可用的辅助存储访问,这意味着什么](https://linux22.com/image/8939/%E9%A1%B5%E9%9D%A2%E9%94%99%E8%AF%AF%E5%8F%AF%E8%83%BD%E6%B6%89%E5%8F%8A%E4%B9%9F%E5%8F%AF%E8%83%BD%E4%B8%8D%E6%B6%89%E5%8F%8A%E4%BD%BF%E8%AF%A5%E9%A1%B5%E9%9D%A2%E5%8F%AF%E7%94%A8%E7%9A%84%E8%BE%85%E5%8A%A9%E5%AD%98%E5%82%A8%E8%AE%BF%E9%97%AE%EF%BC%8C%E8%BF%99%E6%84%8F%E5%91%B3%E7%9D%80%E4%BB%80%E4%B9%88.png)
从联机帮助页top
nMaj -- Major Page Fault Count
The number of major page faults that have occurred for a task. A
page fault occurs when a process attempts to read from or write
to a virtual page that is not currently present in its address
space. **A major page fault is when auxiliary storage access is
involved in making that page available.**
nMin -- Minor Page Fault count
The number of minor page faults that have occurred for a task. A
page fault occurs when a process attempts to read from or write
to a virtual page that is not currently present in its address
space. **A minor page fault does not involve auxiliary storage
access in making that page available.**
如果我是正确的,处理页面错误就是将物理内存中丢失的所需数据从交换区传输到物理内存。交换是存储的一部分,例如硬盘驱动器或 SSD。那么页面错误可能会或可能不会是什么意思?涉及辅助存储访问以使该页面可用?
谢谢。
答案1
只有主要页面错误涉及辅助存储(IE从磁盘读取,无论是从交换区还是其他地方,例如当以二进制形式分页时)。
次要页面错误是无需从磁盘读取即可解决的错误:
- 涉及已映射到内存中其他位置的数据的页面错误(例如可以在进程之间共享内存)
- 新分配内存的页面错误(使用全零页面和写时复制分配)
- 在某些情况下,已标记为调出但尚未调出的数据
(这并不详尽)。
答案2
例如,当数据或代码位于内存中但未映射到进程时,就会发生轻微页面错误。
考虑一个被另一个进程使用的共享库。您的进程想要加载相同的库,因此 ld (我认为通过 libc/glibc?)问题会生成页面错误。内核知道数据已经在内存中,并将其映射到进程。无需从磁盘加载它...