Linux Kernel: What is the major difference between the buffer cache and the page cache?
2015-06-02 15:40
555 查看
The page cache caches pages of files to optimize file I/O. The buffer cache caches disk blocks to optimize block I/O.
Prior to Linux kernel version 2.4, the two caches were distinct: Files were in the page cache, disk blocks were in the buffer cache. 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.
This is simple to implement, but with an obvious inelegance and inefficiency. Starting with Linux kernel version 2.4, the contents of the
two caches were unified. The VM subsystem now drives I/O and it does so out of the page cache. If cached data has both a file and a block representation—as most data does—the buffer cache will simply point into the page cache; thus only one instance of the
data is cached in memory. The page cache is what you picture when you think of a disk cache: It caches file data from a disk to make subsequent I/O faster.
The buffer cache remains, however, as the kernel still needs to perform block I/O in terms of blocks, not pages. 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.
See also my answer to What
is the difference between Buffers and Cached columns in /proc/meminfo output?
Prior to Linux kernel version 2.4, the two caches were distinct: Files were in the page cache, disk blocks were in the buffer cache. 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.
This is simple to implement, but with an obvious inelegance and inefficiency. Starting with Linux kernel version 2.4, the contents of the
two caches were unified. The VM subsystem now drives I/O and it does so out of the page cache. If cached data has both a file and a block representation—as most data does—the buffer cache will simply point into the page cache; thus only one instance of the
data is cached in memory. The page cache is what you picture when you think of a disk cache: It caches file data from a disk to make subsequent I/O faster.
The buffer cache remains, however, as the kernel still needs to perform block I/O in terms of blocks, not pages. 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.
See also my answer to What
is the difference between Buffers and Cached columns in /proc/meminfo output?
相关文章推荐
- Android之使用Http协议实现文件上传功能
- 网马生成器 MS Internet Explorer XML Parsing Buffer Overflow Exploit (vista) 0day
- 揭秘SQL Server 2014有哪些新特性(2)-固态硬盘 Buffer Pool(缓冲池) 扩展
- php中ob(Output Buffer 输出缓冲)函数使用方法
- php中mysql操作buffer用法详解
- Protocol Buffer技术深入理解(C++实例)
- mysqldump造成Buffer Pool污染的研究
- Node.js中使用Buffer编码、解码二进制数据详解
- 用pdo_oci 取数据报错或被截取 UTF-8 output gets truncated
- linux系统日志
- 正确认识Linux Buffer Cache
- 深入Log Buffer分析
- linux cache buffer
- Buffer和Cache的区别
- buffer和cache 区别(另解)
- Linux free命令
- VC str.Format 错误 Buffer too small
- bulk传输bushound显示buffer overrun
- 字节转换
- air max wright "