简体   繁体   English

Linux内存管理(缓存)

[英]Linux memory management (caching)

I'm having a hard time telling the difference between the different cache areas (OS). 我很难分辨不同的缓存区域(OS)之间的区别。 I'd love a brief explanation about disk\\buffer\\swap\\page cache. 我希望对磁盘\\缓冲区\\交换\\页面缓存进行简要说明。 Where do they reside? 他们住在哪里? What are the main differences between them? 它们之间的主要区别是什么?

From what I understand the page cache is part of the main memory that stores pages brought from an I/O device. 据我了解,页面缓存是存储从I / O设备带来的页面的主内存的一部分。 Are buffer cache and disk cache the same? 缓冲区缓存和磁盘缓存是否相同? Do they "live" at the I/O device? 它们是否在I / O设备上“存在”?

Many thanks!! 非常感谢!!

In linux two caches were distinct: Files were in the page cache, disk blocks were in the buffer cache. 在Linux中,两个缓存是不同的:文件在页面缓存中,磁盘块在缓冲区缓存中。 Given that most files are represented by a filesystem on a disk, data was represented twice, once in each of the caches. 假设大多数文件由磁盘上的文件系统表示,则数据被表示两次,每个高速缓存中一次。 Many Unix systems follow a similar pattern. 许多Unix系统遵循类似的模式。

The buffer cache remains, however, as the kernel still needs to perform block I/O in terms of blocks, not pages. 但是,由于内核仍需要根据块而不是页面执行块I / O,因此保留了缓冲区高速缓存。 As most blocks represent file data, most of the buffer cache is represented by the page cache. 由于大多数块表示文件数据,因此大多数缓冲区高速缓存由页高速缓存表示。 But a small amount of block data isn't file backed—metadata and raw block I/O for example—and thus is solely represented by the buffer cache. 但是少量的块数据不是文件备份的(例如,元数据和原始块I / O),因此仅由缓冲区高速缓存表示。

Disk cache/Buffer cache 磁盘缓存/缓冲区缓存

This cache caches disk blocks to optimize block I/O. 该缓存可缓存磁盘块,以优化块I / O。

It is the RAM used for faster access to disk.It is embedded in the disk or it can be portion of Main memory set aside. 它是用于快速访问磁盘的RAM,它嵌入在磁盘中,也可以是主内存的一部分。

Swap cache/Page cache 交换缓存/页面缓存

This cache caches pages of files to optimize file I/O 此缓存缓存文件页面以优化文件I / O

The swap cache is a list of page table entries. 交换缓存是页表条目的列表。 This page table entry for a swapped out page and describes which swap file the page is being held in together with its location in the swap file, so that when has to be brought back again we will be having its location in swap file. 换出页面的页面表条目,描述了该页面被保留在哪个交换文件中以及它在交换文件中的位置,因此当必须再次带回时,我们将在交换文件中保留其位置。

It resides on disk. 它驻留在磁盘上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM