# 页（计算机内存）

页是计算机内存系统中用作管理基本单元的固定长度内存块。这一术语出现在硬件与软件栈的两个层面上：在[虚拟内存](https://www.edgepedia.org/zh/virtual-memory)中，页是操作系统分配内存和映射文件的固定大小单元；在DRAM中，页（也称行）是在激活命令之后其内容驻留在存储体行缓冲区中的那一行存储单元。<sup>[1](https://www.man7.org/linux/man-pages/man2/getpagesize.2.html)</sup><sup> • </sup><sup>[2](https://hps.ece.utexas.edu/pub/TR-HPS-2021-001.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义（虚拟内存） | 固定长度的块，是mmap(2)执行内存分配和文件映射的单元<sup>[1](https://www.man7.org/linux/man-pages/man2/getpagesize.2.html)</sup> |
| 常见页大小 | x86上为4 KB；Armv8-A支持4 KB、16 KB和64 KB翻译粒度<sup>[3](https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space-and-physical-storage)</sup><sup> • </sup><sup>[4](https://developer.arm.com/-/media/Arm%20Developer%20Community/PDF/Learn%20the%20Architecture/LearnTheArchitecture-MemoryManagement-101811_0100_00_en.pdf)</sup> |
| 大页 | Linux大页跨度从2 MB到1 GB，由PMD和PUD页表项映射<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup> |
| 起源 | 分页虚拟内存于1962年在Ferranti Atlas计算机上发明，这是第一台具有分页虚拟内存的计算机<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup> |
| 定义（DRAM） | 存储体中激活的行构成行缓冲区，也称DRAM页<sup>[2](https://hps.ece.utexas.edu/pub/TR-HPS-2021-001.pdf)</sup> |
| DRAM访问延迟 | 行缓冲区命中：\( T_{\mathrm{CL}} \)；行缓冲区为空：\( T_{\mathrm{RCD}} + T_{\mathrm{CL}} \)；行缓冲区冲突：\( T_{\mathrm{RP}} + T_{\mathrm{RCD}} + T_{\mathrm{CL}} \)<sup>[6](https://doi.org/10.1109/access.2023.3299848)</sup> |
| 延迟比 | 行命中延迟约为行冲突延迟的三分之一<sup>[7](https://www.istc-cc.cmu.edu/publications/papers/2011/ieee-tc11.pdf)</sup> |

## 虚拟内存中的页

虚拟内存将物理内存的细节对应用软件抽象化。每次内存访问都使用虚拟地址，由CPU将其转换为内存控制器能够理解的物理地址。物理系统内存被划分为页帧（或称页），每个物理页可以映射为一个或多个虚拟页。这些映射由页表描述，页表按层次组织：虚拟地址的高位索引顶层表中的一项，每一项指向下一层，地址的最低几位定义实际页内的偏移量。<sup>[8](https://docs.kernel.org/admin-guide/mm/concepts.html)</sup>

**页大小。** 每个页的大小因体系结构而异。某些体系结构允许从若干支持的值中选择页大小，这一选择在内核构建时通过配置选项做出。<sup>[8](https://docs.kernel.org/admin-guide/mm/concepts.html)</sup> 在x86计算机上，宿主页大小为4千字节。<sup>[3](https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space-and-physical-storage)</sup> Armv8-A支持三种翻译粒度大小：4 KB、16 KB和64 KB；粒度是可描述的最小内存块，更大的块是其倍数。<sup>[4](https://developer.arm.com/-/media/Arm%20Developer%20Community/PDF/Learn%20the%20Architecture/LearnTheArchitecture-MemoryManagement-101811_0100_00_en.pdf)</sup> 用户程序不应将页大小硬编码，无论是作为字面量还是通过PAGE_SIZE宏，因为某些体系结构支持多种页大小。<sup>[1](https://www.man7.org/linux/man-pages/man2/getpagesize.2.html)</sup>

页大小决定给定内存量包含多少个页。一个具有16 GiB内存和4 KiB页的系统有\( 17{,}179{,}869{,}184 / 4{,}096 = 4{,}194{,}304 \)个页。<sup>[9](https://teaching.os.rwth-aachen.de/LKP/lecture/lkp-lecture.html)</sup> 使用4 KB页和32位地址范围时，页基地址使用地址的第12至31位，因此PAGE_SHIFT为12，PAGE_SIZE定义为\( 1 \ll \mathrm{PAGE\_SHIFT} \)。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup>

**页表与地址转换。** 虚拟地址对应的物理地址由页帧号（pfn）引用，即页的物理地址除以PAGE_SIZE。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup> Linux将页表定义为目前五层高度的层次结构，从上到下依次命名为PGD、P4D、PUD、PMD和PTE；使用较少层数的体系结构会折叠未使用的层，在编译时跳过它们。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup> 内存管理单元（MMU）执行地址转换并将结果缓存在转译后备缓冲区（TLB）和页表遍历缓存中；当找不到转换时，MMU遍历页表。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup>

**大页。** Linux支持比通常的4 KB更大的页大小，称为大页，其包含连续的物理区域，通常跨度从2 MB到1 GB，由PMD和PUD表项映射。大页减轻TLB压力、减少页表开销，并改善某些工作负载的性能，代价是浪费内存和分配困难等权衡。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup> 在x86上，可以使用第二级和第三级页表中的表项映射2 MB甚至1 GB的页；Linux为此提供两种机制：HugeTLB文件系统（hugetlbfs）和透明大页（THP），后者对用户透明地管理此类映射。<sup>[8](https://docs.kernel.org/admin-guide/mm/concepts.html)</sup> 现代内核还支持多尺寸THP（mTHP），它以大于基础页但小于PMD大小的块分配匿名内存，按2的幂递增，如16 KB、32 KB或64 KB。<sup>[10](https://docs.kernel.org/admin-guide/mm/transhuge.html)</sup>

**换页到磁盘。** 当进程的线程试图使用超过可用量的物理内存时，系统会将部分内存内容换页到磁盘，将最近最少使用的页移到页面文件中，并更新受影响进程的页映射；这一操作对应用程序是透明的，应用程序仅在其虚拟地址空间中操作。<sup>[3](https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space-and-physical-storage)</sup> 缺页异常是MMU无法提供转换时引发的异常，例如因为数据不在物理内存中或访问不被允许；预期原因包括延迟分配和写时复制，用户空间中因禁止访问而引发的缺页会导致内核向该线程发送SIGSEGV信号。<sup>[5](https://docs.kernel.org/mm/page_tables.html)</sup>

## DRAM中的页

在DRAM中，存储体中激活的行构成行缓冲区，也称DRAM页。一行被激活后，列访问命令利用行缓冲区中的数据执行实际的读取或写入。对行缓冲区的额外访问称为行缓冲区命中（或页命中），未来访问倾向于命中行缓冲区的特性称为行缓冲区局部性。<sup>[2](https://hps.ece.utexas.edu/pub/TR-HPS-2021-001.pdf)</sup>

**访问场景。** 三种场景具有不同的延迟。行缓冲区命中仅需列访问，最小延迟为\( T_{\mathrm{CL}} \)。行缓冲区为空需要激活后跟列访问，延迟为\( T_{\mathrm{RCD}} + T_{\mathrm{CL}} \)。行缓冲区冲突——即请求的目标页地址与当前打开的页地址不同——需要预充电、激活和列访问，最小延迟为\( T_{\mathrm{RP}} + T_{\mathrm{RCD}} + T_{\mathrm{CL}} \)。因此访问活动页比访问冲突页或空行缓冲区更快。<sup>[6](https://doi.org/10.1109/access.2023.3299848)</sup> 行命中延迟约为行冲突延迟的三分之一。<sup>[7](https://www.istc-cc.cmu.edu/publications/papers/2011/ieee-tc11.pdf)</sup> 冲突的延迟甚至可能超过最小值，因为它必须等待发出预充电，还可能等待对存储体的较早请求完成；若对冲突行有多个待处理请求，延迟会进一步增加。<sup>[11](https://www.pdl.cmu.edu/PDL-FTP/associated/1902.07609.pdf)</sup>

**局部性与调度。** 实测工作负载显示行缓冲区局部性范围很大，行缓冲区命中率在2.4%到53.1%之间不等。<sup>[11](https://www.pdl.cmu.edu/PDL-FTP/associated/1902.07609.pdf)</sup> 由于冲突代价高昂，内存控制器和DRAM设计者已通过多种方式应对这一惩罚。一种体系结构将行缓冲区拆分为两个缓冲区，使得在同一存储体中不同行的激活和预充电操作期间可以服务读或写命令；实验结果表明，与传统的DRAM体系结构相比，内存密集型应用的系统性能最高提升16%。<sup>[12](https://ietresearch.onlinelibrary.wiley.com/doi/full/10.1049/el.2016.1111)</sup> 在操作系统层面，对大多数应用而言，页粒度的访问集中在最常引用的OS页中少数几个连续的缓存行大小的块周围，这促使将频繁访问的数据放在同一DRAM行中，以提高命中率并降低延迟和功耗。<sup>[13](https://users.cs.utah.edu/~rajeev/pubs/asplos10.pdf)</sup>

## 两种含义如何联系

“页”的两种含义在内存系统的地址映射中交汇。[DIMM](https://www.edgepedia.org/zh/dimm)中的DRAM行缓冲区可以容纳不止一个OS页的数据；在一种DDR2-800配置中，一个行缓冲区容纳两个完整的4 KB OS页，DIMM上的每个器件持有某页数据的512字节。<sup>[14](https://www.researchgate.net/publication/220939079_Micro-Pages_Increasing_DRAM_Efficiency_with_Locality-Aware_Data_Placement)</sup> 因此虚拟页如何映射到DRAM行和存储体影响行缓冲区局部性，基于置换的页交错等地址映射方案被用来施加影响。<sup>[15](https://jilp.org/vol3/zhang-jilp.pdf)</sup> 这种映射对软件不直接可见：逆向工程地址到DRAM通道、秩和存储体的映射已被用于安全研究，包括利用多处理器系统中跨CPU共享行缓冲区的攻击。<sup>[16](https://arxiv.org/abs/1511.08756)</sup>

## References

1. [getpagesize(2) - Linux manual page](https://www.man7.org/linux/man-pages/man2/getpagesize.2.html)
2. [DRAM row buffer and page terminology, UT Austin HPS technical report TR-HPS-2021-001](https://hps.ece.utexas.edu/pub/TR-HPS-2021-001.pdf)
3. [Virtual Address Space and Physical Storage, Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space-and-physical-storage)
4. [Memory Management, Arm Learn the Architecture (Armv8-A)](https://developer.arm.com/-/media/Arm%20Developer%20Community/PDF/Learn%20the%20Architecture/LearnTheArchitecture-MemoryManagement-101811_0100_00_en.pdf)
5. [Page Tables, The Linux Kernel documentation](https://docs.kernel.org/mm/page_tables.html)
6. [High-Performance and Power-Saving Mechanism for Page Activations Based on Full Independent DRAM Sub-Arrays in Multi-Core Systems, IEEE Access (2023)](https://doi.org/10.1109/access.2023.3299848)
7. [Row-buffer locality aware DRAM scheduling, IEEE Transactions on Computers (CMU ISTC-CC)](https://www.istc-cc.cmu.edu/publications/papers/2011/ieee-tc11.pdf)
8. [Concepts overview, The Linux Kernel documentation](https://docs.kernel.org/admin-guide/mm/concepts.html)
9. [Linux Kernel Programming lecture, RWTH Aachen](https://teaching.os.rwth-aachen.de/LKP/lecture/lkp-lecture.html)
10. [Transparent Hugepage Support, The Linux Kernel documentation](https://docs.kernel.org/admin-guide/mm/transhuge.html)
11. [Row buffer conflict latency analysis, CMU PDL (arXiv 1902.07609)](https://www.pdl.cmu.edu/PDL-FTP/associated/1902.07609.pdf)
12. [High performance DRAM architecture with split row buffer, Electronics Letters (2016)](https://ietresearch.onlinelibrary.wiley.com/doi/full/10.1049/el.2016.1111)
13. [Row-buffer Hit-Rates, ASPLOS 2010 (University of Utah)](https://users.cs.utah.edu/~rajeev/pubs/asplos10.pdf)
14. [Micro-Pages: Increasing DRAM Efficiency with Locality-Aware Data Placement](https://www.researchgate.net/publication/220939079_Micro-Pages_Increasing_DRAM_Efficiency_with_Locality-Aware_Data_Placement)
15. [Permutation-based page interleaving, Journal of Instruction-Level Parallelism](https://jilp.org/vol3/zhang-jilp.pdf)
16. [DRAMA: Exploiting DRAM Addressing for Cross-CPU Attacks, arXiv 1511.08756](https://arxiv.org/abs/1511.08756)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Storage devices & memory › Storage devices overview

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/page-computer-memory

English original: https://www.edgepedia.org/page-computer-memory
