Differencebetween Buffer and Cache Memory in Linux

What is the difference between buffer and cache memory in Linux?

"Buffers" represent how much portion of RAM is dedicated to cache disk blocks. "Cached" is similar like "Buffers", only this time it caches pages from file reading.

quote from:

  • https://web.archive.org/web/20110207101856/http://www.linuxforums.org/articles/using-top-more-efficiently_89.html

Linux memory management (caching)

In linux 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.

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.

Linux SWAP memory used when RAM is used by Kernel Buffer and Cache

Here is one important thing : some times ago, we don't have such large RAM as now. So we need to use vritual memory for saving (also for other reasons like safe), and we use SWAP and do_page_fault() too.

With the development of RAM, we don't need to foucs on how to save the use of RAM. Instead, we foucs on how to speed up the access to hard disk by using RAM as a chache, that is why we use Buffer and Cache now.



Related Topics



Leave a reply



Submit