Linux Page cache and buffer cache

Source: Internet
Author: User


Linux Page cache and buffer cache are two confusing concepts: Page cache and buffer cache. On the Internet, many people are arguing about the differences between the two caches, at the end of the discussion, there has never been a unified and correct conclusion. During my work, the concepts of page cache and buffer cache have plagued me, but after careful analysis, these two concepts are actually very clear. If we can understand the nature of these two caches, we may be more comfortable in analyzing io problems. The www.2cto.com Page cache is actually for the file system. It is the File cache, and data on the file layer is cached to the page cache. The logic layer of the file needs to be mapped to the actual physical disk. This ing relationship is completed by the file system. When the data in the page cache needs to be refreshed, the data in the page cache is handed over to the buffer cache. However, this kind of processing becomes very simple after the kernel of version 2.6, and there is no real cache operation. Buffer cache is the cache for disk blocks, that is, if no file system is available, data directly operated on the disk will be cached in the buffer cache. For example, the metadata of the file system is cached in the buffer cache. In short, page cache is used to cache file data, and buffer cache is used to cache disk data. In the case of a file system, operations on the file will cache the data to the page cache. If you directly use dd or other tools to read and write the disk, the data will be cached to the buffer cache. In addition, at the file system layer, each device is assigned a file operation method of def_blk_ops. This is the operation method of the device. A radix tree exists under the inode of each device, the page of the cached data will be placed under this radix tree. The number of pages is displayed in the buffer column of the top program. If the device has a file system, an inode will be generated, and the inode will allocate operation methods such as ext3_ops. These methods are the file system methods, there is also a radix tree under this inode, where the page of the file is cached, and the number of cached pages is calculated in the cache column of the top program. From the above analysis, we can see that the buffer cache and page cache in the 2.6 kernel are consistent in terms of processing, but there are conceptual differences. page cache is for File cache, buffer is the cache for disk block data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.